String.prototype.startsWith||(String.prototype.startsWith=function(a,b){b=b||0;return this.indexOf(a,b)===b});var cc=cc||{};cc._tmp=cc._tmp||{};cc._LogInfos={};var _p=window;_p=Object.prototype;_p=null;cc._drawingUtil=null;cc._renderContext=null;cc._supportRender=!1;cc._canvas=null;cc.container=null;cc._gameDiv=null;window.ENABLE_IMAEG_POOL=!1;cc.getUrlParam=function(a){return decodeURIComponent((new RegExp(a+"=([^&#=]*)")).exec(window.location.search)[1])};
cc.each=function(a,b,c){if(a)if(a instanceof Array)for(var d=0,e=a.length;d<e&&!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):[];cc.each(b,function(b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c])});return a};cc.inherits=function(a,b){function c(){}c.prototype=b.prototype;a.superClass_=b.prototype;a.prototype=new c;a.prototype.constructor=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._finished=!1;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._errors=a instanceof Array?[]:{};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,c){if(!a._finished)if(b?a._errors[this.index]=b:a._results[this.index]=c,a.finishedSize++,a._workingSize--,a.finishedSize===a.size)a.onEnd(0===a._errors.length?null:a._errors,a._results);else a._handleItem()}.bind(b),a)}};f.flow=function(){if(0===this._pool.length)this._onEnd&&this._onEnd.call(this._onEndTarget,null,[]);else for(var a=
0;a<this._limit;a++)this._handleItem()};f.onEnd=function(a,b){f._finished=!0;if(f._onEnd){var c=f._onEnd,d=f._onEndTarget;f._onEnd=null;f._onEndTarget=null;c.call(d,a,b)}}};
cc.async={series:function(a,b,c){a=new cc.AsyncPool(a,1,function(a,b,f){a.call(c,f)},b,c);a.flow();return a},parallel:function(a,b,c){a=new cc.AsyncPool(a,0,function(a,b,f){a.call(c,f)},b,c);a.flow();return 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){if(b){if(a)return b.call(c,a);b.apply(c,e)}});f.flow();return 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);a.flow();return a},mapLimit:function(a,b,c,d,e){a=new cc.AsyncPool(a,b,c,d,e);a.flow();return a}};
cc.path={normalizeRE:/[^\.\/]+\/\.\.\//,join:function(){for(var a=arguments.length,b="",c=0;c<a;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="";0<c&&(d=a.substring(c),a=a.substring(0,c));c=a.lastIndexOf(".");return 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):"";0<d&&(e=a.substring(d),
a=a.substring(0,d));d=a.lastIndexOf("/");return a.substring(0,0>=d?0:d+1)+b+c+e},_normalize:function(a){a=String(a);do{var b=a;a=a.replace(this.normalizeRE,"")}while(b.length!==a.length);return a}};
var imagePool={_pool:Array(10),_MAX:10,_smallImg:"data:image/gif;base64,R0lGODlhAQABAAAAACwAAAAAAQABAAA=",count:0,get:function(){if(0<this.count){this.count--;var a=this._pool[this.count];this._pool[this.count]=null;return a}return new Image},put:function(a){var b=this._pool;a instanceof HTMLImageElement&&this.count<this._MAX&&(a.src=this._smallImg,b[this.count]=a,this.count++)}};
cc.loader=function(){var a={},b={},c={},d={},e={},f=/^(?:https?|ftp):\/\/\S*$/i;return{resPath:"",basePath:"",audioPath:"",cache:{},getXMLHttpRequest:function(){var a=window.XMLHttpRequest?new window.XMLHttpRequest:new ActiveXObject("MSXML2.XMLHTTP");try{a.timeout=24E4}catch(h){cc.log(h)}void 0===a.ontimeout&&(a._timeoutId=-1);return a},_getArgs4Js:function(a){var b=a[0],c=a[1],d=a[2],e=[this.basePath,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||this.basePath,e[1]=c instanceof Array?c:[c]);else if(3===a.length)e[0]=b||this.basePath,e[1]=c instanceof Array?c:[c],e[2]=d;else throw Error("arguments error to load js!");return e},isLoading:function(a){return void 0!==e[a]},loadJs:function(b,c,d){var e=this,f=e._getArgs4Js(arguments),g=f[0],h=f[1];f=f[2];-1<navigator.userAgent.indexOf("Trident/5")?e._loadJs4Dependency(g,h,0,f):cc.async.map(h,function(b,c,d){b=cc.path.join(g,b);if(a[b])return d(null);
e._createScript(b,!1,d)},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 Error(a);d.parentNode.removeChild(d);if(e[2])e[2]()})},_createScript:function(b,c,d){var e=document,f=document.createElement("script");f.async=c;a[b]=!0;cc.game.config.noCache&&"string"===typeof b?this._noCacheRex.test(b)?f.src=b+"&_t="+(new Date-0):f.src=b+"?_t="+(new Date-0):f.src=b;f.addEventListener("load",function(){f.parentNode.removeChild(f);
this.removeEventListener("load",arguments.callee,!1);d()},!1);f.addEventListener("error",function(){f.parentNode.removeChild(f);d("Load "+b+" failed!")},!1);e.body.appendChild(f)},_loadJs4Dependency:function(a,b,c,d){if(c>=b.length)d&&d();else{var e=this;e._createScript(cc.path.join(a,b[c]),!1,function(f){if(f)return d(f);e._loadJs4Dependency(a,b,c+1,d)})}},_loadJsImg:function(){var a=document,b=a.getElementById("cocos2d_loadJsImg");if(!b){b=document.createElement("img");cc._loadingImage&&(b.crossOrigin=
"anonymous",b.src=cc._loadingImage);a=a.getElementById(cc.game.config.id);a.style.backgroundColor="transparent";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,c){var d=this,e=function(e,f){null==e?b(e,f):void 0==c||0<c?(cc.warn("retry load: "+
a),cc.director.getScheduler().schedule(function(){cc.loader.loadTxt(a,b,void 0==c?5:c-1)},d,2,0,0,!1,a)):(cc.warn("load failed: "+a),b(e,f))};if(cc._isNodeJs)require("fs").readFile(a,function(a,b){a?e(a):e(null,b.toString())});else{var f=this.getXMLHttpRequest(),g="load "+a+" failed!";void 0==c?f.open("GET",a,!0):f.open("GET",a+(0<=a.indexOf("?")?"&":"?")+"_r="+Math.random(),!0);if(/msie/i.test(navigator.userAgent)&&!/opera/i.test(navigator.userAgent))f.setRequestHeader("Accept-Charset","utf-8"),
f.onreadystatechange=function(){4===f.readyState&&(200===f.status?e(null,f.responseText):e({status:f.status,errorMessage:g},null))};else{f.overrideMimeType&&f.overrideMimeType("text/plain; charset=utf-8");var h=function(){f.removeEventListener("load",h);f.removeEventListener("error",k);0<=f._timeoutId?clearTimeout(f._timeoutId):f.removeEventListener("timeout",v);4===f.readyState&&(200===f.status?e(null,f.responseText):e({status:f.status,errorMessage:g},null))},k=function(){f.removeEventListener("load",
h);f.removeEventListener("error",k);0<=f._timeoutId?clearTimeout(f._timeoutId):f.removeEventListener("timeout",v);e({status:f.status,errorMessage:g},null)},v=function(){f.removeEventListener("load",h);f.removeEventListener("error",k);0<=f._timeoutId?clearTimeout(f._timeoutId):f.removeEventListener("timeout",v);e({status:f.status,errorMessage:"Request timeout: "+g},null)};f.addEventListener("load",h);f.addEventListener("error",k);void 0===f.ontimeout?f._timeoutId=setTimeout(function(){v()},f.timeout):
f.addEventListener("timeout",v)}f.send(null)}},loadCsb:function(a,b,c){var d=this,e=function(e,f){null==e?b(e,f):void 0==c||0<c?(cc.warn("retry load: "+a),cc.director.getScheduler().schedule(function(){cc.loader.loadCsb(a,b,void 0==c?5:c-1)},d,2,0,0,!1,a)):(cc.warn("load failed: "+a),b(e,f))},f=cc.loader.getXMLHttpRequest(),g="load "+a+" failed!";void 0==c?f.open("GET",a,!0):f.open("GET",a+(0<=a.indexOf("?")?"&":"?")+"_r="+Math.random(),!0);f.responseType="arraybuffer";var h=function(){f.removeEventListener("load",
h);f.removeEventListener("error",k);0<=f._timeoutId?clearTimeout(f._timeoutId):f.removeEventListener("timeout",v);var a=f.response;a&&(window.msg=a);4===f.readyState&&(200===f.status?e(null,f.response):e({status:f.status,errorMessage:g},null))},k=function(){f.removeEventListener("load",h);f.removeEventListener("error",k);0<=f._timeoutId?clearTimeout(f._timeoutId):f.removeEventListener("timeout",v);e({status:f.status,errorMessage:g},null)},v=function(){f.removeEventListener("load",h);f.removeEventListener("error",
k);0<=f._timeoutId?clearTimeout(f._timeoutId):f.removeEventListener("timeout",v);e({status:f.status,errorMessage:"Request timeout: "+g},null)};f.addEventListener("load",h);f.addEventListener("error",k);void 0===f.ontimeout?f._timeoutId=setTimeout(function(){v()},f.timeout):f.addEventListener("timeout",v);f.send(null)},loadJson:function(a,b){this.loadTxt(a,function(c,d){if(c)b(c);else{try{var e=JSON.parse(d)}catch(p){throw Error("parse json ["+a+"] failed : "+p);}b(null,e)}})},_checkIsImageURL:function(a){return null!=
/(\.png)|(\.jpg)|(\.bmp)|(\.jpeg)|(\.gif)/.exec(a)},loadImg:function(a,b,c,d){var f={isCrossOrigin:!0};void 0!==c?f.isCrossOrigin=void 0===b.isCrossOrigin?f.isCrossOrigin:b.isCrossOrigin:void 0!==b&&(c=b);if(b=this.getRes(a))return c&&c(null,b),null;if(b=e[a])return b.callbacks.push(c),b.img;d=d||imagePool.get();d.crossOrigin="anonymous";var g=this,h=function(){this.removeEventListener("load",h,!1);this.removeEventListener("error",k,!1);var b=e[a];if(b){for(var c=b.callbacks,f=0;f<c.length;++f){var g=
c[f];g&&g(null,d)}b.img=null;delete e[a]}window.ENABLE_IMAEG_POOL&&cc._renderType===cc.game.RENDER_TYPE_WEBGL&&imagePool.put(d)},k=function(){this.removeEventListener("load",h,!1);this.removeEventListener("error",k,!1);if("https:"!==window.location.protocol&&d.crossOrigin&&"anonymous"===d.crossOrigin.toLowerCase())f.isCrossOrigin=!1,g.release(a),cc.loader.loadImg(a,f,c,d);else{var b=e[a];if(b)if(0<b.retry)cc.warn("retry load image:"+a),--b.retry,cc.director.getScheduler().schedule(function(){cc.warn("try load image:"+
b.url);var a=cc.loader.getXMLHttpRequest();a.open("GET",b.url+(0<=b.url.indexOf("?")?"&":"?")+"_r="+Math.random(),!0);a.responseType="arraybuffer";a.timeout=3E5;var c=function(){a.removeEventListener("load",c);a.removeEventListener("error",d);0<=a._timeoutId?clearTimeout(a._timeoutId):a.removeEventListener("timeout",e);if(4==a.readyState&&200==a.status&&a.response){var f=new Blob([a.response],{type:"application/octet-binary"});f=(window.URL||window.webkitURL).createObjectURL(f);b.img.addEventListener("load",
h);b.img.addEventListener("error",k);b.img.src=f}else cc.warn("load img failed ["+a.status+"] "+b.url),k()},d=function(){a.removeEventListener("load",c);a.removeEventListener("error",d);0<=a._timeoutId?clearTimeout(a._timeoutId):a.removeEventListener("timeout",e);cc.warn("load img failed ["+a.status+"] "+b.url);k()},e=function(){a.removeEventListener("load",c);a.removeEventListener("error",d);0<=a._timeoutId?clearTimeout(a._timeoutId):a.removeEventListener("timeout",e);cc.warn("load img timeout "+
b.url);k()};a.addEventListener("load",c);a.addEventListener("error",d);void 0===a.ontimeout?a._timeoutId=setTimeout(e,a.timeout):a.addEventListener("timeout",e);a.send()},g,2,0,0,!1,b.url);else{for(var m=b.callbacks,n=0;n<m.length;++n){var p=m[n];p&&p("load image failed")}b.img=null;delete e[a]}window.ENABLE_IMAEG_POOL&&cc._renderType===cc.game.RENDER_TYPE_WEBGL&&imagePool.put(d)}};e[a]={url:a,retry:5,img:d,callbacks:c?[c]:[]};d.addEventListener("load",h);d.addEventListener("error",k);d.src=a;return d},
_loadResIterator:function(a,c,d){var e=this,g=null,h=a.type;h?(h="."+h.toLowerCase(),g=a.src?a.src:a.name+h):(g=a,h=cc.path.extname(g));if(c=e.getRes(g))return d(null,c);c=null;h&&(c=b[h.toLowerCase()]);if(!c)return cc.error("loader for ["+h+"] not exists!"),d();h=g;f.test(g)||(h=c.getBasePath?c.getBasePath():cc.path.join(e.basePath,e.resPath),h=e.getUrl(h,g));cc.game.config.noCache&&"string"===typeof h&&(h=e._noCacheRex.test(h)?h+("&_t="+(new Date-0)):h+("?_t="+(new Date-0)));c.load(h,g,a,function(a,
b){a?(cc.log(a),e.cache[g]=null,delete e.cache[g],d({status:520,errorMessage:a},null)):(e.cache[g]=b,d(null,b))})},_noCacheRex:/\?/,getUrl:function(a,d){var e=cc.path;if(void 0!==a&&void 0===d){d=a;var f=e.extname(d);f=f?f.toLowerCase():"";a=(f=b[f])?f.getBasePath?f.getBasePath():cc.path.join(this.basePath,this.resPath):cc.path.join(this.basePath,this.resPath)}d=cc.path.join(a||"",d);if(d.match(/[\/(\\\\)]lang[\/(\\\\)]/i)){if(c[d])return c[d];e=e.extname(d)||"";d=c[d]=d.substring(0,d.length-e.length)+
"_"+cc.sys.language+e}return d},load:function(a,b,c){var d=this,e=arguments.length;if(0===e)throw Error("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,cc.CONCURRENCY_HTTP_REQUEST_COUNT,function(a,c,e,f){d._loadResIterator(a,c,function(a){var c=Array.prototype.slice.call(arguments,1);b.trigger&&b.trigger.call(b.triggerTarget,c[0],f.size,
f.finishedSize);e(a,c[0])})},b.cb,b.cbTarget);e.flow();return e},_handleAliases:function(a,b){var c=[],e;for(e in a){var f=a[e];d[e]=f;c.push(f)}this.load(c,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,c){if(a&&c){if("string"===typeof a)return b[a.trim().toLowerCase()]=c;for(var d=0,e=a.length;d<e;d++)b["."+a[d].trim().toLowerCase()]=c}},getRes:function(a){return this.cache[a]||
this.cache[d[a]]},_getAliase:function(a){return d[a]},release:function(a){var b=this.cache,c=e[a];c&&(c.img=null,delete e[a]);delete b[a];delete b[d[a]];delete d[a]},releaseAll:function(){var a=this.cache,b;for(b in a)delete a[b];for(b in d)delete d[b]}}}();
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;e<b;++e){var f=a[e];if(d)for(;;){var g;if("number"===typeof f&&(g=c.match(/(%d)|(%s)/))){c=c.replace(/(%d)|(%s)/,f);break}c=(g=c.match(/%s/))?c.replace(/%s/,f):c+("    "+f);break}else c+="    "+f}return c};
(function(){function a(a){var b=cc.game.CONFIG_KEY,c=parseInt(a[b.renderMode])||0;if(isNaN(c)||2<c||0>c)a[b.renderMode]=0;cc._renderType=cc.game.RENDER_TYPE_CANVAS;cc._supportRender=!1;0===c?cc.sys.capabilities.opengl?(cc._renderType=cc.game.RENDER_TYPE_WEBGL,cc._supportRender=!0):cc.sys.capabilities.canvas&&(cc._renderType=cc.game.RENDER_TYPE_CANVAS,cc._supportRender=!0):1===c&&cc.sys.capabilities.canvas?(cc._renderType=cc.game.RENDER_TYPE_CANVAS,cc._supportRender=!0):2===c&&cc.sys.capabilities.opengl&&
(cc._renderType=cc.game.RENDER_TYPE_WEBGL,cc._supportRender=!0)}function b(a,c,d){if(h[c])return null;d=d||"";var e=[],f=a[c];if(!f)throw Error("can not find module ["+c+"]");c=cc.path;for(var g=0,k=f.length;g<k;g++){var m=f[g];if(!h[m]){var n=c.extname(m);n?".js"===n.toLowerCase()&&e.push(c.join(d,m)):(n=b(a,m,d))&&(e=e.concat(n));h[m]=1}}return e}function c(a){cc._initDebugSetting&&cc._initDebugSetting(a[cc.game.CONFIG_KEY.debugMode]);cc._engineLoaded=!0;console.log(cc.ENGINE_VERSION);m&&m()}function d(a){var d=
a[cc.game.CONFIG_KEY.engineDir],e=cc.loader;if(cc.Class)c(a);else{var f=cc.path.join(e.basePath,d,"moduleConfig.json");e.loadJson(f,function(e,f){if(e)throw Error(e);var g=a.modules||[],h=f.module,k=[];cc.sys.capabilities.opengl&&0>g.indexOf("base4webgl")?g.splice(0,0,"base4webgl"):0>g.indexOf("core")&&g.splice(0,0,"core");for(var m=0,n=g.length;m<n;m++){var p=b(h,g[m],d);p&&(k=k.concat(p))}cc.loader.loadJsWithImg(k,function(b){if(b)throw b;c(a)})})}}function e(){this.removeEventListener("load",e,
!1);d(cc.game.config)}var f=document.createElement("canvas"),g=document.createElement("canvas");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(v){}if(d)break}return d};(function(){cc.sys={};var a=cc.sys;a.LANGUAGE_ENGLISH="en";a.LANGUAGE_CHINESE="zh";a.LANGUAGE_FRENCH="fr";a.LANGUAGE_ITALIAN="it";a.LANGUAGE_GERMAN="de";a.LANGUAGE_SPANISH="es";a.LANGUAGE_DUTCH="du";a.LANGUAGE_RUSSIAN="ru";
a.LANGUAGE_KOREAN="ko";a.LANGUAGE_JAPANESE="ja";a.LANGUAGE_HUNGARIAN="hu";a.LANGUAGE_PORTUGUESE="pt";a.LANGUAGE_ARABIC="ar";a.LANGUAGE_NORWEGIAN="no";a.LANGUAGE_POLISH="pl";a.LANGUAGE_UNKNOWN="unkonwn";a.OS_IOS="iOS";a.OS_ANDROID="Android";a.OS_WINDOWS="Windows";a.OS_MARMALADE="Marmalade";a.OS_LINUX="Linux";a.OS_BADA="Bada";a.OS_BLACKBERRY="Blackberry";a.OS_OSX="OS X";a.OS_WP8="WP8";a.OS_WINRT="WINRT";a.OS_UNKNOWN="Unknown";a.UNKNOWN=-1;a.WIN32=0;a.LINUX=1;a.MACOS=2;a.ANDROID=3;a.IPHONE=4;a.IPAD=
5;a.BLACKBERRY=6;a.NACL=7;a.EMSCRIPTEN=8;a.TIZEN=9;a.WINRT=10;a.WP8=11;a.MOBILE_BROWSER=100;a.DESKTOP_BROWSER=101;a.BROWSER_TYPE_WECHAT="wechat";a.BROWSER_TYPE_ANDROID="androidbrowser";a.BROWSER_TYPE_IE="ie";a.BROWSER_TYPE_QQ_APP="qq";a.BROWSER_TYPE_QQ="qqbrowser";a.BROWSER_TYPE_MOBILE_QQ="mqqbrowser";a.BROWSER_TYPE_UC="ucbrowser";a.BROWSER_TYPE_360="360browser";a.BROWSER_TYPE_BAIDU_APP="baiduboxapp";a.BROWSER_TYPE_BAIDU="baidubrowser";a.BROWSER_TYPE_MAXTHON="maxthon";a.BROWSER_TYPE_OPERA="opera";
a.BROWSER_TYPE_OUPENG="oupeng";a.BROWSER_TYPE_MIUI="miuibrowser";a.BROWSER_TYPE_FIREFOX="firefox";a.BROWSER_TYPE_SAFARI="safari";a.BROWSER_TYPE_CHROME="chrome";a.BROWSER_TYPE_LIEBAO="liebao";a.BROWSER_TYPE_QZONE="qzone";a.BROWSER_TYPE_SOUGOU="sogou";a.BROWSER_TYPE_UNKNOWN="unknown";a.isNative=!1;var b=window,c=b.navigator,d=document,e=d.documentElement,h=c.userAgent.toLowerCase();a.isMobile=/mobile|android|iphone|ipad/.test(h);a.platform=a.isMobile?a.MOBILE_BROWSER:a.DESKTOP_BROWSER;var k=c.language;
k=(k=k?k:c.browserLanguage)?k.split("-")[0]:a.LANGUAGE_ENGLISH;a.language=k;var m=!1;k=!1;var y="",z=0,A=/android (\d+(?:\.\d+)+)/i.exec(h)||/android (\d+(?:\.\d+)+)/i.exec(c.platform);A&&(m=!0,y=A[1]||"",z=parseInt(y)||0);(A=/(iPad|iPhone|iPod).*OS ((\d+_?){2,3})/i.exec(h))?(k=!0,y=A[2]||"",z=parseInt(y)||0):/(iPhone|iPad|iPod)/.exec(c.platform)&&(k=!0,y="",z=0);A=a.OS_UNKNOWN;-1!==c.appVersion.indexOf("Win")?A=a.OS_WINDOWS:k?A=a.OS_IOS:-1!==c.appVersion.indexOf("Mac")?A=a.OS_OSX:-1!==c.appVersion.indexOf("X11")&&
-1===c.appVersion.indexOf("Linux")?A=a.OS_UNIX:m?A=a.OS_ANDROID:-1!==c.appVersion.indexOf("Linux")&&(A=a.OS_LINUX);a.os=A;a.osVersion=y;a.osMainVersion=z;a.browserType=a.BROWSER_TYPE_UNKNOWN;(function(){var b=/qqbrowser|qq|chrome|safari|firefox|opr|oupeng|opera/i,c=/micromessenger|mqqbrowser|sogou|qzone|liebao|ucbrowser|360 aphone|360browser|baiduboxapp|baidubrowser|maxthon|mxbrowser|trident|miuibrowser/i.exec(h);c||(c=b.exec(h));b=c?c[0]:a.BROWSER_TYPE_UNKNOWN;"micromessenger"===b?b=a.BROWSER_TYPE_WECHAT:
"safari"===b&&m?b=a.BROWSER_TYPE_ANDROID:"trident"===b?b=a.BROWSER_TYPE_IE:"360 aphone"===b?b=a.BROWSER_TYPE_360:"mxbrowser"===b?b=a.BROWSER_TYPE_MAXTHON:"opr"===b&&(b=a.BROWSER_TYPE_OPERA);a.browserType=b})();a.browserVersion="";(function(){var b=/(msie |rv:|firefox|chrome|ucbrowser|qq|oupeng|opera|opr|safari|miui)(mobile)?(browser)?\/?([\d.]+)/i,c=h.match(/(mqqbrowser|micromessenger|sogou|qzone|liebao|maxthon|mxbrowser|baidu)(mobile)?(browser)?\/?([\d.]+)/i);c||(c=h.match(b));a.browserVersion=c?
c[4]:""})();k=window.devicePixelRatio||1;a.windowPixelResolution={width:k*(window.innerWidth||document.documentElement.clientWidth),height:k*(window.innerHeight||document.documentElement.clientHeight)};a._checkWebGLRenderMode=function(){if(cc._renderType!==cc.game.RENDER_TYPE_WEBGL)throw Error("This feature supports WebGL render mode only.");};a._supportCanvasNewBlendModes=function(){var a=f;a.width=1;a.height=1;a=a.getContext("2d");a.fillStyle="#000";a.fillRect(0,0,1,1);a.globalCompositeOperation=
"multiply";var b=g;b.width=1;b.height=1;var c=b.getContext("2d");c.fillStyle="#fff";c.fillRect(0,0,1,1);a.drawImage(b,0,0,1,1);return 0===a.getImageData(0,0,1,1).data[0]}();cc.sys.isMobile&&(k=document.createElement("style"),k.type="text/css",document.body.appendChild(k),k.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);}");try{var B=a.localStorage=b.localStorage;B.setItem("storage",
"");B.removeItem("storage");B=null}catch(D){B=function(){cc.warn("Warning: localStorage isn't enabled. Please confirm browser cookie or privacy option")},a.localStorage={getItem:B,setItem:B,removeItem:B,clear:B}}B=!!f.getContext("2d");k=!1;if(b.WebGLRenderingContext){y=document.createElement("CANVAS");try{if(cc.create3DContext(y)&&(k=!0),k&&a.os===a.OS_IOS&&9===a.osMainVersion&&(window.indexedDB||(k=!1)),k&&a.os===a.OS_ANDROID){var C=parseFloat(a.browserVersion);switch(a.browserType){case a.BROWSER_TYPE_MOBILE_QQ:case a.BROWSER_TYPE_BAIDU:case a.BROWSER_TYPE_BAIDU_APP:k=
6.2<=C?!0:!1;break;case a.BROWSER_TYPE_CHROME:k=30<=C?!0:!1;break;case a.BROWSER_TYPE_ANDROID:a.osMainVersion&&5<=a.osMainVersion&&(k=!0);break;case a.BROWSER_TYPE_UNKNOWN:case a.BROWSER_TYPE_360:case a.BROWSER_TYPE_MIUI:case a.BROWSER_TYPE_UC:k=!1}}}catch(D){}y=null}C=a.capabilities={canvas:B,opengl:k};if(void 0!==e.ontouchstart||void 0!==d.ontouchstart||c.msPointerEnabled)C.touches=!0;void 0!==e.onmouseup&&(C.mouse=!0);void 0!==e.onkeyup&&(C.keyboard=!0);if(b.DeviceMotionEvent||b.DeviceOrientationEvent)C.accelerometer=
!0;a.garbageCollect=function(){};a.dumpRoot=function(){};a.restartVM=function(){};a.cleanScript=function(a){};a.isObjectValid=function(a){return a?!0:!1};a.dump=function(){var a=""+("isMobile : "+this.isMobile+"\r\n");a+="language : "+this.language+"\r\n";a+="browserType : "+this.browserType+"\r\n";a+="browserVersion : "+this.browserVersion+"\r\n";a+="capabilities : "+JSON.stringify(this.capabilities)+"\r\n";a+="os : "+this.os+"\r\n";a+="osVersion : "+this.osVersion+"\r\n";a+="platform : "+this.platform+
"\r\n";a+="Using "+(cc._renderType===cc.game.RENDER_TYPE_WEBGL?"WEBGL":"CANVAS")+" renderer.\r\n";cc.log(a)};a.openURL=function(a){window.open(a)};a.now=function(){return Date.now?Date.now():+new Date}})();g=f=null;cc.log=cc.warn=cc.error=cc.assert=function(){};var h={},k=!1,m=null;cc._engineLoaded=!1;cc.initEngine=function(b,c){if(k){var f=m;m=function(){f&&f();c&&c()}}else m=c,!cc.game.config&&b?cc.game.config=b:cc.game.config||cc.game._loadConfig(),b=cc.game.config,a(b),document.body?d(b):cc._addEventListener(window,
"load",e,!1),k=!0}})();
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",EVENT_RESIZE:"game_on_resize",EVENT_RENDERER_INITED:"renderer_inited",RENDER_TYPE_CANVAS:0,RENDER_TYPE_WEBGL:1,RENDER_TYPE_OPENGL:2,_eventHide:null,_eventShow:null,CONFIG_KEY:{width:"width",height:"height",engineDir:"engineDir",modules:"modules",debugMode:"debugMode",exposeClassName:"exposeClassName",
showFPS:"showFPS",frameRate:"frameRate",id:"id",renderMode:"renderMode",jsList:"jsList"},_paused:!0,_configLoaded:!1,_prepareCalled:!1,_prepared:!1,_rendererInitialized:!1,_renderContext:null,_intervalId:null,_lastTime:null,_frameTime:null,frame:null,container:null,canvas:null,config:null,onStart:null,onStop:null,setFrameRate:function(a){this.config[this.CONFIG_KEY.frameRate]=a;this._intervalId&&window.cancelAnimationFrame(this._intervalId);this._intervalId=0;this._paused=!0;this._setAnimFrame();
this._runMainLoop()},step:function(){cc.director.mainLoop()},pause:function(){this._paused||(this._paused=!0,cc.audioEngine&&cc.audioEngine._pausePlaying(),this._intervalId&&window.cancelAnimationFrame(this._intervalId),this._intervalId=0)},resume:function(){this._paused&&(this._paused=!1,cc.audioEngine&&cc.audioEngine._resumePlaying(),this._runMainLoop())},isPaused:function(){return this._paused},restart:function(){cc.director.popToSceneStackLevel(0);cc.audioEngine&&cc.audioEngine.end();cc.game.onStart()},
end:function(){close()},prepare:function(a){var b=this,c=b.config,d=b.CONFIG_KEY;this._configLoaded?this._prepared?a&&a():this._prepareCalled||(cc._engineLoaded?(this._prepareCalled=!0,this._initRenderer(c[d.width],c[d.height]),cc.view=cc.EGLView._getInstance(),cc.director=cc.Director._getInstance(),cc.director.setOpenGLView&&cc.director.setOpenGLView(cc.view),cc.winSize=cc.director.getWinSize(),this._initEvents(),this._setAnimFrame(),this._runMainLoop(),(c=c[d.jsList])?cc.loader.loadJsWithImg(c,
function(c){if(c)throw Error(c);b._prepared=!0;a&&a()}):a&&a()):cc.initEngine(this.config,function(){b.prepare(a)})):this._loadConfig(function(){b.prepare(a)})},run:function(a,b){"function"===typeof a?cc.game.onStart=a:(a&&("string"===typeof a?(cc.game.config||this._loadConfig(),cc.game.config[cc.game.CONFIG_KEY.id]=a):cc.game.config=a),"function"===typeof b&&(cc.game.onStart=b));this.prepare(cc.game.onStart&&cc.game.onStart.bind(cc.game))},_setAnimFrame:function(){this._lastTime=new Date;var a=cc.game.config[cc.game.CONFIG_KEY.frameRate];
this._frameTime=1E3/a;60!==a&&30!==a?(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);cc.game._lastTime=b+c;return d},_ctTime:function(a){window.clearTimeout(a)},_runMainLoop:function(){var a=this,b=a.config,c=a.CONFIG_KEY,d=cc.director,e=!0,f=b[c.frameRate];d.setDisplayStats(b[c.showFPS]);
var g=function(){a._paused||(30===f&&(e=!e)||d.mainLoop(),a._intervalId=window.requestAnimFrame(g))};a._intervalId=window.requestAnimFrame(g);a._paused=!1},_loadConfig:function(a){var b=this.config||document.ccConfig;if(b)this._initConfig(b),a&&a();else{for(var c=document.getElementsByTagName("script"),d=0;d<c.length&&(b=c[d].getAttribute("cocos"),""!==b&&!b);d++);var e=this;b=function(b,c){var d=JSON.parse(c);e._initConfig(d);a&&a()};if(d<c.length){if(c=c[d].src)c=/(.*)\//.exec(c)[0],cc.loader.basePath=
c,c=cc.path.join(c,"project.json");cc.loader.loadTxt(c,b)}else cc.loader.loadTxt("project.json",b)}},_initConfig:function(a){var b=this.CONFIG_KEY,c=a[b.modules];a[b.showFPS]="undefined"===typeof a[b.showFPS]?!0:a[b.showFPS];a[b.engineDir]=a[b.engineDir]||"frameworks/cocos2d-html5";null==a[b.debugMode]&&(a[b.debugMode]=0);a[b.exposeClassName]=!!a[b.exposeClassName];a[b.frameRate]=a[b.frameRate]||60;null==a[b.renderMode]&&(a[b.renderMode]=0);null==a[b.registerSystemEvent]&&(a[b.registerSystemEvent]=
!0);c&&0>c.indexOf("core")&&c.splice(0,0,"core");c&&(a[b.modules]=c);this.config=a;this._configLoaded=!0},_initRenderer:function(a,b){if(!this._rendererInitialized){if(!cc._supportRender)throw Error("The renderer doesn't support the renderMode "+this.config[this.CONFIG_KEY.renderMode]);var c=this.config[cc.game.CONFIG_KEY.id],d=window;c=cc.$(c)||cc.$("#"+c);var e,f;"CANVAS"===c.tagName?(a=a||c.width,b=b||c.height,this.canvas=cc._canvas=e=c,this.container=cc.container=f=document.createElement("DIV"),
e.parentNode&&e.parentNode.insertBefore(f,e)):("DIV"!==c.tagName&&cc.log("Warning: target element is not a DIV or CANVAS"),a=a||c.clientWidth,b=b||c.clientHeight,this.canvas=cc._canvas=e=cc.$(document.createElement("CANVAS")),this.container=cc.container=f=document.createElement("DIV"),c.appendChild(f));f.setAttribute("id","Cocos2dGameContainer");f.appendChild(e);this.frame=f.parentNode===document.body?document.documentElement:f.parentNode;e.addClass("gameCanvas");e.setAttribute("width",a||480);e.setAttribute("height",
b||320);e.setAttribute("tabindex",99);cc._renderType===cc.game.RENDER_TYPE_WEBGL&&(this._renderContext=cc._renderContext=cc.webglContext=cc.create3DContext(e,{stencil:!0,alpha:!0,antialias:!1,preserveDrawingBuffer:!0}));this._renderContext?(cc.renderer=cc.rendererWebGL,d.gl=this._renderContext,cc.renderer.init(),cc._drawingUtil=new cc.DrawingPrimitiveWebGL(this._renderContext),cc.textureCache._initializingRenderer(),cc.glExt={},cc.glExt.instanced_arrays=d.gl.getExtension("ANGLE_instanced_arrays"),
cc.glExt.element_uint=d.gl.getExtension("OES_element_index_uint")):(cc._renderType=cc.game.RENDER_TYPE_CANVAS,cc.renderer=cc.rendererCanvas,this._renderContext=cc._renderContext=new cc.CanvasContextWrapper(e.getContext("2d")),cc._drawingUtil=cc.DrawingPrimitiveCanvas?new cc.DrawingPrimitiveCanvas(this._renderContext):null);cc._gameDiv=f;cc.game.canvas.oncontextmenu=function(){if(!cc._isContextMenuEnable)return!1};this.dispatchEvent(this.EVENT_RENDERER_INITED,!0);this._rendererInitialized=!0}},_initEvents:function(){var a=
window,b;this._eventHide=this._eventHide||new cc.EventCustom(this.EVENT_HIDE);this._eventHide.setUserData(this);this._eventShow=this._eventShow||new cc.EventCustom(this.EVENT_SHOW);this._eventShow.setUserData(this);this.config[this.CONFIG_KEY.registerSystemEvent]&&cc.inputManager.registerSystemEvent(this.canvas);cc.isUndefined(document.hidden)?cc.isUndefined(document.mozHidden)?cc.isUndefined(document.msHidden)?cc.isUndefined(document.webkitHidden)||(b="webkitHidden"):b="msHidden":b="mozHidden":b=
"hidden";var c=["visibilitychange","mozvisibilitychange","msvisibilitychange","webkitvisibilitychange","qbrowserVisibilityChange"],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)};if(b)for(var f=0;f<c.length;f++)document.addEventListener(c[f],function(a){var c=document[b];(c=c||a.hidden)?d():e()},!1);else a.addEventListener("blur",d,!1),a.addEventListener("focus",
e,!1);-1<navigator.userAgent.indexOf("MicroMessenger")&&(a.onfocus=function(){e()});"onpageshow"in window&&"onpagehide"in window&&(a.addEventListener("pagehide",d,!1),a.addEventListener("pageshow",e,!1));cc.eventManager.addCustomListener(cc.game.EVENT_HIDE,function(){cc.game.pause()});cc.eventManager.addCustomListener(cc.game.EVENT_SHOW,function(){cc.game.resume()})}};
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)))};d.prototype=this.prototype;e.prototype=new d;return e};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)setTimeout(function(){b.call(c)},0);else{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;a<e;a++){var f=d[a];if(f.callback===b&&f.eventTarget===c)return!0}}return!1},removeEventListener:function(a,b,c){if(void 0!==this._listeners&&(a=this._listeners[a],void 0!==a))for(var d=0;d<a.length;){var e=a[d];e.eventTarget===c&&e.callback===b?a.splice(d,1):d++}},removeEventTarget:function(a,
b,c){if(void 0!==this._listeners&&(a=this._listeners[a],void 0!==a))for(b=0;b<a.length;)a[b].eventTarget===c?a.splice(b,1):b++},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;f<e;f++)d[f]=c[f];for(f=0;f<e;f++)d[f].callback.call(d[f].eventTarget,this);b&&(c.length=0)}}}};cc.EventHelper.prototype.apply(cc.game);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 = %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 != RotationY. Don't know which one to return",Node_getScale:"ScaleX != 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 = %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:"cc.Node.reorderChild(): child must be non-null",Node_reorderChild_2:"cc.Node.reorderChild(): this child is not in children list",
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 = %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_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_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=%s %s x %s",textureCache_dumpCachedTextureInfo_2:"cocos2d: '%s' id= 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))try{return JSON.stringify(a)}catch(b){return""}else return a};
cc._initDebugSetting=function(a){var b=cc.game;if(a===b.DEBUG_MODE_NONE){var c=(new Date).getTime();cc.error=function(){cc.logTrace.push("["+c+"] ERROR :  "+cc.formatStr.apply(cc,arguments))};cc.warn=function(){cc.logTrace.push("["+c+"] WARN :  "+cc.formatStr.apply(cc,arguments))};cc.log=function(){cc.logTrace.push("["+c+"] LOG :  "+cc.formatStr.apply(cc,arguments))};cc.assert=function(a,b){if(!a&&b){for(var d=2;d<arguments.length;d++)b=b.replace(/(%s)|(%d)/,cc._formatString(arguments[d]));cc.logTrace.push("["+
c+"] Assert: "+b)}}}else if(a>b.DEBUG_MODE_ERROR){var d=cc._logToWebPage.bind(cc);cc.error=function(){d("ERROR :  "+cc.formatStr.apply(cc,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]));d("Assert: "+b)}};a!==b.DEBUG_MODE_ERROR_FOR_WEB_PAGE&&(cc.warn=function(){d("WARN :  "+cc.formatStr.apply(cc,arguments))});a===b.DEBUG_MODE_INFO_FOR_WEB_PAGE&&(cc.log=function(){d(cc.formatStr.apply(cc,arguments))})}else console&&
console.log.apply&&(cc.error=Function.prototype.bind.call(console.error,console),cc.assert=function(a,b){void 0===b&&(b="no message");if(!a&&b){for(var c=2;c<arguments.length;c++)b=b.replace(/(%s)|(%d)/,cc._formatString(arguments[c]));throw Error(b);}},a!==b.DEBUG_MODE_ERROR&&(cc.warn=Function.prototype.bind.call(console.warn,console)),a===b.DEBUG_MODE_INFO&&(cc.log=Function.prototype.bind.call(console.log,console)))};cc.logTrace=cc.logTrace||[];cc.loader.loadBinary=function(a,b){var c=this,d=this.getXMLHttpRequest(),e="load "+a+" failed!";d.open("GET",a,!0);d.responseType="arraybuffer";cc.loader.loadBinary._IEFilter?(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=x-user-defined"),d.onload=function(){4===d.readyState&&
200===d.status?b(null,new Uint8Array(d.response)):b(e)});d.send(null)};cc.loader.loadBinary._IEFilter=/msie/i.test(navigator.userAgent)&&!/opera/i.test(navigator.userAgent)&&window.IEBinaryToArray_ByteStr&&window.IEBinaryToArray_ByteStr_Last;cc.loader._str2Uint8Array=function(a){if(!a)return null;for(var b=new Uint8Array(a.length),c=0;c<a.length;c++)b[c]=a.charCodeAt(c)&255;return b};
cc.loader.loadBinarySync=function(a){var b=this.getXMLHttpRequest();b.timeout=0;var c="load "+a+" failed!";b.open("GET",a,!1);a=null;if(cc.loader.loadBinary._IEFilter){b.setRequestHeader("Accept-Charset","x-user-defined");b.send(null);if(200!==b.status)return cc.log(c),null;(b=cc._convertResponseBodyToText(b.responseBody))&&(a=this._str2Uint8Array(b))}else{b.overrideMimeType&&b.overrideMimeType("text/plain; charset=x-user-defined");b.send(null);if(200!==b.status)return cc.log(c),null;a=this._str2Uint8Array(b.responseText)}return a};
window.Uint8Array=window.Uint8Array||Array;
if(cc.loader.loadBinary._IEFilter){var IEBinaryToArray_ByteStr_Script='\x3c!-- IEBinaryToArray_ByteStr --\x3e\r\nFunction IEBinaryToArray_ByteStr(Binary)\r\n   IEBinaryToArray_ByteStr = CStr(Binary)\r\nEnd Function\r\nFunction IEBinaryToArray_ByteStr_Last(Binary)\r\n   Dim lastIndex\r\n   lastIndex = LenB(Binary)\r\n   if lastIndex mod 2 Then\r\n       IEBinaryToArray_ByteStr_Last = Chr( AscB( MidB( Binary, lastIndex, 1 ) ) )\r\n   Else\r\n       IEBinaryToArray_ByteStr_Last = ""\r\n   End If\r\nEnd Function\r\n',myVBScript=
document.createElement("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}};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,iVBORw0KGgoAAAANSUhEUgAAAQAAAAAgCAYAAAD9qabkAAAKQ2lDQ1BJQ0MgcHJvZmlsZQAAeNqdU3dYk/cWPt/3ZQ9WQtjwsZdsgQAiI6wIyBBZohCSAGGEEBJAxYWIClYUFRGcSFXEgtUKSJ2I4qAouGdBiohai1VcOO4f3Ke1fXrv7e371/u855zn/M55zw+AERImkeaiagA5UoU8Otgfj09IxMm9gAIVSOAEIBDmy8JnBcUAAPADeXh+dLA//AGvbwACAHDVLiQSx+H/g7pQJlcAIJEA4CIS5wsBkFIAyC5UyBQAyBgAsFOzZAoAlAAAbHl8QiIAqg0A7PRJPgUA2KmT3BcA2KIcqQgAjQEAmShHJAJAuwBgVYFSLALAwgCgrEAiLgTArgGAWbYyRwKAvQUAdo5YkA9AYACAmUIszAAgOAIAQx4TzQMgTAOgMNK/4KlfcIW4SAEAwMuVzZdL0jMUuJXQGnfy8ODiIeLCbLFCYRcpEGYJ5CKcl5sjE0jnA0zODAAAGvnRwf44P5Dn5uTh5mbnbO/0xaL+a/BvIj4h8d/+vIwCBAAQTs/v2l/l5dYDcMcBsHW/a6lbANpWAGjf+V0z2wmgWgrQevmLeTj8QB6eoVDIPB0cCgsL7SViob0w44s+/zPhb+CLfvb8QB7+23rwAHGaQJmtwKOD/XFhbnauUo7nywRCMW735yP+x4V//Y4p0eI0sVwsFYrxWIm4UCJNx3m5UpFEIcmV4hLpfzLxH5b9CZN3DQCshk/ATrYHtctswH7uAQKLDljSdgBAfvMtjBoLkQAQZzQyefcAAJO/+Y9AKwEAzZek4wAAvOgYXKiUF0zGCAAARKCBKrBBBwzBFKzADpzBHbzAFwJhBkRADCTAPBBCBuSAHAqhGJZBGVTAOtgEtbADGqARmuEQtMExOA3n4BJcgetwFwZgGJ7CGLyGCQRByAgTYSE6iBFijtgizggXmY4EImFINJKApCDpiBRRIsXIcqQCqUJqkV1II/ItchQ5jVxA+pDbyCAyivyKvEcxlIGyUQPUAnVAuagfGorGoHPRdDQPXYCWomvRGrQePYC2oqfRS+h1dAB9io5jgNExDmaM2WFcjIdFYIlYGibHFmPlWDVWjzVjHVg3dhUbwJ5h7wgkAouAE+wIXoQQwmyCkJBHWExYQ6gl7CO0EroIVwmDhDHCJyKTqE+0JXoS+cR4YjqxkFhGrCbuIR4hniVeJw4TX5NIJA7JkuROCiElkDJJC0lrSNtILaRTpD7SEGmcTCbrkG3J3uQIsoCsIJeRt5APkE+S+8nD5LcUOsWI4kwJoiRSpJQSSjVlP+UEpZ8yQpmgqlHNqZ7UCKqIOp9aSW2gdlAvU4epEzR1miXNmxZDy6Qto9XQmmlnafdoL+l0ugndgx5Fl9CX0mvoB+nn6YP0dwwNhg2Dx0hiKBlrGXsZpxi3GS+ZTKYF05eZyFQw1zIbmWeYD5hvVVgq9ip8FZHKEpU6lVaVfpXnqlRVc1U/1XmqC1SrVQ+rXlZ9pkZVs1DjqQnUFqvVqR1Vu6k2rs5Sd1KPUM9RX6O+X/2C+mMNsoaFRqCGSKNUY7fGGY0hFsYyZfFYQtZyVgPrLGuYTWJbsvnsTHYF+xt2L3tMU0NzqmasZpFmneZxzQEOxrHg8DnZnErOIc4NznstAy0/LbHWaq1mrX6tN9p62r7aYu1y7Rbt69rvdXCdQJ0snfU6bTr3dQm6NrpRuoW623XP6j7TY+t56Qn1yvUO6d3RR/Vt9KP1F+rv1u/RHzcwNAg2kBlsMThj8MyQY+hrmGm40fCE4agRy2i6kcRoo9FJoye4Ju6HZ+M1eBc+ZqxvHGKsNN5l3Gs8YWJpMtukxKTF5L4pzZRrmma60bTTdMzMyCzcrNisyeyOOdWca55hvtm82/yNhaVFnMVKizaLx5balnzLBZZNlvesmFY+VnlW9VbXrEnWXOss623WV2xQG1ebDJs6m8u2qK2brcR2m23fFOIUjynSKfVTbtox7PzsCuya7AbtOfZh9iX2bfbPHcwcEh3WO3Q7fHJ0dcx2bHC866ThNMOpxKnD6VdnG2ehc53zNRemS5DLEpd2lxdTbaeKp26fesuV5RruutK10/Wjm7ub3K3ZbdTdzD3Ffav7TS6bG8ldwz3vQfTw91jicczjnaebp8LzkOcvXnZeWV77vR5Ps5wmntYwbcjbxFvgvct7YDo+PWX6zukDPsY+Ap96n4e+pr4i3z2+I37Wfpl+B/ye+zv6y/2P+L/hefIW8U4FYAHBAeUBvYEagbMDawMfBJkEpQc1BY0FuwYvDD4VQgwJDVkfcpNvwBfyG/ljM9xnLJrRFcoInRVaG/owzCZMHtYRjobPCN8Qfm+m+UzpzLYIiOBHbIi4H2kZmRf5fRQpKjKqLupRtFN0cXT3LNas5Fn7Z72O8Y+pjLk722q2cnZnrGpsUmxj7Ju4gLiquIF4h/hF8ZcSdBMkCe2J5MTYxD2J43MC52yaM5zkmlSWdGOu5dyiuRfm6c7Lnnc8WTVZkHw4hZgSl7I/5YMgQlAvGE/lp25NHRPyhJuFT0W+oo2iUbG3uEo8kuadVpX2ON07fUP6aIZPRnXGMwlPUit5kRmSuSPzTVZE1t6sz9lx2S05lJyUnKNSDWmWtCvXMLcot09mKyuTDeR55m3KG5OHyvfkI/lz89sVbIVM0aO0Uq5QDhZML6greFsYW3i4SL1IWtQz32b+6vkjC4IWfL2QsFC4sLPYuHhZ8eAiv0W7FiOLUxd3LjFdUrpkeGnw0n3LaMuylv1Q4lhSVfJqedzyjlKD0qWlQyuCVzSVqZTJy26u9Fq5YxVhlWRV72qX1VtWfyoXlV+scKyorviwRrjm4ldOX9V89Xlt2treSrfK7etI66Trbqz3Wb+vSr1qQdXQhvANrRvxjeUbX21K3nShemr1js20zcrNAzVhNe1bzLas2/KhNqP2ep1/XctW/a2rt77ZJtrWv913e/MOgx0VO97vlOy8tSt4V2u9RX31btLugt2PGmIbur/mft24R3dPxZ6Pe6V7B/ZF7+tqdG9s3K+/v7IJbVI2jR5IOnDlm4Bv2pvtmne1cFoqDsJB5cEn36Z8e+NQ6KHOw9zDzd+Zf7f1COtIeSvSOr91rC2jbaA9ob3v6IyjnR1eHUe+t/9+7zHjY3XHNY9XnqCdKD3x+eSCk+OnZKeenU4/PdSZ3Hn3TPyZa11RXb1nQ8+ePxd07ky3X/fJ897nj13wvHD0Ivdi2yW3S609rj1HfnD94UivW2/rZffL7Vc8rnT0Tes70e/Tf/pqwNVz1/jXLl2feb3vxuwbt24m3Ry4Jbr1+Hb27Rd3Cu5M3F16j3iv/L7a/eoH+g/qf7T+sWXAbeD4YMBgz8NZD+8OCYee/pT/04fh0kfMR9UjRiONj50fHxsNGr3yZM6T4aeypxPPyn5W/3nrc6vn3/3i+0vPWPzY8Av5i8+/rnmp83Lvq6mvOscjxx+8znk98ab8rc7bfe+477rfx70fmSj8QP5Q89H6Y8en0E/3Pud8/vwv94Tz+4A5JREAAAAGYktHRAD/AP8A/6C9p5MAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQfcAgcQLxxUBNp/AAAQZ0lEQVR42u2be3QVVZbGv1N17829eRLyIKAEOiISEtPhJTJAYuyBDmhWjAEx4iAGBhxA4wABbVAMWUAeykMCM+HRTcBRWkNH2l5moS0LCCrQTkYeQWBQSCAIgYRXEpKbW/XNH5zS4noR7faPEeu31l0h4dSpvc+t/Z199jkFWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhY/H9D/MR9qfKnLj/00U71aqfJn9+HCkCR/Wk36ddsgyJ/1wF4fkDfqqm9/gPsUeTnVr6a2xlQfnxdI7zs0W7irzD17Ytb2WT7EeNv/r4ox1O3Quf2QP2pgt9utwfout4FQE8AVBSlnaRmfvAURQkg2RlAbwB9AThlW5L0GaiKojhJhgOIBqDa7XaPrusdPtr5kQwF0BVAAoBIABRCKDd5aFUhRDAAw57eAOwAhKIoupft3zoqhB1AqLwuHIBut9uFt02qqvqRDJR2dAEQJj/BAOjn56dqmma+xiaECAEQAWAggLsB6A6HQ2iaZggBhBAqgEAAnQB0kzaEmT4hAITT6VQ8Ho/HJAKKECJQtr8LwD1y/A1/vcdfEUIEyfZ9AcQbYvZ942Px88L2UwlJR0dH0EMPPbRj5syZPUeNGrXR7Xb/641xIwJ1XY9NSUlZm52dfW+XLl1w8uRJzJ8//+OGhoYJqqqe1TSt1Wsm9NN1PSIqKmr12rVrR5WUlHy1bdu2AQCumWc3IYRD1/UwVVXnFRQUTIuNjUVzczN2797dWFJSkq8oymZd15sAGAEnFEUJ1nX9nzIzM1dnZmZGh4SE4OTJk5g5c+Zf29vbp9pstrMej6fVOyhIhgAYU1hY+B+hoaGoqKg4XVlZea+XTULTNFdCQsLGiRMnPuR2u3UhBOV9eeDAAWXTpk095DUe6WsoyRE5OTlr0tLSAux2O/bs2cO5c+e+pijKUpIXSHaQVAGkvPLKK++6XK4OksJLCFlXV2cvKSlJBFAjhU+x2WwhHo9nUHp6+urMzMy7wsLCUF9fjxdffPHjxsbGiTab7WuPx9NiEutOuq4PyMjI+M+srKyYqKgoHD58GDNmzNjq8XhyVFU9b/q+LH7hBAEYu3PnTlZVVRFAGgCX6f/tAHoOHDjwa0p27txp/JO9e/f+QM7cipw9nfL3kQBKt2zZQpJ87rnn6mQmoHilw2EACs+cOUOSrK+vZ1NTE0nyo48+IoBpxswoBcMJ4Ndjx471kOTFixe5d+9ekqTH42H//v13A4jyzpAURfEH0H/OnDnthu1z5sw558MmFUCPWbNmnaMP3nrrLZoyDmP8Hl68eDFJ8siRI9/Yc+zYMQKYKdtAztrTrl27xptRXV1NAKMAOAyBBBA/Y8aMdpLs6Ojgxx9//E37+++//29yvFXppwvAwMcee8xjtDHsuXLlCqOjo//ia3wsfpkoALqFhoZuIckJEyackimm3dQmEMDUmpoakmRISMhhAHOHDx/eQJIbN24kgKEyMAHAFRMTs2XXrl1saWkhSZ0kp0+ffhrAr3wEW/S8efOukORLL72kA1gKYMPWrVtJkk899dRJAHeYrgsEsIQkjx8/TgDvAPjd448/3kaSb7zxBmUa7vC6z53BwcFbSHL9+vU6Sc6aNes8gF5ewWAH0PfVV18lSQL4DMBGIcQ6AKtcLleBFC2jXtFt8ODBe0iyoqKCAJYByC8qKmJDQwOzsrK+MAmqo1OnTveHhoa+GRkZ+XZkZOSWiIiIvzgcjk9mzpypkWRmZuZpmbYbGV4AgPnNzc1sa2sjgN0A5iQmJtaSZHl5OQHcb/K3s81mW0uSTU1NBFAFYFbfvn1Pk+Tbb79NAA8IIVzW42/hByA+Pz/fLR/2ZXIda05NI/z9/TeR5J49ewhgqlxTrtI0jY2NjQQw3zTLuWJiYjaUlJToS5Ys6fjkk080kwDEeAmADcA9GzZsIElGRUW9CyAWwLApU6Y0kOSKFSsog9QICGdERMTGsrIyZmVlEcC9AB4IDw/fTpLbtm0jgN94CUAnAJmVlZVcs2aNZ/LkyRdJcvbs2b4EwAkgZfPmzTxw4AABFAN4BkC6vFeUSewcAO5duXIlSTIhIaEawGMAxgKYAmAGgCS73e5vrKVk/yGythANYEhCQsIhkly+fDkBpKqqGmL6DgIALDKN/3yZpVWQZGVlJQE8aPI3KiMjo5okV61aRQAjAPQBMPfIkSN0u90EUCBtsPiFEwpgbn19PdetW2fM5N4zQ9ekpKQqkty0aRMBpMjiWM6JEydIkoqirJUFJ6iq6pAPVy8A6cZMehMBUACEuVyuFwG8HBwcPEIWx367ZMkSjSQXLVrUJouTRorrkAHdA8BdQogsAOsKCwtJkmPGjDkvMw2bDDo/ADEjRoz4XylyFbm5uY0mAbjLyyZ/AOOrq6tZVlbWsWDBgo69e/eyoqKCgwcPPg4gSQaoIRbp27dvN7KF+tLSUr28vJwFBQXtMpvpYRIM7+wrAkDeqVOnePbsWQIoNKfzpiXPg8uXLydJJicnNwF4f+nSpW6STEtLq5fjYwhk1wkTJtSQ5Ouvv04AqTKj+N2xY8dIkgEBAW/Ie1v8wncRegwZMmQvSfbr12+3Ua33WqPfOWbMmP0kWVpaSgCDZAqcfejQIWNZsEGKgvnh9gfQb9myZd8nAEJVVZtMkUNk8CcNHTq0liR1XWdYWNhmH1mJIme80OnTp18x1rp5eXkEsNJms92Fb7e/IgEsvHz5Mp999tkmAI/l5uZeMC0B7vEqqAYAyL106RJJsra2lpWVld+sucePH38ZQG+5NncBeOrgwYMkqbe3t/Po0aOsra011wAWyl0H7x0JJ4DE+fPnu0kyPT29DsDdUrBuyNKEEAkAdpw/f/6GeoEM8GUmfwEgPCIiopwkGxsbabPZPgOw6L777vvm4p49e26VGYjFLxUhhD+ApLKyMp44ccIoVnXybgbgzkcfffRzklyzZg0BDJYCMMmoCwQFBXkLgLGWvvcWAgBToSsKwNPTp09vMR7UuLi4rwH0lgU8c/Db5ezbeeTIkRWzZ8++aMxu+fn5BPCADBwHgP4LFy701NXVEUAJgAnPP/98kyxMNgHo53A4zH77BQQETMvPz7+Um5vbBuAlAFMSExPPmdbVL0qh8Acw8fDhw5SCchVAEYAVb775JknyhRdeaJYztHfxMwLAaqNwCGC2FArv8x0hAHKNLGPKlCme5OTk/Zs3bzb7O0wKiiG8KXl5ed8IxenTp0mSR48e1UmyW7duWywBuD2xyQcgFECgoih+8H1gyJgZV5Lkyy+/3CbTRIePtl2HDBmyw1QBHyGDdXZdXR1JUghRKkXBjOMHCoBdpr0L3nvvPZLkF198wejo6O0A4lVVDTb74HQ6AwD8Wq7Jh8rgGgDgQ13XjVR8qaxJuADMbmlpYXl5uV5UVNRWUFDgfv/993Vj/ZydnU1c37eHXML4S3viAcQqitJD2l104cIFY8lTKsXSBWBMVVWVcd9yed2A1NTUQ6Zl00CvLMMOoHdubm6zFIlWOf5+PsY/Kj09vdrU11QAwwGsv3jxIk21m2DZr10I0RXAuAcffPBgaWkpV69eTYfDcdiwUxY0w6xw+flX8L1xApjevXv3lREREaW6rofB93aPDUDQpEmTMgHgtddeqwBwEd/utZvpqK6uPgEAcXFxkA94NwB9unfvjrNnz4LklwDcf08iIqv66Zs2bXrl4YcfxooVKxAbG7uqrq5uAYA2TdOEqqpGYIi2tjbl6aeffu/YsWPv5uTk7JaC1wHg4Pnz542MwoVvTx+21dbWYvjw4WLixIl+2dnZ9lGjRgmSTE1NRUpKCkwFTGiaxtTU1OXTpk3707Bhw/6g67pDipnT4biuj7qut+Lbk3Vf1tTUXI9qu91Pjq1QFEUBgJaWFgBo8yGOQ8eNGxcAAOvXr/8QwBUfYygAKL169eoCABcuXACAWtn2hOGv0+kMNO1KiPDw8F4A4rZv3/7R1KlTR0+bNu1ht9u9r1+/fqitrQXJgwDarRC6/QjPzs4+QJIffPCB9/aQmSAA43ft2mW0e1QGoi8CAPyLsZccExNTC2BlRkbGRdOyYJCP2csBIN6UAZzCd7cBbQCijYp/dXU1ExMTz6SmptaMHj36f9LS0vYlJCRsl6mxIWSdu3fv/g5J7t+/nwC2AShMTk6+SJKff/45AWRLYbD7+fndAeDf5BJnLoCCyZMnt5JkdnZ2C4B/F0KEm1Pu+Pj4rST55ZdfEsBWAK+mpaVdMo3raDn7KwDuSEpK+m+S3LBhAwG8DuCtHTt2UBbpjgC408vvcFVV15HkuXPnjMp+p5uMf0RcXNyHJNnQ0EBVVfcCWBQXF3fG+Jv0yxABPwB5LS0tRmFxN4BlTzzxxGWSXLx4sS5F3GGFy+1Hp5SUlJq6ujoWFxdTpsZ2H+0iIyMj/0iSWVlZX5mr5jfJFroPGzasxlhTnjp1iiTZ3NxMl8tlrCd9pfa9SkpKSJI5OTmnZOageLUZZqxvfVFWVkZcPwdgNwnSCKPqb17jkmR8fPzfZMDZ5CRsFBmNI7h95s2b1yhT7/MAYmStwCx4vy0uLqa3v5qmEcCfvSr1QQAeXb16NY3Cm3HQ55133iGAp+SxZTNhKSkpfzUddkrFjYevzAQCeGjp0qXfsYckY2NjTwD4leGDLCL2HTdunNtoY+zWSHFcIHdsFCtcfuZ1vO9Eqs3m7/F47sb1k2qX/f3997W2tl7BjWfpBYDOzzzzzIVJkyZh0KBBCwEsB3AJvl9AETabLcDj8dwRFRW1ctasWb8JCgpSzp07d62wsPC/Wltb8xRFadR1/ZqPXYbgAQMGbI2Pjw/+6quv9ldVVT0r01ezuPRJSUn5Y9euXXVd11WzDaqq6kePHm3+7LPPRgO4KlNuxWazhXo8nuTk5OSXMjIyEl0uFxoaGtqKior+dPXq1VdUVT0jj7r68ieoT58+vx8yZMjdx48fP1JVVTVF9m20VW02WyfZf97YsWPjXS4X6urqWvPy8jYCWCyEuEDS8FdVFKWzruv//OSTTy5OTk7uqWkaPv3007qysrJ8RVH+LI8ym8/rB3Tu3HnRI488knLo0KG2ffv2ZQI4C98vP6mqqoZqmpaclpa2cOTIkX39/f3R0NDQUVxc/G5TU9PLqqrWa5rWLH1QVFUN0TStX1JSUvH48eP7BwYG4uDBg1cKCgpeBbBe2u+2Qug2EwD5N5sMPuNtMe8XP4TT6Qxoa2sbIGeXvUKIK7d4IISiKC5d1wPljOfA9bPwzYqiXNV13dd6Uqiq6qdpml2mpe02m63d4/G4vcTF5fF47LJf71nJA6BZVVW3pmntuPHlmAD5wk6Q9NnbHp9vHaqq6tA0zU/64PZhk1FfCZB9G/23ALiqKEqzD39tpvbGUqoFwFUhRLP3yzpCCDtJpxyXDulfG27+pqRR3DXsUWVd4Yq0x/taVQjhIhksC8L+ABpM9ljBf5sKwI8pIBr75L5E4vvu+UNeG/a+hv+AL7yFH8qPtOfHjtOP6V/Bja8D6z/B2Nys/1u9Xv33tLf4GfF/LC4GCJwByWIAAAAASUVORK5CYII=";
cc._loaderImage="data:image/jpeg;base64,/9j/4QAYRXhpZgAASUkqAAgAAAAAAAAAAAAAAP/sABFEdWNreQABAAQAAAAlAAD/4QMpaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLwA8P3hwYWNrZXQgYmVnaW49Iu+7vyIgaWQ9Ilc1TTBNcENlaGlIenJlU3pOVGN6a2M5ZCI/PiA8eDp4bXBtZXRhIHhtbG5zOng9ImFkb2JlOm5zOm1ldGEvIiB4OnhtcHRrPSJBZG9iZSBYTVAgQ29yZSA1LjAtYzA2MCA2MS4xMzQ3NzcsIDIwMTAvMDIvMTItMTc6MzI6MDAgICAgICAgICI+IDxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+IDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiIHhtbG5zOnhtcE1NPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvbW0vIiB4bWxuczpzdFJlZj0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL3NUeXBlL1Jlc291cmNlUmVmIyIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bXBNTTpEb2N1bWVudElEPSJ4bXAuZGlkOjM4MDBEMDY2QTU1MjExRTFBQTAzQjEzMUNFNzMxRkQwIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOjM4MDBEMDY1QTU1MjExRTFBQTAzQjEzMUNFNzMxRkQwIiB4bXA6Q3JlYXRvclRvb2w9IkFkb2JlIFBob3Rvc2hvcCBDUzUgV2luZG93cyI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkU2RTk0OEM4OERCNDExRTE5NEUyRkE3M0M3QkE1NTlEIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkU2RTk0OEM5OERCNDExRTE5NEUyRkE3M0M3QkE1NTlEIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+/+4ADkFkb2JlAGTAAAAAAf/bAIQADQkJCQoJDQoKDRMMCwwTFhENDREWGhUVFhUVGhkUFhUVFhQZGR0fIB8dGScnKionJzk4ODg5QEBAQEBAQEBAQAEODAwOEA4RDw8RFA4RDhQVERISERUfFRUXFRUfKB0ZGRkZHSgjJiAgICYjLCwoKCwsNzc1NzdAQEBAQEBAQEBA/8AAEQgAyACgAwEiAAIRAQMRAf/EALAAAAEFAQEAAAAAAAAAAAAAAAQAAgMFBgcBAQEAAwEBAAAAAAAAAAAAAAAAAQMEAgUQAAIBAgIEBwoLBgQGAwAAAAECAwAEEQUhMRIGQVFxsTITFGGBwdEiQlKSMzWRoeFicqKyI1NzFYJjJDQWB9KjVCbxwkNkJWXik3QRAAIBAgMFBQcDBQEAAAAAAAABAhEDIRIEMUFRcTJhwVIUBZGhsSJyEzOB0ULhYpIjUxX/2gAMAwEAAhEDEQA/AMJSpUqAVKlXuFAeUq9wpUB5XuFe4V6ooDzZHDox0CnGMinzwl7Z8NajaHeoO3vmTBZBtp9YUIqTEV5ROxHKnWRnaU8VRMhFBUjpV7hSoSeUq9pUB5Sr2lhQHlKvcK8oBV7hSFSRrtaKAZs07YNPM1pG2xJIAw1jSeandry/8X4m8VCKkWwaWwam7Xl/4v1W8VLtmX/i/VbxUoKkWwakSM407tmX/i/VbxUmzGwjQsjdY41IARie/U0IbZO0kNtCXnOCkEBeFu4KI3Bs7DNb27ya+jDx3kJeEnpJJEcQVbWDsk17u5urd591ucZkWhym2Vnd9RkCDEpFxDRpbw0bunu5mlp2De2FMLYXOD2wB2xbOeraUcYGJ72mlSUiqzzdzMd3Z3mixltA2yzcK/NlHM1DQyRXce1HocdNOEfJXZ88y9ZojOqhiBszIRiHQ8Y4cK5TvHuzLljHNMqxNoDjLFraHHnjPxcNCGVbxEUzYNTx5jZSxhpW6qTzlwJ+DCvO2Zf+L9VvFSgqyHYNLYNTdssPxfibxUu15f8Ai/VPiqCakOwa82DU/a8v/F+JvFTDdWPBL8R8VKCvYRYV5UzoMAy6QdIIqI0B4KJtxiRQwou16QoGUkntH5Tz0RbZbmF2hktraSVBo2lUkY8tDye0flPPXTslVUyiyVRsjqUOA4yMT8dW2ram2m6UVTNq9S7EIyUVJydMTn/6DnP+im9Wl+g5z/opvVrpteEhQWY4AaSTwAVf5WPiZh/9S5/zj7zltzlmYWkfWXNvJDGTgGcYDHirR7i7mSbwXParsFMrgb7w6jKw/wCmnc9I14kF3vpvCljbMyWMOJL4aEiB8qU/ObUK7HYWVrl1pFZWiCOCBQqKOLjPGTrNZZqKbUXVHq2nNwTuJRk1VpbgXN8s7Rk5ym0UQQzhIG2NAjhxHWbI+gCBVjBBFbwxwQqEiiUJGg1BVGAFe7dV28WYLYZFmF2Th1UD7JGjymGyn1iK5OyzIBGB1HgrLZhamzumQAGJwSqnSCh1q3GOCodxt4cxurdcpzuN4cyhiWaF5Bg09udUmnWw1H/jV9nFuJ7Quo+8h8peThFA+047vduyMtk7fYqTl07YFdfUufMPzT5p71UdtlmYXaGS2t3mQHAsgxANdadYJopLe4QS2867EsZ4QfCNYrCFbjdDPmgkYyWFxgVf04ifJf6ScNdRUW1XBb6FU5TjF5EpSSrGu/s5lN+g5z/opvVpfoOc/wCim9WtdHnatvObJXDW7xLGhB8nrPaY9/HCr+tEdPCVaSeDoYLnqF63lzW4/PFSW3ecxbI84VSzWUwUaSdg0DXXK5nvAipnd6qgKvWnQO7pri9ZUEmm3Vl2j1kr8pRlFRyquBNZjGxQ/S56Y1S2fu9OVueon11Szahoou06QoQUXadIVCD2FJJ7R+U89dMydv8Axdn+TH9muZye0flPPXQstlK5Tbka1gUjlC1q0vVLkeb6r+O3Tx9xcY1nt8c0NrZCyiOE1108NYjGv1joo7Js1jzKyScYLIvkzL6LDwHXVJksH9Sb49dKNq0tj1jA6uriOCL+02FWX7iVtZX1/AzaHTyeoauKn2MX9W79zebiZCuR5MjSrhfXuEtwTrUeZH+yNfdrRNcxI6IzhXlJEak6WIGJ2Rw4ChWnChndtlVBLMdQA0k1gbXNMzzDfDLs6mjaPKppJbWwJ1bOwwxw43OnHh71YT3DpfWUJmFlb5jHHDdeXBHIsrRea5TSqvxqG04cNN62vetoCS4tre5mgnkGE9q+3DKOkuI2WX6LDQRRHWDh1UCtwj7QRg2wdl8Djgw1qe7XvW0BQ3kfZ7mSLgU+T9E6RVbnuVrnWVSWqj+Lt8ZbRuHEdKPkYVcZ2MJY5fSGyeVar45+rkWQHAqccalPE5km1htWK5nK4Wnt5FuUBUwOMG4nGkA/BXUrW4S6torlOjMgcd/xVn7rLo7zKs0uEjCNeSvdwoBhgsZxX1l2j36k3Lu+uyprdj5Vs5A+i/lD48a0aaVJOPi7jB6lbzWozpjB48pf1NDXNN4vfl7+Z4BXS65pvF78vfzPAK71XTHmZ/S/yT+jvJ7L3fHytz1E+upbL+Qj5W56jfXWRnsIYKLtekKEFGWvSFQgyjk9o/Keet3YthlMP/5x9msJJ7R+U89biyb/AMXEv7gD6tadL1T+kwepRrC39ZkLDMbiwMvUHRPG0bjlGg8ore/23sxBldxfMPLupNhT8yL/AORNZbdzJ484scytxgLqJY5LZj6Q2sV5G1Vud1mjjyG0ij0NEGSZToKyhjtqw4waztuiXA3qKTbSxltfGhbZlE95ZtZqxVbgiOZhrER9ph3Svk9+pJILZ4Y4DGBFCUMKjRsGPobPFhUfW0NJmljE2xJcIrcI2vFUEln1lRXd6lrazXT9GCNpD+yNqoI7mOVduNw6nzlOIoPOUa6yye1XXcbMR5GdQ3xY0BSbj31/FcTQZirJ+q431q7anbHCTZ72Bw7lbPrKBMcBWNNgbMBBh+bsjBdni0VJ1lARZs6yWiupxCuMDy6KpS2IwOo6DTr3Mre3e5tZZVUM4ZBjqOOJoWO4jkXajcOOMHGgDISvWIrdAkKR80+TzVl908bPPL3LzxOuHdifxVfiTAg92qI/w+/8gGgSyN/mR7XPVlp0lF/3L3mbVKtu5Hjbk/8AHE2Fc03i9+Xv5ngFdKNc13i9+Xv5ngFaNV0x5nn+l/kn9HeEWXu+PlbnqJ9dS2Xu9OVueon11kZ7CGCjLXpCgxRlr0hUIPYUcntH5Tz1s8vb+Bt1/dqPirGSe0flPPWusG/g4Py15q06XqlyMWvVYQ+ruI9xJOqzO9hOto/sP8tbGOFIrmWeM7IuMDMnAXXQJOUjQeOsJk0nY96ip0CYunrjaHx1t+srPJUbXBm2LrFPikwTOb+T+VhbZxGMrDXp83x1QSy2tucJpUjPETp+Cn5/ftaRvKvtp3Kx48HG3erHMzOxZiWZtLMdJNQSbbL71Vk6yynViOkqnEEfOWtPbXi3EQkGg6mXiNckjeSJxJGxR10qw0GtxuxmvbImD4CZMFlA4fRfv0BqesqqzTMZNMEDbIHtHH2QeCiZJSqMQdOGiue53mz3czQwsRbIcNHnkec3c4qAMuriz68gTIToxwOOnlp0MjxMJYW741Gs3RVldtbygE/dMcHX/moDaxTiWNZB53B3arb8/wC+4SOF4sf/AKxU9kcBsfOGHfoUHtG/RbzY5Die5HHhXdvavqiZ9Q8Jdlq4/gbKua7xe/L38zwCuhpf2Uk/Zo50kmwJKIdogDjw1VzzeL35e/meAVp1LTgqY4nn+mRauzqmqwrjzCLL3fHytz1E+upLL+Qj5W56jfXWRnroYKLtekKEFF2vSFQg9hSSe0flPPWosm/hIfoLzVl5PaPynnrRWb/w0X0F5q06XqlyM2sVYx5gmbFre/t71NY2T+0h8VbSO5SWNJUOKSAMp7jDGspmMPaLRlXS6eWve1/FRO7WYdbZm1Y/eW/R7qHxHRXGojlm3ulid6aVbaW+OALvgCLq2Hm9WxHKWqjhj6xsK1e8dm15l4niG1LZkswGsxtrPeOmsvayBJA1VItlWjptLuTdPMo7LtjRDq9naK4+WF9IrUW7BaHOljGqVHB7w2hzVoZt87d8vaNYSLl02CcRsDEbJbj71Uu7UBkvJ7/D7q2QoDxySaAO8MTXdxRVMpRp5XZOWdF/ms7R5XdyKfKWJsO/5PhrG5XlNxmEywW6bTnTxAAcJNbGSMXkM1pjgbiNo1PziPJ+Os7u7m/6ReM00ZOgxSpqYYHT3wRXMKN4ll9zUG4bQfNshu8sZVuEA2hirA4qe/VOwwrVbzbww5mI44UKRRYkbWG0S3JWctbd7u5WFfOOLHiUdJqmaipfLsIsObhWe001lMkMVvJNjhghIALMcBxCs7fxXQmkupx1bXDswGPlaTidVaEyKNXkoo4eBV+Sq7L7Vs9zcBgeyQ4GQ/MB1crmoim2orezqcowTuSeEY48jQ7oZX2PLzdyLhNd6RjrEY6I7+uspvH78vfzPAK6UAAAFGAGgAcArmu8Xvy9/M8ArTfio24RW5nnaG67uou3H/KPuqT2X8hHytz1G+upLL3enK3PUb66ys9RDBRdr0hQgou06QqEGUkntH5Tz1e238vF9BeaqKT2j8p56vbb+Xi+gvNWjTdUuRn1XTHmTh8KrJTJlt8t1CPIY44cGnpJVjTJYkmjaN9Ib4u7V923njTethRauZJV3PaW1rfLIiXEDYg6R4VYc9CXW7thfOZbKdbGZtLW8uPVY/u3GrkNUkM9zlcxUjbhfWOA90cRq4gv4LhdqN+VToNYWmnRm9NNVWNTyHc6VWBv8wt4YeHqm6xyPmroq1Z7WGFLSxTq7WLSuPSdjrkfumq5yHXDUeA92oO2SKpVumNAaoJLMXH3myp0rpJ4uKhc3tbDM5BMri1zAj79j7KTiY8TcdBpcsith0286o+sPCagEX9Pzg4zXUCp6QYse8oouCG3tk6m1BYv05W6T+IdyolxbHDAAa2OgDlNCz3ryN2WxBd5PJMg1t81eId2ukqnLlTBbfcuY+9uJLiRcvtPvHdsHK+cfRHcHDWsyawjyy0WBcDI3lTP6TeIcFV+S5OmXx9bJg1048o8Cj0V8Jq2DVu09nL80up7OxHi+oal3P8AXB/IsZS8T/YOV65zvCcc7vfzPAK3ivWCz445zeH954BXOr6I8yfSfyz+jvCLP3fHytz1G+upLP3fHytz1E+usbPaQ0UXadIUIKLtekKhB7Ckk9o/Keer22/l4/oLzVRSe0flPPV7b/y8X0F5q0abqlyM+q6Y8yQsBTDMor1o8aiaE1pbluMqS3sbLLHIhSRQyngqukhaJ9uBjo+H5aOa3ao2t34qouRlLajTalGP8v0IY8ylXQ+PKPFU/bYXOLPge6CKia0LaxTOxHu1Q7cuBd9yPEJ7TbjXKO8CajbMIF6CNIeNvJHjqIWJ7tSpYkalqVblwIdyG+RGXur0hXYJFxal+Dhq5y3slkv3Y2pD0pTr+QUClpJRUdo9XW4OLrTHtM16cZLLWkeC7y4jvlNEpcRtw1Ux27Ci448NZrTFy3nn3IQWxlgGrDZ3pza7/M8ArZo+ArF5171uvp+CqdV0R5l/psUrs2vB3hdl7vTlbnqJ9dS2Xu+PlbnqJ9dY2eshooq16QoQUXa9IVCD2FLJ7RuU89WNtmUSQqkgYMgw0accKrpPaPynnrZWG4Vi+VWmY5tnMWXG+XrIYnA0rhj0mdcTgdNdwnKDqjmduM1SRR/qlr8/4KX6pa8T/BVzDuLZXudRZblmbxXcPUNPc3KqCIwrbOzgrHEnHjoyD+3eSXkht7DeKG4umDGOJVUklfouThXfmbnZ7Cvy1vt9pmv1W1+d8FL9VteJvgq5yrcOGfLmzHN80iyyETPbptAEFo2ZG8pmUa1OFNn3Ky6W/sbDKM5hv5bx2WTZA+7RF2y52WOPJTzE+z2Dy1vt9pT/AKpacTerS/U7Tib1a04/t7kDXPY03jhN0W6sQ7K7W3q2dnrMccaDy/8At80kuZfqWYxWNtlcvUPPhiGYhWDeUy7IwYU8xPs9g8tb7faUn6pacTerTxm9oOBvVq3v9z927aynuId44LiWKNnjhAXF2UYhRg516qpsryjLr21665zFLSTaK9U2GOA87SwqY37knRU+BzOzags0s1Oyr+BKM6sxwP6tSDPLMen6vy0rvdm3Sxlu7K/S7WDDrFUDUTxgnTU826eXW7KlxmqQuwDBXUKcD+1Xee/wXuKX5XDGWLapSVcOyhEM/seJ/V+WnjeGx4pPV+Wkm6kKZlFay3Jlt7iFpYZY8ASVK6DjtDDA0f8A0Tl340/1f8Ndx8xJVWXB0KbktFFpNzdVXAC/qOwA0CQni2flrO3Vwbm5lnI2TKxbDirX/wBE5d+NcfV/wVR7xZPa5U9utvI8nWhmbbw0YEAYYAVxfhfy5rlKR4Fulu6X7mW1mzT8S4Yis/5CPlbnqJ9dSWfu9OVueon11mZvQ2i7XpChKKtekKhBlNJ7R+U89bDfGTb3a3ZX0Lcj6kdY+T2j8p560288m1kWQr6MJ+ylSAr+2cnV5renjs3H1loX+3j9XvbbtxLN9lqW4UnV5jdnjtXHxihtyZNjeSBu5J9k1BJe7xy7W5CJ/wCzuD/mTVTf2+fq97LJuLrPsNRueS7W6aJ/38x+vLVXuY+xvHaNxbf2GoCezf8A36j/APsSf8w1sLnqczTefJluYoLm5uo5F61sBshItP1cNFYe1f8A3ir/APfE/wCZUe9bB94r5jwuPsrQFhmG4l/Z2M17HdW90tuu3IkTHaCjWdIw0VVZdks9/C06yJFEp2dp+E1bbqybGTZ8vpQD7L1XRv8A7blT96Oda7tpNuuNE37Cq9KSisjyuUoxrStKllHbLlWTXsMs8chuSuwEPDqwoLe5y+YRE/gLzmqRekvKKtd4327yM/ulHxmrHJStySWVRyrjxKI2XC/CTlnlPPKTpTdFbP0L1bgrf5Lp0G3dPhQHwV0S1lzBsns3sESR8Crh9WAJGjSOKuU3E+zdZQ3oJh8IArdZXFDmOTpHa3i2+YrI2KtKy4ricBsBuHHgFXSo440+Wa2qqxjvM9uMoy+WvzWpLCWWWE28HxL6e43ojgkeSCBY1Ri5BGIUDT51cl3vm276BBqSEH4WbxV0tlkyXJcxTMb+OW6uY9mGHrCzDQwwAbTp2uKuTZ9N1uYsfRRR8WPhrm419mSSjRyiqxVK7y23B/ftuTm2oSdJyzNVw3BFn7vTlbnqF9dS2fu9OVueon11lZuQ2iLdsGFD05H2dNQGV0ntG5Tz1dWm9N1b2kVq8EVwsI2UaQaQOKhmitZGLOmk68DhSFvY+gfWNSAg7z3Qvo7yKCKIohiaNR5LKxx8qpxvjcqS0VpbxvwOAcRQPZ7D0G9Y0uz2HoH1jUCpLY7zXlpbm3eKO5QuzjrBqZji3x17PvNcyT288VvDBJbMWUovS2hslW7mFQ9nsPQPrGl2ew9A+saCod/WNxtbYsrfb17WBxx5ddD2281xC88klvDcSXEnWuzrqOGGC9zRUPZ7D0G9Y0uzWHoH1jQVCLreq6ntZbaO3it1mGy7RjTs1X2mYy20ZiCq8ZOODcdEdmsPQb1jS7PYegfWNdJuLqnQiSUlRqpFLmryxtH1Ma7Qw2gNNPOdSt0oI27p007s9h6B9Y0uz2HoH1jXX3Z+I4+1b8IJdX89xLHKQFMXQUahpxoiPN5P+onfU+A0/s9h6DesaXZ7D0D6xpG7OLbUtu0StW5JJx2bBsmbtiSiEk+cxoCWWSaVpZOk2vDVo0VYdnsPQb1jSNvZcCH1jSd2c+p1XAmFqEOmOPEfaH+BQd1ueo211IzrgFUYKNAAqI1WztCpUqVCRUqVKgFSpUqAVKlSoBUqVKgFSpUqAVKlSoBUqVKgFSpUqAVKlSoD/9k=";cc=cc||{};
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){var g={enumerable:!1,configurable:!0};c&&(g.get=c);d&&(g.set=d);Object.defineProperty(a,b,g)}else throw Error("browser does not support getters");if(!e&&!f){g=null!=c;for(var 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];b[c]="object"!==typeof d||!d||d instanceof cc.Node||d instanceof HTMLElement?d:cc.clone(d)}return b};cc.inject=function(a,b){for(var c in a)b[c]=a[c]};
var ClassManager=function(){var a=0|998*Math.random(),b=0|998*Math.random();this.getNewID=function(){return a++};this.getNewInstanceId=function(){return b++}},classManager=new ClassManager;
(function(){var a=/\b_super\b/;cc.Class=function(){};cc.Class.extend=function(b){var c=this.prototype,d=Object.create(c),e={writable:!0,enumerable:!1,configurable:!0};var f=cc.game.config&&cc.game.config[cc.game.CONFIG_KEY.exposeClassName]?eval("(function "+(b._className||"Class")+" (arg0, arg1, arg2, arg3, arg4, arg5) {\n    this.__instanceId = classManager.getNewInstanceId();\n    this.getInstanceId = function () {return this.__instanceId;};\n    if (this.ctor) {\n        switch (arguments.length) {\n        case 0: this.ctor(); break;\n        case 1: this.ctor(arg0); break;\n        case 3: this.ctor(arg0, arg1, arg2); break;\n        case 4: this.ctor(arg0, arg1, arg2, arg3); break;\n        case 5: this.ctor(arg0, arg1, arg2, arg3, arg4); break;\n        default: this.ctor.apply(this, arguments);\n        }\n    }\n})"):function(a,
b,c,d,e){this.__instanceId=classManager.getNewInstanceId();this.getInstanceId=function(){return this.__instanceId};if(this.ctor)switch(arguments.length){case 0:this.ctor();break;case 1:this.ctor(a);break;case 2:this.ctor(a,b);break;case 3:this.ctor(a,b,c);break;case 4:this.ctor(a,b,c,d);break;case 5:this.ctor(a,b,c,d,e);break;default:this.ctor.apply(this,arguments)}};e.value=classManager.getNewID();Object.defineProperty(d,"__pid",e);f.prototype=d;e.value=f;Object.defineProperty(d,"constructor",e);
this.__getters__&&(f.__getters__=cc.clone(this.__getters__));this.__setters__&&(f.__setters__=cc.clone(this.__setters__));for(var g=0,h=arguments.length;g<h;++g){var k=arguments[g],m;for(m in k){var n="function"===typeof k[m],p="function"===typeof c[m],r=a.test(k[m]);n&&p&&r?(e.value=function(a,b){return function(){var d=this._super;this._super=c[a];var e=b.apply(this,arguments);this._super=d;return e}}(m,k[m]),Object.defineProperty(d,m,e)):n?(e.value=k[m],Object.defineProperty(d,m,e)):d[m]=k[m];
if(n){if(this.__getters__&&this.__getters__[m]){n=this.__getters__[m];for(var t in this.__setters__)if(this.__setters__[t]===n){var u=t;break}cc.defineGetterSetter(d,n,k[m],k[u]?k[u]:d[u],m,u)}if(this.__setters__&&this.__setters__[m]){n=this.__setters__[m];for(t in this.__getters__)if(this.__getters__[t]===n){var v=t;break}cc.defineGetterSetter(d,n,k[v]?k[v]:d[v],k[m],v,m)}}}}f.extend=cc.Class.extend;f.implement=function(a){for(var b in a)d[b]=a[b]};return f}})();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,"=":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.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);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;return 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);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);return 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){if(this._isSupportDOMParser)var b=this._parser.parseFromString(a,"text/xml");else b=new ActiveXObject("Microsoft.XMLDOM"),b.async="false",b.loadXML(a);return b}});
cc.PlistParser=cc.SAXParser.extend({parse:function(a){a=this._parseXML(a).documentElement;if("plist"!==a.tagName)return cc.warn("Not a plist file!"),{};for(var b=null,c=0,d=a.childNodes.length;c<d&&(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 for(b="",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;c<d;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;d<e;d++){var f=a.childNodes[d];1===f.nodeType&&("key"===f.tagName?c=f.firstChild.nodeValue:b[c]=this._parseNode(f))}return b}});
cc.saxParser=new cc.SAXParser;cc.plistParser=new cc.PlistParser;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){c=cc.loader.isLoading(a)?function(a,c){if(a)return d(a);var e=cc.textureCache.getTextureForKey(b)||cc.textureCache.handleLoadedTexture(b,c);d(null,e)}:function(a,c){if(a)return d(a);var e=cc.textureCache.handleLoadedTexture(b,c);d(null,e)};cc.loader.loadImg(a,c)}};cc.loader.register("png jpg bmp jpeg gif ico tiff webp".split(" "),cc._imgLoader);cc._serverImgLoader={load:function(a,b,c,d){cc._imgLoader.load(c.src,b,c,d)}};cc.loader.register(["serverImg"],cc._serverImgLoader);
cc._plistLoader={load:function(a,b,c,d){cc.loader.loadTxt(a,function(a,b){if(a)return d(a);d(null,cc.plistParser.parse(b))})}};cc.loader.register(["plist"],cc._plistLoader);
cc._fontLoader={TYPE:{".eot":"embedded-opentype",".ttf":"truetype",".ttc":"truetype",".woff":"woff",".svg":"svg"},_loadFont:function(a,b,c){var d=document,e=cc.path,f=this.TYPE,g=document.createElement("style");g.type="text/css";d.body.appendChild(g);var h="";h=isNaN(a-0)?h+("@font-face { font-family:"+a+"; src:"):h+("@font-face { font-family:'"+a+"'; src:");if(b instanceof Array)for(var k=0,m=b.length;k<m;k++){c=b[k];var n=cc.path.join(cc.loader.basePath,cc.loader.resPath,c);c=e.extname(c).toLowerCase();
h+="url('"+n+"') format('"+f[c]+"')";h+=k===m-1?";":","}else c=c.toLowerCase(),h+="url('"+b+"') format('"+f[c]+"');";g.textContent+=h+"}";b=document.createElement("div");e=b.style;e.fontFamily=a;b.innerHTML=".";e.position="absolute";e.left="-100px";e.top="-100px";d.body.appendChild(b)},load:function(a,b,c,d){b=c.type;a=c.name;b=c.srcs;cc.isString(c)?(b=cc.path.extname(c),a=cc.path.basename(c,b),this._loadFont(a,c,b)):this._loadFont(a,b);document.fonts?document.fonts.load("1em "+a).then(function(){d(null,
!0)},function(a){d(a)}):d(null,!0)}};cc.loader.register("font eot ttf woff svg ttc".split(" "),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.16";cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL=0;cc.DIRECTOR_STATS_POSITION=cc.p(0,0);cc.DIRECTOR_FPS_INTERVAL=.5;cc.COCOSNODE_RENDER_SUBPIXEL=1;cc.SPRITEBATCHNODE_RENDER_SUBPIXEL=1;cc.OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA=1;cc.TEXTURE_ATLAS_USE_TRIANGLE_STRIP=0;cc.TEXTURE_ATLAS_USE_VAO=0;cc.TEXTURE_NPOT_SUPPORT=0;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.DRAWNODE_TOTAL_VERTICES=2E4;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;if(a=a instanceof HTMLElement?a:b.querySelector(a))a.find=a.find||cc.$,a.hasClass=a.hasClass||function(a){return this.className.match(new RegExp("(\\s|^)"+a+"(\\s|$)"))},a.addClass=a.addClass||function(a){this.hasClass(a)||(this.className&&(this.className+=" "),this.className+=a);return this},a.removeClass=a.removeClass||function(a){this.hasClass(a)&&(this.className=this.className.replace(a,""));return this},a.remove=a.remove||function(){this.parentNode&&
this.parentNode.removeChild(this);return this},a.appendTo=a.appendTo||function(a){a.appendChild(this);return this},a.prependTo=a.prependTo||function(a){a.childNodes[0]?a.insertBefore(this,a.childNodes[0]):a.appendChild(this);return this},a.transforms=a.transforms||function(){this.style[cc.$.trans]=cc.$.translate(this.position)+cc.$.rotate(this.rotation)+cc.$.scale(this.scale)+cc.$.skew(this.skew);return 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){this.position.x=a;this.position.y=b;this.transforms();return this},a.rotate=function(a){this.rotation=a;this.transforms();return this},a.resize=function(a,b){this.scale.x=a;this.scale.y=b;this.transforms();return this},a.setSkew=function(a,b){this.skew.x=a;this.skew.y=b;this.transforms();return this};return a};
switch(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()-.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){cc.log(cc._LogInfos.radiansToDegress);return a*cc.DEG};cc.REPEAT_FOREVER=Number.MAX_VALUE-1;cc.nodeDrawSetup=function(a){a._shaderProgram&&(a._glProgramState.apply(),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=function(){return cc.director._contentScaleFactor};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=function(a){var b=cc.contentScaleFactor();return cc.rect(a.x/b,a.y/b,a.width/b,a.height/b)};cc.rectPointsToPixels=function(a){var b=cc.contentScaleFactor();return cc.rect(a.x*b,a.y*b,a.width*b,a.height*b)};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.BLEND_SRC=cc.SRC_ALPHA;
cc.game.addEventListener(cc.game.EVENT_RENDERER_INITED,function(){cc._renderType===cc.game.RENDER_TYPE_WEBGL&&cc.OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA&&(cc.BLEND_SRC=cc.ONE)});cc.BLEND_DST=cc.ONE_MINUS_SRC_ALPHA;cc.checkGLErrorDebug=function(){if(cc.renderMode===cc.game.RENDER_TYPE_WEBGL){var a=cc._renderContext.getError();a&&cc.log(cc._LogInfos.checkGLErrorDebug,a)}};cc.ORIENTATION_PORTRAIT=1;cc.ORIENTATION_LANDSCAPE=2;cc.ORIENTATION_AUTO=3;
cc.CONCURRENCY_HTTP_REQUEST_COUNT=cc.sys.isMobile?20:0;cc.BATCH_VERTEX_COUNT=2E3;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=7;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_SPRITE_POSITION_TEXTURECOLOR="ShaderSpritePositionTextureColor";cc.SHADER_SPRITE_POSITION_TEXTURECOLOR_GRAY="ShaderSpritePositionTextureColorGray";cc.SHADER_POSITION_TEXTURECOLORALPHATEST="ShaderPositionTextureColorAlphaTest";cc.SHADER_SPRITE_POSITION_TEXTURECOLORALPHATEST="ShaderSpritePositionTextureColorAlphaTest";
cc.SHADER_POSITION_COLOR="ShaderPositionColor";cc.SHADER_SPRITE_POSITION_COLOR="ShaderSpritePositionColor";cc.SHADER_POSITION_TEXTURE="ShaderPositionTexture";cc.SHADER_POSITION_TEXTURE_UCOLOR="ShaderPositionTextureUColor";cc.SHADER_POSITION_TEXTUREA8COLOR="ShaderPositionTextureA8Color";cc.SHADER_POSITION_UCOLOR="ShaderPositionUColor";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.ATTRIBUTE_NAME_MVMAT="a_mvMatrix";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;c<d;c++)if(a[c]===b){a.splice(c,1);break}};cc.arrayRemoveArray=function(a,b){for(var c=0,d=b.length;c<d;c++)cc.arrayRemoveObject(a,b[c])};cc.arrayAppendObjectsToIndex=function(a,b,c){a.splice.apply(a,[c,0].concat(b));return a};
cc.copyArray=function(a){var b,c=a.length,d=Array(c);for(b=0;b<c;b+=1)d[b]=a[b];return d};cc.Color=function(a,b,c,d){this._val=((a||0)<<24>>>0)+((b||0)<<16)+((c||0)<<8)+("number"===typeof d?d:255)};_p=cc.Color.prototype;_p._getR=function(){return(this._val&4278190080)>>>24};_p._setR=function(a){this._val=this._val&16777215|a<<24>>>0};_p._getG=function(){return(this._val&16711680)>>16};_p._setG=function(a){this._val=this._val&4278255615|a<<16};_p._getB=function(){return(this._val&65280)>>8};_p._setB=function(a){this._val=this._val&4294902015|a<<8};_p._getA=function(){return this._val&255};
_p._setA=function(a){this._val=this._val&4294967040|a};cc.defineGetterSetter(_p,"r",_p._getR,_p._setR);cc.defineGetterSetter(_p,"g",_p._getG,_p._setG);cc.defineGetterSetter(_p,"b",_p._getB,_p._setB);cc.defineGetterSetter(_p,"a",_p._getA,_p._setA);cc.color=function(a,b,c,d){return void 0===a?new cc.Color(0,0,0,255):"object"===typeof a?new cc.Color(a.r,a.g,a.b,null==a.a?255:a.a):"string"===typeof a?cc.hexToColor(a):new cc.Color(a,b,c,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,c,d){this._arrayBuffer=c||new ArrayBuffer(cc.Vertex2F.BYTES_PER_ELEMENT);this._offset=d||0;this._view=new Float32Array(this._arrayBuffer,this._offset,2);this._view[0]=a||0;this._view[1]=b||0};cc.Vertex2F.BYTES_PER_ELEMENT=8;_p=cc.Vertex2F.prototype;_p._getX=function(){return this._view[0]};
_p._setX=function(a){this._view[0]=a};_p._getY=function(){return this._view[1]};_p._setY=function(a){this._view[1]=a};cc.defineGetterSetter(_p,"x",_p._getX,_p._setX);cc.defineGetterSetter(_p,"y",_p._getY,_p._setY);cc.Vertex3F=function(a,b,c,d,e){this._arrayBuffer=d||new ArrayBuffer(cc.Vertex3F.BYTES_PER_ELEMENT);this._offset=e||0;this._view=new Float32Array(this._arrayBuffer,this._offset,3);this._view[0]=a||0;this._view[1]=b||0;this._view[2]=c||0};cc.Vertex3F.BYTES_PER_ELEMENT=12;_p=cc.Vertex3F.prototype;
_p._getX=function(){return this._view[0]};_p._setX=function(a){this._view[0]=a};_p._getY=function(){return this._view[1]};_p._setY=function(a){this._view[1]=a};_p._getZ=function(){return this._view[2]};_p._setZ=function(a){this._view[2]=a};cc.defineGetterSetter(_p,"x",_p._getX,_p._setX);cc.defineGetterSetter(_p,"y",_p._getY,_p._setY);cc.defineGetterSetter(_p,"z",_p._getZ,_p._setZ);
cc.Tex2F=function(a,b,c,d){this._arrayBuffer=c||new ArrayBuffer(cc.Tex2F.BYTES_PER_ELEMENT);this._offset=d||0;this._view=new Float32Array(this._arrayBuffer,this._offset,2);this._view[0]=a||0;this._view[1]=b||0};cc.Tex2F.BYTES_PER_ELEMENT=8;_p=cc.Tex2F.prototype;_p._getU=function(){return this._view[0]};_p._setU=function(a){this._view[0]=a};_p._getV=function(){return this._view[1]};_p._setV=function(a){this._view[1]=a};cc.defineGetterSetter(_p,"u",_p._getU,_p._setU);
cc.defineGetterSetter(_p,"v",_p._getV,_p._setV);
cc.Quad2=function(a,b,c,d,e,f){this._arrayBuffer=e||new ArrayBuffer(cc.Quad2.BYTES_PER_ELEMENT);this._offset=f||0;e=this._arrayBuffer;f=this._offset;var g=cc.Vertex2F.BYTES_PER_ELEMENT;this._tl=a?new cc.Vertex2F(a.x,a.y,e,f):new cc.Vertex2F(0,0,e,f);f+=g;this._tr=b?new cc.Vertex2F(b.x,b.y,e,f):new cc.Vertex2F(0,0,e,f);f+=g;this._bl=c?new cc.Vertex2F(c.x,c.y,e,f):new cc.Vertex2F(0,0,e,f);f+=g;this._br=d?new cc.Vertex2F(d.x,d.y,e,f):new cc.Vertex2F(0,0,e,f)};cc.Quad2.BYTES_PER_ELEMENT=32;_p=cc.Quad2.prototype;
_p._getTL=function(){return this._tl};_p._setTL=function(a){this._tl._view[0]=a.x;this._tl._view[1]=a.y};_p._getTR=function(){return this._tr};_p._setTR=function(a){this._tr._view[0]=a.x;this._tr._view[1]=a.y};_p._getBL=function(){return this._bl};_p._setBL=function(a){this._bl._view[0]=a.x;this._bl._view[1]=a.y};_p._getBR=function(){return this._br};_p._setBR=function(a){this._br._view[0]=a.x;this._br._view[1]=a.y};cc.defineGetterSetter(_p,"tl",_p._getTL,_p._setTL);
cc.defineGetterSetter(_p,"tr",_p._getTR,_p._setTR);cc.defineGetterSetter(_p,"bl",_p._getBL,_p._setBL);cc.defineGetterSetter(_p,"br",_p._getBR,_p._setBR);
cc.Quad3=function(a,b,c,d,e,f){this._arrayBuffer=e||new ArrayBuffer(cc.Quad3.BYTES_PER_ELEMENT);this._offset=f||0;e=this._arrayBuffer;f=this._offset;var g=cc.Vertex3F.BYTES_PER_ELEMENT;this.bl=a?new cc.Vertex3F(a.x,a.y,a.z,e,f):new cc.Vertex3F(0,0,0,e,f);f+=g;this.br=b?new cc.Vertex3F(b.x,b.y,b.z,e,f):new cc.Vertex3F(0,0,0,e,f);f+=g;this.tl=c?new cc.Vertex3F(c.x,c.y,c.z,e,f):new cc.Vertex3F(0,0,0,e,f);f+=g;this.tr=d?new cc.Vertex3F(d.x,d.y,d.z,e,f):new cc.Vertex3F(0,0,0,e,f)};
cc.Quad3.BYTES_PER_ELEMENT=48;cc.V3F_C4B_T2F=function(a,b,c,d,e){this._arrayBuffer=d||new ArrayBuffer(cc.V3F_C4B_T2F.BYTES_PER_ELEMENT);this._offset=e||0;d=this._arrayBuffer;e=this._offset;this._vertices=a?new cc.Vertex3F(a.x,a.y,a.z,d,e):new cc.Vertex3F(0,0,0,d,e);e+=cc.Vertex3F.BYTES_PER_ELEMENT;this._colors=b?new cc._WebGLColor(b.r,b.g,b.b,b.a,d,e):new cc._WebGLColor(0,0,0,0,d,e);e+=cc._WebGLColor.BYTES_PER_ELEMENT;this._texCoords=c?new cc.Tex2F(c.u,c.v,d,e):new cc.Tex2F(0,0,d,e)};
cc.V3F_C4B_T2F.BYTES_PER_ELEMENT=24;_p=cc.V3F_C4B_T2F.prototype;_p._getVertices=function(){return this._vertices};_p._setVertices=function(a){var b=this._vertices;b._view[0]=a.x;b._view[1]=a.y;b._view[2]=a.z};_p._getColor=function(){return this._colors};_p._setColor=function(a){var b=this._colors;b._view[0]=a.r;b._view[1]=a.g;b._view[2]=a.b;b._view[3]=a.a};_p._getTexCoords=function(){return this._texCoords};_p._setTexCoords=function(a){this._texCoords._view[0]=a.u;this._texCoords._view[1]=a.v};
cc.defineGetterSetter(_p,"vertices",_p._getVertices,_p._setVertices);cc.defineGetterSetter(_p,"colors",_p._getColor,_p._setColor);cc.defineGetterSetter(_p,"texCoords",_p._getTexCoords,_p._setTexCoords);
cc.V3F_C4B_T2F_Quad=function(a,b,c,d,e,f){this._arrayBuffer=e||new ArrayBuffer(cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT);this._offset=f||0;e=this._arrayBuffer;f=this._offset;var g=cc.V3F_C4B_T2F.BYTES_PER_ELEMENT;this._tl=a?new cc.V3F_C4B_T2F(a.vertices,a.colors,a.texCoords,e,f):new cc.V3F_C4B_T2F(null,null,null,e,f);f+=g;this._bl=b?new cc.V3F_C4B_T2F(b.vertices,b.colors,b.texCoords,e,f):new cc.V3F_C4B_T2F(null,null,null,e,f);f+=g;this._tr=c?new cc.V3F_C4B_T2F(c.vertices,c.colors,c.texCoords,e,f):new cc.V3F_C4B_T2F(null,
null,null,e,f);f+=g;this._br=d?new cc.V3F_C4B_T2F(d.vertices,d.colors,d.texCoords,e,f):new cc.V3F_C4B_T2F(null,null,null,e,f)};cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT=96;_p=cc.V3F_C4B_T2F_Quad.prototype;_p._getTL=function(){return this._tl};_p._setTL=function(a){var b=this._tl;b.vertices=a.vertices;b.colors=a.colors;b.texCoords=a.texCoords};_p._getBL=function(){return this._bl};_p._setBL=function(a){var b=this._bl;b.vertices=a.vertices;b.colors=a.colors;b.texCoords=a.texCoords};_p._getTR=function(){return this._tr};
_p._setTR=function(a){var b=this._tr;b.vertices=a.vertices;b.colors=a.colors;b.texCoords=a.texCoords};_p._getBR=function(){return this._br};_p._setBR=function(a){var b=this._br;b.vertices=a.vertices;b.colors=a.colors;b.texCoords=a.texCoords};_p._getArrayBuffer=function(){return this._arrayBuffer};cc.defineGetterSetter(_p,"tl",_p._getTL,_p._setTL);cc.defineGetterSetter(_p,"tr",_p._getTR,_p._setTR);cc.defineGetterSetter(_p,"bl",_p._getBL,_p._setBL);cc.defineGetterSetter(_p,"br",_p._getBR,_p._setBR);
cc.defineGetterSetter(_p,"arrayBuffer",_p._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 b=a.tl,c=a.bl,d=a.tr;a=a.br;return{tl:{vertices:{x:b.vertices.x,y:b.vertices.y,z:b.vertices.z},colors:{r:b.colors.r,g:b.colors.g,b:b.colors.b,a:b.colors.a},texCoords:{u:b.texCoords.u,v:b.texCoords.v}},bl:{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}},tr:{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}},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 b=[],c=0;c<a.length;c++)b.push(cc.V3F_C4B_T2F_QuadCopy(a[c]));return b};
cc.V2F_C4B_T2F=function(a,b,c,d,e){this._arrayBuffer=d||new ArrayBuffer(cc.V2F_C4B_T2F.BYTES_PER_ELEMENT);this._offset=e||0;d=this._arrayBuffer;e=this._offset;this._vertices=a?new cc.Vertex2F(a.x,a.y,d,e):new cc.Vertex2F(0,0,d,e);e+=cc.Vertex2F.BYTES_PER_ELEMENT;this._colors=b?new cc._WebGLColor(b.r,b.g,b.b,b.a,d,e):new cc._WebGLColor(0,0,0,0,d,e);e+=cc._WebGLColor.BYTES_PER_ELEMENT;this._texCoords=c?new cc.Tex2F(c.u,c.v,d,e):new cc.Tex2F(0,0,d,e)};cc.V2F_C4B_T2F.BYTES_PER_ELEMENT=20;_p=cc.V2F_C4B_T2F.prototype;
_p._getVertices=function(){return this._vertices};_p._setVertices=function(a){this._vertices._view[0]=a.x;this._vertices._view[1]=a.y};_p._getColor=function(){return this._colors};_p._setColor=function(a){var b=this._colors;b._view[0]=a.r;b._view[1]=a.g;b._view[2]=a.b;b._view[3]=a.a};_p._getTexCoords=function(){return this._texCoords};_p._setTexCoords=function(a){this._texCoords._view[0]=a.u;this._texCoords._view[1]=a.v};cc.defineGetterSetter(_p,"vertices",_p._getVertices,_p._setVertices);
cc.defineGetterSetter(_p,"colors",_p._getColor,_p._setColor);cc.defineGetterSetter(_p,"texCoords",_p._getTexCoords,_p._setTexCoords);
cc.V2F_C4B_T2F_Triangle=function(a,b,c,d,e){this._arrayBuffer=d||new ArrayBuffer(cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT);this._offset=e||0;d=this._arrayBuffer;e=this._offset;var f=cc.V2F_C4B_T2F.BYTES_PER_ELEMENT;this._a=a?new cc.V2F_C4B_T2F(a.vertices,a.colors,a.texCoords,d,e):new cc.V2F_C4B_T2F(null,null,null,d,e);e+=f;this._b=b?new cc.V2F_C4B_T2F(b.vertices,b.colors,b.texCoords,d,e):new cc.V2F_C4B_T2F(null,null,null,d,e);e+=f;this._c=c?new cc.V2F_C4B_T2F(c.vertices,c.colors,c.texCoords,d,e):
new cc.V2F_C4B_T2F(null,null,null,d,e)};cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT=60;_p=cc.V2F_C4B_T2F_Triangle.prototype;_p._getA=function(){return this._a};_p._setA=function(a){var b=this._a;b.vertices=a.vertices;b.colors=a.colors;b.texCoords=a.texCoords};_p._getB=function(){return this._b};_p._setB=function(a){var b=this._b;b.vertices=a.vertices;b.colors=a.colors;b.texCoords=a.texCoords};_p._getC=function(){return this._c};
_p._setC=function(a){var b=this._c;b.vertices=a.vertices;b.colors=a.colors;b.texCoords=a.texCoords};cc.defineGetterSetter(_p,"a",_p._getA,_p._setA);cc.defineGetterSetter(_p,"b",_p._getB,_p._setB);cc.defineGetterSetter(_p,"c",_p._getC,_p._setC);cc.vertex2=function(a,b){return new cc.Vertex2F(a,b)};cc.vertex3=function(a,b,c){return new cc.Vertex3F(a,b,c)};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 new 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(){this.__currId++;return"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){delete this._valueMapTb[c];delete b[c];break}}},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){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.boundingHeight=this.boundingWidth=0;this.strokeEnabled=!1;this.strokeStyle=cc.color(255,255,255,255);this.lineWidth=1;this.fontWeight=this.fontStyle=this.lineHeight="normal";this.shadowEnabled=!1;this.shadowBlur=this.shadowOffsetY=this.shadowOffsetX=0;this.shadowOpacity=1;if(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.game.addEventListener(cc.game.EVENT_RENDERER_INITED,function(){cc._renderType===cc.game.RENDER_TYPE_WEBGL&&(cc._WebGLColor=function(a,b,c,d,e,f){this._arrayBuffer=e||new ArrayBuffer(cc._WebGLColor.BYTES_PER_ELEMENT);this._offset=f||0;this._view=new Uint8Array(this._arrayBuffer,this._offset,4);this._view[0]=a||0;this._view[1]=b||0;this._view[2]=c||0;this._view[3]=null==d?255:d;void 0===d&&(this.a_undefined=!0)},cc._WebGLColor.BYTES_PER_ELEMENT=4,_p=cc._WebGLColor.prototype,_p._getR=function(){return this._view[0]},
_p._setR=function(a){this._view[0]=0>a?0:a},_p._getG=function(){return this._view[1]},_p._setG=function(a){this._view[1]=0>a?0:a},_p._getB=function(){return this._view[2]},_p._setB=function(a){this._view[2]=0>a?0:a},_p._getA=function(){return this._view[3]},_p._setA=function(a){this._view[3]=0>a?0:a},cc.defineGetterSetter(_p,"r",_p._getR,_p._setR),cc.defineGetterSetter(_p,"g",_p._getG,_p._setG),cc.defineGetterSetter(_p,"b",_p._getB,_p._setB),cc.defineGetterSetter(_p,"a",_p._getA,_p._setA))});_p=cc.color;
_p._getWhite=function(){return cc.color(255,255,255)};_p._getYellow=function(){return cc.color(255,255,0)};_p._getBlue=function(){return cc.color(0,0,255)};_p._getGreen=function(){return cc.color(0,255,0)};_p._getRed=function(){return cc.color(255,0,0)};_p._getMagenta=function(){return cc.color(255,0,255)};_p._getBlack=function(){return cc.color(0,0,0)};_p._getOrange=function(){return cc.color(255,127,0)};_p._getGray=function(){return cc.color(166,166,166)};cc.defineGetterSetter(_p,"WHITE",_p._getWhite);
cc.defineGetterSetter(_p,"YELLOW",_p._getYellow);cc.defineGetterSetter(_p,"BLUE",_p._getBlue);cc.defineGetterSetter(_p,"GREEN",_p._getGreen);cc.defineGetterSetter(_p,"RED",_p._getRed);cc.defineGetterSetter(_p,"MAGENTA",_p._getMagenta);cc.defineGetterSetter(_p,"BLACK",_p._getBlack);cc.defineGetterSetter(_p,"ORANGE",_p._getOrange);cc.defineGetterSetter(_p,"GRAY",_p._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.defineGetterSetter(cc.BlendFunc,"DISABLE",cc.BlendFunc._disable);cc.defineGetterSetter(cc.BlendFunc,"ALPHA_PREMULTIPLIED",cc.BlendFunc._alphaPremultiplied);
cc.defineGetterSetter(cc.BlendFunc,"ALPHA_NON_PREMULTIPLIED",cc.BlendFunc._alphaNonPremultiplied);cc.defineGetterSetter(cc.BlendFunc,"ADDITIVE",cc.BlendFunc._additive);cc.Touches=[];cc.TouchesIntergerDict={};cc.DENSITYDPI_DEVICE="device-dpi";cc.DENSITYDPI_HIGH="high-dpi";cc.DENSITYDPI_MEDIUM="medium-dpi";cc.DENSITYDPI_LOW="low-dpi";var __BrowserGetter={init:function(){this.html=document.documentElement},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"},adaptationType:cc.sys.browserType};
-1<window.navigator.userAgent.indexOf("OS 8_1_")&&(__BrowserGetter.adaptationType=cc.sys.BROWSER_TYPE_MIUI);cc.sys.os===cc.sys.OS_IOS&&(__BrowserGetter.adaptationType=cc.sys.BROWSER_TYPE_SAFARI);
switch(__BrowserGetter.adaptationType){case cc.sys.BROWSER_TYPE_SAFARI:__BrowserGetter.meta["minimal-ui"]="true";break;case cc.sys.BROWSER_TYPE_CHROME:__BrowserGetter.__defineGetter__("target-densitydpi",function(){return cc.view._targetDensityDPI});break;case cc.sys.BROWSER_TYPE_MIUI:__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)}}}var _scissorRect=null;
cc.EGLView=cc.Class.extend({_delegate:null,_frameSize:null,_designResolutionSize:null,_originalDesignResolutionSize:null,_viewPortRect:null,_visibleRect:null,_retinaEnabled:!1,_autoFullScreen:!1,_devicePixelRatio:1,_viewName:"",_resizeCallback:null,_orientationChanging:!0,_resizing:!1,_scaleX:1,_originalScaleX:1,_scaleY:1,_originalScaleY:1,_isRotated:!1,_orientation:3,_resolutionPolicy:null,_rpExactFit:null,_rpShowAll:null,_rpNoBorder:null,_rpFixedHeight:null,_rpFixedWidth:null,_initialized:!1,_contentTranslateLeftTop:null,
_frame:null,_frameZoomFactor:1,__resizeWithBrowserSize:!1,_isAdjustViewPort:!0,_targetDensityDPI:null,ctor:function(){var a=document,b=cc.ContainerStrategy,c=cc.ContentStrategy;__BrowserGetter.init(this);this._frame=cc.container.parentNode===a.body?a.documentElement:cc.container.parentNode;this._frameSize=cc.size(0,0);this._initFrameSize();a=cc._canvas.width;var 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;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._targetDensityDPI=cc.DENSITYDPI_HIGH;a.isMobile?window.addEventListener("orientationchange",this._orientationChange):this._orientationChanging=!1},_resizeEvent:function(){var a=this.setDesignResolutionSize?this:cc.view;if(!a._orientationChanging){var b=a._frameSize.width,c=a._frameSize.height,d=a._isRotated;if(cc.sys.isMobile){var e=cc.game.container.style,f=e.margin;e.margin="0";e.display="none";a._initFrameSize();e.margin=f;e.display="block"}else a._initFrameSize();if(a._isRotated!==
d||a._frameSize.width!==b||a._frameSize.height!==c)b=a._originalDesignResolutionSize.width,c=a._originalDesignResolutionSize.height,a._resizing=!0,0<b&&a.setDesignResolutionSize(b,c,a._resolutionPolicy),a._resizing=!1,cc.eventManager.dispatchCustomEvent("canvas-resize"),a._resizeCallback&&a._resizeCallback.call()}},_orientationChange:function(){cc.view._orientationChanging=!0;cc.sys.isMobile&&(cc.game.container.style.display="none");setTimeout(function(){cc.view._orientationChanging=!1;cc.view._resizeEvent()},
300)},setTargetDensityDPI:function(a){this._targetDensityDPI=a;this._adjustViewportMeta()},getTargetDensityDPI:function(){return this._targetDensityDPI},resizeWithBrowserSize:function(a){a?this.__resizeWithBrowserSize||(this.__resizeWithBrowserSize=!0,window.addEventListener("resize",this._resizeEvent)):this.__resizeWithBrowserSize&&(this.__resizeWithBrowserSize=!1,window.removeEventListener("resize",this._resizeEvent))},setResizeCallback:function(a){if("function"===typeof a||null==a)this._resizeCallback=
a},setOrientation:function(a){(a&=cc.ORIENTATION_AUTO)&&this._orientation!==a&&(this._orientation=a,this._resolutionPolicy&&this.setDesignResolutionSize(this._originalDesignResolutionSize.width,this._originalDesignResolutionSize.height,this._resolutionPolicy))},setDocumentPixelWidth:function(a){this._setViewportMeta({width:a},!0);document.documentElement.style.width=a+"px";document.body.style.width="100%";this.setDesignResolutionSize(this._designResolutionSize.width,this._designResolutionSize.height,
this._resolutionPolicy)},_initFrameSize:function(){var a=this._frameSize,b=__BrowserGetter.availWidth(this._frame),c=__BrowserGetter.availHeight(this._frame),d=b>=c;!cc.sys.isMobile||d&&this._orientation&cc.ORIENTATION_LANDSCAPE||!d&&this._orientation&cc.ORIENTATION_PORTRAIT?(a.width=b,a.height=c,cc.container.style["-webkit-transform"]="rotate(0deg)",cc.container.style.transform="rotate(0deg)",this._isRotated=!1):(a.width=c,a.height=b,cc.container.style["-webkit-transform"]="rotate(90deg)",cc.container.style.transform=
"rotate(90deg)",cc.container.style["-webkit-transform-origin"]="0px 0px 0px",cc.container.style.transformOrigin="0px 0px 0px",this._isRotated=!0)},_adjustSizeKeepCanvasSize:function(){var a=this._originalDesignResolutionSize.width,b=this._originalDesignResolutionSize.height;0<a&&this.setDesignResolutionSize(a,b,this._resolutionPolicy)},_setViewportMeta:function(a,b){var c=document.getElementById("cocosMetaElement");c&&b&&document.head.removeChild(c);var d=document.getElementsByName("viewport");d=
d?d[0]:null;var e;var f=d?d.content:"";c=c||document.createElement("meta");c.id="cocosMetaElement";c.name="viewport";c.content="";for(e in a)if(-1==f.indexOf(e))f+=","+e+"="+a[e];else if(b){var g=new RegExp(e+"s*=s*[^,]+");f.replace(g,e+"="+a[e])}/^,/.test(f)&&(f=f.substr(1));c.content=f;d&&(d.content=f);document.head.appendChild(c)},_adjustViewportMeta:function(){this._isAdjustViewPort&&(this._setViewportMeta(__BrowserGetter.meta,!1),this._isAdjustViewPort=!1)},_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},isRetinaEnabled:function(){return this._retinaEnabled},enableAutoFullScreen:function(a){a&&a!==this._autoFullScreen&&cc.sys.isMobile&&this._frame===document.documentElement?(this._autoFullScreen=
!0,cc.screen.autoFullScreen(this._frame)):this._autoFullScreen=!1},isAutoFullScreenEnabled:function(){return this._autoFullScreen},isOpenGLReady:function(){return cc.game.canvas&&cc._renderContext},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},
getCanvasSize:function(){return cc.size(cc._canvas.width,cc._canvas.height)},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())},getVisibleSize:function(){return cc.size(this._visibleRect.width,this._visibleRect.height)},getVisibleSizeInPixel:function(){return cc.size(this._visibleRect.width*
this._scaleX,this._visibleRect.height*this._scaleY)},getVisibleOrigin:function(){return cc.p(this._visibleRect.x,this._visibleRect.y)},getVisibleOriginInPixel:function(){return cc.p(this._visibleRect.x*this._scaleX,this._visibleRect.y*this._scaleY)},canSetContentScaleFactor:function(){return!0},getResolutionPolicy:function(){return this._resolutionPolicy},setResolutionPolicy:function(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)if(this.setResolutionPolicy(c),(c=this._resolutionPolicy)&&c.preApply(this),cc.sys.isMobile&&this._adjustViewportMeta(),this._resizing||this._initFrameSize(),c){this._originalDesignResolutionSize.width=
this._designResolutionSize.width=a;this._originalDesignResolutionSize.height=this._designResolutionSize.height=b;var d=c.apply(this,this._designResolutionSize);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.game.RENDER_TYPE_WEBGL?a.setGLDefaultValues():cc._renderType===cc.game.RENDER_TYPE_CANVAS&&(cc.renderer._allNeedDraw=!0);this._originalScaleX=this._scaleX;this._originalScaleY=this._scaleY;cc.visibleRect&&cc.visibleRect.init(this._visibleRect)}else cc.log(cc._LogInfos.EGLView_setDesignResolutionSize_2);
else cc.log(cc._LogInfos.EGLView_setDesignResolutionSize)},getDesignResolutionSize:function(){return cc.size(this._designResolutionSize.width,this._designResolutionSize.height)},setRealPixelResolution:function(a,b,c){this._setViewportMeta({width:a},!0);document.documentElement.style.width=a+"px";document.body.style.width=a+"px";document.body.style.left="0px";document.body.style.top="0px";this.setDesignResolutionSize(a,b,c)},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;a=Math.ceil(a*f*e+this._viewPortRect.x*e);b=Math.ceil(b*g*e+this._viewPortRect.y*e);c=Math.ceil(c*f*e);d=Math.ceil(d*g*e);_scissorRect||(e=gl.getParameter(gl.SCISSOR_BOX),_scissorRect=cc.rect(e[0],e[1],e[2],e[3]));if(_scissorRect.x!=a||_scissorRect.y!=b||_scissorRect.width!=c||_scissorRect.height!=
d)_scissorRect.x=a,_scissorRect.y=b,_scissorRect.width=c,_scissorRect.height=d,cc._renderContext.scissor(a,b,c,d)},isScissorEnabled:function(){return cc._renderContext.isEnabled(gl.SCISSOR_TEST)},getScissorRect:function(){if(!_scissorRect){var a=gl.getParameter(gl.SCISSOR_BOX);_scissorRect=cc.rect(a[0],a[1],a[2],a[3])}a=1/this._scaleX;var b=1/this._scaleY;return cc.rect((_scissorRect.x-this._viewPortRect.x)*a,(_scissorRect.y-this._viewPortRect.y)*b,_scissorRect.width*a,_scissorRect.height*b)},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){a=this._devicePixelRatio*(a-c.left);b=this._devicePixelRatio*(c.top+c.height-b);return this._isRotated?{x:this._viewPortRect.width-b,y:a}:{x:a,y: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},_convertPointWithScale:function(a){var b=this._viewPortRect;a.x=(a.x-b.x)/this._scaleX;a.y=(a.y-b.y)/this._scaleY},_convertTouchesWithScale:function(a){for(var b=this._viewPortRect,c=this._scaleX,d=this._scaleY,e,f,g=0;g<a.length;g++)e=a[g],f=e._point,e=e._prevPoint,f.x=(f.x-b.x)/c,f.y=(f.y-b.y)/d,e.x=(e.x-b.x)/c,e.y=(e.y-b.y)/d}});
cc.EGLView._getInstance=function(){this._instance||(this._instance=this._instance||new cc.EGLView,this._instance.initialize());return this._instance};
cc.ContainerStrategy=cc.Class.extend({preApply:function(a){},apply:function(a,b){},postApply:function(a){},_setupContainer:function(a,b,c){var d=cc.game.canvas,e=cc.game.container;cc.sys.os===cc.sys.OS_ANDROID&&(document.body.style.width=(a._isRotated?c:b)+"px",document.body.style.height=(a._isRotated?b:c)+"px");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=Math.min(2,window.devicePixelRatio||1));d.width=
b*e;d.height=c*e;cc._renderContext.resetCache&&cc._renderContext.resetCache()},_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);this._result.scale=[e,f];this._result.viewport=a;return 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){var b=a._frameSize.height,c=cc.container.style;this._setupContainer(a,a._frameSize.width,a._frameSize.height);c.margin=a._isRotated?"0 0 0 "+b+"px":"0px"}}),b=cc.ContainerStrategy.extend({apply:function(a,b){var c=a._frameSize.width,d=a._frameSize.height,e=cc.container.style,f=b.width,g=b.height,r=c/f,t=d/g,u,v;r<t?(u=c,v=g*r):(u=f*t,v=d);f=Math.round((c-u)/2);v=Math.round((d-v)/2);this._setupContainer(a,c-2*f,d-2*v);e.margin=a._isRotated?
"0 0 0 "+d+"px":"0px";e.paddingLeft=f+"px";e.paddingRight=f+"px";e.paddingTop=v+"px";e.paddingBottom=v+"px"}});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()}});var c=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;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=cc._canvas.width,d=cc._canvas.height,e=b.width,f=b.height,g=c/e,r=d/f,t=0,u,v;g<r?(t=g,u=c,v=f*t):(t=r,u=e*t,v=d);return this._buildResult(c,d,u,v,t,t)}});c=cc.ContentStrategy.extend({apply:function(a,
b){var c=cc._canvas.width,d=cc._canvas.height,e=b.width,f=b.height,g=c/e,r=d/f,t,u,v;g<r?(t=r,u=e*t,v=d):(t=g,u=c,v=f*t);return this._buildResult(c,d,u,v,t,t)}});var 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){this._containerStrategy.apply(a,b);return 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=this._fnMap,c;var d=0;for(l=b.length;d<l;d++)if((a=b[d])&&a[1]in document){d=0;for(c=a.length;d<c;d++)this._fn[b[0][d]]=a[d];break}this._supportsFullScreen="undefined"!==typeof this._fn.requestFullscreen;this._touchEvent="ontouchstart"in window?"touchstart":"mousedown"},fullScreen:function(){return this._supportsFullScreen?void 0===
document[this._fn.fullscreenElement]||null===document[this._fn.fullscreenElement]?!1:!0:!1},requestFullScreen:function(a,b){if(this._supportsFullScreen){a=a||document.documentElement;if(b){var c=this._fn.fullscreenchange;this._preOnFullScreenChange&&document.removeEventListener(c,this._preOnFullScreenChange);this._preOnFullScreenChange=b;document.addEventListener(c,b,!1)}return a[this._fn.requestFullscreen]()}},exitFullScreen:function(){return this._supportsFullScreen?document[this._fn.exitFullscreen]():
!0},autoFullScreen:function(a,b){function c(){d.removeEventListener(e._touchEvent,c);e.requestFullScreen(a,b)}a=a||document.body;var d=cc.game.canvas||a,e=this;this.requestFullScreen(a,b);d.addEventListener(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={TOUCH_TIMEOUT:5E3,_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=cc.sys.now(),c=0;c<this._maxTouches;c++){if(a&1){var d=this._touches[c];if(b-d._lastModified>this.TOUCH_TIMEOUT)return this._removeUsedIndexBit(c),
delete this._touchesIntegerDict[d.getID()],c}else return this._indexBitsUsed|=1<<c,c;a>>=1}return-1},_removeUsedIndexBit:function(a){0>a||a>=this._maxTouches||(this._indexBitsUsed&=~(1<<a))},_glView:null,handleTouchesBegin:function(a){for(var b,c,d,e=[],f=this._touchesIntegerDict,g=cc.sys.now(),h=0,k=a.length;h<k;h++)if(b=a[h],d=b.getID(),c=f[d],null==c){var m=this._getUnUsedIndex();-1===m?cc.log(cc._LogInfos.inputManager_handleTouchesBegin,m):(c=this._touches[m]=new cc.Touch(b._point.x,b._point.y,
b.getID()),c._lastModified=g,c._setPrevPoint(b._prevPoint),f[d]=m,e.push(c))}0<e.length&&(this._glView._convertTouchesWithScale(e),a=new cc.EventTouch(e),a._eventCode=cc.EventTouch.EventCode.BEGAN,cc.eventManager.dispatchEvent(a))},handleTouchesMove:function(a){for(var b,c,d=[],e=this._touches,f=cc.sys.now(),g=0,h=a.length;g<h;g++)b=a[g],c=b.getID(),c=this._touchesIntegerDict[c],null!=c&&e[c]&&(e[c]._setPoint(b._point),e[c]._setPrevPoint(b._prevPoint),e[c]._lastModified=f,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;h<k;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;a=cc.isFunction(a.getBoundingClientRect)?a.getBoundingClientRect():
{left:0,top:0,width:parseInt(a.style.width),height:parseInt(a.style.height)};return{left:a.left+c.pageXOffset-b.clientLeft,top:a.top+c.pageYOffset-b.clientTop,width:a.width,height:a.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}b||(b=a);return 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);b._setPrevPoint(d.x,d.y);d.x=a.x;d.y=a.y;return b},getMouseEvent:function(a,b,c){var d=this._prevMousePoint;this._glView._convertMouseToLocationInView(a,b);b=new cc.EventMouse(c);b.setLocation(a.x,a.y);b._setPrevCursor(d.x,d.y);d.x=a.x;d.y=a.y;return b},getPointByEvent:function(a,b){if(null!=a.pageX)return{x:a.pageX,
y:a.pageY};b.left-=document.body.scrollLeft;b.top-=document.body.scrollTop;return{x:a.clientX,y:a.clientY}},getTouchesByEvent:function(a,b){for(var c=[],d=this._glView,e,f,g=this._preTouchPoint,h=a.changedTouches.length,k=0;k<h;k++)if(e=a.changedTouches[k]){var m=cc.sys.BROWSER_TYPE_FIREFOX===cc.sys.browserType?d.convertToLocationInView(e.pageX,e.pageY,b):d.convertToLocationInView(e.clientX,e.clientY,b);null!=e.identifier?(e=new cc.Touch(m.x,m.y,e.identifier),f=this.getPreTouch(e).getLocation(),e._setPrevPoint(f.x,
f.y),this.setPreTouch(e)):(e=new cc.Touch(m.x,m.y),e._setPrevPoint(g.x,g.y));g.x=m.x;g.y=m.y;c.push(e)}return c},registerSystemEvent:function(a){if(!this._isRegisterEvent){this._glView=cc.view;var b=this,c="mouse"in cc.sys.capabilities,d="touches"in cc.sys.capabilities,e=!1;cc.sys.isMobile&&(e=!0);c&&(window.addEventListener("mousedown",function(){b._mousePressed=!0},!1),window.addEventListener("mouseup",function(c){if(!e){var d=b._mousePressed;b._mousePressed=!1;if(d){d=b.getHTMLElementPosition(a);
var 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),a.addEventListener("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),a.addEventListener("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),a.addEventListener("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);b._mousePressed?d.setButton(c.button):d.setButton(null);cc.eventManager.dispatchEvent(d);c.stopPropagation();c.preventDefault()}},!1),a.addEventListener("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),a.addEventListener("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));if(window.navigator.msPointerEnabled){c={MSPointerDown:b.handleTouchesBegin,MSPointerMove:b.handleTouchesMove,MSPointerUp:b.handleTouchesEnd,MSPointerCancel:b.handleTouchesCancel};for(var f in c)(function(c,d){a.addEventListener(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&&(a.addEventListener("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),a.addEventListener("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),a.addEventListener("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),a.addEventListener("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._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}};_p=cc.inputManager;_p.setAccelerometerEnabled=function(a){this._accelEnabled!==a&&(this._accelEnabled=a,a=cc.director.getScheduler(),this._accelEnabled?(this._accelCurTime=0,this._registerAccelerometerEvent(),a.scheduleUpdate(this)):(this._accelCurTime=0,this._unregisterAccelerometerEvent(),a.unscheduleUpdate(this)))};_p.setAccelerometerInterval=function(a){this._accelInterval!==a&&(this._accelInterval=a)};
_p._registerKeyboardEvent=function(){cc._canvas.addEventListener("keydown",function(a){cc.eventManager.dispatchEvent(new cc.EventKeyboard(a.keyCode,!0));a.stopPropagation();a.preventDefault()},!1);cc._canvas.addEventListener("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;if(/Android/.test(c)||/Adr/.test(c)&&cc.sys.browserType===cc.BROWSER_TYPE_UC)this._minus=-1;this.didAccelerateCallback=this.didAccelerate.bind(this);
a.addEventListener(b,this.didAccelerateCallback,!1)};_p._unregisterAccelerometerEvent=function(){this._acceleration=null;window.removeEventListener(this._accelDeviceEvent===window.DeviceMotionEvent?"devicemotion":"deviceorientation",this.didAccelerateCallback,!1)};
_p.didAccelerate=function(a){var b=window;if(this._accelEnabled){var c=this._acceleration;if(this._accelDeviceEvent===window.DeviceMotionEvent){var d=a.accelerationIncludingGravity;var e=this._accelMinus*d.x*.1;var f=this._accelMinus*d.y*.1;d=.1*d.z}else e=a.gamma/90*.981,f=.981*-(a.beta/90),d=a.alpha/90*.981;c.x=e;c.y=f;c.z=d;c.timestamp=a.timeStamp||Date.now();a=c.x;b.orientation===cc.UIInterfaceOrientationLandscapeRight?(c.x=-c.y,c.y=a):b.orientation===cc.UIInterfaceOrientationLandscapeLeft?(c.x=
c.y,c.y=-a):b.orientation===cc.UIInterfaceOrientationPortraitUpsideDown&&(c.x=-c.x,c.y=-c.y)}};delete _p;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){if(void 0===c){c=b;var d=a.x;a=a.y}else d=a,a=b;return{x:c.a*d+c.c*a+c.tx,y:c.b*d+c.d*a+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);e=cc.pointApplyAffineTransform(e,f,b);f=Math.min(g.x,c.x,d.x,e.x);var h=Math.min(g.y,c.y,d.y,e.y);return cc.rect(f,h,Math.max(g.x,c.x,d.x,e.x)-f,Math.max(g.y,c.y,d.y,e.y)-h)};
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);var 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);var k=Math.min(g.y,c.y,d.y,h.y);g=Math.max(g.y,c.y,d.y,h.y);a.x=e;a.y=k;a.width=f-e;a.height=g-k;return 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.affineTransformConcatIn=function(a,b){var c=a.a,d=a.b,e=a.c,f=a.d,g=a.tx,h=a.ty;a.a=c*b.a+d*b.c;a.b=c*b.b+d*b.d;a.c=e*b.a+f*b.c;a.d=e*b.b+f*b.d;a.tx=g*b.a+h*b.c+b.tx;a.ty=g*b.b+h*b.d+b.ty;return a};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.affineTransformInvertOut=function(a,b){var c=a.a,d=a.b,e=a.c,f=a.d,g=1/(c*f-d*e);b.a=g*f;b.b=-g*d;b.c=-g*e;b.d=g*c;b.tx=g*(e*a.ty-f*a.tx);b.ty=g*(d*a.tx-c*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),.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 a<b?b:a<c?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;a.x=e*d-a.y*c+b.x;a.y=e*c+a.y*d+b.y;return 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;e.x=g*a-d*h;e.y=f*a-b*h;if(0===c)return 0===e.x||0===e.y?!0:!1;e.x/=c;e.y/=c;return!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){var b=Math.sqrt(a.x*a.x+a.y*a.y);0!==b&&cc.pMultIn(a,1/b)};cc.vertexLineToPolygon=function(a,b,c,d,e){e+=d;if(!(1>=e)){b*=.5;for(var f,g=e-1,h=d;h<e;h++){f=2*h;var k=cc.p(a[2*h],a[2*h+1]);if(0===h)var m=cc.pPerp(cc.pNormalize(cc.pSub(k,cc.p(a[2*(h+1)],a[2*(h+1)+1]))));else if(h===g)m=cc.pPerp(cc.pNormalize(cc.pSub(cc.p(a[2*(h-1)],a[2*(h-1)+1]),k)));else{m=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,k)),r=cc.pNormalize(cc.pSub(m,k)),t=Math.acos(cc.pDot(p,r));m=t<cc.degreesToRadians(70)?cc.pPerp(cc.pNormalize(cc.pMidpoint(p,
r))):t<cc.degreesToRadians(170)?cc.pNormalize(cc.pMidpoint(p,r)):cc.pPerp(cc.pNormalize(cc.pSub(n,m)))}m=cc.pMult(m,b);c[2*f]=k.x+m.x;c[2*f+1]=k.y+m.y;c[2*(f+1)]=k.x-m.x;c[2*(f+1)+1]=k.y-m.y}for(h=0===d?0:d-1;h<g;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){if(a===c&&b===d||e===g&&f===h)return{isSuccess:!1,value:0};c-=a;d-=b;e-=a;f-=b;g-=a;h-=b;a=Math.sqrt(c*c+d*d);c/=a;d/=a;b=e*c+f*d;f=f*c-e*d;e=b;b=g*c+h*d;h=h*c-g*d;g=b;return f===h?{isSuccess:!1,value:0}:{isSuccess:!0,value:(g+(e-g)*h/(h-f))/a}};cc.vertexListIsClockwise=function(a){for(var b=0,c=a.length;b<c;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.Touch=cc.Class.extend({_lastModified:0,_point:null,_prevPoint:null,_id:0,_startPointCaptured:!1,_startPoint:null,ctor:function(a,b,c){this.setTouchInfo(c,a,b)},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(){cc.log("getId is deprecated. Please use getID instead.");return 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),cc.view._convertPointWithScale(this._startPoint),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){this._prevPoint=void 0===b?cc.p(a.x,a.y):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=6;cc.EventListener.FOCUS=7;cc.EventListener.CUSTOM=8;
cc._EventListenerCustom=cc.EventListener.extend({_onCustomEvent:null,ctor:function(a,b,c){this._onCustomEvent=b;this._target=c;cc.EventListener.prototype.ctor.call(this,cc.EventListener.CUSTOM,a,this._callback)},_callback:function(a){null!==this._onCustomEvent&&this._onCustomEvent.call(this._target,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(){cc.EventListener.prototype.ctor.call(this,cc.EventListener.MOUSE,cc._EventListenerMouse.LISTENER_ID,this._callback)},_callback:function(a){var b=cc.EventMouse;switch(a._eventType){case b.DOWN:if(this.onMouseDown)this.onMouseDown(a);break;case b.UP:if(this.onMouseUp)this.onMouseUp(a);break;case b.MOVE:if(this.onMouseMove)this.onMouseMove(a);break;case b.SCROLL:if(this.onMouseScroll)this.onMouseScroll(a)}},
clone:function(){var a=new cc._EventListenerMouse;a.onMouseDown=this.onMouseDown;a.onMouseUp=this.onMouseUp;a.onMouseMove=this.onMouseMove;a.onMouseScroll=this.onMouseScroll;return 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;
a.onTouchBegan=this.onTouchBegan;a.onTouchMoved=this.onTouchMoved;a.onTouchEnded=this.onTouchEnded;a.onTouchCancelled=this.onTouchCancelled;a.swallowTouches=this.swallowTouches;return 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;a.onTouchesBegan=this.onTouchesBegan;a.onTouchesMoved=this.onTouchesMoved;a.onTouchesEnded=this.onTouchesEnded;a.onTouchesCancelled=this.onTouchesCancelled;return 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;a.onFocusChanged=this.onFocusChanged;return 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,this._callback)},_callback:function(a){if(this.onFocusChanged)this.onFocusChanged(a._widgetLoseFocus,a._widgetGetFocus)}});
cc._EventListenerFocus.LISTENER_ID="__cc_focus_event";(function(){function a(a){var b=cc.Event,d=a._type;if(d===b.ACCELERATION)return cc._EventListenerAcceleration.LISTENER_ID;if(d===b.CUSTOM)return a._eventName;if(d===b.KEYBOARD)return cc._EventListenerKeyboard.LISTENER_ID;if(d===b.MOUSE)return cc._EventListenerMouse.LISTENER_ID;if(d===b.FOCUS)return cc._EventListenerFocus.LISTENER_ID;d===b.TOUCH&&cc.log(cc._LogInfos.__getListenerID);return""}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.eventManager={DIRTY_NONE:0,DIRTY_FIXED_PRIORITY:1,DIRTY_SCENE_GRAPH_PRIORITY:2,DIRTY_ALL:3,_listenersMap:{},_priorityDirtyFlagMap:{},_nodeListenersMap:{},_nodePriorityMap:{},_globalZOrderNodeMap:{},_toAddedListeners:[],_toRemovedListeners:[],_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,d=a.length;b<d;b++)this._setDirtyForNode(a[b])},pauseTarget:function(a,c){var b=this._nodeListenersMap[a.__instanceId],e;if(b){var f=0;for(e=b.length;f<e;f++)b[f]._setPaused(!0)}if(!0===c)for(b=a.getChildren(),f=0,e=b.length;f<e;f++)this.pauseTarget(b[f],!0)},resumeTarget:function(a,c){var b=this._nodeListenersMap[a.__instanceId],e;if(b){var f=0;for(e=
b.length;f<e;f++)b[f]._setPaused(!1)}this._setDirtyForNode(a);if(!0===c)for(b=a.getChildren(),f=0,e=b.length;f<e;f++)this.resumeTarget(b[f],!0)},_addListener:function(a){0===this._inDispatch?this._forceAddEventListener(a):this._toAddedListeners.push(a)},_forceAddEventListener:function(a){var b=a._getListenerID(),d=this._listenersMap[b];d||(d=new cc._EventListenerVector,this._listenersMap[b]=d);d.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=this._dirtyNodes,c,d,e=this._nodeListenersMap,f=0,g=a.length;f<g;f++)if(c=e[a[f].__instanceId])for(var h=0,k=c.length;h<k;h++)(d=c[h])&&this._setDirty(d._getListenerID(),this.DIRTY_SCENE_GRAPH_PRIORITY);
this._dirtyNodes.length=0}},_removeAllListenersInVector:function(a){if(a)for(var b,d=0;d<a.length;)b=a[d],b._setRegistered(!1),null!=b._getSceneGraphPriority()&&(this._dissociateNodeAndEventListener(b._getSceneGraphPriority(),b),b._setSceneGraphPriority(null)),0===this._inDispatch?cc.arrayRemoveObject(a,b):++d},_removeListenersForListenerID:function(a){var b=this._listenersMap[a];if(b){var d=b.getFixedPriorityListeners(),e=b.getSceneGraphPriorityListeners();this._removeAllListenersInVector(e);this._removeAllListenersInVector(d);
delete this._priorityDirtyFlagMap[a];this._inDispatch||b.clear();delete this._listenersMap[a]}d=this._toAddedListeners;for(b=0;b<d.length;)(e=d[b])&&e._getListenerID()===a?cc.arrayRemoveObject(d,e):++b},_sortEventListeners:function(a){var b=this.DIRTY_NONE,d=this._priorityDirtyFlagMap;d[a]&&(b=d[a]);b!==this.DIRTY_NONE&&(d[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):d[a]=this.DIRTY_SCENE_GRAPH_PRIORITY))},_sortListenersOfSceneGraphPriority:function(a,c){var b=this._getListeners(a);if(b){var e=b.getSceneGraphPriorityListeners();e&&0!==e.length&&(this._nodePriorityIndex=0,this._nodePriorityMap={},this._visitTarget(c,!0),b.getSceneGraphPriorityListeners().sort(this._sortEventListenersOfSceneGraphPriorityDes))}},_sortEventListenersOfSceneGraphPriorityDes:function(a,c){var b=cc.eventManager._nodePriorityMap,e=a._getSceneGraphPriority(),f=c._getSceneGraphPriority();
return c&&f&&b[f.__instanceId]?a&&e&&b[e.__instanceId]?b[c._getSceneGraphPriority().__instanceId]-b[a._getSceneGraphPriority().__instanceId]:1:-1},_sortListenersOfFixedPriority:function(a){if(a=this._listenersMap[a]){var b=a.getFixedPriorityListeners();if(b&&0!==b.length){b.sort(this._sortListenersOfFixedPriorityAsc);for(var d=0,e=b.length;d<e&&!(0<=b[d]._getFixedPriority());)++d;a.gt0Index=d}}},_sortListenersOfFixedPriorityAsc:function(a,c){return a._getFixedPriority()-c._getFixedPriority()},_onUpdateListeners:function(a){var b=
a.getFixedPriorityListeners(),d=a.getSceneGraphPriorityListeners(),e,f=this._toRemovedListeners;if(d)for(e=0;e<d.length;){var g=d[e];g._isRegistered()?++e:(cc.arrayRemoveObject(d,g),g=f.indexOf(g),-1!==g&&f.splice(g,1))}if(b)for(e=0;e<b.length;)g=b[e],g._isRegistered()?++e:(cc.arrayRemoveObject(b,g),g=f.indexOf(g),-1!==g&&f.splice(g,1));d&&0===d.length&&a.clearSceneGraphListeners();b&&0===b.length&&a.clearFixedListeners()},frameUpdateListeners:function(){var a=this._listenersMap,c=this._priorityDirtyFlagMap,
d;for(d in a)a[d].empty()&&(delete c[d],delete a[d]);a=this._toAddedListeners;if(0!==a.length){c=0;for(d=a.length;c<d;c++)this._forceAddEventListener(a[c]);a.length=0}0!==this._toRemovedListeners.length&&this._cleanToRemovedListeners()},_updateTouchListeners:function(a){a=this._inDispatch;cc.assert(0<a,cc._LogInfos.EventManager__updateListeners);if(!(1<a)){var b;(b=this._listenersMap[cc._EventListenerTouchOneByOne.LISTENER_ID])&&this._onUpdateListeners(b);(b=this._listenersMap[cc._EventListenerTouchAllAtOnce.LISTENER_ID])&&
this._onUpdateListeners(b);cc.assert(1===a,cc._LogInfos.EventManager__updateListeners_2);a=this._toAddedListeners;if(0!==a.length){b=0;for(var d=a.length;b<d;b++)this._forceAddEventListener(a[b]);a.length=0}0!==this._toRemovedListeners.length&&this._cleanToRemovedListeners()}},_cleanToRemovedListeners:function(){for(var a=this._toRemovedListeners,c=0;c<a.length;c++){var d=a[c],e=this._listenersMap[d._getListenerID()];if(e){var f=e.getFixedPriorityListeners(),g=e.getSceneGraphPriorityListeners();g&&
(e=g.indexOf(d),-1!==e&&g.splice(e,1));f&&(e=f.indexOf(d),-1!==e&&f.splice(e,1))}}a.length=0},_onTouchEventCallback:function(a,c){if(!a._isRegistered)return!1;var b=c.event,e=c.selTouch;b._setCurrentTarget(a._node);var f=!1,g,h=b.getEventCode(),k=cc.EventTouch.EventCode;if(h===k.BEGAN)a.onTouchBegan&&(f=a.onTouchBegan(e,b))&&a._registered&&a._claimedTouches.push(e);else if(0<a._claimedTouches.length&&-1!==(g=a._claimedTouches.indexOf(e)))if(f=!0,h===k.MOVED&&a.onTouchMoved)a.onTouchMoved(e,b);else if(h===
k.ENDED){if(a.onTouchEnded)a.onTouchEnded(e,b);a._registered&&a._claimedTouches.splice(g,1)}else if(h===k.CANCELLED){if(a.onTouchCancelled)a.onTouchCancelled(e,b);a._registered&&a._claimedTouches.splice(g,1)}return b.isStopped()?(cc.eventManager._updateTouchListeners(b),!0):f&&a._registered&&a.swallowTouches?(c.needsMutableSet&&c.touches.splice(e,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),d=this._getListeners(cc._EventListenerTouchAllAtOnce.LISTENER_ID);if(null!==b||null!==d){var e=a.getTouches(),f=cc.copyArray(e),g={event:a,needsMutableSet:b&&d,touches:f,selTouch:null};if(b)for(var h=0;h<e.length;h++)if(g.selTouch=e[h],this._dispatchEventToListeners(b,this._onTouchEventCallback,g),a.isStopped())return;if(d&&0<f.length&&(this._dispatchEventToListeners(d,this._onTouchesEventCallback,{event:a,touches:f}),a.isStopped()))return;
this._updateTouchListeners(a)}},_onTouchesEventCallback:function(a,c){if(!a._registered)return!1;var b=cc.EventTouch.EventCode,e=c.event,f=c.touches,g=e.getEventCode();e._setCurrentTarget(a._node);if(g===b.BEGAN&&a.onTouchesBegan)a.onTouchesBegan(f,e);else if(g===b.MOVED&&a.onTouchesMoved)a.onTouchesMoved(f,e);else if(g===b.ENDED&&a.onTouchesEnded)a.onTouchesEnded(f,e);else if(g===b.CANCELLED&&a.onTouchesCancelled)a.onTouchesCancelled(f,e);return e.isStopped()?(cc.eventManager._updateTouchListeners(e),
!0):!1},_associateNodeAndEventListener:function(a,c){var b=this._nodeListenersMap[a.__instanceId];b||(b=[],this._nodeListenersMap[a.__instanceId]=b);b.push(c)},_dissociateNodeAndEventListener:function(a,c){var b=this._nodeListenersMap[a.__instanceId];b&&(cc.arrayRemoveObject(b,c),0===b.length&&delete this._nodeListenersMap[a.__instanceId])},_dispatchEventToListeners:function(a,c,d){var b=!1,f=a.getFixedPriorityListeners(),g=a.getSceneGraphPriorityListeners(),h=0;if(f&&0!==f.length)for(;h<a.gt0Index;++h){var k=
f[h];if(k.isEnabled()&&!k._isPaused()&&k._isRegistered()&&c(k,d)){b=!0;break}}if(g&&!b)for(a=0;a<g.length;a++)if(k=g[a],k.isEnabled()&&!k._isPaused()&&k._isRegistered()&&c(k,d)){b=!0;break}if(f&&!b)for(;h<f.length&&(k=f[h],!k.isEnabled()||k._isPaused()||!k._isRegistered()||!c(k,d));++h);},_setDirty:function(a,c){var b=this._priorityDirtyFlagMap;b[a]=null==b[a]?c:c|b[a]},_visitTarget:function(a,c){var b=a.getChildren(),e=0,f=b.length,g=this._globalZOrderNodeMap,h=this._nodeListenersMap;if(0<f){for(var k;e<
f;e++)if((k=b[e])&&0>k.getLocalZOrder())this._visitTarget(k,!1);else break;null!=h[a.__instanceId]&&(g[a.getGlobalZOrder()]||(g[a.getGlobalZOrder()]=[]),g[a.getGlobalZOrder()].push(a.__instanceId));for(;e<f;e++)(k=b[e])&&this._visitTarget(k,!1)}else null!=h[a.__instanceId]&&(g[a.getGlobalZOrder()]||(g[a.getGlobalZOrder()]=[]),g[a.getGlobalZOrder()].push(a.__instanceId));if(c){b=[];for(var m in g)b.push(m);b.sort(this._sortNumberAsc);m=b.length;k=this._nodePriorityMap;for(e=0;e<m;e++)for(f=g[b[e]],
h=0;h<f.length;h++)k[f[h]]=++this._nodePriorityIndex;this._globalZOrderNodeMap={}}},_sortNumberAsc:function(a,c){return a-c},addListener:function(a,c){cc.assert(a&&c,cc._LogInfos.eventManager_addListener_2);if(!(a instanceof cc.EventListener))cc.assert(!cc.isNumber(c),cc._LogInfos.eventManager_addListener_3),a=cc.EventListener.create(a);else if(a._isRegistered()){cc.log(cc._LogInfos.eventManager_addListener_4);return}if(a.checkAvailable()){if(cc.isNumber(c)){if(0===c){cc.log(cc._LogInfos.eventManager_addListener);
return}a._setSceneGraphPriority(null);a._setFixedPriority(c);a._setRegistered(!0);a._setPaused(!1)}else a._setSceneGraphPriority(c),a._setFixedPriority(0),a._setRegistered(!0);this._addListener(a);return a}},addCustomListener:function(a,c,d){a=new cc._EventListenerCustom(a,c,d);this.addListener(a,1);return a},removeListener:function(a){if(null!=a){var b=this._listenersMap;for(g in b){var d=b[g],e=d.getFixedPriorityListeners();var f=d.getSceneGraphPriorityListeners();(f=this._removeListenerInVector(f,
a))?this._setDirty(a._getListenerID(),this.DIRTY_SCENE_GRAPH_PRIORITY):(f=this._removeListenerInVector(e,a))&&this._setDirty(a._getListenerID(),this.DIRTY_FIXED_PRIORITY);d.empty()&&(delete this._priorityDirtyFlagMap[a._getListenerID()],delete b[g]);if(f)break}if(!f){b=this._toAddedListeners;var g=0;for(d=b.length;g<d;g++)if(e=b[g],e===a){cc.arrayRemoveObject(b,e);e._setRegistered(!1);break}}}},_removeListenerInCallback:function(a,c){if(null==a)return!1;for(var b=0,e=a.length;b<e;b++){var f=a[b];
if(f._onCustomEvent===c||f._onEvent===c)return f._setRegistered(!1),null!=f._getSceneGraphPriority()&&(this._dissociateNodeAndEventListener(f._getSceneGraphPriority(),f),f._setSceneGraphPriority(null)),0===this._inDispatch&&cc.arrayRemoveObject(a,f),!0}return!1},_removeListenerInVector:function(a,c){if(null==a)return!1;for(var b=0,e=a.length;b<e;b++){var f=a[b];if(f===c)return f._setRegistered(!1),null!=f._getSceneGraphPriority()&&(this._dissociateNodeAndEventListener(f._getSceneGraphPriority(),f),
f._setSceneGraphPriority(null)),0===this._inDispatch?cc.arrayRemoveObject(a,f):this._toRemovedListeners.push(f),!0}return!1},removeListeners:function(a,c){if(a instanceof cc.Node){delete this._nodePriorityMap[a.__instanceId];cc.arrayRemoveObject(this._dirtyNodes,a);var b=this._nodeListenersMap[a.__instanceId];if(b){var e=cc.copyArray(b);for(b=0;b<e.length;b++)this.removeListener(e[b]);e.length=0}e=this._toAddedListeners;for(b=0;b<e.length;){var f=e[b];f._getSceneGraphPriority()===a?(f._setSceneGraphPriority(null),
f._setRegistered(!1),e.splice(b,1)):++b}if(!0===c)for(e=a.getChildren(),b=0,f=e.length;b<f;b++)this.removeListeners(e[b],!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,c=this._internalCustomListenerIDs,d;for(d in a)-1===c.indexOf(d)&&this._removeListenersForListenerID(d)},setPriority:function(a,c){if(null!=a){var b=this._listenersMap,e;for(e in b){var f=b[e].getFixedPriorityListeners();
if(f&&-1!==f.indexOf(a)){null!=a._getSceneGraphPriority()&&cc.log(cc._LogInfos.eventManager_setPriority);a._getFixedPriority()!==c&&(a._setFixedPriority(c),this._setDirty(a._getListenerID(),this.DIRTY_FIXED_PRIORITY));break}}}},setEnabled:function(a){this._isEnabled=a},isEnabled:function(){return this._isEnabled},dispatchEvent:function(b){if(this._isEnabled){this._updateDirtyFlagForSceneGraph();this._inDispatch++;if(!b||!b.getType)throw Error("event is undefined");if(b._type===cc.Event.TOUCH)this._dispatchTouchEvent(b);
else{var c=a(b);this._sortEventListeners(c);if(c=this._listenersMap[c])this._dispatchEventToListeners(c,this._onListenerCallback,b),this._onUpdateListeners(c)}this._inDispatch--}},_onListenerCallback:function(a,c){c._setCurrentTarget(a._getSceneGraphPriority());a._onEvent(c);return c.isStopped()},dispatchCustomEvent:function(a,c){var b=new cc.EventCustom(a);b.setUserData(c);this.dispatchEvent(b)}}})();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(){cc.assert(this._onAccelerationEvent,cc._LogInfos._EventListenerAcceleration_checkAvailable);return!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){if(b._isPressed){if(a.onKeyPressed)a.onKeyPressed(b._keyCode,b)}else if(a.onKeyReleased)a.onKeyReleased(b._keyCode,b)})},clone:function(){var a=new cc._EventListenerKeyboard;a.onKeyPressed=this.onKeyPressed;a.onKeyReleased=this.onKeyReleased;return 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};var GlobalVertexBuffer=function(){var a=function(a,c){this.gl=a;this.vertexBuffer=a.createBuffer();this.size=888;this.byteLength=c||3552*cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT;this.data=new ArrayBuffer(this.byteLength);this.dataArray=new Float32Array(this.data);a.bindBuffer(a.ARRAY_BUFFER,this.vertexBuffer);a.bufferData(a.ARRAY_BUFFER,this.dataArray,a.DYNAMIC_DRAW);this._dirty=!1;this._spaces={0:this.byteLength}};a.prototype={constructor:a,allocBuffer:function(a,c){var b=this._spaces[a];return b&&
b>=c?(delete this._spaces[a],b>c&&(this._spaces[a+c]=b-c),!0):!1},requestBuffer:function(a){var b;for(b in this._spaces){var d=parseInt(b);var e=this._spaces[b];if(e>=a&&this.allocBuffer(d,a))return d}return-1},freeBuffer:function(a,c){var b=this._spaces,e;for(e in b){var f=parseInt(e);if(f>a)break;if(f+b[e]>=a){c=c+a-f;a=f;break}}b=a+c;this._spaces[b]&&(c+=this._spaces[b],delete this._spaces[b]);this._spaces[a]=c},setDirty:function(){this._dirty=!0},update:function(){this._dirty&&(this.gl.bindBuffer(gl.ARRAY_BUFFER,
this.vertexBuffer),this.gl.bufferSubData(gl.ARRAY_BUFFER,0,this.dataArray),this._dirty=!1)},updateSubData:function(a,c){this.gl.bindBuffer(gl.ARRAY_BUFFER,this.vertexBuffer);this.gl.bufferSubData(gl.ARRAY_BUFFER,a,c)},destroy:function(){this.gl.deleteBuffer(this.vertexBuffer);this.vertexBuffer=this.texCoords=this.colors=this.positions=this.data=null}};return a}();cc.rendererCanvas={childrenOrderDirty:!0,assignedZ:0,assignedZStep:1E-4,_transformNodePool:[],_renderCmds:[],_isCacheToCanvasOn:!1,_cacheToCanvasCmds:{},_cacheInstanceIds:[],_currentID:0,_clearColor:cc.color(),_clearFillStyle:"rgb(0, 0, 0)",_dirtyRegion:null,_allNeedDraw:!0,_enableDirtyRegion:!1,_debugDirtyRegion:!1,_canUseDirtyRegion:!1,_dirtyRegionCountThreshold:10,getRenderCmd:function(a){return a._createRenderCmd()},enableDirtyRegion:function(a){this._enableDirtyRegion=a},isDirtyRegionEnabled:function(){return this._enableDirtyRegion},
setDirtyRegionCountThreshold:function(a){this._dirtyRegionCountThreshold=a},_collectDirtyRegion:function(){var a=this._renderCmds,b,c=this._dirtyRegion,d=0,e=!0,f=cc.Node.CanvasRenderCmd.RegionStatus;var g=0;for(b=a.length;g<b;g++){var h=a[g],k=h._oldRegion,m=h._currentRegion;h._regionFlag>f.NotDirty&&(++d,d>this._dirtyRegionCountThreshold&&(e=!1),e&&(!m.isEmpty()&&c.addRegion(m),h._regionFlag>f.Dirty&&!k.isEmpty()&&c.addRegion(k)),h._regionFlag=f.NotDirty)}return e},_beginDrawDirtyRegion:function(a){var b=
a.getContext(),c=this._dirtyRegion.getDirtyRegions();b.save();a.setTransform({a:1,b:0,c:0,d:1,tx:0,ty:0},a._scaleX,a._scaleY);b.beginPath();a=0;for(var d=c.length;a<d;++a){var e=c[a];b.rect(e._minX,-e._maxY,e._width,e._height)}b.clip()},_endDrawDirtyRegion:function(a){a.restore()},_debugDrawDirtyRegion:function(a){if(this._debugDirtyRegion){var b=a.getContext(),c=this._dirtyRegion.getDirtyRegions();a.setTransform({a:1,b:0,c:0,d:1,tx:0,ty:0},a._scaleX,a._scaleY);b.beginPath();a=0;for(var d=c.length;a<
d;++a){var e=c[a];b.rect(e._minX,-e._maxY,e._width,e._height)}c=b.fillStyle;b.fillStyle="green";b.fill();b.fillStyle=c}},rendering:function(a){var b=this._dirtyRegion=this._dirtyRegion||new cc.DirtyRegion,c=cc._canvas;a=a||cc._renderContext;var d=a.getContext(),e=cc.view.getScaleX(),f=cc.view.getScaleY();a.setViewScale(e,f);a.computeRealOffsetY();var g=this._dirtyRegion.getDirtyRegions(),h=this._renderCmds,k=this._allNeedDraw||!this._enableDirtyRegion||!this._canUseDirtyRegion;var m=!0;k||(m=this._collectDirtyRegion());
(k=k||!m)||this._beginDrawDirtyRegion(a);d.setTransform(1,0,0,1,0,0);d.clearRect(0,0,c.width,c.height);if(255!==this._clearColor.r||255!==this._clearColor.g||255!==this._clearColor.b)a.setFillStyle(this._clearFillStyle),a.setGlobalAlpha(this._clearColor.a),d.fillRect(0,0,c.width,c.height);c=0;for(m=h.length;c<m;c++){var n=h[c],p=!1,r=n._currentRegion;if(!r||k)p=!0;else for(var t=0,u=g.length;t<u;++t)if(g[t].intersects(r)){p=!0;break}p&&n.rendering(a,e,f)}k||(this._debugDrawDirtyRegion(a),this._endDrawDirtyRegion(d));
b.clear();this._allNeedDraw=!1},_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=this._cacheToCanvasCmds[b],f;a.computeRealOffsetY();var g=0;for(f=e.length;g<f;g++)e[g].rendering(a,c,d);this._removeCache(b);a=this._cacheInstanceIds;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},_removeCache:function(a){a=a||this._currentID;var b=this._cacheToCanvasCmds[a];b&&(b.length=0,delete this._cacheToCanvasCmds[a]);cc.arrayRemoveObject(this._cacheInstanceIds,a)},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;b<c;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)},clear:function(){},clearRenderCommands:function(){this._renderCmds.length=0;this._cacheInstanceIds.length=0;this._isCacheToCanvasOn=!1;this._canUseDirtyRegion=this._allNeedDraw=!0},pushRenderCommand:function(a){if(a.needDraw())if(a._canUseDirtyRegion||
(this._canUseDirtyRegion=!1),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)}};
(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*c,-a.b*d,-a.c*c,a.d*d,a.tx*c,-(a.ty*d))):this._context.setTransform(a.a*c,-a.b*d,-a.c*c,a.d*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.rendererWebGL=function(){var a={texture:null,blendSrc:null,blendDst:null,glProgramState:null},b=!1,c=null,d=null,e=0,f=0,g=0,h=null,k=0,m=null,n=null,p=null,r=0,t=!0,u={QUAD:0,TRIANGLE:1,CUSTOM:2};return{mat4Identity:null,childrenOrderDirty:!0,assignedZ:0,assignedZStep:.01,VertexType:u,_transformNodePool:[],_renderCmds:[],_isCacheToBufferOn:!1,_cacheToBufferCmds:{},_cacheInstanceIds:[],_currentID:0,_clearColor:cc.color(0,0,0,255),init:function(){var a=cc._renderContext;a.disable(a.CULL_FACE);a.disable(a.DEPTH_TEST);
this.mat4Identity=new cc.math.Matrix4;this.mat4Identity.identity();a=cc.BATCH_VERTEX_COUNT;var b=cc._renderContext;null===c&&(d=b.createBuffer(),c=b.createBuffer());b=cc._renderContext;if(c){var f=6*Math.ceil(a/4);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,c);p=new Uint16Array(f);for(var g=0,t=0;t<f;t+=6)p[t]=g+0,p[t+1]=g+1,p[t+2]=g+2,p[t+3]=g+1,p[t+4]=g+2,p[t+5]=g+3,g+=4;b.bufferData(b.ELEMENT_ARRAY_BUFFER,p,b.DYNAMIC_DRAW)}d&&(k=6*a,h=new ArrayBuffer(4*k),m=new Float32Array(h),n=new Uint32Array(h),b.bindBuffer(b.ARRAY_BUFFER,
d),b.bufferData(b.ARRAY_BUFFER,m,b.DYNAMIC_DRAW));e=a-200},getVertexSize:function(){return e},getRenderCmd:function(a){return a._createRenderCmd()},_turnToCacheMode:function(a){this._isCacheToBufferOn=!0;a=a||0;this._cacheToBufferCmds[a]?this._cacheToBufferCmds[a].length=0:this._cacheToBufferCmds[a]=[];-1===this._cacheInstanceIds.indexOf(a)&&this._cacheInstanceIds.push(a);this._currentID=a},_turnToNormalMode:function(){this._isCacheToBufferOn=!1},_removeCache:function(a){a=a||this._currentID;var b=
this._cacheToBufferCmds[a];b&&(b.length=0,delete this._cacheToBufferCmds[a]);cc.arrayRemoveObject(this._cacheInstanceIds,a)},_renderingToBuffer:function(a){a=a||this._currentID;this.rendering(cc._renderContext,this._cacheToBufferCmds[a]);this._removeCache(a);a=this._cacheInstanceIds;0===a.length?this._isCacheToBufferOn=!1:this._currentID=a[a.length-1]},resetFlag:function(){this.childrenOrderDirty&&(this.childrenOrderDirty=!1);this._transformNodePool.length=0},transform:function(){var a=this._transformNodePool;
a.sort(this._sortNodeByLevelAsc);var b;var c=0;for(b=a.length;c<b;c++){var d=a[c];d.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},clear:function(){var a=cc._renderContext;a.clearColor(this._clearColor.r/255,this._clearColor.g/255,this._clearColor.b/255,this._clearColor.a/
255);a.clear(a.COLOR_BUFFER_BIT|a.DEPTH_BUFFER_BIT)},setDepthTest:function(a){var b=cc._renderContext;a?(b.clearDepth(1),b.enable(b.DEPTH_TEST),b.depthFunc(b.LEQUAL)):b.disable(b.DEPTH_TEST)},pushRenderCommand:function(a){if(a.rendering||a.uploadData)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)},_increaseBatchingSize:function(a,b,c){b=b||u.QUAD;switch(b){case u.QUAD:for(b=0;b<
a;b+=4)c=f+b,p[g++]=c+0,p[g++]=c+1,p[g++]=c+2,p[g++]=c+1,p[g++]=c+2,p[g++]=c+3;break;case u.TRIANGLE:t=!1;for(b=0;b<a;b+=3)c=f+b,p[g++]=c+0,p[g++]=c+1,p[g++]=c+2;break;case u.CUSTOM:t=!1;var d=c.length;for(b=0;b<d;b++)p[g++]=f+c[b];break;default:return}f+=a},_updateBatchedInfo:function(b,c,d){return b!==a.texture||c.src!==a.blendSrc||c.dst!==a.blendDst||d!==a.glProgramState?(this._batchRendering(),a.texture=b,a.blendSrc=c.src,a.blendDst=c.dst,a.glProgramState=d,!0):!1},_breakBatch:function(){b=!0},
_uploadBufferData:function(c){f>=e&&this._batchRendering();var d=c._node,g=d._texture||d._spriteFrame&&d._spriteFrame._texture,h=d._blendFunc.src;d=d._blendFunc.dst;var k=c._glProgramState;if(b||a.texture!==g||a.blendSrc!==h||a.blendDst!==d||a.glProgramState!==k)this._batchRendering(),a.texture=g,a.blendSrc=h,a.blendDst=d,a.glProgramState=k,b=!1;g=c.uploadData(m,n,6*f);0<g&&this._increaseBatchingSize(g,c.vertexType)},_batchRendering:function(){if(0!==f&&a.texture){var b=cc._renderContext,h=a.texture,
k=a.glProgramState,n=f>.5*e;k&&(k.apply(),k.getGLProgram()._updateProjectionUniform());cc.glBlendFunc(a.blendSrc,a.blendDst);cc.glBindTexture2DN(0,h);b.bindBuffer(b.ARRAY_BUFFER,d);n?b.bufferData(b.ARRAY_BUFFER,m,b.DYNAMIC_DRAW):(h=m.subarray(0,6*f),b.bufferData(b.ARRAY_BUFFER,h,b.DYNAMIC_DRAW));b.enableVertexAttribArray(cc.VERTEX_ATTRIB_POSITION);b.enableVertexAttribArray(cc.VERTEX_ATTRIB_COLOR);b.enableVertexAttribArray(cc.VERTEX_ATTRIB_TEX_COORDS);b.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,
3,b.FLOAT,!1,24,0);b.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR,4,b.UNSIGNED_BYTE,!0,24,12);b.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS,2,b.FLOAT,!1,24,16);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,c);if(!r||!t||g>r)n?b.bufferData(b.ELEMENT_ARRAY_BUFFER,p,b.DYNAMIC_DRAW):b.bufferData(b.ELEMENT_ARRAY_BUFFER,p.subarray(0,g),b.DYNAMIC_DRAW);b.drawElements(b.TRIANGLES,g,b.UNSIGNED_SHORT,0);cc.g_NumberOfDraws++;t?r=g:(r=0,t=!0);g=f=0}},rendering:function(b,c){var d=c||this._renderCmds,e,g=b||cc._renderContext;
g.bindBuffer(gl.ARRAY_BUFFER,null);var h=0;for(e=d.length;h<e;++h){var k=d[h];k.needDraw()&&(k.uploadData?this._uploadBufferData(k):(0<f&&this._batchRendering(),k.rendering(g)))}this._batchRendering();a.texture=null}}}();var Region=function(){this._area=this._height=this._width=this._maxY=this._maxX=this._minY=this._minX=0},regionProto=Region.prototype,regionPool=[];function regionCreate(){var a=regionPool.pop();a||(a=new Region);return a}function regionRelease(a){regionPool.push(a)}regionProto.setTo=function(a,b,c,d){this._minX=a;this._minY=b;this._maxX=c;this._maxY=d;this.updateArea();return this};
regionProto.intValues=function(){this._minX=Math.floor(this._minX);this._minY=Math.floor(this._minY);this._maxX=Math.ceil(this._maxX);this._maxY=Math.ceil(this._maxY);this.updateArea()};regionProto.updateArea=function(){this._width=this._maxX-this._minX;this._height=this._maxY-this._minY;this._area=this._width*this._height};
regionProto.union=function(a){0>=this._width||0>=this._height?this.setTo(a._minX,a._minY,a._maxX,a._maxY):(this._minX>a._minX&&(this._minX=a._minX),this._minY>a._minY&&(this._minY=a._minY),this._maxX<a._maxX&&(this._maxX=a._maxX),this._maxY<a._maxY&&(this._maxY=a._maxY),this.updateArea())};regionProto.setEmpty=function(){this._area=this._height=this._width=this._maxY=this._maxX=this._minY=this._minX=0};regionProto.isEmpty=function(){return 0>=this._width||0>=this._height};
regionProto.intersects=function(a){if(0>=this._width||0>=this._height||0>=a._width||0>=a._height)return!1;var b=this._minX>a._minX?this._minX:a._minX,c=this._maxX<a._maxX?this._maxX:a._maxX;if(b>c)return!1;b=this._minY>a._minY?this._minY:a._minY;c=this._maxY<a._maxY?this._maxY:a._maxY;return b<=c};
regionProto.updateRegion=function(a,b){if(0==a.width||0==a.height)this.setEmpty();else{var c=b.a,d=b.b,e=b.c,f=b.d,g=b.tx,h=b.ty,k=a.x,m=a.y,n=k+a.width,p=m+a.height;if(1==c&&0==d&&0==e&&1==f){var r=k+g-1;var t=m+h-1;var u=n+g+1;m=p+h+1}else{r=c*k+e*m+g;t=d*k+f*m+h;u=c*n+e*m+g;m=d*n+f*m+h;var v=c*n+e*p+g;n=d*n+f*p+h;g=c*k+e*p+g;h=d*k+f*p+h;r>u&&(p=r,r=u,u=p);v>g&&(p=v,v=g,g=p);r=(r<v?r:v)-1;u=(u>g?u:g)+1;t>m&&(p=t,t=m,m=p);n>h&&(p=n,n=h,h=p);t=(t<n?t:n)-1;m=(m>h?m:h)+1}this._minX=r;this._minY=t;this._maxX=
u;this._maxY=m;this._width=u-r;this._height=m-t;this._area=this._width*this._height}};function unionArea(a,b){return((a._maxX>b._maxX?a._maxX:b._maxX)-(a._minX<b._minX?a._minX:b._minX))*((a._maxY>b._maxY?a._maxY:b._maxY)-(a._minY<b._minY?a._minY:b._minY))}var DirtyRegion=function(){this.dirtyList=[];this.hasClipRect=!1;this.clipArea=this.clipHeight=this.clipWidth=0;this.clipRectChanged=!1},dirtyRegionProto=DirtyRegion.prototype;
dirtyRegionProto.setClipRect=function(a,b){this.clipRectChanged=this.hasClipRect=!0;this.clipWidth=Math.ceil(a);this.clipHeight=Math.ceil(b);this.clipArea=this.clipWidth*this.clipHeight};
dirtyRegionProto.addRegion=function(a){var b=a._minX,c=a._minY,d=a._maxX;a=a._maxY;this.hasClipRect&&(0>b&&(b=0),0>c&&(c=0),d>this.clipWidth&&(d=this.clipWidth),a>this.clipHeight&&(a=this.clipHeight));if(b>=d||c>=a)return!1;if(this.clipRectChanged)return!0;var e=this.dirtyList,f=regionCreate();e.push(f.setTo(b,c,d,a));this.mergeDirtyList(e);return!0};dirtyRegionProto.clear=function(){for(var a=this.dirtyList,b=a.length,c=0;c<b;c++)regionRelease(a[c]);a.length=0};
dirtyRegionProto.getDirtyRegions=function(){var a=this.dirtyList;if(this.clipRectChanged){this.clipRectChanged=!1;this.clear();var b=regionCreate();a.push(b.setTo(0,0,this.clipWidth,this.clipHeight))}else for(;this.mergeDirtyList(a););a=this.dirtyList.length;if(0<a)for(b=0;b<a;b++)this.dirtyList[b].intValues();return this.dirtyList};
dirtyRegionProto.mergeDirtyList=function(a){var b=a.length;if(2>b)return!1;for(var c=this.hasClipRect,d=3<b?Number.POSITIVE_INFINITY:0,e=0,f=0,g=0,h=0;h<b-1;h++){var k=a[h];c&&(g+=k.area);for(var m=h+1;m<b;m++){var n=a[m];n=unionArea(k,n)-k.area-n.area;d>n&&(e=h,f=m,d=n)}}c&&.95<g/this.clipArea&&(this.clipRectChanged=!0);return e!=f?(b=a[f],a[e].union(b),regionRelease(b),a.splice(f,1),!0):!1};cc.Region=Region;cc.DirtyRegion=DirtyRegion;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);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,"skewX",a.getSkewX,a.setSkewX);cc.defineGetterSetter(a,"skewY",
a.getSkewY,a.setSkewY);cc.defineGetterSetter(a,"zIndex",a.getLocalZOrder,a.setLocalZOrder);cc.defineGetterSetter(a,"vertexZ",a.getVertexZ,a.setVertexZ);cc.defineGetterSetter(a,"rotation",a.getRotation,a.setRotation);cc.defineGetterSetter(a,"rotationX",a.getRotationX,a.setRotationX);cc.defineGetterSetter(a,"rotationY",a.getRotationY,a.setRotationY);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,"children",a.getChildren);cc.defineGetterSetter(a,"childrenCount",a.getChildrenCount);cc.defineGetterSetter(a,"parent",a.getParent,a.setParent);cc.defineGetterSetter(a,"visible",a.isVisible,a.setVisible);cc.defineGetterSetter(a,"running",a.isRunning);cc.defineGetterSetter(a,"ignoreAnchor",a.isIgnoreAnchorPointForPosition,a.ignoreAnchorPointForPosition);cc.defineGetterSetter(a,"actionManager",a.getActionManager,a.setActionManager);cc.defineGetterSetter(a,"scheduler",
a.getScheduler,a.setScheduler);cc.defineGetterSetter(a,"shaderProgram",a.getShaderProgram,a.setShaderProgram);cc.defineGetterSetter(a,"opacity",a.getOpacity,a.setOpacity);cc.defineGetterSetter(a,"opacityModifyRGB",a.isOpacityModifyRGB);cc.defineGetterSetter(a,"cascadeOpacity",a.isCascadeOpacityEnabled,a.setCascadeOpacityEnabled);cc.defineGetterSetter(a,"color",a.getColor,a.setColor);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,_customZ:NaN,_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,arrivalOrder:0,_actionManager:null,_scheduler:null,_additionalTransformDirty:!1,
_additionalTransform:null,_componentContainer:null,_isTransitionFinished:!1,_className:"Node",_showNode:!1,_name:"",_realOpacity:255,_realColor:null,_cascadeColorEnabled:!1,_cascadeOpacityEnabled:!1,_renderCmd:null,ctor: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=[];this._additionalTransform=cc.affineTransformMakeIdentity();cc.ComponentContainer&&(this._componentContainer=new cc.ComponentContainer(this));
this._realColor=cc.color(255,255,255,255);this._renderCmd=this._createRenderCmd()},init:function(){return!0},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){a!==this._localZOrder&&(this._parent?
this._parent.reorderChild(this,a):this._localZOrder=a,cc.eventManager._setDirtyForNode(this))},_setLocalZOrder:function(a){this._localZOrder=a},getLocalZOrder:function(){return this._localZOrder},getZOrder:function(){cc.log(cc._LogInfos.Node_getZOrder);return 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._customZ=this._vertexZ=a},getRotation:function(){this._rotationX!==this._rotationY&&cc.log(cc._LogInfos.Node_getRotation);return 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(){this._scaleX!==this._scaleY&&cc.log(cc._LogInfos.Node_getScale);return 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;this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)},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||
cc.director.getActionManager()},setActionManager:function(a){this._actionManager!==a&&(this.stopAllActions(),this._actionManager=a)},getScheduler:function(){return this._scheduler||cc.director.getScheduler()},setScheduler:function(a){this._scheduler!==a&&(this.unscheduleAllCallbacks(),this._scheduler=a)},boundingBox:function(){cc.log(cc._LogInfos.Node_boundingBox);return 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)},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;c<d;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=!1;
if(void 0===c)var e=a._name;else"string"===typeof c?(e=c,c=void 0):"number"===typeof c&&(d=!0,e="");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,e,d)},_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._performRecursive(cc.Node._stateCallbackType.onEnter),
this._isTransitionFinished&&a._performRecursive(cc.Node._stateCallbackType.onEnterTransitionDidFinish));a._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty);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._performRecursive(cc.Node._stateCallbackType.onExitTransitionDidStart),d._performRecursive(cc.Node._stateCallbackType.onExit)),a&&d._performRecursive(cc.Node._stateCallbackType.cleanup),d.parent=null,d._renderCmd.detachFromParent())}this._children.length=0;cc.renderer.childrenOrderDirty=!0}},_detachChild:function(a,b){this._running&&(a._performRecursive(cc.Node._stateCallbackType.onExitTransitionDidStart),
a._performRecursive(cc.Node._stateCallbackType.onExit));b&&a._performRecursive(cc.Node._stateCallbackType.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);-1===this._children.indexOf(a)?
cc.log(cc._LogInfos.Node_reorderChild_2):(cc.renderer.childrenOrderDirty=this._reorderChildDirty=!0,a.arrivalOrder=cc.s_globalOrderOfArrival,cc.s_globalOrderOfArrival++,a._setLocalZOrder(b),this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.orderDirty))},sortAllChildren:function(){if(this._reorderChildDirty){var a=this._children,b=a.length,c,d;for(c=1;c<b;c++){var e=a[c];for(d=c-1;0<=d;){if(e._localZOrder<a[d]._localZOrder)a[d+1]=a[d];else if(e._localZOrder===a[d]._localZOrder&&e.arrivalOrder<a[d].arrivalOrder)a[d+
1]=a[d];else break;d--}a[d+1]=e}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.resume()},_performRecursive:function(a){var b=cc.Node._stateCallbackType;if(!(a>=b.max)){var c=0,d,e,f,g=cc.Node._performStacks[cc.Node._performing];g||(g=[],cc.Node._performStacks.push(g));g.length=0;cc.Node._performing++;for(e=g[0]=this;e;){if((d=
e._children)&&0<d.length){var h=0;for(f=d.length;h<f;++h){var k=d[h];g.push(k)}}if((d=e._protectedChildren)&&0<d.length)for(h=0,f=d.length;h<f;++h)k=d[h],g.push(k);c++;e=g[c]}for(h=g.length-1;0<=h;--h)if(e=g[h],g[h]=null,e)switch(a){case b.onEnter:e.onEnter();break;case b.onExit:e.onExit();break;case b.onEnterTransitionDidFinish:e.onEnterTransitionDidFinish();break;case b.cleanup:e.cleanup();break;case b.onExitTransitionDidStart:e.onExitTransitionDidStart()}cc.Node._performing--}},onEnterTransitionDidFinish:function(){this._isTransitionFinished=
!0},onExitTransitionDidStart:function(){},onExit:function(){this._running=!1;this.pause();this.removeAllComponents()},runAction:function(a){cc.assert(a,cc._LogInfos.Node_runAction);this.actionManager.addAction(a,this,!this._running);return a},stopAllActions:function(){this.actionManager&&this.actionManager.removeAllActionsFromTarget(this)},stopAction:function(a){this.actionManager.removeAction(a)},stopActionByTag:function(a){a===cc.ACTION_TAG_INVALID?cc.log(cc._LogInfos.Node_stopActionByTag):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);b=b||0;c=isNaN(c)?cc.REPEAT_FOREVER:
c;this.scheduler.schedule(a,this,b,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){if(void 0===a)return this._additionalTransformDirty=!1;this._additionalTransform=a;this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty);this._additionalTransformDirty=!0},getParentToNodeTransform:function(){return 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){a=a||cc.p(0,0);return 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(){for(var a=this._children,b,c=0;c<a.length;c++)(b=a[c])&&b.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){var b=this._renderCmd,c=a?a._renderCmd:null;if(this._visible){a=cc.renderer;b.visit(c);var d=this._children,e=d.length;if(0<e){this._reorderChildDirty&&
this.sortAllChildren();for(c=0;c<e;c++){var f=d[c];if(0>f._localZOrder)f.visit(this);else break}for(a.pushRenderCommand(b);c<e;c++)d[c].visit(this)}else a.pushRenderCommand(b);b._dirtyFlag=0}else b._propagateFlagsDown(c)},transform:function(a,b){this._renderCmd.transform(a,b)},nodeToParentTransform:function(){return this.getNodeToParentTransform()},getNodeToParentTransform:function(a){var b=this._renderCmd.getNodeToParentTransform();if(a){b={a:b.a,b:b.b,c:b.c,d:b.d,tx:b.tx,ty:b.ty};for(var c=this._parent;null!=
c&&c!=a;c=c.getParent())cc.affineTransformConcatIn(b,c.getNodeToParentTransform())}return b},getNodeToParentAffineTransform:function(a){return this.getNodeToParentTransform(a)},getCamera:function(){return null},getGrid:function(){return this.grid},setGrid:function(a){this.grid=a},getShaderProgram:function(){return this._renderCmd.getShaderProgram()},setShaderProgram:function(a){this._renderCmd.setShaderProgram(a)},setGLProgramState:function(a){this._renderCmd.setGLProgramState(a)},getGLProgramState:function(){return this._renderCmd.getGLProgramState()},
getGLServerState:function(){return 0},setGLServerState:function(a){},getBoundingBoxToWorld:function(){var a=cc.rect(0,0,this._contentSize.width,this._contentSize.height),b=this.getNodeToWorldTransform();a=cc.rectApplyAffineTransform(a,b);if(!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);b=cc.rectApplyAffineTransform(b,a);if(!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},_createRenderCmd:function(){return cc._renderType===cc.game.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){var d=!1;if(a.doEnumerate(b,c))d=
!0;else for(var e=a.getChildren(),f=e.length,g=0;g<f;g++)if(a=e[g],this.doEnumerateRecursive(a,b,c)){d=!0;break}return d},doEnumerate:function(a,b){var c=a.indexOf("/"),d=a,e=!1;-1!==c&&(d=a.substr(0,c),e=!0);c=!1;for(var f,g=this._children,h=g.length,k=0;k<h;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,onExitTransitionDidStart:5,max:6};cc.Node._performStacks=[[]];cc.Node._performing=0;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};cc.CustomRenderCmd.prototype.rendering=function(a,b,c){this._callback&&this._callback.call(this._target,a,b,c)};cc.CustomRenderCmd.prototype.needDraw=function(){return this._needDraw};var dirtyFlags=cc.Node._dirtyFlags={transformDirty:1,visibleDirty:2,colorDirty:4,opacityDirty:8,cacheDirty:16,orderDirty:32,textDirty:64,gradientDirty:128,textureDirty:256,contentDirty:512,COUNT:10,all:1023},ONE_DEGREE=Math.PI/180;
function transformChildTree(a){var b=1,c,d,e=cc.Node._performStacks[cc.Node._performing];e||(e=[],cc.Node._performStacks.push(e));e.length=0;cc.Node._performing++;for(e[0]=a;b;){b--;var f=e[b];e[b]=null;if(f){if((c=f._children)&&0<c.length){var g=f._renderCmd;var h=0;for(d=c.length;h<d;++h)a=c[h],e[b]=a,b++,a._renderCmd.transform(g)}if((c=f._protectedChildren)&&0<c.length)for(g=f._renderCmd,h=0,d=c.length;h<d;++h)a=c[h],e[b]=a,b++,a._renderCmd.transform(g)}}cc.Node._performing--}
cc.Node.RenderCmd=function(a){this._node=a;this._anchorPointInPoints={x:0,y:0};this._displayedColor=cc.color(255,255,255,255)};
cc.Node.RenderCmd.prototype={constructor:cc.Node.RenderCmd,_needDraw:!1,_dirtyFlag:1,_curLevel:-1,_displayedOpacity:255,_cascadeColorEnabledDirty:!1,_cascadeOpacityEnabledDirty:!1,_transform:null,_worldTransform:null,_inverse:null,needDraw:function(){return this._needDraw},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(){this._inverse||(this._inverse={a:1,b:0,c:0,d:1,tx:0,ty:0});this._dirtyFlag&cc.Node._dirtyFlags.transformDirty&&cc.affineTransformInvertOut(this.getNodeToParentTransform(),this._inverse);return 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},transform:function(a,b){this._transform||(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});var c=this._node,d=a?a._worldTransform:null,e=this._transform,f=this._worldTransform;if(c._usingNormalizedPosition&&c._parent){var g=c._parent._contentSize;c._position.x=c._normalizedPosition.x*g.width;c._position.y=c._normalizedPosition.y*g.height;c._normalizedPositionDirty=!1}var h=c._rotationX||c._rotationY,k=c._skewX||c._skewY,m=c._scaleX,n=c._scaleY;g=this._anchorPointInPoints.x;var p=this._anchorPointInPoints.y,r=1,t=0,u=0,v=1;if(h||k){e.tx=c._position.x;e.ty=c._position.y;
h&&(r=c._rotationX*ONE_DEGREE,u=Math.sin(r),v=Math.cos(r),c._rotationY===c._rotationX?(r=v,t=-u):(t=c._rotationY*ONE_DEGREE,r=Math.cos(t),t=-Math.sin(t)));e.a=r*=m;e.b=t*=m;e.c=u*=n;e.d=v*=n;k&&(k=Math.tan(c._skewX*ONE_DEGREE),m=Math.tan(c._skewY*ONE_DEGREE),Infinity===k&&(k=99999999),Infinity===m&&(m=99999999),e.a=r+u*m,e.b=t+v*m,e.c=u+r*k,e.d=v+t*k);if(g||p)e.tx-=e.a*g+e.c*p,e.ty-=e.b*g+e.d*p,c._ignoreAnchorPointForPosition&&(e.tx+=g,e.ty+=p);c._additionalTransformDirty&&cc.affineTransformConcatIn(e,
c._additionalTransform);d?(f.a=e.a*d.a+e.b*d.c,f.b=e.a*d.b+e.b*d.d,f.c=e.c*d.a+e.d*d.c,f.d=e.c*d.b+e.d*d.d,f.tx=d.a*e.tx+d.c*e.ty+d.tx,f.ty=d.d*e.ty+d.ty+d.b*e.tx):(f.a=e.a,f.b=e.b,f.c=e.c,f.d=e.d,f.tx=e.tx,f.ty=e.ty)}else{e.a=m;e.b=0;e.c=0;e.d=n;e.tx=c._position.x;e.ty=c._position.y;if(g||p)e.tx-=e.a*g,e.ty-=e.d*p,c._ignoreAnchorPointForPosition&&(e.tx+=g,e.ty+=p);c._additionalTransformDirty&&cc.affineTransformConcatIn(e,c._additionalTransform);d?(f.a=e.a*d.a+e.b*d.c,f.b=e.a*d.b+e.b*d.d,f.c=e.c*
d.a+e.d*d.c,f.d=e.c*d.b+e.d*d.d,f.tx=e.tx*d.a+e.ty*d.c+d.tx,f.ty=e.tx*d.b+e.ty*d.d+d.ty):(f.a=e.a,f.b=e.b,f.c=e.c,f.d=e.d,f.tx=e.tx,f.ty=e.ty)}this._updateCurrentRegions&&(this._updateCurrentRegions(),this._notifyRegionStatus&&this._notifyRegionStatus(cc.Node.CanvasRenderCmd.RegionStatus.DirtyDouble));b&&transformChildTree(c);this._cacheDirty=!0},getNodeToParentTransform:function(){(!this._transform||this._dirtyFlag&cc.Node._dirtyFlags.transformDirty)&&this.transform();return this._transform},visit:function(a){var b=
this._node,c=cc.renderer;if(a=a||this.getParentRenderCmd())this._curLevel=a._curLevel+1;isNaN(b._customZ)&&(b._vertexZ=c.assignedZ,c.assignedZ+=c.assignedZStep);this._syncStatus(a)},_updateDisplayColor:function(a){var b=this._node,c=this._displayedColor,d=b._realColor,e;this._notifyRegionStatus&&this._notifyRegionStatus(cc.Node.CanvasRenderCmd.RegionStatus.Dirty);if(this._cascadeColorEnabledDirty&&!b._cascadeColorEnabled){c.r=d.r;c.g=d.g;c.b=d.b;c=new cc.Color(255,255,255,255);a=b._children;b=0;for(d=
a.length;b<d;b++)(e=a[b])&&e._renderCmd&&e._renderCmd._updateDisplayColor(c);this._cascadeColorEnabledDirty=!1}else if(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,b._cascadeColorEnabled)for(a=b._children,b=0,d=a.length;b<d;b++)(e=a[b])&&e._renderCmd&&(e._renderCmd._updateDisplayColor(c),e._renderCmd._updateColor());this._dirtyFlag&=~dirtyFlags.colorDirty},_updateDisplayOpacity:function(a){var b=this._node,
c;this._notifyRegionStatus&&this._notifyRegionStatus(cc.Node.CanvasRenderCmd.RegionStatus.Dirty);if(this._cascadeOpacityEnabledDirty&&!b._cascadeOpacityEnabled){this._displayedOpacity=b._realOpacity;var d=b._children;a=0;for(b=d.length;a<b;a++)(c=d[a])&&c._renderCmd&&c._renderCmd._updateDisplayOpacity(255);this._cascadeOpacityEnabledDirty=!1}else if(void 0===a&&(d=b._parent,a=255,d&&d._cascadeOpacityEnabled&&(a=d.getDisplayedOpacity())),this._displayedOpacity=b._realOpacity*a/255,b._cascadeOpacityEnabled)for(d=
b._children,a=0,b=d.length;a<b;a++)(c=d[a])&&c._renderCmd&&(c._renderCmd._updateDisplayOpacity(this._displayedOpacity),c._renderCmd._updateColor());this._dirtyFlag&=~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(){},_propagateFlagsDown:function(a){var b=this._dirtyFlag,c=a?a._node:null;c&&c._cascadeColorEnabled&&a._dirtyFlag&dirtyFlags.colorDirty&&(b|=dirtyFlags.colorDirty);c&&c._cascadeOpacityEnabled&&a._dirtyFlag&dirtyFlags.opacityDirty&&(b|=dirtyFlags.opacityDirty);a&&a._dirtyFlag&dirtyFlags.transformDirty&&(b|=dirtyFlags.transformDirty);this._dirtyFlag=b},updateStatus:function(){var a=
this._dirtyFlag,b=a&dirtyFlags.colorDirty,c=a&dirtyFlags.opacityDirty;a&dirtyFlags.contentDirty&&(this._notifyRegionStatus&&this._notifyRegionStatus(cc.Node.CanvasRenderCmd.RegionStatus.Dirty),this._dirtyFlag&=~dirtyFlags.contentDirty);b&&this._updateDisplayColor();c&&this._updateDisplayOpacity();(b||c)&&this._updateColor();a&dirtyFlags.transformDirty&&(this.transform(this.getParentRenderCmd(),!0),this._dirtyFlag&=~dirtyFlags.transformDirty);a&dirtyFlags.orderDirty&&(this._dirtyFlag&=~dirtyFlags.orderDirty)},
_syncStatus:function(a){var b=this._dirtyFlag,c=a?a._node:null;c&&c._cascadeColorEnabled&&a._dirtyFlag&dirtyFlags.colorDirty&&(b|=dirtyFlags.colorDirty);c&&c._cascadeOpacityEnabled&&a._dirtyFlag&dirtyFlags.opacityDirty&&(b|=dirtyFlags.opacityDirty);a&&a._dirtyFlag&dirtyFlags.transformDirty&&(b|=dirtyFlags.transformDirty);this._dirtyFlag=b;c=b&dirtyFlags.colorDirty;var d=b&dirtyFlags.opacityDirty;c&&this._syncDisplayColor();d&&this._syncDisplayOpacity();(c||d)&&this._updateColor();b&dirtyFlags.transformDirty&&
this.transform(a);b&dirtyFlags.orderDirty&&(this._dirtyFlag&=~dirtyFlags.orderDirty)},setShaderProgram:function(a){},getShaderProgram:function(){return null},getGLProgramState:function(){return null},setGLProgramState:function(a){}};cc.Node.RenderCmd.prototype.originTransform=cc.Node.RenderCmd.prototype.transform;cc.Node.RenderCmd.prototype.originUpdateStatus=cc.Node.RenderCmd.prototype.updateStatus;cc.Node.RenderCmd.prototype._originSyncStatus=cc.Node.RenderCmd.prototype._syncStatus;
(function(){cc.Node.CanvasRenderCmd=function(a){this._node=a;this._anchorPointInPoints={x:0,y:0};this._displayedColor=cc.color(255,255,255,255);this._cachedParent=null;this._cacheDirty=!1;this._currentRegion=new cc.Region;this._oldRegion=new cc.Region;this._regionFlag=0;this._canUseDirtyRegion=!1};cc.Node.CanvasRenderCmd.RegionStatus={NotDirty:0,Dirty:1,DirtyDouble:2};var a=cc.Node.CanvasRenderCmd.prototype=Object.create(cc.Node.RenderCmd.prototype);a.constructor=cc.Node.CanvasRenderCmd;a._rootCtor=
cc.Node.CanvasRenderCmd;a._notifyRegionStatus=function(a){this._needDraw&&this._regionFlag<a&&(this._regionFlag=a)};var b=new cc.Rect;a.getLocalBB=function(){var a=this._node;b.x=b.y=0;b.width=a._contentSize.width;b.height=a._contentSize.height;return b};a._updateCurrentRegions=function(){var a=this._currentRegion;this._currentRegion=this._oldRegion;this._oldRegion=a;cc.Node.CanvasRenderCmd.RegionStatus.DirtyDouble!==this._regionFlag||this._currentRegion.isEmpty()||this._oldRegion.union(this._currentRegion);
this._currentRegion.updateRegion(this.getLocalBB(),this._worldTransform)};a.setDirtyFlag=function(a,b){cc.Node.RenderCmd.prototype.setDirtyFlag.call(this,a,b);this._setCacheDirty(b);this._cachedParent&&this._cachedParent.setDirtyFlag(a,!0)};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 b=this._node._children,
c=0,f=b.length;c<f;c++)b[c]._renderCmd._setCachedParent(a)}};a.detachFromParent=function(){this._cachedParent=null;for(var a=this._node._children,b,e=0,f=a.length;e<f;e++)(b=a[e])&&b._renderCmd&&b._renderCmd.detachFromParent()};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"}})();(function(){cc.Node.WebGLRenderCmd=function(a){this._node=a;this._anchorPointInPoints={x:0,y:0};this._displayedColor=cc.color(255,255,255,255);this._glProgramState=null};var a=cc.Node.WebGLRenderCmd.prototype=Object.create(cc.Node.RenderCmd.prototype);a.constructor=cc.Node.WebGLRenderCmd;a._rootCtor=cc.Node.WebGLRenderCmd;a._updateColor=function(){};a.setShaderProgram=function(a){this._glProgramState=cc.GLProgramState.getOrCreateWithGLProgram(a)};a.getShaderProgram=function(){return this._glProgramState?
this._glProgramState.getGLProgram():null};a.getGLProgramState=function(){return this._glProgramState};a.setGLProgramState=function(a){this._glProgramState=a};Object.defineProperty(a,"_shaderProgram",{set:function(a){this.setShaderProgram(a)},get:function(){return this.getShaderProgram()}})})();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",_texture:null,_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(){this._renderCmd=cc._renderType===cc.game.RENDER_TYPE_CANVAS?
new cc.AtlasNode.CanvasRenderCmd(this):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){this._blendFunc=void 0===b?a:{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 Error("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._texture},setTexture:function(a){this._texture=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);cc.defineGetterSetter(_p,"texture",_p.getTexture,_p.setTexture);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){this._rootCtor(a);this._needDraw=!1;this._colorUnmodified=cc.color.WHITE;this._textureToRender=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 b=this._node;b._itemWidth=c;b._itemHeight=d;b._opacityModifyRGB=!0;b._texture=a;if(!b._texture)return cc.log(cc._LogInfos.AtlasNode__initWithTexture),!1;this._textureToRender=
a;this._calculateMaxItems();b.quadsToDraw=e;return!0};a.setColor=function(a){var b=this._node._realColor;if(b.r!==a.r||b.g!==a.g||b.b!==a.b)this._colorUnmodified=a,this._changeTextureColor()};a._changeTextureColor=function(){var a=this._node._texture,c=this._colorUnmodified,d=a.getHtmlElementObj();d=cc.rect(0,0,d.width,d.height);a===this._textureToRender?this._textureToRender=a._generateColorTexture(c.r,c.g,c.b,d):a._generateColorTexture(c.r,c.g,c.b,d,this._textureToRender.getHtmlElementObj())};a.setOpacity=
function(a){cc.Node.prototype.setOpacity.call(this._node,a)};a._calculateMaxItems=function(){var a=this._node,c=a._texture.getContentSize();a._itemsPerColumn=0|c.height/a._itemHeight;a._itemsPerRow=0|c.width/a._itemWidth}})();(function(){cc.AtlasNode.WebGLRenderCmd=function(a){this._rootCtor(a);this._needDraw=!0;this._textureAtlas=null;this._colorUnmodified=cc.color.WHITE;this._uniformColor=this._colorF32Array=null;this._matrix=new cc.math.Matrix4;this._matrix.identity();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 b=this._node,d=this._worldTransform;this._matrix.mat[0]=d.a;this._matrix.mat[4]=d.c;this._matrix.mat[12]=d.tx;this._matrix.mat[1]=
d.b;this._matrix.mat[5]=d.d;this._matrix.mat[13]=d.ty;this._glProgramState.apply(this._matrix);cc.glBlendFunc(b._blendFunc.src,b._blendFunc.dst);this._uniformColor&&this._colorF32Array&&(a.uniform4fv(this._uniformColor,this._colorF32Array),this._textureAtlas.drawNumberOfQuads(b.quadsToDraw,0))};a.initWithTexture=function(a,c,d,e){var b=this._node;b._itemWidth=c;b._itemHeight=d;this._colorUnmodified=cc.color.WHITE;b._opacityModifyRGB=!0;b._blendFunc.src=cc.BLEND_SRC;b._blendFunc.dst=cc.BLEND_DST;c=
b._realColor;this._colorF32Array=new Float32Array([c.r/255,c.g/255,c.b/255,b._realOpacity/255]);this._textureAtlas=new cc.TextureAtlas;this._textureAtlas.initWithTexture(a,e);if(!this._textureAtlas)return cc.log(cc._LogInfos.AtlasNode__initWithTexture),!1;this._updateBlendFunc();this._updateOpacityModifyRGB();this._calculateMaxItems();b.quadsToDraw=e;return!0};a.setColor=function(a){var b=cc.color(a.r,a.g,a.b),d=this._node;this._colorUnmodified=a;a=this._displayedOpacity;d._opacityModifyRGB&&(b.r=
b.r*a/255,b.g=b.g*a/255,b.b=b.b*a/255);cc.Node.prototype.setColor.call(d,b)};a.setOpacity=function(a){var b=this._node;cc.Node.prototype.setOpacity.call(b,a);b._opacityModifyRGB&&(b.color=this._colorUnmodified)};a._updateColor=function(){if(this._colorF32Array){var a=this._displayedColor;this._colorF32Array[0]=a.r/255;this._colorF32Array[1]=a.g/255;this._colorF32Array[2]=a.b/255;this._colorF32Array[3]=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._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);
this._htmlElementObj=null;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"<cc.Texture2D | Name = "+
this._name+" | Dimensions = "+this._pixelsWide+" x "+this._pixelsHigh+" | Coordinates = ("+this.maxS+", "+this.maxT+")>"},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;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);switch(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)}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._hasMipmaps=this._hasPremultipliedAlpha=!1;this.shaderProgram=cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURE);
return this._textureLoaded=!0},drawAtPoint:function(a){var b=[0,this.maxT,this.maxS,this.maxT,0,0,this.maxS,0],c=cc._renderContext,d=this._pixelsWide*this.maxS,e=this._pixelsHigh*this.maxT;a=[a.x,a.y,0,d+a.x,a.y,0,a.x,e+a.y,0,d+a.x,e+a.y,0];this._glProgramState.apply();this._glProgramState._glprogram.setUniformsForBuiltins();cc.glBindTexture2D(this);c.enableVertexAttribArray(cc.VERTEX_ATTRIB_POSITION);c.enableVertexAttribArray(cc.VERTEX_ATTRIB_TEX_COORDS);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];this._glProgramState.apply();this._glProgramState._glprogram.setUniformsForBuiltins();cc.glBindTexture2D(this);var c=cc._renderContext;c.enableVertexAttribArray(cc.VERTEX_ATTRIB_POSITION);c.enableVertexAttribArray(cc.VERTEX_ATTRIB_TEX_COORDS);
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();if(b>d||c>d)return cc.log(cc._LogInfos.Texture2D_initWithImage_2,b,c,d,d),!1;this._textureLoaded=!0;return this._initPremultipliedATextureWithImage(a,b,c)},initWithElement:function(a){a&&
(this._webTextureObj=cc._renderContext.createTexture(),this._htmlElementObj=a,this._hasPremultipliedAlpha=this._textureLoaded=!0)},getHtmlElementObj:function(){return this._htmlElementObj},isLoaded:function(){return this._textureLoaded},handleLoadedTexture:function(a){a=void 0!==a?a:this._hasPremultipliedAlpha;if(cc.game._rendererInitialized&&this._htmlElementObj&&this._htmlElementObj.width&&this._htmlElementObj.height){var 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;window.ENABLE_IMAEG_POOL&&(this._htmlElementObj=null);this.dispatchEvent("load")}},initWithString:function(a,b,c,d,e,f){cc.log(cc._LogInfos.Texture2D_initWithString);return null},initWithETCFile:function(a){cc.log(cc._LogInfos.Texture2D_initWithETCFile_2);
return!1},initWithPVRFile:function(a){cc.log(cc._LogInfos.Texture2D_initWithPVRFile_2);return!1},initWithPVRTCData:function(a,b,c,d,e,f){cc.log(cc._LogInfos.Texture2D_initWithPVRTCData_2);return!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];if(null!=b)return b;cc.log(cc._LogInfos.Texture2D_bitsPerPixelForFormat,a);return-1},_initPremultipliedATextureWithImage:function(a,b,c){var d=cc.Texture2D,e=a.getData(),f=a.hasAlpha(),g=cc.size(a.getWidth(),a.getHeight()),h=d.defaultPixelFormat,
k=a.getBitsPerComponent();f||(8<=k?h=d.PIXEL_FORMAT_RGB888:(cc.log(cc._LogInfos.Texture2D__initPremultipliedATextureWithImage),h=d.PIXEL_FORMAT_RGB565));var m=b*c;if(h===d.PIXEL_FORMAT_RGB565)if(f){e=new Uint16Array(b*c);var n=a.getData();for(k=0;k<m;++k)e[k]=(n[k]>>0&255)>>3<<11|(n[k]>>8&255)>>2<<5|(n[k]>>16&255)>>3<<0}else for(e=new Uint16Array(b*c),n=a.getData(),k=0;k<m;++k)e[k]=(n[k]&255)>>3<<11|(n[k]&255)>>2<<5|(n[k]&255)>>3<<0;else if(h===d.PIXEL_FORMAT_RGBA4444)for(e=new Uint16Array(b*c),n=
a.getData(),k=0;k<m;++k)e[k]=(n[k]>>0&255)>>4<<12|(n[k]>>8&255)>>4<<8|(n[k]>>16&255)>>4<<4|(n[k]>>24&255)>>4<<0;else if(h===d.PIXEL_FORMAT_RGB5A1)for(e=new Uint16Array(b*c),n=a.getData(),k=0;k<m;++k)e[k]=(n[k]>>0&255)>>3<<11|(n[k]>>8&255)>>3<<6|(n[k]>>16&255)>>3<<1|(n[k]>>24&255)>>7<<0;else if(h===d.PIXEL_FORMAT_A8)for(e=new Uint8Array(b*c),n=a.getData(),k=0;k<m;++k)e[k]=n>>24&255;if(f&&h===d.PIXEL_FORMAT_RGB888)for(n=a.getData(),e=new Uint8Array(b*c*3),k=0;k<m;++k)e[3*k]=n>>0&255,e[3*k+1]=n>>8&255,
e[3*k+2]=n>>16&255;this.initWithData(e,h,b,c,g);a.getData();this._hasPremultipliedAlpha=a.isPremultipliedAlpha();return!0},addLoadedEventListener:function(a,b){this.addEventListener("load",a,b)},removeLoadedEventListener:function(a){this.removeEventTarget("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){c=c||0;if(0!==a&&this.texture&&this.texture.isLoaded()){var b=cc._renderContext;cc.glBindTexture2D(this.texture);b.bindBuffer(b.ARRAY_BUFFER,this._quadsWebBuffer);this.dirty&&(b.bufferData(b.ARRAY_BUFFER,this._quadsArrayBuffer,b.DYNAMIC_DRAW),this.dirty=!1);b.enableVertexAttribArray(cc.VERTEX_ATTRIB_POSITION);b.enableVertexAttribArray(cc.VERTEX_ATTRIB_COLOR);b.enableVertexAttribArray(cc.VERTEX_ATTRIB_TEX_COORDS);b.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,
3,b.FLOAT,!1,24,0);b.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR,4,b.UNSIGNED_BYTE,!0,24,12);b.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS,2,b.FLOAT,!1,24,16);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,this._buffersVBO[1]);cc.TEXTURE_ATLAS_USE_TRIANGLE_STRIP?b.drawElements(b.TRIANGLE_STRIP,6*a,b.UNSIGNED_SHORT,6*c*this._indices.BYTES_PER_ELEMENT):b.drawElements(b.TRIANGLES,6*a,b.UNSIGNED_SHORT,6*c*this._indices.BYTES_PER_ELEMENT);cc.g_NumberOfDraws++}}};
cc._tmp.WebGLTextureCache=function(){var a=cc.textureCache;a.handleLoadedTexture=function(a,c){var b=this._textures;cc.game._rendererInitialized||(b=this._loadedTexturesBefore);var e=b[a];e||(e=b[a]=new cc.Texture2D,e.url=a);e.initWithElement(c);".png"===cc.path.extname(a)?e.handleLoadedTexture(!0):e.handleLoadedTexture();return e};a.addImage=function(a,c,d){cc.assert(a,cc._LogInfos.Texture2D_addImage_2);var b=this._textures;cc.game._rendererInitialized||(b=this._loadedTexturesBefore);var f=b[a]||
b[cc.loader._getAliase(a)];if(f)return f.isLoaded()?c&&c.call(d,f):f.addEventListener("load",function(){c&&c.call(d,f)},d),f;f=b[a]=new cc.Texture2D;f.url=a;b=a.startsWith("http")?null:cc.loader.getBasePath?cc.loader.getBasePath():cc.path.join(cc.loader.basePath,cc.loader.resPath);cc.loader.loadImg(cc.path.join(b||"",a),function(b,e){if(b)return c&&c.call(d,b);var f=cc.textureCache.handleLoadedTexture(a,e);c&&c.call(d,f)});return f};a.addImageAsync=a.addImage;a=null};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;a.defaultPixelFormat=a.PIXEL_FORMAT_DEFAULT;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;a=cc.Texture2D.prototype;cc.defineGetterSetter(a,"name",a.getName);cc.defineGetterSetter(a,"pixelFormat",a.getPixelFormat);cc.defineGetterSetter(a,"pixelsWidth",a.getPixelsWide);cc.defineGetterSetter(a,"pixelsHeight",a.getPixelsHigh);cc.defineGetterSetter(a,"width",a._getWidth);cc.defineGetterSetter(a,"height",a._getHeight)};
cc._tmp.PrototypeTextureAtlas=function(){var a=cc.TextureAtlas.prototype;cc.defineGetterSetter(a,"totalQuads",a.getTotalQuads);cc.defineGetterSetter(a,"capacity",a.getCapacity);cc.defineGetterSetter(a,"quads",a.getQuads,a.setQuads)};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.game.addEventListener(cc.game.EVENT_RENDERER_INITED,function(){if(cc._renderType===cc.game.RENDER_TYPE_CANVAS){var a={_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="";this._pixelsHigh=this._pixelsWide=0},getPixelsWide:function(){return this._pixelsWide},getPixelsHigh:function(){return this._pixelsHigh},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._pixelsWide=this._contentSize.width=a.width,this._pixelsHigh=this._contentSize.height=a.height,this._textureLoaded=!0)},getHtmlElementObj:function(){return this._htmlElementObj},
isLoaded:function(){return this._textureLoaded},handleLoadedTexture:function(){if(this._htmlElementObj){var a=this._htmlElementObj;this._pixelsWide=this._contentSize.width=a.width;this._pixelsHigh=this._contentSize.height=a.height;this.dispatchEvent("load")}},description:function(){return"<cc.Texture2D | width = "+this._contentSize.width+" height "+this._contentSize.height+">"},initWithData:function(a,c,d,e,f){return!1},initWithImage:function(a){return!1},initWithString:function(a,c,d,e,f,g){return!1},
releaseTexture:function(){this._htmlElementObj=null;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,c){return a},drawAtPoint:function(a){},drawInRect:function(a){},
initWithETCFile:function(a){cc.log(cc._LogInfos.Texture2D_initWithETCFile);return!1},initWithPVRFile:function(a){cc.log(cc._LogInfos.Texture2D_initWithPVRFile);return!1},initWithPVRTCData:function(a,c,d,e,f,g){cc.log(cc._LogInfos.Texture2D_initWithPVRTCData);return!1},setTexParameters:function(a,c,d,e){void 0!==c&&(a={minFilter:a,magFilter:c,wrapS:d,wrapT:e});this._pattern=a.wrapS===cc.REPEAT&&a.wrapT===cc.REPEAT?"repeat":a.wrapS===cc.REPEAT?"repeat-x":a.wrapT===cc.REPEAT?"repeat-y":""},setAntiAliasTexParameters:function(){},
setAliasTexParameters:function(){},generateMipmap:function(){},stringForFormat:function(){return""},bitsPerPixelForFormat:function(a){return-1},addLoadedEventListener:function(a,c){this.addEventListener("load",a,c)},removeLoadedEventListener:function(a){this.removeEventTarget("load",a)},_generateColorTexture:function(){},_generateTextureCacheForColor:function(){if(this.channelCache)return this.channelCache;var a=[document.createElement("canvas"),document.createElement("canvas"),document.createElement("canvas"),
document.createElement("canvas")],c=this._htmlElementObj,d=c.width,e=c.height;a[0].width=d;a[0].height=e;a[1].width=d;a[1].height=e;a[2].width=d;a[2].height=e;a[3].width=d;a[3].height=e;var f=a[3].getContext("2d");f.drawImage(c,0,0);f=f.getImageData(0,0,d,e).data;for(var g,h=0;4>h;h++){g=a[h].getContext("2d");for(var k=g.getImageData(0,0,d,e),m=k.data,n=0;n<f.length;n+=4)m[n]=0===h?f[n]:0,m[n+1]=1===h?f[n+1]:0,m[n+2]=2===h?f[n+2]:0,m[n+3]=f[n+3];g.putImageData(k,0,0)}c.onload=null;return this.channelCache=
a},_grayElementObj:null,_backupElement:null,_isGray:!1,_switchToGray:function(a){this._textureLoaded&&this._isGray!==a&&((this._isGray=a)?(this._backupElement=this._htmlElementObj,this._grayElementObj||(this._grayElementObj=cc.Texture2D._generateGrayTexture(this._htmlElementObj)),this._htmlElementObj=this._grayElementObj):null!==this._backupElement&&(this._htmlElementObj=this._backupElement))},_generateGrayTexture:function(){if(!this._textureLoaded)return null;var a=cc.Texture2D._generateGrayTexture(this._htmlElementObj),
c=new cc.Texture2D;c.initWithElement(a);c.handleLoadedTexture();return c}};a._generateColorTexture=cc.sys._supportCanvasNewBlendModes?function(a,c,d,e,f){var b=!1;f?b=!0:f=document.createElement("canvas");var h=this._htmlElementObj;e||(e=cc.rect(0,0,h.width,h.height));f.width=e.width;f.height=e.height;var k=f.getContext("2d");k.globalCompositeOperation="source-over";k.fillStyle="rgb("+(a|0)+","+(c|0)+","+(d|0)+")";k.fillRect(0,0,e.width,e.height);k.globalCompositeOperation="multiply";k.drawImage(h,
e.x,e.y,e.width,e.height,0,0,e.width,e.height);k.globalCompositeOperation="destination-atop";k.drawImage(h,e.x,e.y,e.width,e.height,0,0,e.width,e.height);if(b)return f;a=new cc.Texture2D;a.initWithElement(f);a.handleLoadedTexture();return a}:function(a,c,d,e,f){var b=!1;f?b=!0:f=document.createElement("canvas");var h=this._htmlElementObj;e||(e=cc.rect(0,0,h.width,h.height));h=e.x;var k=e.y;var m=e.width;e=e.height;if(m&&e){f.width=m;f.height=e;var n=f.getContext("2d"),p=cc.textureCache.getTextureColors(this);
n.globalCompositeOperation="lighter";n.drawImage(p[3],h,k,m,e,0,0,m,e);0<a&&(n.globalAlpha=a/255,n.drawImage(p[0],h,k,m,e,0,0,m,e));0<c&&(n.globalAlpha=c/255,n.drawImage(p[1],h,k,m,e,0,0,m,e));0<d&&(n.globalAlpha=d/255,n.drawImage(p[2],h,k,m,e,0,0,m,e));if(b)return f;a=new cc.Texture2D;a.initWithElement(f);a.handleLoadedTexture();return a}};cc.Texture2D=cc.Class.extend(a);cc.Texture2D._generateGrayTexture=function(a,c,d){if(null===a)return null;d=d||document.createElement("canvas");c=c||cc.rect(0,
0,a.width,a.height);d.width=c.width;d.height=c.height;var b=d.getContext("2d");b.drawImage(a,c.x,c.y,c.width,c.height,0,0,c.width,c.height);a=b.getImageData(0,0,c.width,c.height);c=a.data;for(var f=0,g=c.length;f<g;f+=4)c[f]=c[f+1]=c[f+2]=.34*c[f]+.5*c[f+1]+.16*c[f+2];b.putImageData(a,0,0);return d}}else cc._renderType===cc.game.RENDER_TYPE_WEBGL&&(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"<TextureCache | Number of textures = "+this._textures.length+
">"},textureForKey:function(a){cc.log(cc._LogInfos.textureCache_textureForKey);return this.getTextureForKey(a)},getTextureForKey:function(a){return this._textures[a]||this._textures[cc.loader._getAliase(a)]},getKeyByTexture:function(a){for(var b in this._textures)if(this._textures[b]===a)return b;return null},_generalTextureKey:function(a){return"_textureKey_"+a},getTextureColors:function(a){var b=a._htmlElementObj,c=this.getKeyByTexture(b);c||(c=b instanceof HTMLImageElement?b.src:this._generalTextureKey(a.__instanceId));
this._textureColorsCache[c]||(this._textureColorsCache[c]=a._generateTextureCacheForColor());return this._textureColorsCache[c]},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){if(null!=a){var b=this._textures[a];b&&(b.releaseTexture(),
delete this._textures[a])}},cacheImage:function(a,b){if(b instanceof cc.Texture2D)this._textures[a]=b;else{var c=new cc.Texture2D;c.initWithElement(b);c.handleLoadedTexture();this._textures[a]=c}},addUIImage:function(a,b){cc.assert(a,cc._LogInfos.textureCache_addUIImage_2);if(b&&this._textures[b])return this._textures[b];var c=new cc.Texture2D;c.initWithImage(a);null!=b?this._textures[b]=c:cc.log(cc._LogInfos.textureCache_addUIImage);return 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.getPixelsWide(),e.getPixelsHigh()):cc.log(cc._LogInfos.textureCache_dumpCachedTextureInfo_2,d,e.getPixelsWide(),e.getPixelsHigh());b+=e.getPixelsWide()*e.getPixelsHigh()*4}c=this._textureColorsCache;for(d in c){e=c[d];for(var f in e){var g=e[f];a++;cc.log(cc._LogInfos.textureCache_dumpCachedTextureInfo_2,d,g.width,g.height);b+=g.width*g.height*
4}}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.game.addEventListener(cc.game.EVENT_RENDERER_INITED,function(){if(cc._renderType===cc.game.RENDER_TYPE_CANVAS){var a=cc.textureCache;a.handleLoadedTexture=function(a,c){var b=this._textures,e=b[a];e||(e=b[a]=new cc.Texture2D,e.url=a);e.initWithElement(c);e.handleLoadedTexture();return e};a.addImage=function(a,c,d){cc.assert(a,cc._LogInfos.Texture2D_addImage);var b=this._textures,f=b[a]||b[cc.loader._getAliase(a)];if(f)return f.isLoaded()?c&&c.call(d,f):f.addEventListener("load",function(){c&&c.call(d,
f)},d),f;f=b[a]=new cc.Texture2D;f.url=a;b=a.startsWith("http")?null:cc.loader.getBasePath?cc.loader.getBasePath():cc.loader.resPath;cc.loader.loadImg(cc.path.join(b||"",a),function(b,e){if(b)return c&&c.call(d,b);var f=cc.textureCache.handleLoadedTexture(a,e);c&&c.call(d,f)});return f};a.addImageAsync=a.addImage;a=null}else cc._renderType===cc.game.RENDER_TYPE_WEBGL&&(cc.assert(cc.isFunction(cc._tmp.WebGLTextureCache),cc._LogInfos.MissingFile,"TexturesWebGL.js"),cc._tmp.WebGLTextureCache(),delete cc._tmp.WebGLTextureCache)});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;c[b]?(c[b].bl=a.bl,c[b].br=a.br,c[b].tl=a.tl,c[b].tr=a.tr):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"<cc.TextureAtlas | totalQuads ="+
this._totalQuads+">"},_setupIndices:function(){if(0!==this._capacity)for(var a=this._indices,b=this._capacity,c=0;c<b;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);if(c)return this.initWithTexture(c,b);cc.log(cc._LogInfos.TextureAtlas_initWithFile,a);return!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;this._quadsArrayBuffer=new ArrayBuffer(c*b);this._quadsReader=new Uint8Array(this._quadsArrayBuffer);if((!this._quads||!this._indices)&&0<b)return!1;for(var d=this._quads,e=0;e<b;e++)d[e]=new cc.V3F_C4B_T2F_Quad(null,null,null,null,this._quadsArrayBuffer,e*c);this._setupIndices();this._setupVBO();return this.dirty=!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){cc.assert(b<this._capacity,cc._LogInfos.TextureAtlas_insertQuad_2);this._totalQuads++;if(this._totalQuads>this._capacity)cc.log(cc._LogInfos.TextureAtlas_insertQuad);else{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;this._totalQuads+=c;if(this._totalQuads>this._capacity)cc.log(cc._LogInfos.TextureAtlas_insertQuad);else{var e=b*d,f=(this._totalQuads-1-b-c)*d,g=this._totalQuads-
1-c,h;for(h=0;h<c;h++)this._quads[g+h]=new cc.V3F_C4B_T2F_Quad(null,null,null,null,this._quadsArrayBuffer,(this._totalQuads-1)*d);this._quadsReader.set(this._quadsReader.subarray(e,e+f),e+d*c);for(h=0;h<c;h++)this._setQuadToArray(a[h],b+h);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=cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT,
d=this._quadsReader,e=d.subarray(a*c,c);if(a>b){var f=b*c;d.set(d.subarray(f,f+(a-b)*c),f+c);d.set(e,f)}else f=(a+1)*c,d.set(d.subarray(f,f+(b-a)*c),f-c),d.set(e,b*c);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;this._totalQuads--;this._quads.length=this._totalQuads;if(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){cc.assert(a+b<=this._totalQuads,cc._LogInfos.TextureAtlas_removeQuadsAtIndex);this._totalQuads-=b;if(a!==this._totalQuads){var c=cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT,d=(a+b)*c,e=a*c;this._quadsReader.set(this._quadsReader.subarray(d,d+(this._totalQuads-a)*c),e)}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)for(this._quads=[],this._quadsArrayBuffer=new ArrayBuffer(b*d),this._quadsReader=new Uint8Array(this._quadsArrayBuffer),a=0;a<d;a++)this._quads=new cc.V3F_C4B_T2F_Quad(null,null,null,null,this._quadsArrayBuffer,a*b);else{var f=this._quads;if(d>c){var g=[];var h=new ArrayBuffer(b*d);for(a=0;a<e;a++)g[a]=new cc.V3F_C4B_T2F_Quad(f[a].tl,f[a].bl,f[a].tr,f[a].br,h,a*b);for(;a<
d;a++)g[a]=new cc.V3F_C4B_T2F_Quad(null,null,null,null,h,a*b)}else for(e=Math.max(e,d),g=[],h=new ArrayBuffer(b*d),a=0;a<e;a++)g[a]=new cc.V3F_C4B_T2F_Quad(f[a].tl,f[a].bl,f[a].tr,f[a].br,h,a*b);this._quadsReader=new Uint8Array(h);this._quads=g;this._quadsArrayBuffer=h}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);this._setupIndices();this._mapBuffers();return this.dirty=!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=cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT,e=a*d,f=b*d,g=this._quadsReader,h=g.subarray(e,e+f),k=c*d;c<a?(b=c*d,g.set(g.subarray(b,b+
(a-c)*d),b+f)):(b=(a+b)*d,g.set(g.subarray(b,b+(c-a)*d),e));g.set(h,k);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;e<c;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;cc.defineGetterSetter(_p,"totalQuads",_p.getTotalQuads);cc.defineGetterSetter(_p,"capacity",_p.getCapacity);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.game.addEventListener(cc.game.EVENT_RENDERER_INITED,function(){cc._renderType===cc.game.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.Scene=cc.Node.extend({_className:"Scene",ctor:function(){cc.Node.prototype.ctor.call(this);this._ignoreAnchorPointForPosition=!0;this.setAnchorPoint(.5,.5);this.setContentSize(cc.director.getWinSize())}});cc.Scene.create=function(){return new cc.Scene};cc.LoaderScene=cc.Scene.extend({_interval:null,_label:null,_logo: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);d.setPosition(cc.pAdd(cc.visibleRect.center,cc.p(0,e)));
d.setColor(cc.color(180,180,180));c.addChild(this._label,10);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,.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){a._label.setString("Loading... "+Math.min(d/c*100|0,100)+"%")},function(){a.cb&&a.cb.call(a.target)})},_updateTransform:function(){this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty);this._bgLayer._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty);this._label._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty);
this._logo&&this._logo._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)}});cc.LoaderScene.preload=function(a,b,c){var d=cc;d.loaderScene||(d.loaderScene=new cc.LoaderScene,d.loaderScene.init(),cc.eventManager.addCustomListener(cc.Director.EVENT_PROJECTION_CHANGED,function(){d.loaderScene._updateTransform()}));d.loaderScene.initWithResources(a,b,c);cc.director.runScene(d.loaderScene);return d.loaderScene};cc.Layer=cc.Node.extend({_className:"Layer",ctor:function(){cc.Node.prototype.ctor.call(this);this._ignoreAnchorPointForPosition=!0;this.setAnchorPoint(.5,.5);this.setContentSize(cc.winSize);this._cascadeOpacityEnabled=this._cascadeColorEnabled=!1},bake:function(){this._renderCmd.bake()},unbake:function(){this._renderCmd.unbake()},isBaked:function(){return this._renderCmd._isBaked},visit:function(a){var b=this._renderCmd,c=a?a._renderCmd:null;if(this._visible){a=cc.renderer;b.visit(c);if(b._isBaked)a.pushRenderCommand(b),
b._bakeSprite.visit(this);else{var d=this._children,e=d.length;if(0<e){this._reorderChildDirty&&this.sortAllChildren();for(c=0;c<e;c++){var f=d[c];if(0>f._localZOrder)f.visit(this);else break}for(a.pushRenderCommand(b);c<e;c++)d[c].visit(this)}else a.pushRenderCommand(b)}b._dirtyFlag=0}else b._propagateFlagsDown(c)},addChild:function(a,b,c){cc.Node.prototype.addChild.call(this,a,b,c);this._renderCmd._bakeForAddChild(a)},_createRenderCmd:function(){return cc._renderType===cc.game.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=cc.BlendFunc._alphaNonPremultiplied();cc.LayerColor.prototype.init.call(this,a,b,c)},init:function(a,
b,c){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;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);return!0},visit:function(a){var b=this._renderCmd,c=a?a._renderCmd:null;if(this._visible){a=cc.renderer;b.visit(c);if(b._isBaked)a.pushRenderCommand(b._bakeRenderCmd),b._bakeSprite._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty),
b._bakeSprite.visit(this);else{var d=this._children,e=d.length;if(0<e){this._reorderChildDirty&&this.sortAllChildren();for(c=0;c<e;c++)if(child=d[c],0>child._localZOrder)child.visit(this);else break;for(a.pushRenderCommand(b);c<e;c++)d[c].visit(this)}else a.pushRenderCommand(b)}b._dirtyFlag=0}else b._propagateFlagsDown(c)},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)},_createRenderCmd:function(){return cc._renderType===
cc.game.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;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);
return!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;(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.game.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;cc.defineGetterSetter(a,"startColor",a.getStartColor,a.setStartColor);cc.defineGetterSetter(a,"endColor",a.getEndColor,a.setEndColor);cc.defineGetterSetter(a,"startOpacity",a.getStartOpacity,a.setStartOpacity);cc.defineGetterSetter(a,"endOpacity",a.getEndOpacity,a.setEndOpacity);cc.defineGetterSetter(a,"vector",a.getVector,a.setVector);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){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]);
return!0},switchTo:function(a){a>=this._layers.length?cc.log(cc._LogInfos.LayerMultiplex_switchTo):(this.removeChild(this._layers[this._enabledLayer],!0),this._enabledLayer=a,this.addChild(this._layers[a]))},switchToAndReleaseMe:function(a){a>=this._layers.length?cc.log(cc._LogInfos.LayerMultiplex_switchToAndReleaseMe):(this.removeChild(this._layers[this._enabledLayer],!0),this._layers[this._enabledLayer]=null,this._enabledLayer=a,this.addChild(this._layers[a]))},addLayer:function(a){a?this._layers.push(a):
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){this._rootCtor(a);this._isBaked=!1;this._bakeSprite=null;this._canUseDirtyRegion=!0;this._updateCache=2};var a=cc.Layer.CanvasRenderCmd.prototype=Object.create(cc.Node.CanvasRenderCmd.prototype);a.constructor=cc.Layer.CanvasRenderCmd;a._layerCmdCtor=cc.Layer.CanvasRenderCmd;a._setCacheDirty=function(a){a&&0===this._updateCache&&(this._updateCache=2);!1===this._cacheDirty&&(this._cacheDirty=!0,(a=this._cachedParent)&&a!==this&&a._setNodeDirtyForCache&&
a._setNodeDirtyForCache())};a.updateStatus=function(){var a=cc.Node._dirtyFlags;this._dirtyFlag&a.orderDirty&&(this._cacheDirty=!0,0===this._updateCache&&(this._updateCache=2),this._dirtyFlag&=~a.orderDirty);this.originUpdateStatus()};a._syncStatus=function(a){var b=cc.Node._dirtyFlags,d=this._dirtyFlag;if(this._isBaked||d&b.orderDirty)this._cacheDirty=!0,0===this._updateCache&&(this._updateCache=2),this._dirtyFlag&=~b.orderDirty;this._originSyncStatus(a)};a.transform=function(a,c){this._worldTransform||
(this._worldTransform={a:1,b:0,c:0,d:1,tx:0,ty:0});var b=this._worldTransform,e=b.a,f=b.b,g=b.c,h=b.d;this.originTransform(a,c);b.a===e&&b.b===f&&b.c===g&&b.d===h||0!==this._updateCache||(this._updateCache=2)};a.bake=function(){if(!this._isBaked){this._needDraw=!0;this._isBaked=this._cacheDirty=cc.renderer.childrenOrderDirty=!0;0===this._updateCache&&(this._updateCache=2);for(var a=this._node._children,c=0,d=a.length;c<d;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;0===this._updateCache&&(this._updateCache=2);for(var a=this._node._children,c=0,d=a.length;c<d;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+.5;e.height=0|e.height+.5;var f=d.getCacheContext(),g=f.getContext();d.setPosition(e.x,e.y);if(0<this._updateCache){d.resetCanvasSize(e.width,e.height);f.setOffset(0-e.x,g.canvas.height-e.height+e.y);a.sortAllChildren();cc.renderer._turnToCacheMode(this.__instanceId);a=0;for(e=c.length;a<e;a++)c[a].visit(this);cc.renderer._renderingToCacheCanvas(f,this.__instanceId);d.transform();this._updateCache--}this._cacheDirty=!1}};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);var d=c.getNodeToWorldTransform();c=c._children;for(var e=0,f=c.length;e<f;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){this._layerCmdCtor(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 b=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),b.fillRect(0,0,k,-f),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=this._node,c=this._bakeSprite,d=a._children,e=d.length;this.transform(this.getParentRenderCmd(),!0);var f=this._getBoundingBoxForBake();f.width=0|f.width+.5;f.height=0|f.height+.5;var g=c.getCacheContext(),h=g.getContext();c.setPosition(f.x,f.y);if(0<this._updateCache){h.fillStyle=g._currentFillStyle;c.resetCanvasSize(f.width,f.height);g.setOffset(0-f.x,h.canvas.height-f.height+f.y);cc.renderer._turnToCacheMode(this.__instanceId);
if(0<e){a.sortAllChildren();for(f=0;f<e;f++)if(h=d[f],0>h._localZOrder)h.visit(a);else break;for(cc.renderer.pushRenderCommand(this);f<e;f++)d[f].visit(a)}else cc.renderer.pushRenderCommand(this);cc.renderer._renderingToCacheCanvas(g,this.__instanceId);c.transform();this._updateCache--}this._cacheDirty=!1}};a._getBoundingBoxForBake=function(){var a=this._node,c=cc.rect(0,0,a._contentSize.width,a._contentSize.height),d=a.getNodeToWorldTransform();c=cc.rectApplyAffineTransform(c,a.getNodeToWorldTransform());
if(!a._children||0===a._children.length)return c;a=a._children;for(var 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.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);a.constructor=cc.LayerGradient.CanvasRenderCmd;a.rendering=function(a,c,d){a=a||cc._renderContext;var b=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=b.createLinearGradient(this._startPoint.x,this._startPoint.y,this._endPoint.x,this._endPoint.y);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);b.fillRect(0,0,h,-k);cc.g_NumberOfDraws++}};a.updateStatus=function(){var a=
cc.Node._dirtyFlags;this._dirtyFlag&a.gradientDirty&&(this._dirtyFlag|=a.colorDirty,this._dirtyFlag&=~a.gradientDirty);this.originUpdateStatus()};a._syncStatus=function(a){var b=cc.Node._dirtyFlags;this._dirtyFlag&b.gradientDirty&&(this._dirtyFlag|=b.colorDirty,this._dirtyFlag&=~b.gradientDirty);this._originSyncStatus(a)};a._updateColor=function(){var a=this._node,c=a._contentSize,d=.5*c.width;c=.5*c.height;var e=cc.pAngleSigned(cc.p(0,-1),a._alongVector);e=cc.pRotateByAngle(cc.p(0,-1),cc.p(0,0),
e);var 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._endOpacity/255;this._startStopStr="rgba("+Math.round(d.r)+","+Math.round(d.g)+","+Math.round(d.b)+","+(a._startOpacity/255).toFixed(4)+")";this._endStopStr="rgba("+Math.round(c.r)+","+Math.round(c.g)+","+Math.round(c.b)+","+e.toFixed(4)+")";if(a._colorStops)for(this._endOpacity=this._startOpacity=
0,this._colorStopsStr=[],d=0;d<a._colorStops.length;d++)c=a._colorStops[d].color,this._colorStopsStr.push("rgba("+Math.round(c.r)+","+Math.round(c.g)+","+Math.round(c.b)+","+(null==c.a?1:c.a/255).toFixed(4)+")")}})();(function(){cc.Layer.WebGLRenderCmd=function(a){this._rootCtor(a);this._isBaked=!1};var a=cc.Layer.WebGLRenderCmd.prototype=Object.create(cc.Node.WebGLRenderCmd.prototype);a.constructor=cc.Layer.WebGLRenderCmd;a._layerCmdCtor=cc.Layer.WebGLRenderCmd;a.bake=function(){};a.unbake=function(){};a._bakeForAddChild=function(){}})();
(function(){cc.LayerColor.WebGLRenderCmd=function(a){this._layerCmdCtor(a);this._needDraw=!0;this._matrix=null;this.initData(4);this._color=new Uint32Array(1);this._vertexBuffer=null;this._shaderProgram=cc.shaderCache.programForKey(cc.SHADER_POSITION_COLOR)};var a=cc.LayerColor.WebGLRenderCmd.prototype=Object.create(cc.Layer.WebGLRenderCmd.prototype);a.constructor=cc.LayerColor.WebGLRenderCmd;a.initData=function(a){this._data=new ArrayBuffer(16*a);this._positionView=new Float32Array(this._data);this._colorView=
new Uint32Array(this._data);this._dataDirty=!0};a.transform=function(a,c){this.originTransform(a,c);var b=this._node,e=b._contentSize.width,f=b._contentSize.height,g=this._positionView;g[4]=e;g[9]=f;g[12]=e;g[13]=f;g[2].z=g[6]=g[10]=g[14]=b._vertexZ;this._dataDirty=!0};a._updateColor=function(){var a=this._displayedColor;this._color[0]=this._displayedOpacity<<24|a.b<<16|a.g<<8|a.r;a=this._colorView;for(var c=0;4>c;c++)a[4*c+3]=this._color[0];this._dataDirty=!0};a.rendering=function(a){a=a||cc._renderContext;
var b=this._node;this._matrix||(this._matrix=new cc.math.Matrix4,this._matrix.identity());var d=this._worldTransform;this._matrix.mat[0]=d.a;this._matrix.mat[4]=d.c;this._matrix.mat[12]=d.tx;this._matrix.mat[1]=d.b;this._matrix.mat[5]=d.d;this._matrix.mat[13]=d.ty;this._dataDirty&&(this._vertexBuffer||(this._vertexBuffer=a.createBuffer()),a.bindBuffer(a.ARRAY_BUFFER,this._vertexBuffer),a.bufferData(a.ARRAY_BUFFER,this._data,a.DYNAMIC_DRAW),this._dataDirty=!1);this._glProgramState.apply(this._matrix);
cc.glBlendFunc(b._blendFunc.src,b._blendFunc.dst);a.bindBuffer(a.ARRAY_BUFFER,this._vertexBuffer);a.enableVertexAttribArray(cc.VERTEX_ATTRIB_POSITION);a.enableVertexAttribArray(cc.VERTEX_ATTRIB_COLOR);a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,3,a.FLOAT,!1,16,0);a.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR,4,a.UNSIGNED_BYTE,!0,16,12);a.drawArrays(a.TRIANGLE_STRIP,0,4)};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);a.constructor=cc.LayerGradient.WebGLRenderCmd;a.updateStatus=function(){var a=cc.Node._dirtyFlags;this._dirtyFlag&a.gradientDirty&&(this._dirtyFlag|=a.colorDirty,this._updateVertex(),this._dirtyFlag&=~a.gradientDirty);this.originUpdateStatus()};
a._syncStatus=function(a){var b=cc.Node._dirtyFlags;this._dirtyFlag&b.gradientDirty&&(this._dirtyFlag|=b.colorDirty,this._updateVertex(),this._dirtyFlag&=~b.gradientDirty);this._originSyncStatus(a)};a.transform=function(a,c){this.originTransform(a,c);this._updateVertex()};a._updateVertex=function(){var a=this._node,c=a._colorStops;if(c&&!(2>c.length)){this._clippingRectDirty=!0;var d=c.length,e=2*d,f=a._contentSize;this._positionView.length/4<e&&this.initData(e);var g=Math.PI+cc.pAngleSigned(cc.p(0,
-1),a._alongVector);e=cc.p(f.width/2,f.height/2);var h=Math.round(cc.radiansToDegrees(g)),k=cc.affineTransformMake(1,0,0,1,e.x,e.y);k=cc.affineTransformRotate(k,g);if(90>h){h=cc.p(-e.x,e.y);var m=cc.p(e.x,e.y)}else 180>h?(h=cc.p(e.x,e.y),m=cc.p(e.x,-e.y)):270>h?(h=cc.p(e.x,-e.y),m=cc.p(-e.x,-e.y)):(h=cc.p(-e.x,-e.y),m=cc.p(-e.x,e.y));var n=Math.sin(g);g=Math.cos(g);k=cc.affineTransformScale(k,Math.abs((h.x*g-h.y*n)/e.x),Math.abs((m.x*n+m.y*g)/e.y));h=this._positionView;for(g=0;g<d;g++){n=c[g].p*f.height;
var p=cc.pointApplyAffineTransform(-e.x,n-e.y,k);m=8*g;h[m]=p.x;h[m+1]=p.y;h[m+2]=a._vertexZ;n=cc.pointApplyAffineTransform(f.width-e.x,n-e.y,k);m+=4;h[m]=n.x;h[m+1]=n.y;h[m+2]=a._vertexZ}this._dataDirty=!0}};a._updateColor=function(){var a=this._node._colorStops;if(a&&!(2>a.length)){var c=a.length,d=this._colorView,e=this._displayedOpacity/255;for(i=0;i<c;i++){var f=a[i].color;this._color[0]=f.a*e<<24|f.b<<16|f.g<<8|f.r;f=8*i;d[f+3]=this._color[0];f+=4;d[f+3]=this._color[0]}this._dataDirty=!0}};
a.rendering=function(a){a=a||cc._renderContext;var b=this._node;this._matrix||(this._matrix=new cc.math.Matrix4,this._matrix.identity());var d=this._getClippingRect();a.enable(a.SCISSOR_TEST);cc.view.setScissorInPoints(d.x,d.y,d.width,d.height);d=this._worldTransform;this._matrix.mat[0]=d.a;this._matrix.mat[4]=d.c;this._matrix.mat[12]=d.tx;this._matrix.mat[1]=d.b;this._matrix.mat[5]=d.d;this._matrix.mat[13]=d.ty;this._dataDirty&&(this._vertexBuffer||(this._vertexBuffer=gl.createBuffer()),gl.bindBuffer(gl.ARRAY_BUFFER,
this._vertexBuffer),gl.bufferData(gl.ARRAY_BUFFER,this._data,gl.DYNAMIC_DRAW),this._dataDirty=!1);this._glProgramState.apply(this._matrix);cc.glBlendFunc(b._blendFunc.src,b._blendFunc.dst);gl.bindBuffer(gl.ARRAY_BUFFER,this._vertexBuffer);gl.enableVertexAttribArray(cc.VERTEX_ATTRIB_POSITION);gl.enableVertexAttribArray(cc.VERTEX_ATTRIB_COLOR);gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,3,gl.FLOAT,!1,16,0);gl.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR,4,gl.UNSIGNED_BYTE,!0,16,12);gl.drawArrays(gl.TRIANGLE_STRIP,
0,4);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}})();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);cc.defineGetterSetter(a,"flippedX",a.isFlippedX,a.setFlippedX);cc.defineGetterSetter(a,"flippedY",a.isFlippedY,a.setFlippedY);cc.defineGetterSetter(a,"offsetX",a._getOffsetX);cc.defineGetterSetter(a,"offsetY",a._getOffsetY);cc.defineGetterSetter(a,
"texture",a.getTexture,a.setTexture);cc.defineGetterSetter(a,"textureRectRotated",a.isTextureRectRotated);cc.defineGetterSetter(a,"batchNode",a.getBatchNode,a.setBatchNode);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.setAnchorPoint(.5,.5);this._loader=new cc.Sprite.LoadManager;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);return this.setSpriteFrame(a)},initWithSpriteFrameName:function(a){cc.assert(a,
cc._LogInfos.Sprite_initWithSpriteFrameName);var b=cc.spriteFrameCache.getSpriteFrame(a);cc.assert(b,a+cc._LogInfos.Sprite_initWithSpriteFrameName1);return this.initWithSpriteFrame(b)},useBatchNode:function(a){},setVertexRect:function(a){var b=this._rect;b.x=a.x;b.y=a.y;b.width=a.width;b.height=a.height;this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)},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);c?(c=c.getFrames()[b])?this.setSpriteFrame(c.getSpriteFrame()):cc.log(cc._LogInfos.Sprite_setDisplayFrameWithAnimationName_2):cc.log(cc._LogInfos.Sprite_setDisplayFrameWithAnimationName)},getBatchNode:function(){return this._batchNode},getTexture:function(){return this._texture},_softInit:function(a,b,c){if(void 0===a)cc.Sprite.prototype.init.call(this);else if("string"===typeof a)(c=cc.spriteFrameCache.getSpriteFrame(a))?
this.initWithSpriteFrame(c):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 null},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(){if(0<arguments.length)return 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.anchorY=this.anchorX=.5;this._offsetPosition.x=0;this._offsetPosition.y=0;this._hasChildren=!1;this.setTextureRect(cc.rect(0,0,0,0),!1,cc.size(0,0));return!0},initWithFile:function(a,
b){cc.assert(a,cc._LogInfos.Sprite_initWithFile);var c=cc.textureCache.getTextureForKey(a);c||(c=cc.textureCache.addImage(a));if(!c.isLoaded())return this._loader.clear(),this._loader.once(c,function(){this.initWithFile(a,b);this.dispatchEvent("load")},this),!1;if(!b){var d=c.getContentSize();b=cc.rect(0,0,d.width,d.height)}return this.initWithTexture(c,b)},initWithTexture:function(a,b,c,d){cc.assert(0!==arguments.length,cc._LogInfos.CCSpriteBatchNode_initWithTexture);this._loader.clear();this._textureLoaded=
a.isLoaded();if(!this._textureLoaded)return this._loader.once(a,function(){this.initWithTexture(a,b,c,d);this.dispatchEvent("load")},this),!1;c=c||!1;a=this._renderCmd._handleTextureForRotatedTexture(a,b,c,d);if(!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._offsetPosition.x=0;this._offsetPosition.y=0;this._hasChildren=
!1;this._rectRotated=c;b&&(this._rect.x=b.x,this._rect.y=b.y,this._rect.width=b.width,this._rect.height=b.height);b||(b=cc.rect(0,0,a.width,a.height));this._renderCmd._checkTextureBoundary(a,b,c);this.setTexture(a);this.setTextureRect(b,c);this.setBatchNode(null);return!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},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){"string"===typeof a&&(a=cc.spriteFrameCache.getSpriteFrame(a),
cc.assert(a,cc._LogInfos.Sprite_setSpriteFrame));this._loader.clear();this.setNodeDirty(!0);var b=a.getTexture();this._textureLoaded=a.textureLoaded();this._loader.clear();if(!this._textureLoaded)return this._loader.once(b,function(){this.setSpriteFrame(a);this.dispatchEvent("load")},this),!1;var c=a.getOffset();this._unflippedOffsetPositionFromCenter.x=c.x;this._unflippedOffsetPositionFromCenter.y=c.y;b!==this._texture&&(this._renderCmd._setTexture(b),this.setColor(this._realColor));this.setTextureRect(a.getRect(),
a.isRotated(),a.getOriginalSize())},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){},
setTexture:function(a){if(!a)return this._renderCmd._setTexture(null);var b="string"===typeof a;b&&(a=cc.textureCache.addImage(a));this._loader.clear();if(!a._textureLoaded)return this._loader.once(a,function(){this.setTexture(a);this.dispatchEvent("load")},this),!1;this._renderCmd._setTexture(a);b&&this._changeRectWithTexture(a);this.setColor(this._realColor);this._textureLoaded=!0},_changeRectWithTexture:function(a){a=a._contentSize;a=cc.rect(0,0,a.width,a.height);this.setTextureRect(a)},_createRenderCmd:function(){return cc._renderType===
cc.game.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(){var a=cc.Sprite.LoadManager=function(){this.list=[]};a.prototype.add=function(a,c,d){a&&a.addEventListener&&(a.addEventListener("load",c,d),this.list.push({source:a,listener:c,target:d}))};a.prototype.once=function(a,c,d){if(a&&a.addEventListener){var b=function(e){a.removeEventListener("load",b,d);c.call(d,e)};a.addEventListener("load",b,d);this.list.push({source:a,listener:b,target:d})}};a.prototype.clear=function(){for(;0<this.list.length;){var a=this.list.pop();a.source.removeEventListener("load",
a.listener,a.target)}}})();(function(){cc.Sprite.CanvasRenderCmd=function(a){this._rootCtor(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._canUseDirtyRegion=!0;this._textureToRender=null};var a=cc.Sprite.CanvasRenderCmd.prototype=Object.create(cc.Node.CanvasRenderCmd.prototype);a.constructor=cc.Sprite.CanvasRenderCmd;a._spriteCmdCtor=cc.Sprite.CanvasRenderCmd;a.setDirtyRecursively=function(a){};a._setTexture=function(a){var b=
this._node;b._texture!==a&&(b._textureLoaded=a?a._textureLoaded:!1,b._texture=a,a=a._contentSize,a=cc.rect(0,0,a.width,a.height),b.setTextureRect(a),this._updateColor())};a._setColorDirty=function(){this.setDirtyFlag(cc.Node._dirtyFlags.colorDirty|cc.Node._dirtyFlags.opacityDirty)};a.isFrameDisplayed=function(a){var b=this._node;return a.getTexture()!==b._texture?!1:cc.rectEqualToRect(a.getRect(),b._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))};a.rendering=function(a,c,d){var b=this._node,f=this._textureCoord,g=this._displayedOpacity/255,h=this._textureToRender||b._texture;if((!h||0!==f.width&&0!==f.height&&h._textureLoaded)&&0!==g){a=a||cc._renderContext;var k=a.getContext(),m=b._offsetPosition.x,n=b._rect.height,p=b._rect.width,r=-b._offsetPosition.y-n;a.setTransform(this._worldTransform,c,d);a.setCompositeOperation(this._blendFuncStr);a.setGlobalAlpha(g);(b._flippedX||b._flippedY)&&a.save();b._flippedX&&(m=-m-p,k.scale(-1,1));
b._flippedY&&(r=b._offsetPosition.y,k.scale(1,-1));if(this._colorized)var t=g=0;else g=f.renderX,t=f.renderY;var u=f.width;var v=f.height;h&&h._htmlElementObj?(c=h._htmlElementObj,""!==h._pattern?(a.setFillStyle(k.createPattern(c,h._pattern)),k.fillRect(m,r,p,n)):k.drawImage(c,g,t,u,v,m,r,p,n)):(h=b._contentSize,f.validRect&&(f=this._displayedColor,a.setFillStyle("rgba("+f.r+","+f.g+","+f.b+",1)"),k.fillRect(m,r,h.width*c,h.height*d)));(b._flippedX||b._flippedY)&&a.restore();cc.g_NumberOfDraws++}};
a._updateColor=function(){var a=this._node._texture,c=this._textureCoord,d=this._displayedColor;a&&(255!==d.r||255!==d.g||255!==d.b?(this._textureToRender=a._generateColorTexture(d.r,d.g,d.b,c),this._colorized=!0):a&&(this._textureToRender=a,this._colorized=!1))};a._textureLoadedCallback=function(a){if(!this._textureLoaded){this._textureLoaded=!0;var b=this._rect,d=this._renderCmd;b?cc._rectEqualToZero(b)&&(b.width=a.width,b.height=a.height):b=cc.rect(0,0,a.width,a.height);this.texture=a;this.setTextureRect(b,
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 b=this._textureCoord,e=c?cc.contentScaleFactor():1;b.renderX=b.x=0|a.x*e;b.renderY=b.y=0|a.y*e;b.width=0|a.width*e;b.height=0|a.height*e;b.validRect=!(0===b.width||0===b.height||0>b.x||0>b.y)};cc.Sprite.CanvasRenderCmd._cutRotateImageToCanvas=function(a,c,d){if(!a)return null;if(!c)return a;
d=null==d?!0:d;var b=document.createElement("canvas");b.width=c.width;b.height=c.height;var f=b.getContext("2d");f.translate(b.width/2,b.height/2);d?f.rotate(-1.5707963267948966):f.rotate(1.5707963267948966);f.drawImage(a,c.x,c.y,c.height,c.width,-c.height/2,-c.width/2,c.height,c.width);return b}})();(function(){cc.Sprite.WebGLRenderCmd=function(a){this._rootCtor(a);this._needDraw=!0;this._vertices=[{x:0,y:0,u:0,v:0},{x:0,y:0,u:0,v:0},{x:0,y:0,u:0,v:0},{x:0,y:0,u:0,v:0}];this._color=new Uint32Array(1);this._recursiveDirty=this._dirty=!1;this._shaderProgram=cc.shaderCache.programForKey(cc.SHADER_SPRITE_POSITION_TEXTURECOLOR)};var a=cc.Sprite.WebGLRenderCmd.prototype=Object.create(cc.Node.WebGLRenderCmd.prototype);a.constructor=cc.Sprite.WebGLRenderCmd;a._spriteCmdCtor=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 b=this._node._children,d,e=b?b.length:0,f=0;f<e;f++)d=b[f],d instanceof cc.Sprite&&d._renderCmd.setDirtyRecursively(a)};a._setBatchNodeForAddChild=function(a){var b=this._node;if(b._batchNode){if(!(a instanceof cc.Sprite))return cc.log(cc._LogInfos.Sprite_addChild),!1;a.texture._webTextureObj!==
b.textureAtlas.texture._webTextureObj&&cc.log(cc._LogInfos.Sprite_addChild_2);b._batchNode.appendChild(a);b._reorderChildDirty||b._setReorderChildDirtyRecursively()}return!0};a._handleTextureForRotatedTexture=function(a){return a};a.isFrameDisplayed=function(a){var b=this._node;return cc.rectEqualToRect(a.getRect(),b._rect)&&a.getTexture().getName()===b._texture.getName()&&cc.pointEqualToPoint(a.getOffset(),b._unflippedOffsetPositionFromCenter)};a._textureLoadedCallback=function(a){if(!this._textureLoaded){this._textureLoaded=
!0;var b=this._rect;b?cc._rectEqualToZero(b)&&(b.width=a.width,b.height=a.height):b=cc.rect(0,0,a.width,a.height);this.texture=a;this.setTextureRect(b,this._rectRotated);this.setBatchNode(this._batchNode);this.dispatchEvent("load");cc.renderer.childrenOrderDirty=!0}};a._setTextureCoords=function(a,c){void 0===c&&(c=!0);c&&(a=cc.rectPointsToPixels(a));var b=this._node,e=b._batchNode?b.textureAtlas.texture:b._texture,f=this._vertices;if(e){var g=e.pixelsWidth,h=e.pixelsHeight;if(b._rectRotated){if(cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL){e=
(2*a.x+1)/(2*g);g=e+(2*a.height-2)/(2*g);var k=(2*a.y+1)/(2*h);h=k+(2*a.width-2)/(2*h)}else e=a.x/g,g=(a.x+a.height)/g,k=a.y/h,h=(a.y+a.width)/h;if(b._flippedX){var m=k;k=h;h=m}b._flippedY&&(m=e,e=g,g=m);f[0].u=g;f[0].v=k;f[1].u=e;f[1].v=k;f[2].u=g;f[2].v=h;f[3].u=e}else cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL?(e=(2*a.x+1)/(2*g),g=e+(2*a.width-2)/(2*g),k=(2*a.y+1)/(2*h),h=k+(2*a.height-2)/(2*h)):(e=a.x/g,g=(a.x+a.width)/g,k=a.y/h,h=(a.y+a.height)/h),b._flippedX&&(m=e,e=g,g=m),b._flippedY&&(m=k,k=h,h=
m),f[0].u=e,f[0].v=k,f[1].u=e,f[1].v=h,f[2].u=g,f[2].v=k,f[3].u=g;f[3].v=h}};a._setColorDirty=function(){};a._updateBlendFunc=function(){if(this._batchNode)cc.log(cc._LogInfos.Sprite__updateBlendFunc);else{var a=this._node,c=a._blendFunc;a._texture&&a._texture.hasPremultipliedAlpha()?(c.src===cc.SRC_ALPHA&&c.dst===cc.BLEND_DST&&(c.src=cc.ONE),a.opacityModifyRGB=!0):(c.src===cc.ONE&&c.dst===cc.BLEND_DST&&(c.src=cc.SRC_ALPHA),a.opacityModifyRGB=!1)}};a._setTexture=function(a){var b=this._node;if(b._texture!==
a){b._textureLoaded=a?a._textureLoaded:!1;if(b._texture=a)a=a._contentSize,a=cc.rect(0,0,a.width,a.height),b.setTextureRect(a),this._updateBlendFunc();b._textureLoaded&&(cc.renderer.childrenOrderDirty=!0)}};a._checkTextureBoundary=function(a,c,d){a&&a.url&&(d?(d=c.x+c.height,c=c.y+c.width):(d=c.x+c.width,c=c.y+c.height),d>a.width&&cc.error(cc._LogInfos.RectWidth,a.url),c>a.height&&cc.error(cc._LogInfos.RectHeight,a.url))};a.transform=function(a,c){this.originTransform(a,c);var b=this._node,e=b._offsetPosition.x,
f=e+b._rect.width,g=b._offsetPosition.y,h=g+b._rect.height,k=this._worldTransform;b=k.tx;var m=k.ty,n=e*k.a;e*=k.b;var p=f*k.a;f*=k.b;var r=h*k.c;h*=k.d;var t=g*k.c;g*=k.d;k=this._vertices;k[0].x=n+r+b;k[0].y=e+h+m;k[1].x=n+t+b;k[1].y=e+g+m;k[2].x=p+r+b;k[2].y=f+h+m;k[3].x=p+t+b;k[3].y=f+g+m};a.needDraw=function(){var a=this._node._texture;return this._needDraw&&a};a.uploadData=function(a,c,d){var b=this._node,f=b._texture;if(!(f&&f._textureLoaded&&b._rect.width&&b._rect.height&&this._displayedOpacity))return 0;
f=this._displayedOpacity;var g=this._displayedColor.r,h=this._displayedColor.g,k=this._displayedColor.b;if(b._opacityModifyRGB){var m=f/255;g*=m;h*=m;k*=m}this._color[0]=f<<24|k<<16|h<<8|g;b=b._vertexZ;f=this._vertices;g=f.length;k=d;for(d=0;d<g;++d)h=f[d],a[k]=h.x,a[k+1]=h.y,a[k+2]=b,c[k+3]=this._color[0],a[k+4]=h.u,a[k+5]=h.v,k+=6;return g}})();cc.SpriteBatchNode=cc.Node.extend({_blendFunc:null,_texture:null,_className:"SpriteBatchNode",ctor:function(a){cc.Node.prototype.ctor.call(this);this._blendFunc=new cc.BlendFunc(cc.BLEND_SRC,cc.BLEND_DST);var b;cc.isString(a)?(b=cc.textureCache.getTextureForKey(a))||(b=cc.textureCache.addImage(a)):a instanceof cc.Texture2D&&(b=a);b&&this.initWithTexture(b)},addSpriteWithoutQuad:function(a,b,c){this.addChild(a,b,c);return this},getTextureAtlas:function(){return null},setTextureAtlas:function(a){},
getDescendants:function(){return this._children},initWithFile:function(a,b){var c=cc.textureCache.getTextureForKey(a);c||(c=cc.textureCache.addImage(a));return this.initWithTexture(c,b)},init:function(a,b){var c=cc.textureCache.getTextureForKey(a);c||(c=cc.textureCache.addImage(a));return this.initWithTexture(c,b)},increaseAtlasCapacity:function(){},removeChildAtIndex:function(a,b){this.removeChild(this._children[a],b)},rebuildIndexInOrder:function(a,b){return b},highestAtlasIndexInChild:function(a){var b=
a.children;return b&&0!==b.length?this.highestAtlasIndexInChild(b[b.length-1]):a.zIndex},lowestAtlasIndexInChild:function(a){var b=a.children;return b&&0!==b.length?this.lowestAtlasIndexInChild(b[b.length-1]):a.zIndex},atlasIndexForChild:function(a){return a.zIndex},reorderBatch:function(a){this._reorderChildDirty=a},setBlendFunc:function(a,b){this._blendFunc=void 0===b?a:{src:a,dst:b}},getBlendFunc:function(){return new cc.BlendFunc(this._blendFunc.src,this._blendFunc.dst)},updateQuadFromSprite:function(a,
b){cc.assert(a,cc._LogInfos.CCSpriteBatchNode_updateQuadFromSprite_2);a instanceof cc.Sprite?(a.dirty=!0,a._renderCmd.transform(this._renderCmd,!0)):cc.log(cc._LogInfos.CCSpriteBatchNode_updateQuadFromSprite)},insertQuadFromSprite:function(a,b){this.addChild(a,b)},insertChild:function(a,b){this.addChild(a,b)},appendChild:function(a){this.sortAllChildren();this.addChild(a.lastLocalZOrder+1)},removeSpriteFromAtlas:function(a,b){this.removeChild(a,b)},initWithTexture:function(a){this.setTexture(a);return!0},
getTexture:function(){return this._texture},setTexture:function(a){this._texture=a;if(a._textureLoaded){var b,c=this._children,d=c.length;for(b=0;b<d;++b)c[b].setTexture(a)}else a.addEventListener("load",function(){var b,c=this._children,d=c.length;for(b=0;b<d;++b)c[b].setTexture(a)},this)},setShaderProgram:function(a){this._renderCmd.setShaderProgram(a);var b,c=this._children,d=c.length;for(b=0;b<d;++b)c[b].setShaderProgram(a)},addChild:function(a,b,c){cc.assert(void 0!==a,cc._LogInfos.CCSpriteBatchNode_addChild_3);
this._isValidChild(a)&&(b=void 0===b?a.zIndex:b,c=void 0===c?a.tag:c,cc.Node.prototype.addChild.call(this,a,b,c),this._renderCmd._shaderProgram&&(a.shaderProgram=this._renderCmd._shaderProgram))},_isValidChild:function(a){return a instanceof cc.Sprite?a.texture!==this._texture?(cc.log(cc._LogInfos.Sprite_addChild_5),!1):!0:(cc.log(cc._LogInfos.Sprite_addChild_4),!1)}});_p=cc.SpriteBatchNode.prototype;cc.defineGetterSetter(_p,"texture",_p.getTexture,_p.setTexture);
cc.defineGetterSetter(_p,"shaderProgram",_p.getShaderProgram,_p.setShaderProgram);cc.SpriteBatchNode.create=function(a){return new cc.SpriteBatchNode(a)};cc.SpriteBatchNode.createWithTexture=cc.SpriteBatchNode.create;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){var c=this._cacheCanvas,
d=this._cacheContext,e=d._context.strokeStyle,f=d._context.fillStyle;void 0===b&&(b=a.height,a=a.width);c.width=a;c.height=b;e!==d._context.strokeStyle&&(d._context.strokeStyle=e);f!==d._context.fillStyle&&(d._context.fillStyle=f);this.getTexture().handleLoadedTexture();this.setTextureRect(cc.rect(0,0,a,b),!1,null,!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;a.initWithSpriteFrame(this._spriteFrame.clone(),this._delayPerUnit,this._userInfo);return a},copyWithZone:function(a){return cc.clone(this)},copy:function(a){a=new cc.AnimationFrame;a.initWithSpriteFrame(this._spriteFrame.clone(),this._delayPerUnit,this._userInfo);return a},initWithSpriteFrame:function(a,
b,c){this._spriteFrame=a;this._delayPerUnit=b;this._userInfo=c;return!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){this._frames=[];if(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;a.initWithAnimationFrames(this._copyFrames(),this._delayPerUnit,this._loops);a.setRestoreOriginalFrame(this._restoreOriginalFrame);return a},copyWithZone:function(a){a=new cc.Animation;a.initWithAnimationFrames(this._copyFrames(),this._delayPerUnit,this._loops);a.setRestoreOriginalFrame(this._restoreOriginalFrame);return 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;b.length=0;if(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){var d=1,e=a.properties;if(e){d=null!=e.format?parseInt(e.format):d;e=e.spritesheets;for(var 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)}}else cc.log(cc._LogInfos.animationCache__addAnimationsWithDictionary)},addAnimations:function(a){cc.assert(a,cc._LogInfos.animationCache_addAnimations_2);var b=cc.loader.getRes(a);b?this._addAnimationsWithDictionary(b,a):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;if(e){for(var f=[],g=0;g<e.length;g++){var h=b.getSpriteFrame(e[g]);if(h){var k=new cc.AnimationFrame;k.initWithSpriteFrame(h,1,null);f.push(k)}else cc.log(cc._LogInfos.animationCache__parseVersion1_2,c,e[g])}0===f.length?cc.log(cc._LogInfos.animationCache__parseVersion1_3,c):(f.length!==e.length&&cc.log(cc._LogInfos.animationCache__parseVersion1_4,c),e=new cc.Animation(f,d,1),cc.animationCache.addAnimation(e,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;var 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){n=parseFloat(m.delayUnits)||0;m=m.notification;var 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);a&&(this._textureLoaded=a.isLoaded());return 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){this._textureLoaded=!0;if(this._rotated&&cc._renderType===cc.game.RENDER_TYPE_CANVAS){var b=a.getHtmlElementObj();b=cc.Sprite.CanvasRenderCmd._cutRotateImageToCanvas(b,this.getRect());var c=new cc.Texture2D;c.initWithElement(b);c.handleLoadedTexture();
this.setTexture(c);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;a.initWithTexture(this._textureFilename,this._rectInPixels,this._rotated,this._offsetInPixels,this._originalSizeInPixels);a.setTexture(this._texture);return a},copyWithZone:function(){var a=new cc.SpriteFrame;a.initWithTexture(this._textureFilename,this._rectInPixels,this._rotated,this._offsetInPixels,this._originalSizeInPixels);a.setTexture(this._texture);return a},copy:function(){return this.copyWithZone()},initWithTexture:function(a,
b,c,d,e){2===arguments.length&&(b=cc.rectPointsToPixels(b));d=d||cc.p(0,0);e=e||b;c=c||!1;"string"===typeof a?(this._texture=null,this._textureFilename=a):a instanceof cc.Texture2D&&this.setTexture(a);a=this.getTexture();this._rectInPixels=b;this._rect=cc.rectPixelsToPoints(b);if(a&&a.url&&a.isLoaded()){if(c){var f=b.x+b.height;var g=b.y+b.width}else 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)}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;return!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;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;return 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);cc.assert(b,cc._LogInfos.spriteFrameCache__getFrameConfig_2,a);cc.loader.release(a);if(b._inited)return this._frameConfigCache[a]=b;this._frameConfigCache[a]=this._parseFrameConfig(b);return this._frameConfigCache[a]},_getFrameConfigByJsonObject:function(a,b){cc.assert(b,cc._LogInfos.spriteFrameCache__getFrameConfig_2,
a);this._frameConfigCache[a]=this._parseFrameConfig(b);return 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){h=this._sizeFromString(g.spriteSize);var 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){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,cc.rect(f.rect),f.rotated,f.offset,f.size);if(f=f.aliases)for(var h=0,k=f.length;h<k;h++){var m=f[h];a[m]&&cc.log(cc._LogInfos.spriteFrameCache_addSpriteFrames,m);a[m]=e}cc._renderType===cc.game.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),g.setRotated(!1),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()])||
delete this._spriteFramesAliases[a])}return b},_clear:function(){this._spriteFrames={};this._spriteFramesAliases={};this._frameConfigCache={}}};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.game.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 Error("Please load the resource first : "+a);cc.assert(b,cc._LogInfos.configuration_loadConfigFile_2,a);if(b=b.data)for(var c in b)this._valueDict[c]=b[c];else cc.log(cc._LogInfos.configuration_loadConfigFile,a)}};cc.g_NumberOfDraws=0;
cc.Director=cc.Class.extend({_landscape:!1,_nextDeltaTimeZero:!1,_paused:!1,_purgeDirectorInNextLoop:!1,_sendCleanupToScene:!1,_animationInterval:0,_oldAnimationInterval:0,_projection:0,_contentScaleFactor:1,_deltaTime:0,_winSizeInPoints:null,_lastUpdate:null,_nextScene:null,_notificationNode:null,_openGLView:null,_scenesStack:null,_projectionDelegate:null,_runningScene:null,_totalFrames:0,_secondsPerFrame:0,_dirtyRegion:null,_scheduler:null,_actionManager:null,_eventProjectionChanged:null,_eventAfterUpdate:null,
_eventAfterVisit:null,_eventAfterDraw:null,ctor:function(){var a=this;a._lastUpdate=Date.now();cc.eventManager.addCustomListener(cc.game.EVENT_SHOW,function(){a._lastUpdate=Date.now()})},init:function(){this._oldAnimationInterval=this._animationInterval=1/cc.defaultFPS;this._scenesStack=[];this._projection=cc.Director.PROJECTION_DEFAULT;this._projectionDelegate=null;this._totalFrames=0;this._lastUpdate=Date.now();this._purgeDirectorInNextLoop=this._paused=!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._eventAfterUpdate=new cc.EventCustom(cc.Director.EVENT_AFTER_UPDATE);this._eventAfterUpdate.setUserData(this);this._eventAfterVisit=new cc.EventCustom(cc.Director.EVENT_AFTER_VISIT);this._eventAfterVisit.setUserData(this);this._eventAfterDraw=new cc.EventCustom(cc.Director.EVENT_AFTER_DRAW);
this._eventAfterDraw.setUserData(this);this._eventProjectionChanged=new cc.EventCustom(cc.Director.EVENT_PROJECTION_CHANGED);this._eventProjectionChanged.setUserData(this);return!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]&&.2<this._deltaTime&&(this._deltaTime=1/60);this._lastUpdate=a},convertToGL:function(a){var b=document.documentElement,
c=cc.view,d=b.getBoundingClientRect();d.left+=window.pageXOffset-b.clientLeft;d.top+=window.pageYOffset-b.clientTop;b=c._devicePixelRatio*(a.x-d.left);a=c._devicePixelRatio*(d.top+d.height-a.y);return c._isRotated?{x:c._viewPortRect.width-a,y:b}:{x:b,y:a}},convertToUI:function(a){var b=document.documentElement,c=cc.view,d=b.getBoundingClientRect();d.left+=window.pageXOffset-b.clientLeft;d.top+=window.pageYOffset-b.clientTop;b={x:0,y:0};c._isRotated?(b.x=d.left+a.y/c._devicePixelRatio,b.y=d.top+d.height-
(c._viewPortRect.width-a.x)/c._devicePixelRatio):(b.x=d.left+a.x/c._devicePixelRatio,b.y=d.top+d.height-a.y/c._devicePixelRatio);return b},drawScene:function(){var a=cc.renderer;this.calculateDeltaTime();this._paused||(this._scheduler.update(this._deltaTime),cc.eventManager.dispatchEvent(this._eventAfterUpdate));this._nextScene&&this.setNextScene();this._runningScene&&(a.childrenOrderDirty?(cc.renderer.clearRenderCommands(),cc.renderer.assignedZ=0,this._runningScene._renderCmd._curLevel=0,this._runningScene.visit(),
a.resetFlag()):a.transformDirty()&&a.transform());a.clear();this._notificationNode&&this._notificationNode.visit();cc.eventManager.dispatchEvent(this._eventAfterVisit);cc.g_NumberOfDraws=0;a.rendering(cc._renderContext);this._totalFrames++;cc.eventManager.dispatchEvent(this._eventAfterDraw);cc.eventManager.frameUpdateListeners();this._calculateMPF()},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(.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._performRecursive(cc.Node._stateCallbackType.onExitTransitionDidStart),this._runningScene._performRecursive(cc.Node._stateCallbackType.onExit),
this._runningScene._performRecursive(cc.Node._stateCallbackType.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){cc.assert(a,cc._LogInfos.Director_pushScene);if(this._runningScene){var b=this._scenesStack.length;0===b?(this._sendCleanupToScene=
!0,this._scenesStack[b]=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())||cc.log(cc._LogInfos.Director_resume),this._paused=!1,this._deltaTime=0)},setContentScaleFactor:function(a){a!==this._contentScaleFactor&&(this._contentScaleFactor=a)},setDepthTest:null,setClearColor:null,setDefaultValues:function(){},setNextDeltaTimeZero:function(a){this._nextDeltaTimeZero=
a},setNextScene:function(){var a=!1,b=!1;cc.TransitionScene&&(a=this._runningScene?this._runningScene instanceof cc.TransitionScene:!1,b=this._nextScene?this._nextScene instanceof cc.TransitionScene:!1);if(!b){if(b=this._runningScene)b._performRecursive(cc.Node._stateCallbackType.onExitTransitionDidStart),b._performRecursive(cc.Node._stateCallbackType.onExit);this._sendCleanupToScene&&b&&b._performRecursive(cc.Node._stateCallbackType.cleanup)}this._runningScene=this._nextScene;cc.renderer.childrenOrderDirty=
!0;this._nextScene=null;a||null===this._runningScene||(this._runningScene._performRecursive(cc.Node._stateCallbackType.onEnter),this._runningScene._performRecursive(cc.Node._stateCallbackType.onEnterTransitionDidFinish))},setNotificationNode:function(a){cc.renderer.childrenOrderDirty=!0;this._notificationNode&&(this._notificationNode._performRecursive(cc.Node._stateCallbackType.onExitTransitionDidStart),this._notificationNode._performRecursive(cc.Node._stateCallbackType.onExit),this._notificationNode._performRecursive(cc.Node._stateCallbackType.cleanup));
if(this._notificationNode=a)this._notificationNode._performRecursive(cc.Node._stateCallbackType.onEnter),this._notificationNode._performRecursive(cc.Node._stateCallbackType.onEnterTransitionDidFinish)},getDelegate:function(){return this._projectionDelegate},setDelegate:function(a){this._projectionDelegate=a},setOpenGLView:null,setProjection:null,setViewport:null,getOpenGLView:null,getProjection:null,setAlphaBlending:null,isSendCleanupToScene:function(){return this._sendCleanupToScene},getRunningScene:function(){return this._runningScene},
getAnimationInterval:function(){return this._animationInterval},isDisplayStats:function(){return cc.profiler?cc.profiler.isShowingStats():!1},setDisplayStats:function(a){cc.profiler&&(a?cc.profiler.showStats():cc.profiler.hideStats())},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===a)this.end();else if(!(a>=c)){for(;c>a;){var d=b.pop();d.running&&(d._performRecursive(cc.Node._stateCallbackType.onExitTransitionDidStart),d._performRecursive(cc.Node._stateCallbackType.onExit));d._performRecursive(cc.Node._stateCallbackType.cleanup);c--}this._nextScene=b[b.length-1];this._sendCleanupToScene=!0}},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},_calculateMPF:function(){this._secondsPerFrame=(Date.now()-this._lastUpdate)/1E3}});cc.Director.EVENT_PROJECTION_CHANGED="director_projection_changed";cc.Director.EVENT_AFTER_UPDATE="director_after_update";cc.Director.EVENT_AFTER_VISIT="director_after_visit";
cc.Director.EVENT_AFTER_DRAW="director_after_draw";cc.DisplayLinkDirector=cc.Director.extend({invalid:!1,startAnimation:function(){this._nextDeltaTimeZero=!0;this.invalid=!1},mainLoop:function(){this._purgeDirectorInNextLoop?(this._purgeDirectorInNextLoop=!1,this.purgeDirector()):this.invalid||this.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(){cc.Director.firstUseDirector&&(cc.Director.firstUseDirector=!1,cc.Director.sharedDirector=new cc.DisplayLinkDirector,cc.Director.sharedDirector.init());return cc.Director.sharedDirector};cc.defaultFPS=60;cc.Director.PROJECTION_2D=0;cc.Director.PROJECTION_3D=1;cc.Director.PROJECTION_CUSTOM=3;cc.Director.PROJECTION_DEFAULT=cc.Director.PROJECTION_2D;cc.game.addEventListener(cc.game.EVENT_RENDERER_INITED,function(){if(cc._renderType===cc.game.RENDER_TYPE_CANVAS){var a=cc.Director.prototype;a.getProjection=function(a){return this._projection};a.setProjection=function(a){this._projection=a;cc.eventManager.dispatchEvent(this._eventProjectionChanged)};a.setDepthTest=function(){};a.setClearColor=function(a){cc.renderer._clearColor=a;cc.renderer._clearFillStyle="rgb("+a.r+","+a.g+","+a.b+")"};a.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)};a.getVisibleSize=function(){return this.getWinSize()};a.getVisibleOrigin=function(){return cc.p(0,0)}}else cc.Director._fpsImage=new Image,cc.Director._fpsImage.addEventListener("load",function(){cc.Director._fpsImageLoaded=!0}),cc._fpsImage&&(cc.Director._fpsImage.src=cc._fpsImage)});cc.game.addEventListener(cc.game.EVENT_RENDERER_INITED,function(){if(cc._renderType===cc.game.RENDER_TYPE_WEBGL){cc.DirectorDelegate=cc.Class.extend({updateProjection:function(){}});var a=cc.Director.prototype,b=function(a){if(a&&a._renderCmd){a._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty);var c=a._children;for(a=0;a<c.length;a++)b(c[a])}};cc.eventManager.addCustomListener(cc.Director.EVENT_PROJECTION_CHANGED,function(){for(var a=cc.director._scenesStack,d=0;d<a.length;d++)b(a[d])});
a.setProjection=function(a){var b=this._winSizeInPoints;this.setViewport();var c=this._openGLView,f=c._viewPortRect.x/c._scaleX,g=c._viewPortRect.y/c._scaleY;switch(a){case cc.Director.PROJECTION_2D:cc.kmGLMatrixMode(cc.KM_GL_PROJECTION);cc.kmGLLoadIdentity();c=cc.math.Matrix4.createOrthographicProjection(0,b.width,0,b.height,-1024,1024);cc.kmGLMultMatrix(c);cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW);cc.kmGLLoadIdentity();break;case cc.Director.PROJECTION_3D:var h=this.getZEye();new cc.math.Matrix4;c=
new cc.math.Matrix4;cc.kmGLMatrixMode(cc.KM_GL_PROJECTION);cc.kmGLLoadIdentity();var k=cc.math.Matrix4.createPerspectiveProjection(60,b.width/b.height,.1,2*h);cc.kmGLMultMatrix(k);h=new cc.math.Vec3(-f+b.width/2,-g+b.height/2,h);b=new cc.math.Vec3(-f+b.width/2,-g+b.height/2,0);f=new cc.math.Vec3(0,1,0);c.lookAt(h,b,f);cc.kmGLMultMatrix(c);cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW);cc.kmGLLoadIdentity();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){cc.renderer.setDepthTest(a)};a.setClearColor=function(a){cc.renderer._clearColor=a};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.setGLDefaultValues();cc.eventManager&&cc.eventManager.setEnabled(!0)};a.getVisibleSize=function(){return this._openGLView.getVisibleSize()};a.getVisibleOrigin=function(){return this._openGLView.getVisibleOrigin()};a.getZEye=function(){return this._winSizeInPoints.height/1.1546999375};a.setViewport=function(){var a=this._openGLView;if(a){var b=this._winSizeInPoints;a.setViewPortInPoints(-a._viewPortRect.x/a._scaleX,-a._viewPortRect.y/a._scaleY,b.width,b.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.setProjection(this._projection);cc._renderContext.clearColor(0,0,0,0)}}});(function(){var a=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},b=[];a.get=function(c,d,e,f,g,h,u){var k=b.pop();k?(k.prev=c,k.next=d,k.callback=e,k.target=f,k.priority=g,k.paused=h,k.markedForDeletion=u):k=new a(c,d,e,f,g,h,u);return k};a.put=function(a){a.prev=null;a.next=null;a.callback=null;a.target=null;a.priority=0;a.paused=!1;a.markedForDeletion=!1;20>b.length&&b.push(a)};var c=function(a,b,c,d){this.list=
a;this.entry=b;this.target=c;this.callback=d},d=[];c.get=function(a,b,e,f){var g=d.pop();g?(g.list=a,g.entry=b,g.target=e,g.callback=f):g=new c(a,b,e,f);return g};c.put=function(a){a.list=null;a.entry=null;a.target=null;a.callback=null;20>d.length&&d.push(a)};var e=function(a,b,c,d,e,f){this.timers=a;this.target=b;this.timerIndex=c;this.currentTimer=d;this.currentTimerSalvaged=e;this.paused=f},f=[];e.get=function(a,b,c,d,g,h){var k=f.pop();k?(k.timers=a,k.target=b,k.timerIndex=c,k.currentTimer=d,
k.currentTimerSalvaged=g,k.paused=h):k=new e(a,b,c,d,g,h);return k};e.put=function(a){a.timers=null;a.target=null;a.timerIndex=0;a.currentTimer=null;a.currentTimerSalvaged=!1;a.paused=!1;20>f.length&&f.push(a)};var g=function(){this._scheduler=null;this._elapsed=-1;this._useDelay=this._runForever=!1;this._interval=this._delay=this._repeat=this._timesExecuted=0;this._key=this._callback=this._target=null};cc.inject({initWithCallback:function(a,b,c,d,e,f,g){this._scheduler=a;this._target=c;this._callback=
b;g&&(this._key=g);this._elapsed=-1;this._interval=d;this._delay=f;this._useDelay=0<this._delay;this._repeat=e;this._runForever=this._repeat===cc.REPEAT_FOREVER;return!0},getInterval:function(){return this._interval},setInterval:function(a){this._interval=a},update:function(a){-1===this._elapsed?this._timesExecuted=this._elapsed=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._callback&&!this._runForever&&this._timesExecuted>this._repeat&&this.cancel()))},getCallback:function(){return this._callback},getKey:function(){return this._key},trigger:function(){this._target&&this._callback&&this._callback.call(this._target,this._elapsed)},cancel:function(){this._scheduler.unschedule(this._callback,this._target)}},g.prototype);
var h=[];g.get=function(){return h.pop()||new g};g.put=function(a){a._scheduler=null;a._elapsed=-1;a._runForever=!1;a._useDelay=!1;a._timesExecuted=0;a._repeat=0;a._delay=0;a._interval=0;a._target=null;a._callback=null;a._key=null;20>h.length&&h.push(a)};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){if(this._updateHashLocked){cc.log("warning: you CANNOT change update priority in scheduled function");e.entry.markedForDeletion=!1;e.entry.paused=d;return}this.unscheduleUpdate(b)}else{e.entry.markedForDeletion=
!1;e.entry.paused=d;return}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];for(var b=this._arrayForTimers,c=0,d=b.length;c<d;c++)if(b[c]===a){b.splice(c,1);break}e.put(a)},_removeUpdateFromHash:function(b){if(b=this._hashForUpdates[b.target.__instanceId]){for(var d=b.list,e=b.entry,f=0,g=d.length;f<g;f++)if(d[f]===e){d.splice(f,
1);break}delete this._hashForUpdates[b.target.__instanceId];a.put(e);c.put(b)}},_priorityIn:function(b,d,e,f,g){d=a.get(null,null,d,e,f,g,!1);if(b){g=b.length-1;for(var h=0;h<=g&&!(f<b[h].priority);h++);b.splice(h,0,d)}else b=[],b.push(d);this._hashForUpdates[e.__instanceId]=c.get(b,d,e,null);return b},_appendIn:function(b,d,e,f){d=a.get(null,null,d,e,0,f,!1);b.push(d);this._hashForUpdates[e.__instanceId]=c.get(b,d,e,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;var c=0;var d=this._updatesNegList;for(b=d.length;c<b;c++){var e=d[c];e.paused||e.markedForDeletion||e.callback(a)}c=0;d=this._updates0List;for(b=d.length;c<b;c++)e=d[c],e.paused||e.markedForDeletion||e.callback(a);c=0;d=this._updatesPosList;for(b=d.length;c<b;c++)e=d[c],e.paused||e.markedForDeletion||e.callback(a);b=this._arrayForTimers;for(c=0;c<b.length;c++){this._currentTarget=d=b[c];this._currentTargetSalvaged=
!1;if(!d.paused)for(d.timerIndex=0;d.timerIndex<d.timers.length;++d.timerIndex)d.currentTimer=d.timers[d.timerIndex],d.currentTimerSalvaged=!1,d.currentTimer.update(a),d.currentTimer=null;this._currentTargetSalvaged&&0===this._currentTarget.timers.length&&this._removeHashElement(this._currentTarget)}c=0;for(d=this._updatesNegList;c<d.length;)e=d[c],e.markedForDeletion?this._removeUpdateFromHash(e):c++;c=0;for(d=this._updates0List;c<d.length;)e=d[c],e.markedForDeletion?this._removeUpdateFromHash(e):
c++;c=0;for(d=this._updatesPosList;c<d.length;)e=d[c],e.markedForDeletion?this._removeUpdateFromHash(e):c++;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,f,h,u){if("function"!==typeof a){var k=a;a=b;b=k}if(4===arguments.length||5===arguments.length)u=f,h=d,d=cc.REPEAT_FOREVER,f=0;void 0===u&&(u=b.__instanceId+"");cc.assert(b,cc._LogInfos.Scheduler_scheduleCallbackForTarget_3);
(k=this._hashForTimers[b.__instanceId])?cc.assert(k.paused===h,""):(k=e.get(null,b,0,null,null,h),this._arrayForTimers.push(k),this._hashForTimers[b.__instanceId]=k);var m;if(null==k.timers)k.timers=[];else for(m=0;m<k.timers.length;m++){var n=k.timers[m];if(a===n._callback){cc.log(cc._LogInfos.Scheduler_scheduleCallbackForTarget,n.getInterval().toFixed(4),c.toFixed(4));n._interval=c;return}}n=g.get();n.initWithCallback(this,a,b,c,d,f,u);k.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._key;case "function":return a===b._callback}},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;e<f;e++){var h=d[e];if(this._getUnscheduleMark(a,h)){h!==c.currentTimer||c.currentTimerSalvaged||(c.currentTimerSalvaged=!0);d.splice(e,1);g.put(h);c.timerIndex>=e&&c.timerIndex--;0===d.length&&(this._currentTarget===c?this._currentTargetSalvaged=
!0:this._removeHashElement(c));break}}}},unscheduleUpdate:function(a){a&&(a=this._hashForUpdates[a.__instanceId])&&(this._updateHashLocked?a.entry.markedForDeletion=!0:this._removeUpdateFromHash(a.entry))},unscheduleAllForTarget:function(a){if(a){var b=this._hashForTimers[a.__instanceId];if(b){var c=b.timers;-1<c.indexOf(b.currentTimer)&&!b.currentTimerSalvaged&&(b.currentTimerSalvaged=!0);for(var d=0,e=c.length;d<e;d++)g.put(c[d]);c.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=this._arrayForTimers;for(b=c.length-1;0<=b;b--){var d=c[b];this.unscheduleAllForTarget(d.target)}if(0>a)for(b=0;b<this._updatesNegList.length;)c=this._updatesNegList.length,(d=this._updatesNegList[b])&&d.priority>=a&&this.unscheduleUpdate(d.target),c==this._updatesNegList.length&&b++;if(0>=a)for(b=0;b<this._updates0List.length;)c=
this._updates0List.length,(d=this._updates0List[b])&&this.unscheduleUpdate(d.target),c==this._updates0List.length&&b++;for(b=0;b<this._updatesPosList.length;)c=this._updatesPosList.length,(d=this._updatesPosList[b])&&d.priority>=a&&this.unscheduleUpdate(d.target),c==this._updatesPosList.length&&b++},isScheduled:function(a,b){cc.assert(a,"Argument callback must not be empty");cc.assert(b,"Argument target must be non-nullptr");var c=this._hashForTimers[b.__instanceId];if(!c)return!1;if(null!=c.timers){c=
c.timers;for(var d=0;d<c.length;++d)if(a===c[d]._callback)return!0}return!1},pauseAllTargets:function(){return this.pauseAllTargetsWithMinPriority(cc.Scheduler.PRIORITY_SYSTEM)},pauseAllTargetsWithMinPriority:function(a){var b=[],c,d=this._arrayForTimers,e;var f=0;for(e=d.length;f<e;f++)if(c=d[f])c.paused=!0,b.push(c.target);if(0>a)for(f=0;f<this._updatesNegList.length;f++)(c=this._updatesNegList[f])&&c.priority>=a&&(c.paused=!0,b.push(c.target));if(0>=a)for(f=0;f<this._updates0List.length;f++)if(c=
this._updates0List[f])c.paused=!0,b.push(c.target);for(f=0;f<this._updatesPosList.length;f++)(c=this._updatesPosList[f])&&c.priority>=a&&(c.paused=!0,b.push(c.target));return b},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.Scheduler.PRIORITY_NON_SYSTEM=cc.Scheduler.PRIORITY_SYSTEM+1})();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);var 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;f<
g;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();cc.view.getScaleX();cc.view.getScaleY();c.beginPath();c.moveTo(a.x,-a.y);c.lineTo(b.x,-b.y);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){d=d||!1;if(null!=a){if(3>a.length)throw Error("Polygon's point must greater than 2");var e=a[0];b=this._renderContext.getContext();cc.view.getScaleX();cc.view.getScaleY();b.beginPath();b.moveTo(e.x,-e.y);e=1;for(var f=a.length;e<f;e++)b.lineTo(a[e].x,-a[e].y);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();cc.view.getScaleX();cc.view.getScaleY();d.beginPath();d.arc(0|a.x,0|-a.y,b,-c,-(c-2*Math.PI),!1);e&&d.lineTo(0|a.x,0|-a.y);d.stroke()},drawQuadBezier:function(a,b,c,d){for(var e=this._cacheArray,f=e.length=0,g=0;g<d;g++)e.push(cc.p(Math.pow(1-f,2)*a.x+2*(1-f)*f*b.x+f*f*c.x,Math.pow(1-f,2)*a.y+2*(1-f)*f*b.y+f*f*c.y)),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;h<e;h++)f.push(cc.p(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,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.push(cc.p(d.x,d.y));this.drawPoly(f,e+1,!1,!1)},drawCatmullRom:function(a,b){this.drawCardinalSpline(a,.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;h<c+1;h++)f=h/c,1===f?(e=a.length-1,f=1):(e=0|f/g,f=(f-g*e)/g),e=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(e);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();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(.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(.3,c+", 0.8)");e.addColorStop(.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()}});cc.DrawingPrimitiveWebGL=cc.Class.extend({_renderContext:null,_initialized:!1,_shader:null,_colorLocation:"u_color",_colorArray:null,_pointSizeLocation:"u_pointSize",_pointSize:-1,ctor:function(a){null==a&&(a=cc._renderContext);if(!a instanceof WebGLRenderingContext)throw Error("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._shader._addUniformLocation(this._colorLocation),this._shader._addUniformLocation(this._pointSizeLocation),this._glProgramState=cc.GLProgramState.getOrCreateWithGLProgram(this._shader),this._initialized=!0)},drawInit:function(){this._initialized=!1},drawPoint:function(a){this.lazy_init();var b=this._renderContext;this._glProgramState.apply();this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();b.enableVertexAttribArray(cc.VERTEX_ATTRIB_POSITION);this._shader.setUniformLocationWith4fv(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._glProgramState.apply();this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();
c.enableVertexAttribArray(cc.VERTEX_ATTRIB_POSITION);this._shader.setUniformLocationWith4fv(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._glProgramState.apply();this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();c.enableVertexAttribArray(cc.VERTEX_ATTRIB_POSITION);this._shader.setUniformLocationWith4fv(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._glProgramState.apply();
this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();b.enableVertexAttribArray(cc.VERTEX_ATTRIB_POSITION);this._shader.setUniformLocationWith4fv(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._glProgramState.apply();this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();b.enableVertexAttribArray(cc.VERTEX_ATTRIB_POSITION);this._shader.setUniformLocationWith4fv(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;e=new Float32Array(2*(d+2));for(var h=0;h<=d;h++){var k=h*g,m=b*Math.sin(k+c)+a.y;e[2*h]=b*Math.cos(k+c)+a.x;e[2*h+1]=m}e[2*(d+1)]=a.x;e[2*(d+1)+1]=a.y;a=this._renderContext;this._glProgramState.apply();this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();a.enableVertexAttribArray(cc.VERTEX_ATTRIB_POSITION);this._shader.setUniformLocationWith4fv(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;g<d;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._glProgramState.apply();this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();a.enableVertexAttribArray(cc.VERTEX_ATTRIB_POSITION);this._shader.setUniformLocationWith4fv(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;h<e;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._glProgramState.apply();this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();a.enableVertexAttribArray(cc.VERTEX_ATTRIB_POSITION);this._shader.setUniformLocationWith4fv(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,.5,b)},drawCardinalSpline:function(a,b,c){this.lazy_init();for(var d=new Float32Array(2*(c+1)),e,f,g=1/a.length,h=0;h<c+1;h++)f=h/c,1===f?(e=a.length-1,f=1):(e=0|f/g,f=(f-g*e)/g),e=cc.cardinalSplineAt(cc.getControlPointAt(a,e-1),
cc.getControlPointAt(a,e),cc.getControlPointAt(a,e+1),cc.getControlPointAt(a,e+2),b,f),d[2*h]=e.x,d[2*h+1]=e.y;a=this._renderContext;this._glProgramState.apply();this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();a.enableVertexAttribArray(cc.VERTEX_ATTRIB_POSITION);this._shader.setUniformLocationWith4fv(this._colorLocation,this._colorArray);b=a.createBuffer();a.bindBuffer(a.ARRAY_BUFFER,b);a.bufferData(a.ARRAY_BUFFER,d,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)}});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);cc.defineGetterSetter(a,"string",a.getString,a.setString);cc.defineGetterSetter(a,"textAlign",a.getHorizontalAlignment,a.setHorizontalAlignment);cc.defineGetterSetter(a,"verticalAlign",a.getVerticalAlignment,a.setVerticalAlignment);cc.defineGetterSetter(a,"fontSize",a.getFontSize,a.setFontSize);cc.defineGetterSetter(a,
"fontName",a.getFontName,a.setFontName);cc.defineGetterSetter(a,"font",a._getFont,a._setFont);cc.defineGetterSetter(a,"boundingWidth",a._getBoundingWidth,a._setBoundingWidth);cc.defineGetterSetter(a,"boundingHeight",a._getBoundingHeight,a._setBoundingHeight);cc.defineGetterSetter(a,"fillStyle",a._getFillStyle,a.setFontFillColor);cc.defineGetterSetter(a,"strokeStyle",a._getStrokeStyle,a._setStrokeStyle);cc.defineGetterSetter(a,"lineWidth",a._getLineWidth,a._setLineWidth);cc.defineGetterSetter(a,"shadowOffsetX",
a._getShadowOffsetX,a._setShadowOffsetX);cc.defineGetterSetter(a,"shadowOffsetY",a._getShadowOffsetY,a._setShadowOffsetY);cc.defineGetterSetter(a,"shadowOpacity",a._getShadowOpacity,a._setShadowOpacity);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,_onCacheCanvasMode:!0,_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){a=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=a;this._renderCmd._setColorsString();this._renderCmd._updateTexture();this._setUpdateTextureDirty();
this._scaleX=this._scaleY=1/cc.view.getDevicePixelRatio();return!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"<cc.LabelTTF | FontName ="+this._fontName+" FontSize = "+this._fontSize.toFixed(1)+">"},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){this._updateWithTextDefinition(b,!1);this.string=a;return!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||.5;!1===this._shadowEnabled&&(this._shadowEnabled=!0);var e=this._shadowOffset;if(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:.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);if(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;if(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;if(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;if(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;this._lineHeight=a.lineHeight?a.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;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;if(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;b.fillStyle=cc.color(a.r,a.g,a.b);return b},getScale:function(){this._scaleX!==this._scaleY&&cc.log(cc._LogInfos.Node_getScale);return this._scaleX*cc.view.getDevicePixelRatio()},
setScale:function(a,b){var c=cc.view.getDevicePixelRatio();this._scaleX=a/c;this._scaleY=(b||0===b?b:a)/c;this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)},getScaleX:function(){return this._scaleX*cc.view.getDevicePixelRatio()},setScaleX:function(a){this._scaleX=a/cc.view.getDevicePixelRatio();this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)},getScaleY:function(){return this._scaleY*cc.view.getDevicePixelRatio()},setScaleY:function(a){this._scaleY=a/cc.view.getDevicePixelRatio();
this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)},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){if(void 0===b){var c=a.width;b=a.height}else c=a;if(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){if(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(){this._needUpdateTexture&&this._renderCmd._updateTTF();
var a=cc.view.getDevicePixelRatio();return cc.size(this._contentSize.width/a,this._contentSize.height/a)},_getWidth:function(){this._needUpdateTexture&&this._renderCmd._updateTTF();return this._contentSize.width/cc.view.getDevicePixelRatio()},_getHeight:function(){this._needUpdateTexture&&this._renderCmd._updateTTF();return this._contentSize.height/cc.view.getDevicePixelRatio()},setTextureRect:function(a,b,c){this._rectRotated=b||!1;this.setContentSize(c||a);b=this._rect;b.x=a.x;b.y=a.y;b.width=a.width;
b.height=a.height;this._renderCmd._setTextureCoords(a,!1);c=this._unflippedOffsetPositionFromCenter.x;var d=this._unflippedOffsetPositionFromCenter.y;this._flippedX&&(c=-c);this._flippedY&&(d=-d);this._offsetPosition.x=c+(a.width-b.width)/2;this._offsetPosition.y=d+(a.height-b.height)/2},setDrawMode:function(a){this._onCacheCanvasMode=a},_createRenderCmd:function(){return cc._renderType===cc.game.RENDER_TYPE_WEBGL?new cc.LabelTTF.WebGLRenderCmd(this):this._onCacheCanvasMode?new cc.LabelTTF.CacheCanvasRenderCmd(this):
new cc.LabelTTF.CanvasRenderCmd(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.LabelTTF.__labelHeightDiv=document.createElement("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):window.addEventListener("load",function(){this.removeEventListener("load",arguments.callee,!1);document.body.appendChild(cc.LabelTTF.__labelHeightDiv)},!1);
cc.LabelTTF.__getFontHeightByDiv=function(a,b){var c=cc.LabelTTF.__labelHeightDiv;if(a instanceof cc.FontDefinition){var d=cc.LabelTTF.__fontHeightCache[a._getCanvasFontStr()];if(0<d)return d;c.innerHTML="ajghl~!";c.style.fontFamily=a.fontName;c.style.fontSize=a.fontSize+"px";c.style.fontStyle=a.fontStyle;c.style.fontWeight=a.fontWeight;d=c.clientHeight;cc.LabelTTF.__fontHeightCache[a._getCanvasFontStr()]=d}else{d=cc.LabelTTF.__fontHeightCache[a+"."+b];if(0<d)return d;c.innerHTML="ajghl~!";c.style.fontFamily=
a;c.style.fontSize=b+"px";d=c.clientHeight;cc.LabelTTF.__fontHeightCache[a+"."+b]=d}c.innerHTML="";return d};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\-¿¡«À-ÖØ-öø-ʯ\u0300-\u034e\u0350-\u036FͰ-ԯ\u2011‵-‷‹⁅]+|\S)/;cc.LabelTTF._symbolRex=/^[!,.:;}\]%\?>、‘“》»？。，！\u2010′-‴›‼⁆⁇-⁉]/;cc.LabelTTF._lastWordRex=/([a-zA-Z0-9\-¿¡«À-ÖØ-öø-ʯ\u0300-\u034e\u0350-\u036FͰ-ԯ\u2011‵-‷‹⁅]+|\S)$/;cc.LabelTTF._lastEnglish=/[a-zA-Z0-9\-¿¡«À-ÖØ-öø-ʯ\u0300-\u034e\u0350-\u036FͰ-ԯ\u2011‵-‷‹⁅]+$/;
cc.LabelTTF._firsrEnglish=/^[a-zA-Z0-9\-¿¡«À-ÖØ-öø-ʯ\u0300-\u034e\u0350-\u036FͰ-ԯ\u2011‵-‷‹⁅]/;
(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;this._status=[];this._renderingIndex=0;this._canUseDirtyRegion=!0};var a=cc.LabelTTF.RenderCmd.prototype;a.constructor=cc.LabelTTF.RenderCmd;a._labelCmdCtor=cc.LabelTTF.RenderCmd;a._setFontStyle=
function(a,b,e,f){if(a instanceof cc.FontDefinition)this._fontStyleStr=a._getCanvasFontStr(),this._fontClientHeight=cc.LabelTTF.__getFontHeightByDiv(a);else{var c=b*cc.view.getDevicePixelRatio();this._fontStyleStr=e+" "+f+" "+c+"px '"+a+"'";this._fontClientHeight=cc.LabelTTF.__getFontHeightByDiv(a,b)}};a._getFontStyle=function(){return this._fontStyleStr};a._getFontClientHeight=function(){return this._fontClientHeight};a._updateColor=function(){this._setColorsString();this._updateTexture()};a._setColorsString=
function(){var a=this._displayedColor,b=this._node,e=b._shadowColor||this._displayedColor,f=b._strokeColor,g=b._textFillColor,h=a.r/255,k=a.g/255;a=a.b/255;this._shadowColorStr="rgba("+(0|h*e.r)+","+(0|k*e.g)+","+(0|a*e.b)+","+b._shadowOpacity+")";this._fillColorStr="rgba("+(0|h*g.r)+","+(0|k*g.g)+","+(0|a*g.b)+", 1)";this._strokeColorStr="rgba("+(0|h*f.r)+","+(0|k*f.g)+","+(0|a*f.b)+", 1)"};var b=new cc.Rect;a.getLocalBB=function(){var a=this._node;b.x=b.y=0;var d=cc.view.getDevicePixelRatio();b.width=
a._getWidth()*d;b.height=a._getHeight()*d;return b};a._updateTTF=function(){var a=this._node,b=cc.view.getDevicePixelRatio(),e=a._dimensions.width*b,f,g,h=this._lineWidths;h.length=0;this._isMultiLine=!1;this._measureConfig();var k={};if(0!==e)for(this._strings=a._string.split("\n"),f=0;f<this._strings.length;f++)this._checkWarp(this._strings,f,e);else for(this._strings=a._string.split("\n"),f=0,g=this._strings.length;f<g;f++)if(this._strings[f]){var m=this._measure(this._strings[f]);h.push(m);k[this._strings[f]]=
m}else h.push(0);1<this._strings.length&&(this._isMultiLine=!0);g=f=0;a._strokeEnabled&&(f=g=2*a._strokeSize);a._shadowEnabled&&(m=a._shadowOffset,f+=2*Math.abs(m.x),g+=2*Math.abs(m.y));0===e?this._isMultiLine?b=cc.size(Math.ceil(Math.max.apply(Math,h)+f),Math.ceil(this._fontClientHeight*b*this._strings.length+g)):(m=k[a._string],!m&&a._string&&(m=this._measure(a._string)),b=cc.size(Math.ceil((m?m:0)+f),Math.ceil(this._fontClientHeight*b+g))):b=0===a._dimensions.height?this._isMultiLine?cc.size(Math.ceil(e+
f),Math.ceil(a.getLineHeight()*b*this._strings.length+g)):cc.size(Math.ceil(e+f),Math.ceil(a.getLineHeight()*b+g)):cc.size(Math.ceil(e+f),Math.ceil(a._dimensions.height*b+g));"normal"!==a._getFontStyle()&&(b.width=Math.ceil(b.width+.3*a._fontSize));a.setContentSize(b);a._strokeShadowOffsetX=f;a._strokeShadowOffsetY=g;a=a._anchorPoint;this._anchorPointInPoints.x=Math.ceil(.5*f+(b.width-f)*a.x);this._anchorPointInPoints.y=Math.ceil(.5*g+(b.height-g)*a.y)};a._saveStatus=function(){var a=this._node,b=
cc.view.getDevicePixelRatio(),e=a._strokeShadowOffsetX,f=a._strokeShadowOffsetY,g=a._contentSize.height-f,h=a._vAlignment,k=a._hAlignment,m=.5*e;f=g+.5*f;var n=0,p=0,r=[];e=a._contentSize.width-e;a=a.getLineHeight()*b;b=(a-this._fontClientHeight*b)/2;n=k===cc.TEXT_ALIGNMENT_RIGHT?n+e:k===cc.TEXT_ALIGNMENT_CENTER?n+e/2:n+0;if(this._isMultiLine)for(k=this._strings.length,h===cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM?p=a-2*b+g-a*k:h===cc.VERTICAL_TEXT_ALIGNMENT_CENTER&&(p=(a-2*b)/2+(g-a*k)/2),h=0;h<k;h++)r.push(-g+
(a*h+b)+p);else h!==cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM&&(p=h===cc.VERTICAL_TEXT_ALIGNMENT_TOP?p-g:p-.5*g),r.push(p);g={contextTransform:cc.p(m,f),xOffset:n,OffsetYArray:r};this._status.push(g)};a._drawTTFInCanvas=function(a){if(a){var b=this._status.pop();a.setTransform(1,0,0,1,b.contextTransform.x,b.contextTransform.y);this.drawLabels(a,b.xOffset,b.OffsetYArray)}};a._checkWarp=function(a,b,e){var c=a[b],d=this._measure(c);if(d>e&&1<c.length){for(var h=e/d*c.length|0,k=c.substr(h),m=d-this._measure(k),
n,p=0,r=0;m>e&&100>r++;)h*=e/m,h|=0,k=c.substr(h),m=d-this._measure(k);for(r=0;m<e&&100>r++;)k&&(p=(n=cc.LabelTTF._wordRex.exec(k))?n[0].length:1,n=k),h+=p,k=c.substr(h),m=d-this._measure(k);h-=p;0===h&&(h=1,n=n.substr(1));e=c.substr(0,h);cc.LabelTTF.wrapInspection&&cc.LabelTTF._symbolRex.test(n||k)&&(d=cc.LabelTTF._lastWordRex.exec(e),h-=d?d[0].length:0,0===h&&(h=1),n=c.substr(h),e=c.substr(0,h));cc.LabelTTF._firsrEnglish.test(n)&&(d=cc.LabelTTF._lastEnglish.exec(e))&&e!==d[0]&&(h-=d[0].length,n=
c.substr(h),e=c.substr(0,h));a[b]=n||k;a.splice(b,0,e)}};a.updateStatus=function(){this._dirtyFlag&cc.Node._dirtyFlags.textDirty&&this._updateTexture();this.originUpdateStatus()};a._syncStatus=function(a){var b=cc.Node._dirtyFlags,c=this._dirtyFlag;c&b.textDirty&&this._updateTexture();this._originSyncStatus(a);(cc._renderType===cc.game.RENDER_TYPE_WEBGL||c&b.transformDirty)&&this.transform(a)};a.drawLabels=function(a,b,e){var c=this._node;if(c._shadowEnabled){var d=c._shadowOffset;a.shadowColor=this._shadowColorStr;
a.shadowOffsetX=d.x;a.shadowOffsetY=-d.y;a.shadowBlur=c._shadowBlur}d=c._hAlignment;var h=c._vAlignment,k=c._strokeSize;a.font!==this._fontStyleStr&&(a.font=this._fontStyleStr);a.fillStyle=this._fillColorStr;if(c=c._strokeEnabled)a.lineWidth=2*k,a.strokeStyle=this._strokeColorStr;a.textBaseline=cc.LabelTTF._textBaseline[h];a.textAlign=cc.LabelTTF._textAlign[d];d=this._strings.length;for(h=0;h<d;h++)k=this._strings[h],c&&(a.lineJoin="round",a.strokeText(k,b,e[h])),a.fillText(k,b,e[h]);cc.g_NumberOfDraws++}})();
(function(){cc.LabelTTF.CacheRenderCmd=function(){this._labelCmdCtor();var a=this._labelCanvas=document.createElement("canvas");a.width=1;a.height=1;this._labelContext=a.getContext("2d")};cc.LabelTTF.CacheRenderCmd.prototype=Object.create(cc.LabelTTF.RenderCmd.prototype);cc.inject(cc.LabelTTF.RenderCmd.prototype,cc.LabelTTF.CacheRenderCmd.prototype);var a=cc.LabelTTF.CacheRenderCmd.prototype;a.constructor=cc.LabelTTF.CacheRenderCmd;a._cacheCmdCtor=cc.LabelTTF.CacheRenderCmd;a._updateTexture=function(){this._dirtyFlag^=
this._dirtyFlag&cc.Node._dirtyFlags.textDirty;var a=this._node;a._needUpdateTexture=!1;var c=a._contentSize;this._updateTTF();var d=c.width,e=c.height,f=this._labelContext,g=this._labelCanvas;if(!a._texture){var h=new cc.Texture2D;h.initWithElement(this._labelCanvas);a.setTexture(h)}if(0===a._string.length)return g.width=1,g.height=c.height||1,a._texture&&(a._texture._htmlElementObj=this._labelCanvas,a._texture.handleLoadedTexture()),a.setTextureRect(cc.rect(0,0,1,c.height)),!0;f.font=this._fontStyleStr;
c=g.width===d&&g.height===e;g.width=d;g.height=e;c&&f.clearRect(0,0,d,e);this._saveStatus();this._drawTTFInCanvas(f);a._texture&&(a._texture._htmlElementObj=this._labelCanvas,a._texture.handleLoadedTexture());a.setTextureRect(cc.rect(0,0,d,e));return!0};a._measureConfig=function(){this._labelContext.font=this._fontStyleStr};a._measure=function(a){return a?this._labelContext.measureText(a).width:0}})();
(function(){cc.LabelTTF.CacheCanvasRenderCmd=function(a){this._spriteCmdCtor(a);this._cacheCmdCtor()};var a=cc.LabelTTF.CacheCanvasRenderCmd.prototype=Object.create(cc.Sprite.CanvasRenderCmd.prototype);cc.inject(cc.LabelTTF.CacheRenderCmd.prototype,a);a.constructor=cc.LabelTTF.CacheCanvasRenderCmd})();
(function(){cc.LabelTTF.CanvasRenderCmd=function(a){this._spriteCmdCtor(a);this._labelCmdCtor()};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._measureConfig=function(){};a._measure=function(a){if(a){var b=cc._renderContext.getContext();b.font=this._fontStyleStr;return b.measureText(a).width}return 0};
a._updateTexture=function(){this._dirtyFlag^=this._dirtyFlag&cc.Node._dirtyFlags.textDirty;var a=this._node,c=a._contentSize;this._updateTTF();var d=c.width,e=c.height;if(0===a._string.length)return a.setTextureRect(cc.rect(0,0,1,c.height)),!0;this._saveStatus();a.setTextureRect(cc.rect(0,0,d,e));return!0};a.rendering=function(a){var b=cc.view.getScaleX(),d=cc.view.getScaleY();a=a||cc._renderContext;var e=a.getContext();if(e){var f=this._node;a.computeRealOffsetY();if(!(0>=this._status.length)){var g=
this._renderingIndex>=this._status.length?this._renderingIndex-this._status.length:this._renderingIndex,h=this._status[g];this._renderingIndex=g+1;var k=f._offsetPosition.x;g=-f._offsetPosition.y-f._rect.height;var m=this._displayedOpacity/255;a.setTransform(this._worldTransform,b,d);a.setCompositeOperation(this._blendFuncStr);a.setGlobalAlpha(m);a.save();f._flippedX&&(k=-k-f._rect.width,e.scale(-1,1));f._flippedY&&(g=f._offsetPosition.y,e.scale(1,-1));b=h.xOffset+h.contextTransform.x+k*b;f=[];k=
this._strings.length;for(m=0;m<k;m++)f.push(h.OffsetYArray[m]+h.contextTransform.y+g*d);this.drawLabels(e,b,f);a.restore()}}}})();(function(){cc.LabelTTF.WebGLRenderCmd=function(a){this._spriteCmdCtor(a);this._cacheCmdCtor()};var a=cc.LabelTTF.WebGLRenderCmd.prototype=Object.create(cc.Sprite.WebGLRenderCmd.prototype);cc.inject(cc.LabelTTF.CacheRenderCmd.prototype,a);a.constructor=cc.LabelTTF.WebGLRenderCmd;a._updateColor=function(){}})();cc.HashElement=function(){this.actions=[];this.target=null;this.actionIndex=0;this.currentAction=null;this.lock=this.paused=!1};
cc.ActionManager=cc.Class.extend({_elementPool:[],_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},_getElement:function(a,b){var c=this._elementPool.pop();c||(c=new cc.HashElement);c.target=a;c.paused=!!b;return c},_putElement:function(a){a.actions.length=0;a.actionIndex=0;a.currentAction=null;a.paused=!1;a.target=null;a.lock=!1;this._elementPool.push(a)},
addAction:function(a,b,c){if(!a)throw Error("cc.ActionManager.addAction(): action must be non-null");if(!b)throw Error("cc.ActionManager.addAction(): target must be non-null");var d=this._hashTargets[b.__instanceId];d?d.actions||(d.actions=[]):(d=this._getElement(b,c),this._hashTargets[b.__instanceId]=d,this._arrayTargets.push(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&&(c.actions.length=0,this._deleteHashElement(c))}},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);b.actionIndex>=c&&b.actionIndex--;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;e<d;++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: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.splice(a,1);b.actionIndex>=a&&b.actionIndex--;0===b.actions.length&&this._deleteHashElement(b)},_deleteHashElement:function(a){var b=!1;if(a&&!a.lock&&this._hashTargets[a.target.__instanceId]){delete this._hashTargets[a.target.__instanceId];b=this._arrayTargets;for(var c=0,d=b.length;c<d;c++)if(b[c]===a){b.splice(c,1);break}this._putElement(a);b=!0}return b},
update:function(a){for(var b=this._arrayTargets,c,d=0;d<b.length;d++){c=this._currentTarget=b[d];if(!c.paused&&c.actions){c.lock=!0;for(c.actionIndex=0;c.actionIndex<c.actions.length;c.actionIndex++)if(c.currentAction=c.actions[c.actionIndex],c.currentAction){c.currentAction.step(a*(c.currentAction._speedMethod?c.currentAction._speed:1));if(c.currentAction&&c.currentAction.isDone()){c.currentAction.stop();var e=c.currentAction;c.currentAction=null;this.removeAction(e)}c.currentAction=null}c.lock=
!1}0===c.actions.length&&this._deleteHashElement(c)&&d--}}});cc.profiler=function(){var a=!1,b=!1,c=0,d=0,e=0,f=0,g=null,h=document.createElement("div"),k=document.createElement("div"),m=document.createElement("div"),n=document.createElement("div"),p=10,r=[0,10,20,30],t=[0,0,0,0],u=3,v=0,x=0;n.id="fps";n.style.position="absolute";n.style.padding="3px";n.style.textAlign="left";n.style.backgroundColor="rgb(0, 0, 34)";n.style.bottom=cc.DIRECTOR_STATS_POSITION.y+"0px";n.style.left=cc.DIRECTOR_STATS_POSITION.x+"px";n.style.width="45px";n.style.height="80px";for(var w=
[m,k,h],y=0;3>y;++y){var z=w[y].style;z.color="rgb(0, 255, 255)";z.font="bold 12px Helvetica, Arial";z.lineHeight="20px";z.width="100%";n.appendChild(w[y])}var A=function(){e=cc.director.getSecondsPerFrame();c++;f+=cc.director.getDeltaTime();if(f>cc.DIRECTOR_FPS_INTERVAL){d=c/f;f=c=0;if(B.onFrameRateChange){var b=d,g=r.length-1,n=g;v++;for(x+=b;0<=n;n--)if(b>=r[n]){t[n]++;break}if(v>=p){var w=x/p;for(n=g;0<n;n--)if(b=t[n]/p,.6<=b&&w>=r[n]){n!=u&&(u=n,B.onFrameRateChange&&B.onFrameRateChange(w.toFixed(2)));
break}x=v=_changeCount=0;for(n=g;0<n;n--)t[n]=0}}a&&(g=cc._renderType===cc.game.RENDER_TYPE_CANVAS?"\n canvas":"\n webgl",k.innerHTML=e.toFixed(3),h.innerHTML=d.toFixed(1).toString()+g,m.innerHTML=(0|cc.g_NumberOfDraws).toString())}},B={onFrameRateChange:null,getSecondsPerFrame:function(){return e},getFrameRate:function(){return d},setProfileDuration:function(a){!isNaN(a)&&0<a&&(p=a/cc.DIRECTOR_FPS_INTERVAL)},resumeProfiling:function(){cc.eventManager.addListener(g,1)},stopProfiling:function(){cc.eventManager.removeListener(g)},
isShowingStats:function(){return a},showStats:function(){b||this.init();null===n.parentElement&&cc.container.appendChild(n);a=!0},hideStats:function(){a=!1;n.parentElement===cc.container&&cc.container.removeChild(n)},init:function(){b||(g=cc.eventManager.addCustomListener(cc.Director.EVENT_AFTER_VISIT,A),b=!0)}};return B}();cc.math=cc.math||{};cc.math.EPSILON=.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();this.x*=a;this.y*=a;return this};a.math.Vec2.add=function(a,b,e){a.x=b.x+e.x;a.y=b.y+e.y;return a};b.add=function(a){this.x+=a.x;this.y+=
a.y;return this};b.dot=function(a){return this.x*a.x+this.y*a.y};a.math.Vec2.subtract=function(a,b,e){a.x=b.x-e.x;a.y=b.y-e.y;return a};b.subtract=function(a){this.x-=a.x;this.y-=a.y;return this};b.transform=function(a){var b=this.x,c=this.y;this.x=b*a.mat[0]+c*a.mat[3]+a.mat[6];this.y=b*a.mat[1]+c*a.mat[4]+a.mat[7];return this};a.math.Vec2.scale=function(a,b,e){a.x=b.x*e;a.y=b.y*e;return a};b.scale=function(a){this.x*=a;this.y*=a;return 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.math.Vec3=a.kmVec3=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){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);return 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();this.x*=a;this.y*=a;this.z*=a;return this};b.cross=function(a){var b=this.x,c=this.y,f=this.z;this.x=c*a.z-f*a.y;this.y=f*a.x-b*a.z;this.z=b*a.y-c*a.x;return this};b.dot=function(a){return this.x*a.x+this.y*a.y+this.z*a.z};b.add=function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this};b.subtract=function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this};b.transform=function(a){var b=this.x,c=this.y,f=this.z;a=a.mat;this.x=b*
a[0]+c*a[4]+f*a[8]+a[12];this.y=b*a[1]+c*a[5]+f*a[9]+a[13];this.z=b*a[2]+c*a[6]+f*a[10]+a[14];return this};b.transformNormal=function(a){var b=this.x,c=this.y,f=this.z;a=a.mat;this.x=b*a[0]+c*a[4]+f*a[8];this.y=b*a[1]+c*a[5]+f*a[9];this.z=b*a[2]+c*a[6]+f*a[10];return this};b.transformCoord=function(b){var c=new a.math.Vec4(this.x,this.y,this.z,1);c.transform(b);this.x=c.x/c.w;this.y=c.y/c.w;this.z=c.z/c.w;return this};b.scale=function(a){this.x*=a;this.y*=a;this.z*=a;return this};b.equals=function(b){var c=
a.math.EPSILON;return this.x<b.x+c&&this.x>b.x-c&&this.y<b.y+c&&this.y>b.y-c&&this.z<b.z+c&&this.z>b.z-c};b.inverseTransform=function(b){b=b.mat;var c=new a.math.Vec3(this.x-b[12],this.y-b[13],this.z-b[14]);this.x=c.x*b[0]+c.y*b[1]+c.z*b[2];this.y=c.x*b[4]+c.y*b[5]+c.z*b[6];this.z=c.x*b[8]+c.y*b[9]+c.z*b[10];return this};b.inverseTransformNormal=function(a){var b=this.x,c=this.y,f=this.z;a=a.mat;this.x=b*a[0]+c*a[1]+f*a[2];this.y=b*a[4]+c*a[5]+f*a[6];this.z=b*a[8]+c*a[9]+f*a[10];return this};b.assignFrom=
function(a){if(!a)return this;this.x=a.x;this.y=a.y;this.z=a.z;return this};a.math.Vec3.zero=function(a){a.x=a.y=a.z=0;return a};b.toTypeArray=function(){var a=new Float32Array(3);a[0]=this.x;a[1]=this.y;a[2]=this.z;return 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){if(!a)return this;this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return 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();this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this};b.scale=function(a){this.normalize();this.x*=a;this.y*=a;this.z*=a;this.w*=a;return 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,c=this.y,f=this.z,g=this.w;a=a.mat;this.x=b*a[0]+c*a[4]+f*a[8]+g*a[12];this.y=b*a[1]+c*a[5]+f*a[9]+g*a[13];this.z=b*a[2]+c*a[6]+f*a[10]+g*a[14];this.w=b*a[3]+c*a[7]+f*a[11]+g*a[15];return this};a.math.Vec4.transformArray=function(b,d){for(var c=[],f=0;f<b.length;f++){var g=new a.math.Vec4(b[f]);g.transform(d);c.push(g)}return c};b.equals=function(b){var c=a.math.EPSILON;return this.x<b.x+c&&this.x>b.x-c&&this.y<b.y+c&&this.y>b.y-c&&
this.z<b.z+c&&this.z>b.z-c&&this.w<b.w+c&&this.w>b.w-c};b.assignFrom=function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this};b.toTypeArray=function(){var a=new Float32Array(4);a[0]=this.x;a[1]=this.y;a[2]=this.z;a[3]=this.w;return 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 c=this.start.x,g=this.start.y,h=this.start.x+this.dir.x,k=this.start.y+this.dir.y,m=b.x,n=b.y,p=d.x,r=d.y,t=(r-n)*(h-c)-(p-m)*(k-g);if(t>-a.math.EPSILON&&
t<a.math.EPSILON)return!1;n=((p-m)*(g-n)-(r-n)*(c-m))/t;m=c+n*(h-c);n=g+n*(k-g);if(m<Math.min(b.x,d.x)-a.math.EPSILON||m>Math.max(b.x,d.x)+a.math.EPSILON||n<Math.min(b.y,d.y)-a.math.EPSILON||n>Math.max(b.y,d.y)+a.math.EPSILON||m<Math.min(c,h)-a.math.EPSILON||m>Math.max(c,h)+a.math.EPSILON||n<Math.min(g,k)-a.math.EPSILON||n>Math.max(g,k)+a.math.EPSILON)return!1;e.x=m;e.y=n;return!0};a.math.Ray2.prototype.intersectTriangle=function(c,d,e,f,g){var h=new a.math.Vec2,k=new a.math.Vec2,m=new a.math.Vec2,
n=1E4,p=!1;if(this.intersectLineSegment(c,d,h)){p=!0;var r=h.subtract(this.start).length();r<n&&(k.x=h.x,k.y=h.y,n=r,b(c,d,m))}this.intersectLineSegment(d,e,h)&&(p=!0,r=h.subtract(this.start).length(),r<n&&(k.x=h.x,k.y=h.y,n=r,b(d,e,m)));this.intersectLineSegment(e,c,h)&&(p=!0,r=h.subtract(this.start).length(),r<n&&(k.x=h.x,k.y=h.y,b(e,c,m)));p&&(f.x=k.x,f.y=k.y,g&&(g.x=m.x,g.y=m.y));return p}})(cc);window.Uint16Array=window.Uint16Array||Array;window.Float32Array=window.Float32Array||Array;
(function(a){a.math.Matrix3=function(a){this.mat=a&&a.mat?new Float32Array(a.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;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];return 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];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;return this};b.identity=function(){var a=this.mat;a[1]=a[2]=a[3]=a[5]=a[6]=a[7]=0;a[0]=a[4]=a[8]=1;return this};var c=new a.math.Matrix3;b.inverse=function(a){if(0===a)return this;c.assignFrom(this);a=1/a;this.adjugate();this.multiplyScalar(a);return 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];a[1]=a[3];a[2]=h;a[3]=b;a[5]=
k;a[6]=c;a[7]=g;return this};b.determinant=function(){var a=this.mat,b=a[0]*a[4]*a[8]+a[1]*a[5]*a[6]+a[2]*a[3]*a[7];return b-=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 d=b[1],h=b[2],k=b[3],m=b[4],n=b[5],p=b[6],r=b[7],t=b[8],u=c[0],v=c[1],x=c[2],w=c[3],y=c[4],z=c[5],A=c[6],B=c[7];c=c[8];b[0]=a*u+k*v+p*x;b[1]=d*u+m*v+r*x;b[2]=h*u+n*v+t*x;b[3]=h*u+n*v+t*x;b[4]=d*w+m*y+r*z;b[5]=h*w+n*y+t*z;b[6]=a*A+k*B+p*c;b[7]=d*A+m*B+r*c;b[8]=h*A+n*B+t*c;
return this};b.multiplyScalar=function(a){var b=this.mat;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;return this};a.math.Matrix3.rotationAxisAngle=function(b,c){var d=Math.cos(c),e=Math.sin(c),h=new a.math.Matrix3,k=h.mat;k[0]=d+b.x*b.x*(1-d);k[1]=b.z*e+b.y*b.x*(1-d);k[2]=-b.y*e+b.z*b.x*(1-d);k[3]=-b.z*e+b.x*b.y*(1-d);k[4]=d+b.y*b.y*(1-d);k[5]=b.x*e+b.z*b.y*(1-d);k[6]=b.y*e+b.x*b.z*(1-d);k[7]=-b.x*e+b.y*b.z*(1-d);k[8]=d+b.z*b.z*(1-d);return 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;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];return this};b.equals=function(b){if(this===b)return!0;var c=a.math.EPSILON,d=this.mat;b=b.mat;for(var g=0;9>g;++g)if(!(d[g]+c>b[g]&&d[g]-c<b[g]))return!1;return!0};a.math.Matrix3.createByRotationX=function(b){var c=new a.math.Matrix3,d=c.mat;d[0]=1;d[1]=0;d[2]=0;d[3]=0;d[4]=Math.cos(b);d[5]=Math.sin(b);d[6]=0;
d[7]=-Math.sin(b);d[8]=Math.cos(b);return c};a.math.Matrix3.createByRotationY=function(b){var c=new a.math.Matrix3,d=c.mat;d[0]=Math.cos(b);d[1]=0;d[2]=-Math.sin(b);d[3]=0;d[4]=1;d[5]=0;d[6]=Math.sin(b);d[7]=0;d[8]=Math.cos(b);return c};a.math.Matrix3.createByRotationZ=function(b){var c=new a.math.Matrix3,d=c.mat;d[0]=Math.cos(b);d[1]=-Math.sin(b);d[2]=0;d[3]=Math.sin(b);d[4]=Math.cos(b);d[5]=0;d[6]=0;d[7]=0;d[8]=1;return c};a.math.Matrix3.createByRotation=function(b){var c=new a.math.Matrix3,d=c.mat;
d[0]=Math.cos(b);d[1]=Math.sin(b);d[2]=0;d[3]=-Math.sin(b);d[4]=Math.cos(b);d[5]=0;d[6]=0;d[7]=0;d[8]=1;return c};a.math.Matrix3.createByScale=function(b,c){var d=new a.math.Matrix3;d.identity();d.mat[0]=b;d.mat[4]=c;return d};a.math.Matrix3.createByTranslation=function(b,c){var d=new a.math.Matrix3;d.identity();d.mat[6]=b;d.mat[7]=c;return d};a.math.Matrix3.createByQuaternion=function(b){if(!b)return null;var c=new a.math.Matrix3,d=c.mat;d[0]=1-2*(b.y*b.y+b.z*b.z);d[1]=2*(b.x*b.y-b.w*b.z);d[2]=2*
(b.x*b.z+b.w*b.y);d[3]=2*(b.x*b.y+b.w*b.z);d[4]=1-2*(b.x*b.x+b.z*b.z);d[5]=2*(b.y*b.z-b.w*b.x);d[6]=2*(b.x*b.z-b.w*b.y);d[7]=2*(b.y*b.z+b.w*b.x);d[8]=1-2*(b.x*b.x+b.y*b.y);return c};b.rotationToAxisAngle=function(){return a.math.Quaternion.rotationMatrix(this).toAxisAndAngle()}})(cc);(function(a){a.math.Matrix4=function(a){this.mat=a&&a.mat?new Float32Array(a.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;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;return a};b.identity=function(){var a=this.mat;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;
return 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 e=this.mat,f=e[a+4*b];e[a+4*b]=e[c+4*d];e[c+4*d]=f};a.math.Matrix4._gaussj=function(a,b){var c,d=0,e=0,f,n,p,r=[0,0,0,0],t=[0,0,0,0],u=[0,0,0,0];for(c=0;4>c;c++){for(f=p=0;4>f;f++)if(1!==u[f])for(n=0;4>n;n++)if(0===u[n]){var v=Math.abs(a.get(f,n));v>=p&&(p=v,e=f,d=n)}++u[d];if(e!==d){for(f=0;4>f;f++)a.swap(e,f,d,f);for(f=0;4>f;f++)b.swap(e,f,d,f)}t[c]=e;r[c]=d;if(0===a.get(d,
d))return!1;n=1/a.get(d,d);a.set(d,d,1);for(f=0;4>f;f++)a.set(d,f,a.get(d,f)*n);for(f=0;4>f;f++)b.set(d,f,b.get(d,f)*n);for(n=0;4>n;n++)if(n!==d){v=a.get(n,d);a.set(n,d,0);for(f=0;4>f;f++)a.set(n,f,a.get(n,f)-a.get(d,f)*v);for(f=0;4>f;f++)b.set(n,f,a.get(n,f)-b.get(d,f)*v)}}for(f=3;0<=f;f--)if(t[f]!==r[f])for(n=0;4>n;n++)a.swap(n,t[f],n,r[f]);return!0};var c=(new a.math.Matrix4).identity();a.kmMat4Inverse=function(b,d){var e=new a.math.Matrix4(d),f=new a.math.Matrix4(c);if(!1===a.math.Matrix4._gaussj(e,
f))return null;b.assignFrom(e);return b};b.inverse=function(){var b=new a.math.Matrix4(this),d=new a.math.Matrix4(c);return!1===a.math.Matrix4._gaussj(b,d)?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],t=a[12],u=a[13],v=a[14];a[1]=a[4];
a[2]=n;a[3]=t;a[4]=b;a[6]=p;a[7]=u;a[8]=c;a[9]=k;a[11]=v;a[12]=d;a[13]=m;a[14]=r;return this};a.kmMat4Multiply=function(a,b,c){var d=a.mat,e=b.mat,f=c.mat;c=e[0];b=e[1];var g=e[2],p=e[3],r=e[4],t=e[5],u=e[6],v=e[7],x=e[8],w=e[9],y=e[10],z=e[11],A=e[12],B=e[13],C=e[14];e=e[15];var D=f[0],E=f[1],J=f[2],I=f[3],G=f[4],H=f[5],F=f[6],K=f[7],L=f[8],M=f[9],O=f[10],P=f[11],N=f[12],S=f[13],R=f[14];f=f[15];d[0]=D*c+E*r+J*x+I*A;d[1]=D*b+E*t+J*w+I*B;d[2]=D*g+E*u+J*y+I*C;d[3]=D*p+E*v+J*z+I*e;d[4]=G*c+H*r+F*x+K*
A;d[5]=G*b+H*t+F*w+K*B;d[6]=G*g+H*u+F*y+K*C;d[7]=G*p+H*v+F*z+K*e;d[8]=L*c+M*r+O*x+P*A;d[9]=L*b+M*t+O*w+P*B;d[10]=L*g+M*u+O*y+P*C;d[11]=L*p+M*v+O*z+P*e;d[12]=N*c+S*r+R*x+f*A;d[13]=N*b+S*t+R*w+f*B;d[14]=N*g+S*u+R*y+f*C;d[15]=N*p+S*v+R*z+f*e;return a};b.multiply=function(a){var b=this.mat,c=a.mat;a=b[0];var d=b[1],e=b[2],m=b[3],n=b[4],p=b[5],r=b[6],t=b[7],u=b[8],v=b[9],x=b[10],w=b[11],y=b[12],z=b[13],A=b[14],B=b[15],C=c[0],D=c[1],E=c[2],J=c[3],I=c[4],G=c[5],H=c[6],F=c[7],K=c[8],L=c[9],M=c[10],O=c[11],
P=c[12],N=c[13],S=c[14];c=c[15];b[0]=C*a+D*n+E*u+J*y;b[1]=C*d+D*p+E*v+J*z;b[2]=C*e+D*r+E*x+J*A;b[3]=C*m+D*t+E*w+J*B;b[4]=I*a+G*n+H*u+F*y;b[5]=I*d+G*p+H*v+F*z;b[6]=I*e+G*r+H*x+F*A;b[7]=I*m+G*t+H*w+F*B;b[8]=K*a+L*n+M*u+O*y;b[9]=K*d+L*p+M*v+O*z;b[10]=K*e+L*r+M*x+O*A;b[11]=K*m+L*t+M*w+O*B;b[12]=P*a+N*n+S*u+c*y;b[13]=P*d+N*p+S*v+c*z;b[14]=P*e+N*r+S*x+c*A;b[15]=P*m+N*t+S*w+c*B;return this};a.getMat4MultiplyValue=function(a,b){var c=a.mat,d=b.mat,e=new Float32Array(16);e[0]=c[0]*d[0]+c[4]*d[1]+c[8]*d[2]+
c[12]*d[3];e[1]=c[1]*d[0]+c[5]*d[1]+c[9]*d[2]+c[13]*d[3];e[2]=c[2]*d[0]+c[6]*d[1]+c[10]*d[2]+c[14]*d[3];e[3]=c[3]*d[0]+c[7]*d[1]+c[11]*d[2]+c[15]*d[3];e[4]=c[0]*d[4]+c[4]*d[5]+c[8]*d[6]+c[12]*d[7];e[5]=c[1]*d[4]+c[5]*d[5]+c[9]*d[6]+c[13]*d[7];e[6]=c[2]*d[4]+c[6]*d[5]+c[10]*d[6]+c[14]*d[7];e[7]=c[3]*d[4]+c[7]*d[5]+c[11]*d[6]+c[15]*d[7];e[8]=c[0]*d[8]+c[4]*d[9]+c[8]*d[10]+c[12]*d[11];e[9]=c[1]*d[8]+c[5]*d[9]+c[9]*d[10]+c[13]*d[11];e[10]=c[2]*d[8]+c[6]*d[9]+c[10]*d[10]+c[14]*d[11];e[11]=c[3]*d[8]+c[7]*
d[9]+c[11]*d[10]+c[15]*d[11];e[12]=c[0]*d[12]+c[4]*d[13]+c[8]*d[14]+c[12]*d[15];e[13]=c[1]*d[12]+c[5]*d[13]+c[9]*d[14]+c[13]*d[15];e[14]=c[2]*d[12]+c[6]*d[13]+c[10]*d[14]+c[14]*d[15];e[15]=c[3]*d[12]+c[7]*d[13]+c[11]*d[14]+c[15]*d[15];return e};a.kmMat4Assign=function(b,c){if(b===c)return a.log("cc.kmMat4Assign(): pOut equals pIn"),b;var d=b.mat,e=c.mat;d[0]=e[0];d[1]=e[1];d[2]=e[2];d[3]=e[3];d[4]=e[4];d[5]=e[5];d[6]=e[6];d[7]=e[7];d[8]=e[8];d[9]=e[9];d[10]=e[10];d[11]=e[11];d[12]=e[12];d[13]=e[13];
d[14]=e[14];d[15]=e[15];return 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;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];return 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,
e=0;16>e;e++)if(!(c[e]+d>b[e]&&c[e]-d<b[e]))return!1;return!0};a.math.Matrix4.createByRotationX=function(b,c){c=c||new a.math.Matrix4;var d=c.mat;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;return c};a.math.Matrix4.createByRotationY=function(b,c){c=c||new a.math.Matrix4;var d=c.mat;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;return c};a.math.Matrix4.createByRotationZ=function(b,c){c=c||new a.math.Matrix4;var d=c.mat;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;return c};a.math.Matrix4.createByPitchYawRoll=function(b,c,d,h){h=h||new a.math.Matrix4;var e=Math.cos(b);b=Math.sin(b);var f=Math.cos(c);c=Math.sin(c);var g=Math.cos(d);d=Math.sin(d);var p=b*c,r=e*c,t=h.mat;t[0]=f*g;t[4]=f*d;
t[8]=-c;t[1]=p*g-e*d;t[5]=p*d+e*g;t[9]=b*f;t[2]=r*g+b*d;t[6]=r*d-b*g;t[10]=e*f;t[3]=t[7]=t[11]=0;t[15]=1;return h};a.math.Matrix4.createByQuaternion=function(b,c){c=c||new a.math.Matrix4;var d=c.mat;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;return c};a.math.Matrix4.createByRotationTranslation=
function(b,c,d){d=d||new a.math.Matrix4;var e=d.mat;b=b.mat;e[0]=b[0];e[1]=b[1];e[2]=b[2];e[3]=0;e[4]=b[3];e[5]=b[4];e[6]=b[5];e[7]=0;e[8]=b[6];e[9]=b[7];e[10]=b[8];e[11]=0;e[12]=c.x;e[13]=c.y;e[14]=c.z;e[15]=1;return d};a.math.Matrix4.createByScale=function(b,c,d,h){h=h||new a.math.Matrix4;var e=h.mat;e[0]=b;e[5]=c;e[10]=d;e[15]=1;e[1]=e[2]=e[3]=e[4]=e[6]=e[7]=e[8]=e[9]=e[11]=e[12]=e[13]=e[14]=0;return h};a.kmMat4Translation=function(a,b,c,d){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;return a};a.math.Matrix4.createByTranslation=function(b,c,d,h){h=h||new a.math.Matrix4;h.identity();h.mat[12]=b;h.mat[13]=c;h.mat[14]=d;return 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 e=a.degreesToRadians(c/2);c=k-h;var f=Math.sin(e);if(0===c||0===f||0===d)return null;e=Math.cos(e)/f;b.identity();b.mat[0]=e/d;b.mat[5]=e;b.mat[10]=-(k+h)/c;b.mat[11]=-1;b.mat[14]=-2*h*k/c;b.mat[15]=0;return b};a.math.Matrix4.createPerspectiveProjection=function(b,c,d,h){var e=a.degreesToRadians(b/2);b=h-d;var f=Math.sin(e);if(0===b||0===f||0===c)return null;e=Math.cos(e)/f;f=new a.math.Matrix4;var g=f.mat;f.identity();
g[0]=e/c;g[5]=e;g[10]=-(h+d)/b;g[11]=-1;g[14]=-2*d*h/b;g[15]=0;return f};a.kmMat4OrthographicProjection=function(a,b,c,d,k,m,n){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));return a};a.math.Matrix4.createOrthographicProjection=function(b,c,d,h,k,m){var e=new a.math.Matrix4,f=e.mat;e.identity();f[0]=2/(c-b);f[5]=2/(h-d);f[10]=-2/(m-k);f[12]=-((c+b)/(c-b));f[13]=-((h+d)/(h-d));f[14]=-((m+k)/(m-k));return e};
a.kmMat4LookAt=function(b,c,d,h){d=new a.math.Vec3(d);var e=new a.math.Vec3(h);d.subtract(c);d.normalize();e.normalize();h=new a.math.Vec3(d);h.cross(e);h.normalize();e=new a.math.Vec3(h);e.cross(d);h.normalize();b.identity();b.mat[0]=h.x;b.mat[4]=h.y;b.mat[8]=h.z;b.mat[1]=e.x;b.mat[5]=e.y;b.mat[9]=e.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);b.multiply(c);return b};var d=new a.math.Matrix4;b.lookAt=function(b,c,g){c=new a.math.Vec3(c);var e=
new a.math.Vec3(g);g=this.mat;c.subtract(b);c.normalize();e.normalize();var f=new a.math.Vec3(c);f.cross(e);f.normalize();e=new a.math.Vec3(f);e.cross(c);f.normalize();this.identity();g[0]=f.x;g[4]=f.y;g[8]=f.z;g[1]=e.x;g[5]=e.y;g[9]=e.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);return this};a.kmMat4RotationAxisAngle=function(b,c,d){var e=Math.cos(d);d=Math.sin(d);c=new a.math.Vec3(c);c.normalize();b.mat[0]=e+c.x*c.x*(1-e);b.mat[1]=c.z*
d+c.y*c.x*(1-e);b.mat[2]=-c.y*d+c.z*c.x*(1-e);b.mat[3]=0;b.mat[4]=-c.z*d+c.x*c.y*(1-e);b.mat[5]=e+c.y*c.y*(1-e);b.mat[6]=c.x*d+c.z*c.y*(1-e);b.mat[7]=0;b.mat[8]=c.y*d+c.x*c.z*(1-e);b.mat[9]=-c.x*d+c.y*c.z*(1-e);b.mat[10]=e+c.z*c.z*(1-e);b.mat[11]=0;b.mat[12]=0;b.mat[13]=0;b.mat[14]=0;b.mat[15]=1;return b};a.math.Matrix4.createByAxisAndAngle=function(b,c,d){d=d||new a.math.Matrix4;var e=this.mat,f=Math.cos(c);c=Math.sin(c);b=new a.math.Vec3(b);b.normalize();e[0]=f+b.x*b.x*(1-f);e[1]=b.z*c+b.y*b.x*
(1-f);e[2]=-b.y*c+b.z*b.x*(1-f);e[3]=0;e[4]=-b.z*c+b.x*b.y*(1-f);e[5]=f+b.y*b.y*(1-f);e[6]=b.x*c+b.z*b.y*(1-f);e[7]=0;e[8]=b.y*c+b.x*b.z*(1-f);e[9]=-b.x*c+b.y*b.z*(1-f);e[10]=f+b.z*b.z*(1-f);e[11]=0;e[12]=e[13]=e[14]=0;e[15]=1;return d};b.extractRotation=function(){var b=new a.math.Matrix3,c=this.mat,d=b.mat;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];return 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);c.a/=b;c.b/=b;c.c/=b;c.d/=b;return 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 c=new a.math.Plane;d.subtract(b);e.subtract(b);d.cross(e);d.normalize();c.a=d.x;c.b=d.y;c.c=d.z;c.d=d.scale(-1).dot(b);return c};b.normalize=function(){var b=new a.math.Vec3(this.a,this.b,this.c),d=1/
b.length();b.normalize();this.a=b.x;this.b=b.y;this.c=b.z;this.d*=d;return this};b.classifyPoint=function(b){b=this.a*b.x+this.b*b.y+this.c*b.z+this.d;return.001<b?a.math.Plane.POINT_INFRONT_OF_PLANE:-.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){this.x=-a.x;this.y=-a.y;this.z=-a.z;this.w=a.w;return 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(){this.z=this.y=this.x=0;this.w=1;return this};b.inverse=function(){var b=
this.length();if(Math.abs(b)>a.math.EPSILON)return this.w=this.z=this.y=this.x=0,this;this.conjugate(this).scale(1/b);return 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,c=this.y,f=this.z,g=this.w;this.w=g*a.w-b*a.x-c*a.y-f*a.z;this.x=g*a.x+b*a.w+c*a.z-f*a.y;this.y=g*a.y+c*a.w+f*a.x-
b*a.z;this.z=g*a.z+f*a.w+b*a.y-c*a.x;return this};b.normalize=function(){var b=this.length();if(Math.abs(b)<=a.math.EPSILON)throw Error("current quaternion is an invalid value");this.scale(1/b);return this};b.rotationAxis=function(a,b){var c=.5*b,d=Math.sin(c);this.w=Math.cos(c);this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;return this};a.math.Quaternion.rotationMatrix=function(b){if(!b)return null;var c=[];b=b.mat;c[0]=b[0];c[1]=b[3];c[2]=b[6];c[4]=b[1];c[5]=b[4];c[6]=b[7];c[8]=b[2];c[9]=b[5];c[10]=b[8];
c[15]=1;var e=c[0];c=e[0]+e[5]+e[10]+1;if(c>a.math.EPSILON){var f=2*Math.sqrt(c);c=(e[9]-e[6])/f;b=(e[2]-e[8])/f;var g=(e[4]-e[1])/f;e=.25*f}else e[0]>e[5]&&e[0]>e[10]?(f=2*Math.sqrt(1+e[0]-e[5]-e[10]),c=.25*f,b=(e[4]+e[1])/f,g=(e[2]+e[8])/f,e=(e[9]-e[6])/f):e[5]>e[10]?(f=2*Math.sqrt(1+e[5]-e[0]-e[10]),c=(e[4]+e[1])/f,b=.25*f,g=(e[9]+e[6])/f,e=(e[2]-e[8])/f):(f=2*Math.sqrt(1+e[10]-e[0]-e[5]),c=(e[2]+e[8])/f,b=(e[9]+e[6])/f,g=.25*f,e=(e[4]-e[1])/f);return new a.math.Quaternion(c,b,g,e)};a.math.Quaternion.rotationYawPitchRoll=
function(b,d,e){var c=a.degreesToRadians(d)/2;var g=a.degreesToRadians(b)/2;var h=a.degreesToRadians(e)/2;e=Math.cos(c);b=Math.cos(g);d=Math.cos(h);c=Math.sin(c);g=Math.sin(g);h=Math.sin(h);var k=b*d;var m=g*h;var n=new a.math.Quaternion;n.w=e*k+c*m;n.x=c*k-e*m;n.y=e*g*d+c*b*h;n.z=e*b*h-c*g*d;n.normalize();return 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 c=this.dot(b),f=Math.acos(c),g=Math.sqrt(1-a.math.square(c));c=Math.sin(d*f)/g;f=Math.sin((1-
d)*f)/g;g=new a.math.Quaternion(b);this.scale(f);g.scale(c);this.add(g);return this};b.toAxisAndAngle=function(){var b=new a.math.Vec3;var d=Math.acos(this.w);var e=Math.sqrt(a.math.square(this.x)+a.math.square(this.y)+a.math.square(this.z));e>-a.math.EPSILON&&e<a.math.EPSILON||e<2*Math.PI+a.math.EPSILON&&e>2*Math.PI-a.math.EPSILON?(d=0,b.x=0,b.y=0,b.z=1):(d*=2,b.x=this.x/e,b.y=this.y/e,b.z=this.z/e,b.normalize());return{axis:b,angle:d}};b.scale=function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;
return this};b.assignFrom=function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this};b.add=function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this};a.math.Quaternion.rotationBetweenVec3=function(b,d,e){var c=new a.math.Vec3(b),g=new a.math.Vec3(d);c.normalize();g.normalize();var h=c.dot(g);d=new a.math.Quaternion;if(1<=h)return d.identity(),d;-.999999>h?Math.abs(e.lengthSq())<a.math.EPSILON?d.rotationAxis(e,Math.PI):(c=new a.math.Vec3(1,0,0),c.cross(b),Math.abs(c.lengthSq())<
a.math.EPSILON&&(c.fill(0,1,0),c.cross(b)),c.normalize(),d.rotationAxis(c,Math.PI)):(b=Math.sqrt(2*(1+h)),e=1/b,c.cross(g),d.x=c.x*e,d.y=c.y*e,d.z=c.z*e,d.w=.5*b,d.normalize());return d};b.multiplyVec3=function(b){var c=this.x,e=this.y,f=this.z,g=new a.math.Vec3(b),h=new a.math.Vec3(c,e,f);c=new a.math.Vec3(c,e,f);h.cross(b);c.cross(h);h.scale(2*q.w);c.scale(2);g.add(h);g.add(c);return 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){a.min.assignFrom(b.min);a.max.assignFrom(b.max);return a};(function(a){a.math.Matrix4Stack=function(a,b){this.top=a;this.stack=b||[];this.lastUpdated=0};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 c=this._matrixPool;if(0===c.length)return new a.math.Matrix4(b);c=c.pop();c.assignFrom(b);return c};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 Error("Invalid matrix mode specified");}a.current_stack.lastUpdated=a.director.getTotalFrames()};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 Error("Invalid matrix mode specified");}}})(cc);cc.SHADER_POSITION_UCOLOR_FRAG="precision lowp float;\nvarying vec4 v_fragmentColor;\nvoid main()                              \n{ \n    gl_FragColor = 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 = (CC_PMatrix * CC_MVMatrix) * a_position;  \n    gl_PointSize = u_pointSize;          \n    v_fragmentColor = u_color;           \n}";
cc.SHADER_POSITION_COLOR_FRAG="precision lowp float; \nvarying vec4 v_fragmentColor; \nvoid main() \n{ \n     gl_FragColor = 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 = (CC_PMatrix * CC_MVMatrix) * a_position;  \n    v_fragmentColor = a_color;             \n}";cc.SHADER_SPRITE_POSITION_COLOR_VERT="attribute vec4 a_position;\nattribute vec4 a_color;\nvarying lowp vec4 v_fragmentColor;\nvoid main()\n{\n    gl_Position = CC_PMatrix * a_position;  \n    v_fragmentColor = 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 = v_color*smoothstep(0.0, length(fwidth(v_texcoord)), 1.0 - length(v_texcoord)); \n// #else\t\ngl_FragColor = 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 = a_color;//vec4(a_color.rgb * a_color.a, a_color.a); \n     v_texcoord = a_texcoord; \n    gl_Position = (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 =  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 = (CC_PMatrix * CC_MVMatrix) * a_position;  \n    v_texCoord = 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 =  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 = (CC_PMatrix * CC_MVMatrix) * a_position;  \n    v_texCoord = 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 = 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 = (CC_PMatrix * CC_MVMatrix) * a_position;  \n    v_fragmentColor = a_color; \n    v_texCoord = 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 = 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 = (CC_PMatrix * CC_MVMatrix) * a_position;  \n    v_fragmentColor = a_color; \n    v_texCoord = a_texCoord; \n}";cc.SHADER_SPRITE_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 = CC_PMatrix * a_position;  \n    v_fragmentColor = a_color; \n    v_texCoord = a_texCoord; \n}";
cc.SHADER_SPRITE_POSITION_TEXTURE_COLOR_GRAY_FRAG="precision lowp float;\nvarying vec4 v_fragmentColor; \nvarying vec2 v_texCoord; \nvoid main() \n{ \n    vec4 c = texture2D(CC_Texture0, v_texCoord); \n    gl_FragColor.xyz = vec3(0.2126*c.r + 0.7152*c.g + 0.0722*c.b); \n     gl_FragColor.w = c.w ; \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 = texture2D(CC_Texture0, v_texCoord);  \n    if ( texColor.a <= CC_alpha_value )          \n        discard; \n    gl_FragColor = 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   = texture2D(u_texture, v_texCoord);  \n    vec4 maskColor  = texture2D(u_mask, v_texCoord); \n    vec4 finalColor = vec4(texColor.r, texColor.g, texColor.b, maskColor.a * texColor.a);        \n    gl_FragColor    = 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_SPRITE_POSITION_TEXTURECOLOR:8,TYPE_SPRITE_POSITION_TEXTURECOLOR_ALPHATEST:9,TYPE_SPRITE_POSITION_COLOR:10,TYPE_SPRITE_POSITION_TEXTURECOLOR_GRAY:11,TYPE_MAX:11,_keyMap:[cc.SHADER_POSITION_TEXTURECOLOR,cc.SHADER_POSITION_TEXTURECOLORALPHATEST,cc.SHADER_POSITION_COLOR,
cc.SHADER_POSITION_TEXTURE,cc.SHADER_POSITION_TEXTURE_UCOLOR,cc.SHADER_POSITION_TEXTUREA8COLOR,cc.SHADER_POSITION_UCOLOR,cc.SHADER_POSITION_LENGTHTEXTURECOLOR,cc.SHADER_SPRITE_POSITION_TEXTURECOLOR,cc.SHADER_SPRITE_POSITION_TEXTURECOLORALPHATEST,cc.SHADER_SPRITE_POSITION_COLOR,cc.SHADER_SPRITE_POSITION_TEXTURECOLOR_GRAY],_programs:{},_init:function(){this.loadDefaultShaders();return!0},_loadDefaultShader:function(a,b){switch(b){case cc.SHADER_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 cc.SHADER_SPRITE_POSITION_TEXTURECOLOR:a.initWithVertexShaderByteArray(cc.SHADER_SPRITE_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 cc.SHADER_SPRITE_POSITION_TEXTURECOLOR_GRAY:a.initWithVertexShaderByteArray(cc.SHADER_SPRITE_POSITION_TEXTURE_COLOR_VERT,cc.SHADER_SPRITE_POSITION_TEXTURE_COLOR_GRAY_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 cc.SHADER_POSITION_TEXTURECOLORALPHATEST: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 cc.SHADER_SPRITE_POSITION_TEXTURECOLORALPHATEST:a.initWithVertexShaderByteArray(cc.SHADER_SPRITE_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 cc.SHADER_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 cc.SHADER_SPRITE_POSITION_COLOR:a.initWithVertexShaderByteArray(cc.SHADER_SPRITE_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 cc.SHADER_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 cc.SHADER_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 cc.SHADER_POSITION_TEXTUREA8COLOR: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 cc.SHADER_POSITION_UCOLOR:a.initWithVertexShaderByteArray(cc.SHADER_POSITION_UCOLOR_VERT,cc.SHADER_POSITION_UCOLOR_FRAG);a.addAttribute("aVertex",cc.VERTEX_ATTRIB_POSITION);break;case cc.SHADER_POSITION_LENGTHTEXTURECOLOR: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:cc.log("cocos2d: cc.shaderCache._loadDefaultShader, error shader type");return}a.link();a.updateUniforms()},loadDefaultShaders:function(){for(var a=0;a<this.TYPE_MAX;++a)this.programForKey(this._keyMap[a])},reloadDefaultShaders:function(){var a=this.programForKey(cc.SHADER_POSITION_TEXTURECOLOR);a.reset();this._loadDefaultShader(a,cc.SHADER_POSITION_TEXTURECOLOR);a=this.programForKey(cc.SHADER_SPRITE_POSITION_TEXTURECOLOR);
a.reset();this._loadDefaultShader(a,cc.SHADER_SPRITE_POSITION_TEXTURECOLOR);a=this.programForKey(cc.SHADER_POSITION_TEXTURECOLORALPHATEST);a.reset();this._loadDefaultShader(a,cc.SHADER_POSITION_TEXTURECOLORALPHATEST);a=this.programForKey(cc.SHADER_SPRITE_POSITION_TEXTURECOLORALPHATEST);a.reset();this._loadDefaultShader(a,cc.SHADER_SPRITE_POSITION_TEXTURECOLORALPHATEST);a=this.programForKey(cc.SHADER_POSITION_COLOR);a.reset();this._loadDefaultShader(a,cc.SHADER_POSITION_COLOR);a=this.programForKey(cc.SHADER_POSITION_TEXTURE);
a.reset();this._loadDefaultShader(a,cc.SHADER_POSITION_TEXTURE);a=this.programForKey(cc.SHADER_SPRITE_POSITION_TEXTURE_COLOR_GRAY_FRAG);a.reset();this._loadDefaultShader(a,cc.SHADER_SPRITE_POSITION_TEXTURE_COLOR_GRAY_FRAG);a=this.programForKey(cc.SHADER_POSITION_TEXTURE_UCOLOR);a.reset();this._loadDefaultShader(a,cc.SHADER_POSITION_TEXTURE_UCOLOR);a=this.programForKey(cc.SHADER_POSITION_TEXTUREA8COLOR);a.reset();this._loadDefaultShader(a,cc.SHADER_POSITION_TEXTUREA8COLOR);a=this.programForKey(cc.SHADER_POSITION_UCOLOR);
a.reset();this._loadDefaultShader(a,cc.SHADER_POSITION_UCOLOR)},programForKey:function(a){if(!this._programs[a]){var b=new cc.GLProgram;this._loadDefaultShader(b,a);this._programs[a]=b}return this._programs[a]},getProgram:function(a){return this.programForKey(a)},addProgram:function(a,b){this._programs[b]=a},hasProgram:function(a){return void 0!=this._programs[a]}};cc.GLProgram=cc.Class.extend({_glContext:null,_programObj:null,_vertShader:null,_fragShader:null,_uniforms:null,_hashForUniforms:null,_usesTime:!1,_projectionUpdated:-1,_updateUniform:function(a){if(!a)return!1;var b=!1,c=this._hashForUniforms[a];if(Array.isArray(arguments[1]))var d=arguments[1];else{d=Array(arguments.length-1);for(var e=1;e<arguments.length;e+=1)d[e-1]=arguments[e]}if(c&&c.length===d.length)for(e=0;e<d.length;e+=1){if(d[e]!==c[e]||"object"===typeof d[e])c[e]=d[e],b=!0}else this._hashForUniforms[a]=
[].concat(d),b=!0;return b},_description:function(){return"<CCGLProgram = "+this.toString()+" | Program = "+this._programObj.toString()+", VertexShader = "+this._vertShader.toString()+", FragmentShader = "+this._fragShader.toString()+">"},_compileShader:function(a,b,c){if(!c||!a)return!1;var d=cc.GLProgram._isHighpSupported()?"precision highp float;\n":"precision mediump float;\n";this._glContext.shaderSource(a,d+"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.compileShader(a);c=this._glContext.getShaderParameter(a,this._glContext.COMPILE_STATUS);c||(cc.log("cocos2d: ERROR: Failed to compile shader:\n"+this._glContext.getShaderSource(a)),b===this._glContext.VERTEX_SHADER?cc.log("cocos2d: \n"+this.vertexShaderLog()):cc.log("cocos2d: \n"+this.fragmentShaderLog()));return!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;this._programObj=c.createProgram();this._fragShader=this._vertShader=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);0<Object.keys(this._hashForUniforms).length&&(this._hashForUniforms={});cc.checkGLErrorDebug();return!0},initWithString:function(a,b){return this.initWithVertexShaderByteArray(a,b)},initWithVertexShaderFilename:function(a,b){var c=cc.loader.getRes(a);if(!c)throw Error("Please load the resource firset : "+
a);var d=cc.loader.getRes(b);if(!d)throw Error("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(){if(!this._programObj)return 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._fragShader=this._vertShader=null;return 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._addUniformLocation(cc.UNIFORM_PMATRIX_S);
this._addUniformLocation(cc.UNIFORM_MVMATRIX_S);this._addUniformLocation(cc.UNIFORM_MVPMATRIX_S);this._addUniformLocation(cc.UNIFORM_TIME_S);this._addUniformLocation(cc.UNIFORM_SINTIME_S);this._addUniformLocation(cc.UNIFORM_COSTIME_S);this._addUniformLocation(cc.UNIFORM_RANDOM01_S);this._addUniformLocation(cc.UNIFORM_SAMPLER_S);this._usesTime=null!=this._uniforms[cc.UNIFORM_TIME_S]||null!=this._uniforms[cc.UNIFORM_SINTIME_S]||null!=this._uniforms[cc.UNIFORM_COSTIME_S];this.use();this.setUniformLocationWith1i(this._uniforms[cc.UNIFORM_SAMPLER_S],
0)},_addUniformLocation:function(a){var b=this._glContext.getUniformLocation(this._programObj,a);b&&(b._name=a);return this._uniforms[a]=b},getUniformLocationForName:function(a){if(!a)throw Error("cc.GLProgram.getUniformLocationForName(): uniform name should be non-null");if(!this._programObj)throw Error("cc.GLProgram.getUniformLocationForName(): Invalid operation. Cannot get uniform location when program is not initialized");return this._uniforms[a]||this._addUniformLocation(a)},getUniformMVPMatrix:function(){return this._uniforms[cc.UNIFORM_MVPMATRIX_S]},
getUniformSampler:function(){return this._uniforms[cc.UNIFORM_SAMPLER_S]},setUniformLocationWith1i:function(a,b){var c="string"===typeof a,d=c?a:a&&a._name;d?this._updateUniform(d,b)&&(c&&(a=this.getUniformLocationForName(d)),this._glContext.uniform1i(a,b)):this._glContext.uniform1i(a,b)},setUniformLocationWith2i:function(a,b,c){var d="string"===typeof a,e=d?a:a&&a._name;e?this._updateUniform(e,b,c)&&(d&&(a=this.getUniformLocationForName(e)),this._glContext.uniform2i(a,b,c)):this._glContext.uniform2i(a,
b,c)},setUniformLocationWith3i:function(a,b,c,d){var e="string"===typeof a,f=e?a:a&&a._name;f?this._updateUniform(f,b,c,d)&&(e&&(a=this.getUniformLocationForName(f)),this._glContext.uniform3i(a,b,c,d)):this._glContext.uniform3i(a,b,c,d)},setUniformLocationWith4i:function(a,b,c,d,e){var f="string"===typeof a,g=f?a:a&&a._name;g?this._updateUniform(g,b,c,d,e)&&(f&&(a=this.getUniformLocationForName(g)),this._glContext.uniform4i(a,b,c,d,e)):this._glContext.uniform4i(a,b,c,d,e)},setUniformLocationWith2iv:function(a,
b){var c="string"===typeof a,d=c?a:a&&a._name;d?this._updateUniform(d,b)&&(c&&(a=this.getUniformLocationForName(d)),this._glContext.uniform2iv(a,b)):this._glContext.uniform2iv(a,b)},setUniformLocationWith3iv:function(a,b){var c="string"===typeof a,d=c?a:a&&a._name;d?this._updateUniform(d,b)&&(c&&(a=this.getUniformLocationForName(d)),this._glContext.uniform3iv(a,b)):this._glContext.uniform3iv(a,b)},setUniformLocationWith4iv:function(a,b){var c="string"===typeof a,d=c?a:a&&a._name;d?this._updateUniform(d,
b)&&(c&&(a=this.getUniformLocationForName(d)),this._glContext.uniform4iv(a,b)):this._glContext.uniform4iv(a,b)},setUniformLocationI32:function(a,b){this.setUniformLocationWith1i(a,b)},setUniformLocationWith1f:function(a,b){var c="string"===typeof a,d=c?a:a&&a._name;d?this._updateUniform(d,b)&&(c&&(a=this.getUniformLocationForName(d)),this._glContext.uniform1f(a,b)):this._glContext.uniform1f(a,b)},setUniformLocationWith2f:function(a,b,c){var d="string"===typeof a,e=d?a:a&&a._name;e?this._updateUniform(e,
b,c)&&(d&&(a=this.getUniformLocationForName(e)),this._glContext.uniform2f(a,b,c)):this._glContext.uniform2f(a,b,c)},setUniformLocationWith3f:function(a,b,c,d){var e="string"===typeof a,f=e?a:a&&a._name;f?this._updateUniform(f,b,c,d)&&(e&&(a=this.getUniformLocationForName(f)),this._glContext.uniform3f(a,b,c,d)):this._glContext.uniform3f(a,b,c,d)},setUniformLocationWith4f:function(a,b,c,d,e){var f="string"===typeof a,g=f?a:a&&a._name;g?this._updateUniform(g,b,c,d,e)&&(f&&(a=this.getUniformLocationForName(g)),
this._glContext.uniform4f(a,b,c,d,e)):(this._glContext.uniform4f(a,b,c,d,e),cc.log("uniform4f",b,c,d,e))},setUniformLocationWith2fv:function(a,b){var c="string"===typeof a,d=c?a:a&&a._name;d?this._updateUniform(d,b)&&(c&&(a=this.getUniformLocationForName(d)),this._glContext.uniform2fv(a,b)):this._glContext.uniform2fv(a,b)},setUniformLocationWith3fv:function(a,b){var c="string"===typeof a,d=c?a:a&&a._name;d?this._updateUniform(d,b)&&(c&&(a=this.getUniformLocationForName(d)),this._glContext.uniform3fv(a,
b)):this._glContext.uniform3fv(a,b)},setUniformLocationWith4fv:function(a,b){var c="string"===typeof a,d=c?a:a&&a._name;d?this._updateUniform(d,b)&&(c&&(a=this.getUniformLocationForName(d)),this._glContext.uniform4fv(a,b)):(this._glContext.uniform4fv(a,b),cc.log("uniform4fv",b))},setUniformLocationWithMatrix2fv:function(a,b){var c="string"===typeof a,d=c?a:a&&a._name;d?this._updateUniform(d,b)&&(c&&(a=this.getUniformLocationForName(d)),this._glContext.uniformMatrix2fv(a,!1,b)):this._glContext.uniformMatrix2fv(a,
!1,b)},setUniformLocationWithMatrix3fv:function(a,b){var c="string"===typeof a,d=c?a:a&&a._name;d?this._updateUniform(d,b)&&(c&&(a=this.getUniformLocationForName(d)),this._glContext.uniformMatrix3fv(a,!1,b)):this._glContext.uniformMatrix3fv(a,!1,b)},setUniformLocationWithMatrix4fv:function(a,b){var c="string"===typeof a,d=c?a:a&&a._name;d?this._updateUniform(d,b)&&(c&&(a=this.getUniformLocationForName(d)),this._glContext.uniformMatrix4fv(a,!1,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;
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_S],a.mat,1);this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_MVMATRIX_S],b.mat,1);this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_MVPMATRIX_S],c.mat,1);this._usesTime&&(a=cc.director,a=a.getTotalFrames()*a.getAnimationInterval(),this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_TIME_S],a/10,
a,2*a,4*a),this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_SINTIME_S],a/8,a/4,a/2,Math.sin(a)),this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_COSTIME_S],a/8,a/4,a/2,Math.cos(a)));-1!==this._uniforms[cc.UNIFORM_RANDOM01_S]&&this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_RANDOM01_S],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;cc.kmGLGetMatrix(cc.KM_GL_PROJECTION,
b);cc.kmMat4Multiply(c,b,a._renderCmd._stackMatrix);this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_PMATRIX_S],b.mat,1);this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_MVMATRIX_S],a._renderCmd._stackMatrix.mat,1);this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_MVPMATRIX_S],c.mat,1);this._usesTime&&(a=cc.director,a=a.getTotalFrames()*a.getAnimationInterval(),this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_TIME_S],a/10,a,2*a,4*a),this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_SINTIME_S],
a/8,a/4,a/2,Math.sin(a)),this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_COSTIME_S],a/8,a/4,a/2,Math.cos(a)));-1!==this._uniforms[cc.UNIFORM_RANDOM01_S]&&this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_RANDOM01_S],Math.random(),Math.random(),Math.random(),Math.random())}},setUniformForModelViewProjectionMatrix:function(){this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_MVPMATRIX_S],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.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_MVPMATRIX_S],a.mat)},setUniformForModelViewAndProjectionMatrixWithMat4:function(){this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_MVMATRIX_S],cc.modelview_matrix_stack.top.mat);this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_PMATRIX_S],cc.projection_matrix_stack.top.mat)},
_setUniformForMVPMatrixWithMat4:function(a){if(!a)throw Error("modelView matrix is undefined.");this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_MVMATRIX_S],a.mat);this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_PMATRIX_S],cc.projection_matrix_stack.top.mat)},_updateProjectionUniform:function(){var a=cc.projection_matrix_stack;a.lastUpdated!==this._projectionUpdated&&(this._glContext.uniformMatrix4fv(this._uniforms[cc.UNIFORM_PMATRIX_S],!1,a.top.mat),this._projectionUpdated=
a.lastUpdated)},vertexShaderLog:function(){return this._glContext.getShaderInfoLog(this._vertShader)},getVertexShaderLog:function(){return this._glContext.getShaderInfoLog(this._vertShader)},getFragmentShaderLog:function(){return this._glContext.getShaderInfoLog(this._vertShader)},fragmentShaderLog:function(){return this._glContext.getShaderInfoLog(this._fragShader)},programLog:function(){return this._glContext.getProgramInfoLog(this._programObj)},getProgramLog:function(){return this._glContext.getProgramInfoLog(this._programObj)},
reset:function(){this._fragShader=this._vertShader=null;0<Object.keys(this._uniforms).length&&(this._uniforms={});this._glContext.deleteProgram(this._programObj);this._programObj=null;0<Object.keys(this._hashForUniforms).length&&(this._hashForUniforms={})},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(){var a=cc._renderContext;a.getShaderPrecisionFormat&&null==cc.GLProgram._highpSupported&&(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)};var types={GL_FLOAT:0,GL_INT:1,GL_FLOAT_VEC2:2,GL_FLOAT_VEC3:3,GL_FLOAT_VEC4:4,GL_FLOAT_MAT4:5,GL_CALLBACK:6,GL_TEXTURE:7};cc.UniformValue=function(a,b){this._uniform=a;this._glprogram=b;this._value=null;this._type=-1};
cc.UniformValue.prototype={setFloat:function(a){this._value=a;this._type=types.GL_FLOAT},setInt:function(a){this._value=a;this._type=types.GL_INT},setVec2:function(a,b){this._value=[a,b];this._type=types.GL_FLOAT_VEC2},setVec2v:function(a){this._value=a.slice(0);this._type=types.GL_FLOAT_VEC2},setVec3:function(a,b,c){this._value=[a,b,c];this._type=types.GL_FLOAT_VEC3},setVec3v:function(a){this._value=a.slice(0);this._type=types.GL_FLOAT_VEC3},setVec4:function(a,b,c,d){this._value=[a,b,c,d];this._type=
types.GL_FLOAT_VEC4},setVec4v:function(a){this._value=a.slice(0);this._type=types.GL_FLOAT_VEC4},setMat4:function(a){this._value=a.slice(0);this._type=types.GL_FLOAT_MAT4},setCallback:function(a){this._value=a;this._type=types.GL_CALLBACK},setTexture:function(a,b){this._value=b;this._textureId=a;this._type=types.GL_TEXTURE},apply:function(){switch(this._type){case types.GL_INT:this._glprogram.setUniformLocationWith1i(this._uniform._location,this._value);break;case types.GL_FLOAT:this._glprogram.setUniformLocationWith1f(this._uniform._location,
this._value);break;case types.GL_FLOAT_VEC2:this._glprogram.setUniformLocationWith2fv(this._uniform._location,this._value);break;case types.GL_FLOAT_VEC3:this._glprogram.setUniformLocationWith3fv(this._uniform._location,this._value);break;case types.GL_FLOAT_VEC4:this._glprogram.setUniformLocationWith4fv(this._uniform._location,this._value);break;case types.GL_FLOAT_MAT4:this._glprogram.setUniformLocationWithMatrix4fv(this._uniform._location,this._value);break;case types.GL_CALLBACK:this._value(this._glprogram,
this._uniform);break;case types.GL_TEXTURE:this._glprogram.setUniformLocationWith1i(this._uniform._location,this._value),cc.glBindTexture2DN(this._value,this._textureId)}}};
cc.GLProgramState=function(a){this._glprogram=a;this._uniforms={};this._boundTextureUnits={};this._textureUnitIndex=1;for(var b=a._glContext.getProgramParameter(a._programObj,a._glContext.ACTIVE_UNIFORMS),c=0;c<b;c+=1){var d=a._glContext.getActiveUniform(a._programObj,c);if(0!==d.name.indexOf("CC_")){d._location=a._glContext.getUniformLocation(a._programObj,d.name);d._location._name=d.name;var e=new cc.UniformValue(d,a);this._uniforms[d.name]=e}}};
cc.GLProgramState.prototype={apply:function(a){this._glprogram.use();a&&this._glprogram._setUniformForMVPMatrixWithMat4(a);for(var b in this._uniforms)this._uniforms[b].apply()},setGLProgram:function(a){this._glprogram=a},getGLProgram:function(){return this._glprogram},getUniformCount:function(){return this._uniforms.length},getUniformValue:function(a){return this._uniforms[a]},setUniformInt:function(a,b){var c=this.getUniformValue(a);c?c.setInt(b):cc.log("cocos2d: warning: Uniform not found: "+a)},
setUniformFloat:function(a,b){var c=this.getUniformValue(a);c?c.setFloat(b):cc.log("cocos2d: warning: Uniform not found: "+a)},setUniformVec2:function(a,b,c){var d=this.getUniformValue(a);d?d.setVec2(b,c):cc.log("cocos2d: warning: Uniform not found: "+a)},setUniformVec2v:function(a,b){var c=this.getUniformValue(a);c?c.setVec2v(b):cc.log("cocos2d: warning: Uniform not found: "+a)},setUniformVec3:function(a,b,c,d){var e=this.getUniformValue(a);e?e.setVec3(b,c,d):cc.log("cocos2d: warning: Uniform not found: "+
a)},setUniformVec3v:function(a,b){var c=this.getUniformValue(a);c?c.setVec3v(b):cc.log("cocos2d: warning: Uniform not found: "+a)},setUniformVec4:function(a,b,c,d,e){var f=this.getUniformValue(a);f?f.setVec4(b,c,d,e):cc.log("cocos2d: warning: Uniform not found: "+a)},setUniformVec4v:function(a,b){var c=this.getUniformValue(a);c?c.setVec4v(b):cc.log("cocos2d: warning: Uniform not found: "+a)},setUniformMat4:function(a,b){var c=this.getUniformValue(a);c?c.setMat4(b):cc.log("cocos2d: warning: Uniform not found: "+
a)},setUniformCallback:function(a,b){var c=this.getUniformValue(a);c?c.setCallback(b):cc.log("cocos2d: warning: Uniform not found: "+a)},setUniformTexture:function(a,b){var c=this.getUniformValue(a);if(c){var d=this._boundTextureUnits[a];d?c.setTexture(b,d):(c.setTexture(b,this._textureUnitIndex),this._boundTextureUnits[a]=this._textureUnitIndex++)}}};cc.GLProgramState._cache={};
cc.GLProgramState.getOrCreateWithGLProgram=function(a){var b=cc.GLProgramState._cache[a.__instanceId];b||(b=new cc.GLProgramState(a),cc.GLProgramState._cache[a.__instanceId]=b);return b};cc._currentProjectionMatrix=-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(){cc.kmGLFreeAll();cc._currentProjectionMatrix=-1;if(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=cc.ENABLE_GL_STATE_CACHE?function(a){a!==cc._currentShaderProgram&&(cc._currentShaderProgram=a,cc._renderContext.useProgram(a))}: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.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.glBlendFunc=cc.ENABLE_GL_STATE_CACHE?function(a,b){if(a!==cc._blendingSource||b!==cc._blendingDest)cc._blendingSource=a,cc._blendingDest=b,cc.setBlending(a,b)}:cc.setBlending;
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.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.glBindTexture2D=function(a){cc.glBindTexture2DN(0,a)};
cc.glBindTexture2DN=cc.ENABLE_GL_STATE_CACHE?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)}}: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._webTextureObj)};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.IMAGE_FORMAT_JPEG=0;cc.IMAGE_FORMAT_PNG=1;cc.IMAGE_FORMAT_RAWDATA=9;cc.NextPOT=function(a){--a;a|=a>>1;a|=a>>2;a|=a>>4;a|=a>>8;return(a|a>>16)+1};
cc.RenderTexture=cc.Node.extend({sprite:null,clearFlags:0,clearDepthVal:0,autoDraw:!1,_texture:null,_pixelFormat:0,clearStencilVal:0,_clearColor:null,_className:"RenderTexture",ctor:function(a,b,c,d){cc.Node.prototype.ctor.call(this);this._cascadeOpacityEnabled=this._cascadeColorEnabled=!0;this._pixelFormat=cc.Texture2D.PIXEL_FORMAT_RGBA8888;this._clearColor=new cc.Color(0,0,0,255);void 0!==a&&void 0!==b&&(c=c||cc.Texture2D.PIXEL_FORMAT_RGBA8888,this.initWithWidthAndHeight(a,b,c,d||0));this.setAnchorPoint(0,
0)},_createRenderCmd:function(){return cc._renderType===cc.game.RENDER_TYPE_CANVAS?new cc.RenderTexture.CanvasRenderCmd(this):new cc.RenderTexture.WebGLRenderCmd(this)},visit:function(a){var b=this._renderCmd;a=a?a._renderCmd:null;if(this._visible){var c=cc.renderer;b.visit(a);c.pushRenderCommand(b);this.sprite.visit(this);b._dirtyFlag=0}else b._propagateFlagsDown(a)},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){cc.log("saveToFile isn't supported on cocos2d-html5");
return null},listenToBackground:function(a){},listenToForeground:function(a){}});_p=cc.RenderTexture.prototype;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){this._rootCtor(a);this._needDraw=!1;this._clearColorStr="rgba(255,255,255,1)";this._cacheCanvas=document.createElement("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 b=cc.contentScaleFactor();e.width=0|a*b;e.height=0|c*b;a=new cc.Texture2D;a.initWithElement(e);a.handleLoadedTexture();a=d.sprite=new cc.Sprite(a);a.setBlendFunc(cc.ONE,cc.ONE_MINUS_SRC_ALPHA);d.autoDraw=!1;d.addChild(a);return!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=a.sprite._renderCmd;a._notifyRegionStatus&&a._notifyRegionStatus(cc.Node.CanvasRenderCmd.RegionStatus.Dirty)};
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")}})();(function(){cc.RenderTexture.WebGLRenderCmd=function(a){this._rootCtor(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.needDraw=function(){return this._needDraw&&this._node.autoDraw};a.rendering=function(a){var b=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&b.COLOR_BUFFER_BIT&&(e=b.getParameter(b.COLOR_CLEAR_VALUE),b.clearColor(a._clearColor.r/255,a._clearColor.g/255,a._clearColor.b/255,a._clearColor.a/255));d&b.DEPTH_BUFFER_BIT&&(f=b.getParameter(b.DEPTH_CLEAR_VALUE),b.clearDepth(a.clearDepthVal));d&b.STENCIL_BUFFER_BIT&&(g=
b.getParameter(b.STENCIL_CLEAR_VALUE),b.clearStencil(a.clearStencilVal));b.clear(d);d&b.COLOR_BUFFER_BIT&&b.clearColor(e[0],e[1],e[2],e[3]);d&b.DEPTH_BUFFER_BIT&&b.clearDepth(f);d&b.STENCIL_BUFFER_BIT&&b.clearStencil(g)}a.sortAllChildren();b=a._children;for(d=0;d<b.length;d++)e=b[d],e!==a.sprite&&e.visit(a.sprite);a.end()}};a.clearStencil=function(a){var b=cc._renderContext,d=b.getParameter(b.STENCIL_CLEAR_VALUE);b.clearStencil(a);b.clear(b.STENCIL_BUFFER_BIT);b.clearStencil(d)};a.cleanup=function(){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 b=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);if(cc.configuration.supportsNPOT()){h=a;var k=c}else h=cc.NextPOT(a),k=cc.NextPOT(c);for(var m=new Uint8Array(h*k*4),n=0;n<h*k*4;n++)m[n]=0;this._pixelFormat=d;n=b._texture=new cc.Texture2D;if(!b._texture)return!1;n.initWithData(m,b._pixelFormat,h,k,cc.size(a,c));d=g.getParameter(g.RENDERBUFFER_BINDING);if(cc.configuration.checkForGLExtension("GL_QCOM")){this._textureCopy=new cc.Texture2D;if(!this._textureCopy)return!1;this._textureCopy.initWithData(m,
b._pixelFormat,h,k,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,h,k),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=b.sprite=new cc.Sprite(n);a.scaleY=-1;a.setBlendFunc(g.ONE,g.ONE_MINUS_SRC_ALPHA);g.bindRenderbuffer(g.RENDERBUFFER,
d);g.bindFramebuffer(g.FRAMEBUFFER,this._oldFBO);b.autoDraw=!1;b.addChild(a);return!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=d.width/this._fullRect.width*(this._fullRect.x-this._rtTextureRect.x);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 b=cc._renderContext,m=[0,0,0,0],n=0,p=0;h&b.COLOR_BUFFER_BIT&&(m=b.getParameter(b.COLOR_CLEAR_VALUE),b.clearColor(a,c,d,e));h&b.DEPTH_BUFFER_BIT&&(n=b.getParameter(b.DEPTH_CLEAR_VALUE),b.clearDepth(f));h&b.STENCIL_BUFFER_BIT&&(p=b.getParameter(b.STENCIL_CLEAR_VALUE),b.clearStencil(g));
b.clear(h);h&b.COLOR_BUFFER_BIT&&b.clearColor(m[0],m[1],m[2],m[3]);h&b.DEPTH_BUFFER_BIT&&b.clearDepth(n);h&b.STENCIL_BUFFER_BIT&&b.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 b=this._node;
b.begin();var d=cc._renderContext,e=d.getParameter(d.DEPTH_CLEAR_VALUE);d.clearDepth(a);d.clear(d.DEPTH_BUFFER_BIT);d.clearDepth(e);b.end()}})();cc.LabelBMFont=cc.SpriteBatchNode.extend({_opacityModifyRGB:!1,_string:"",_config:null,_fntFile:"",_initialString:"",_alignment:cc.TEXT_ALIGNMENT_CENTER,_width:-1,_lineBreakWithoutSpaces:!1,_imageOffset:null,_textureLoaded:!1,_className:"LabelBMFont",_createRenderCmd:function(){return cc._renderType===cc.game.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._string&&0<this._string.length&&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._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._config&&cc.log("cc.LabelBMFont.initWithString(): re-init is no longer supported");if(b){var f=cc.loader.getRes(b);if(!f&&(f=cc.FntFrameCache[b]||cc.FntFrameCache[cc.path.basename(b)],
!f))return cc.log("cc.LabelBMFont.initWithString(): Impossible to create font. Please check file"),!1;this._config=f;this._fntFile=b;b=f.atlasName;(b=cc.spriteFrameCache.getSpriteFrame(b)||cc.spriteFrameCache.getSpriteFrame(cc.path.basename(b)))?(f=b.getTexture(),this._spriteFrame=b):f=cc.textureCache.addImage(f.atlasName);(this._textureLoaded=b=f.isLoaded())||f.addEventListener("load",function(a){this._textureLoaded=!0;this.initWithTexture(a,this._initialString.length);this.setString(this._initialString,
!0);this.dispatchEvent("load")},this)}else f=new cc.Texture2D,b=new Image,f.initWithElement(b),this._textureLoaded=!1;return this.initWithTexture(f,a.length)?(this._alignment=d||cc.TEXT_ALIGNMENT_LEFT,this._imageOffset=e||cc.p(0,0),this._width=void 0===c?-1:c,this._realOpacity=255,this._realColor=cc.color(255,255,255,255),this._contentSize.width=0,this._contentSize.height=0,this.setAnchorPoint(.5,.5),this.setString(a,!0),!0):!1},createFontChars:function(){var a=this._string,b=a?a.length:0,c=this._renderCmd,
d=c._texture||this._texture,e=0,f=cc.size(0,0),g=0,h=1,k,m=this._config,n=m.kerningDict,p=m.commonHeight,r=m.fontDefDictionary;for(k=0;k<b-1;k++)10===a.charCodeAt(k)&&h++;var t=p*h;h=-(p-p*h);var u=-1;for(k=0;k<b;k++)if(p=a.charCodeAt(k),0!==p)if(10===p)e=0,h-=m.commonHeight;else{u=n[u<<16|p&65535]||0;var v=r[p];v||(cc.log("cocos2d: LabelBMFont: character not found "+a[k]),v={rect:{x:0,y:0,width:0,height:0},xOffset:0,yOffset:0,xAdvance:0});var x=cc.rect(v.rect.x,v.rect.y,v.rect.width,v.rect.height);
x=cc.rectPixelsToPoints(x);x.x+=this._imageOffset.x;x.y+=this._imageOffset.y;var w=!1;if(this._spriteFrame){var y=this._spriteFrame._rect;if(this._spriteFrame._rotated){w=!0;var z=x.x;x.x=x.y+y.x;x.y=z+y.y}else x.x+=y.x,x.y+=y.y}(y=this.getChildByTag(k))?c._updateCharTexture(y,x,p,w):(y=new cc.Sprite,y.initWithTexture(d,x,w),y._newTextureWhenChangeColor=!0,this.addChild(y,0,k));y.opacityModifyRGB=this._opacityModifyRGB;c._updateCharColorAndOpacity(y);x=cc.p(e+v.xOffset+.5*v.rect.width+u,h+(m.commonHeight-
v.yOffset)-.5*x.height*cc.contentScaleFactor());y.setPosition(cc.pointPixelsToPoints(x));e+=v.xAdvance+u;u=p;g<e&&(g=e)}f.width=v&&v.xAdvance<v.rect.width?g-v.xAdvance+v.rect.width:g;f.height=t;this.setContentSize(cc.sizePixelsToPoints(f))},updateString:function(a){var b=this._children;if(b)for(var c=0,d=b.length;c<d;c++){var e=b[c];e&&(e.visible=!1)}this._config&&this._string&&0<this._string.length&&this.createFontChars();a||this.updateLabel()},getString:function(){return this._initialString},setString:function(a,
b){a=String(a);void 0===b&&(b=!0);if(void 0===a||"string"!==typeof 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;g<b;g++)f+=a[g].length;f=f+b-d;var h=this._getCharsWidth(f,a[b].length-
1);if(h>c&&1<e.length){d=c/h*e.length|0;g=e.substr(d);for(var k=h-this._getCharsWidth(f+d,g.length-1),m,n=0,p=0;k>c&&100>p++;)d*=c/k,d|=0,g=e.substr(d),k=h-this._getCharsWidth(f+d,g.length-1);for(p=0;k<c&&100>p++;)g&&(n=(m=cc.LabelTTF._wordRex.exec(g))?m[0].length:1,m=g),this._lineBreakWithoutSpaces&&(n=0),d+=n,g=e.substr(d),k=h-this._getCharsWidth(f+d,g.length-1);d-=n;0===d&&(d=1,m=m.substr(1));c=e.substr(0,d);cc.LabelTTF.wrapInspection&&cc.LabelTTF._symbolRex.test(m||g)&&(n=(f=cc.LabelTTF._lastWordRex.exec(c))?
f[0].length:0,this._lineBreakWithoutSpaces&&(n=0),d-=n,m=e.substr(d),c=e.substr(0,d));cc.LabelTTF._firsrEnglish.test(m)&&(f=cc.LabelTTF._lastEnglish.exec(c))&&c!==f[0]&&(n=f[0].length,this._lineBreakWithoutSpaces&&(n=0),d-=n,m=e.substr(d),c=e.substr(0,d));a[b]=m||g;a.splice(b,0,c)}},updateLabel:function(){this.string=this._initialString;var a;if(0<this._width){var b=this.string.split("\n"),c="",d=0;for(a=0;a<b.length;a++){var e=b.length;this._checkWarp(b,a,this._width*this._scaleX,d);e<b.length&&
d++;0<a&&(c+="\n");c+=b[a]}c+=String.fromCharCode(0);this._setString(c,!1)}if(this._alignment!==cc.TEXT_ALIGNMENT_LEFT)for(b=a=0,c=this._string.length,d=[],e=0;e<c;e++)if(10===this._string[e].charCodeAt(0)||0===this._string[e].charCodeAt(0)){var f=d.length;if(0===f)b++;else{var g=a+f-1+b;if(!(0>g)){var h=this.getChildByTag(g);if(null!=h){var k=h.getPositionX()+h._getWidth()/2;h=0;switch(this._alignment){case cc.TEXT_ALIGNMENT_CENTER:h=this.width/2-k/2;break;case cc.TEXT_ALIGNMENT_RIGHT:h=this.width-
k}if(0!==h)for(k=0;k<f;k++)g=a+k+b,0>g||(g=this.getChildByTag(g))&&(g.x+=h);a+=f;b++;d.length=0}}}}else d.push(this._string[a])},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);b?(this._fntFile=a,this._config=b,a=cc.textureCache.addImage(b.atlasName),(this._textureLoaded=b=a.isLoaded())?(this.setTexture(a),this._string&&0<this._string.length&&this.createFontChars()):a.addEventListener("load",function(a){this._textureLoaded=
!0;this.setTexture(a);this._string&&0<this._string.length&&this.createFontChars();this._changeTextureColor();this.updateLabel();this.dispatchEvent("load")},this)):cc.log("cc.LabelBMFont.setFntFile() : Impossible to create font. Please check file")}},getFntFile:function(){return this._fntFile},setTexture:function(a){this._texture=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|b&65535).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){a=a.charCodeAt(0);return 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,this._isspace_unicode(a[b]))){for(var c=b-1;0<=c;--c)if(this._isspace_unicode(a[c]))b=c;else break;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);cc.defineGetterSetter(a,"string",a.getString,a._setStringForSetter);cc.defineGetterSetter(a,"boundingWidth",a._getBoundingWidth,a.setBoundingWidth);cc.defineGetterSetter(a,"textAlign",a._getAlignment,a.setAlignment);cc.defineGetterSetter(a,"texture",a.getTexture,a.setTexture)})();cc.LabelBMFont.create=function(a,b,c,d,e){return new cc.LabelBMFont(a,b,c,d,e)};cc.FntFrameCache={};
var _fntLoader={FNT_HEAD:/fntframes [^\n]*(\n|$)/gi,FNT_FRAME_NAME:/fntframe [^\n]*(\n|$)/gi,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;c<d;c++){var e=a[c],f=e.indexOf("="),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},_parseFntContent:function(a,b,c,d){var e=this._parseStrToObj(b.match(this.COMMON_EXP)[0]);a.commonHeight=e.lineHeight;if(cc._renderType===cc.game.RENDER_TYPE_WEBGL){var f=cc.configuration.getMaxTextureSize();(e.scaleW>f.width||e.scaleH>f.height)&&cc.log("cc.LabelBMFont._parseCommonArguments(): page can't be larger than supported")}1!==e.pages&&cc.log("cc.LabelBMFont._parseCommonArguments(): only supports 1 page");e=this._parseStrToObj(b.match(this.PAGE_EXP)[0]);
0!==e.id&&cc.log("cc.LabelBMFont._parseImageFileName() : file could not be found");a.atlasName=d?cc.path.join(cc.path.dirname(d.path)+e.file):cc.path.changeBasename(c,e.file);e=b.match(this.CHAR_EXP);f=a.fontDefDictionary={};c=0;for(d=e.length;c<d;c++){var g=this._parseStrToObj(e[c]);f[g.id]={rect:{x:g.x,y:g.y,width:g.width,height:g.height},xOffset:g.xoffset,yOffset:g.yoffset,xAdvance:g.xadvance}}e=a.kerningDict={};if(b=b.match(this.KERNING_EXP))for(c=0,d=b.length;c<d;c++)f=this._parseStrToObj(b[c]),
e[f.first<<16|f.second&65535]=f.amount;return a},parseFnt:function(a,b){var c={},d=a.match(this.FNT_HEAD);if(d){var e=this._parseStrToObj(d[0]);if(e&&e.count){a=a.substr(d[0].length);d=a.split("----");for(var f=0;f<e.count;++f){var g=d[f],h=g.match(this.FNT_FRAME_NAME);if(h){var k=this._parseStrToObj(h[0]);if(k&&k.name){c={};var m=cc.path.join(cc.path.dirname(b),k.name);cc.FntFrameCache[m]=this._parseFntContent(c,g.substr(h[0].length),b,{path:k.name})}}}}}else c=this._parseFntContent(c,a,b);return c},
load:function(a,b,c,d){var e=this;cc.loader.loadTxt(a,function(a,c){if(a)return d(a);d(null,e.parseFnt(c,b))})}};cc.loader.register(["fnt"],_fntLoader);(function(){cc.LabelBMFont.CanvasRenderCmd=function(a){this._rootCtor(a)};var a=cc.LabelBMFont.CanvasRenderCmd.prototype=Object.create(cc.Node.CanvasRenderCmd.prototype);a.constructor=cc.LabelBMFont.CanvasRenderCmd;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.setTexture=function(a){for(var b=this._node,d=b._children,e=this._displayedColor,f=0;f<d.length;f++){var g=d[f],h=g._renderCmd,k=h._displayedColor;if(b._texture===h._texture||k.r===e.r&&k.g===e.g&&k.b===e.b)g.texture=a}b._texture=a};a._changeTextureColor=function(){var a=this._node,c=a._texture,d=c.getContentSize(),e=a._texture,f=e.getHtmlElementObj(),g=this._displayedColor,h=cc.rect(0,0,f.width,f.height);c&&0<d.width&&f&&(c=e._generateColorTexture(g.r,
g.g,g.b,h),a.setTexture(c))};a._updateChildrenDisplayedOpacity=function(a){cc.Node.prototype.updateDisplayedOpacity.call(a,this._displayedOpacity)};a._updateChildrenDisplayedColor=function(a){cc.Node.prototype.updateDisplayedColor.call(a,this._displayedColor)}})();(function(){cc.LabelBMFont.WebGLRenderCmd=function(a){this._rootCtor(a)};var a=cc.LabelBMFont.WebGLRenderCmd.prototype=Object.create(cc.Node.WebGLRenderCmd.prototype);a.constructor=cc.LabelBMFont.WebGLRenderCmd;a.setTexture=function(a){this._node.setOpacityModifyRGB(this._node._texture.hasPremultipliedAlpha())};a._updateCharTexture=function(a,c,d,e){a.setTextureRect(c,e);a.visible=!0};a._changeTextureColor=function(){};a._updateCharColorAndOpacity=function(){}})();cc.LabelAtlas=cc.LabelBMFont.extend({_className:"LabelAtlas",ctor:function(a,b,c,d,e){cc.SpriteBatchNode.prototype.ctor.call(this);this._imageOffset=cc.p(0,0);this._cascadeOpacityEnabled=this._cascadeColorEnabled=!0;b&&cc.LabelAtlas.prototype.initWithString.call(this,a,b,c,d,e)},_createRenderCmd:function(){return cc._renderType===cc.game.RENDER_TYPE_WEBGL?new cc.LabelBMFont.WebGLRenderCmd(this):new cc.LabelBMFont.CanvasRenderCmd(this)},_createFntConfig:function(a,b,c,d){var e={};e.commonHeight=c;
var f=e.fontDefDictionary={},g=a.pixelsWidth;a=a.pixelsHeight;d=d.charCodeAt(0);for(var h=0,k=c;k<=a;k+=c)for(var m=0;m<g;m+=b)f[d+h]={rect:{x:m,y:k-c,width:b,height:c},xOffset:0,yOffset:0,xAdvance:b},++h;e.kerningDict={};return e},initWithString:function(a,b,c,d,e){this._string=this._initialString=a=a+""||"";if(void 0===c){e=cc.loader.getRes(b);if(1!==parseInt(e.version,10))return cc.log("cc.LabelAtlas.initWithString(): Unsupported version. Upgrade cocos2d version"),!1;var f=cc.path.changeBasename(b,
e.textureFilename);d=cc.contentScaleFactor();c=parseInt(e.itemWidth,10)/d;d=parseInt(e.itemHeight,10)/d;e=String.fromCharCode(parseInt(e.firstChar,10))}else f=b,c=c||0,d=d||0,e=e||" ";if(b){this._fntFile="dummy_fnt_file:"+f;b=f;var g=cc.spriteFrameCache.getSpriteFrame(b)||cc.spriteFrameCache.getSpriteFrame(cc.path.basename(b));g?(b=g.getTexture(),this._spriteFrame=g):b=cc.textureCache.addImage(f);c=this._createFntConfig(b,c,d,e);c.atlasName=f;this._config=c;(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=cc.TEXT_ALIGNMENT_LEFT,this._imageOffset=cc.p(0,0),this._width=-1,this._realOpacity=255,this._realColor=cc.color(255,255,255,255),this._contentSize.width=0,this._contentSize.height=0,this.setString(a,!0),!0):
!1},setFntFile:function(){cc.warn("setFntFile doesn't support with LabelAtlas.")}});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._textureToRender,f=a._itemWidth,g=a._itemHeight,h=0,k=-1;h<d;h++){var m=
c.charCodeAt(h)-a._mapStartChar.charCodeAt(0),n=parseInt(m%a._itemsPerRow,10);m=parseInt(m/a._itemsPerRow,10);if(!(0>n||0>m||(n=cc.rect(n*f,m*g,f,g),m=e._contentSize,0>n.x||0>n.y||n.x+n.width>m.width||n.y+n.height>m.height))){k++;m=c.charCodeAt(h);var p=a.getChildByTag(h);p?32===m?(p.init(),p.setTextureRect(cc.rect(0,0,10,10),!1,cc.size(0,0))):(p.initWithTexture(e,n),p.visible=!0):(p=new cc.Sprite,32===m?(p.init(),p.setTextureRect(cc.rect(0,0,10,10),!1,cc.size(0,0))):p.initWithTexture(e,n),cc.Node.prototype.addChild.call(a,
p,0,h));p.setPosition(k*f+f/2,g/2)}}this.updateContentSize(h,k+1)};a.updateContentSize=function(a,c){var b=this._node,e=b._contentSize;a!==c&&a*b._itemWidth===e.width&&b._itemHeight===e.height&&b.setContentSize(c*b._itemWidth,b._itemHeight)};a.setString=function(a){a=this._node;if(a._children){a=a._children;for(var b=a.length,d=0;d<b;d++){var e=a[d];e&&!e._lateChild&&(e.visible=!1)}}};a._addChild=function(){child._lateChild=!0}})();(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._updateColor=function(){if(this._colorF32Array){var a=this._displayedColor,c=this._displayedOpacity/255;this._node._opacityModifyRGB?(this._colorF32Array[0]=a.r*c/255,this._colorF32Array[1]=a.g*c/255,this._colorF32Array[2]=a.b*c/255):(this._colorF32Array[0]=
a.r/255,this._colorF32Array[1]=a.g/255,this._colorF32Array[2]=a.b/255);this._colorF32Array[3]=c}};a.setCascade=function(){var a=this._node;a._cascadeOpacityEnabled=!0;a._cascadeColorEnabled=!0};a.rendering=function(a){cc.AtlasNode.WebGLRenderCmd.prototype.rendering.call(this,a);if(cc.LABELATLAS_DEBUG_DRAW){var b=this._node;a=b.getContentSize();b=b.getBoundingBoxToWorld();var d=b.x,e=b.y;a.width=b.width;a.height=b.height;a=[cc.p(d,e),cc.p(d+a.width,e),cc.p(a.width+d,a.height+e),cc.p(d,e+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;var 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=a._itemWidth,p=a._itemHeight,r=0,t=-1;r<d;r++){var u=c.charCodeAt(r)-a._mapStartChar.charCodeAt(0),
v=u%a._itemsPerRow,x=0|u/a._itemsPerRow;if(!(0>v||0>x||v*n+n>g||x*p+p>f)){t++;if(cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL){v=(2*v*h+1)/(2*g);u=v+(2*h-2)/(2*g);x=(2*x*k+1)/(2*f);var w=x+(2*k-2)/(2*f)}else v=v*h/g,u=v+h/g,x=x*k/f,w=x+k/f;var y=m[r],z=y.tl,A=y.tr,B=y.bl;y=y.br;z.texCoords.u=v;z.texCoords.v=x;A.texCoords.u=u;A.texCoords.v=x;B.texCoords.u=v;B.texCoords.v=w;y.texCoords.u=u;y.texCoords.v=w;B.vertices.x=t*n;B.vertices.y=0;B.vertices.z=0;y.vertices.x=t*n+n;y.vertices.y=0;y.vertices.z=0;z.vertices.x=
t*n;z.vertices.y=a._itemHeight;z.vertices.z=0;A.vertices.x=t*n+n;A.vertices.y=a._itemHeight;A.vertices.z=0}}this._updateColor();this.updateContentSize(r,t+1);0<d&&(e.dirty=!0,a=e.totalQuads,d>a&&e.increaseTotalQuadsWith(d-a))};a.updateContentSize=function(a,c){var b=this._node,e=b._contentSize;a!==c&&a*b._itemWidth===e.width&&b._itemHeight===e.height&&b.setContentSize(c*b._itemWidth,b._itemHeight)};a.setString=function(a){a=a.length;a>this._textureAtlas.totalQuads&&this._textureAtlas.resizeCapacity(a)};
a._addChild=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(){cc.log("cc.MotionStreak.getOpacity has not been supported.");return 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 Error("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;this._maxPoints=a=(0|60*a)+2;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);return!0},tintWithColor:function(a){this.color=a;for(var b=this._colorPointer,c=0,d=2*this._nuPoints;c<d;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=0,d=this._nuPoints,e=this._pointState,f=this._pointVertexes,g=this._vertices,h=this._colorPointer;for(b=0;b<d;b++)if(e[b]-=a,0>=e[b])c++;else{var k=b-c;if(0<c){e[k]=e[b];f[2*k]=f[2*b];f[2*k+1]=f[2*b+1];var m=2*b;var n=2*k;g[2*n]=g[2*m];g[2*n+1]=g[2*m+1];g[2*(n+1)]=g[2*(m+1)];g[2*(n+1)+1]=g[2*(m+1)+1];m*=4;n*=4;h[n+0]=h[m+0];h[n+1]=h[m+1];h[n+
2]=h[m+2];h[n+4]=h[m+4];h[n+5]=h[m+5];h[n+6]=h[m+6]}else n=8*k;k=255*e[k];h[n+3]=k;h[n+7]=k}d-=c;b=!0;d>=this._maxPoints?b=!1:0<d&&(a=cc.pDistanceSQ(cc.p(f[2*(d-1)],f[2*(d-1)+1]),this._positionR)<this._minSeg,n=1===d?!1:cc.pDistanceSQ(cc.p(f[2*(d-2)],f[2*(d-2)+1]),this._positionR)<2*this._minSeg,a||n)&&(b=!1);b&&(f[2*d]=this._positionR.x,f[2*d+1]=this._positionR.y,e[d]=1,e=8*d,b=this.getDisplayedColor(),h[e]=b.r,h[e+1]=b.g,h[e+2]=b.b,h[e+4]=b.r,h[e+5]=b.g,h[e+6]=b.b,h[e+3]=255,h[e+7]=255,0<d&&this.fastMode&&
(1<d?cc.vertexLineToPolygon(f,this._stroke,this._vertices,d,1):cc.vertexLineToPolygon(f,this._stroke,this._vertices,0,2)),d++);this.fastMode||cc.vertexLineToPolygon(f,this._stroke,this._vertices,0,d);if(d&&this._previousNuPoints!==d){f=1/d;h=this._texCoords;for(b=0;b<d;b++)h[4*b]=0,h[4*b+1]=f*b,h[2*(2*b+1)]=1,h[2*(2*b+1)+1]=f*b;this._previousNuPoints=d}this._nuPoints=d}},_createRenderCmd:function(){return cc._renderType===cc.game.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){this._rootCtor(a);this._needDraw=!0;this._matrix=new cc.math.Matrix4;this._matrix.identity();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;if(!(1>=b._nuPoints)&&b.texture&&b.texture.isLoaded()){a=a||cc._renderContext;var c=this._worldTransform;this._matrix.mat[0]=c.a;this._matrix.mat[4]=c.c;this._matrix.mat[12]=c.tx;this._matrix.mat[1]=c.b;this._matrix.mat[5]=c.d;this._matrix.mat[13]=c.ty;this._glProgramState.apply(this._matrix);cc.glBlendFunc(b._blendFunc.src,b._blendFunc.dst);cc.glBindTexture2D(b.texture);a.enableVertexAttribArray(cc.VERTEX_ATTRIB_POSITION);
a.enableVertexAttribArray(cc.VERTEX_ATTRIB_COLOR);a.enableVertexAttribArray(cc.VERTEX_ATTRIB_TEX_COORDS);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,_gridRect:null,ctor:function(a){cc.Node.prototype.ctor.call(this);void 0===a&&(a=cc.rect());this._gridRect=a},getGrid:function(){return this.grid},setGrid:function(a){this.grid=a},setGridRect:function(a){this._gridRect=a},getGridRect:function(){return this._gridRect},setTarget:function(a){this._target=a},_createRenderCmd:function(){return cc._renderType===cc.game.RENDER_TYPE_WEBGL?new cc.NodeGrid.WebGLRenderCmd(this):new cc.Node.CanvasRenderCmd(this)}});
_p=cc.NodeGrid.prototype;cc.defineGetterSetter(_p,"target",null,_p.setTarget);cc.NodeGrid.create=function(){return new cc.NodeGrid};(function(){cc.NodeGrid.WebGLRenderCmd=function(a){this._rootCtor(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 b=this._node;if(b._visible){if(a=a||this.getParentRenderCmd())this._curLevel=a._curLevel+1;var d=cc.current_stack;d.stack.push(d.top);
this._syncStatus(a);d.top=this._stackMatrix;cc.renderer.pushRenderCommand(this._gridBeginCommand);b._target&&b._target.visit();if((a=b._children)&&0<a.length){var e=a.length;b.sortAllChildren();for(b=0;b<e;b++){var f=a[b];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.DrawNode=cc.Node.extend({_buffer:null,_blendFunc:null,_lineWidth:1,_drawColor:null,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)}});cc.DrawNode.create=function(){return new cc.DrawNode};cc.DrawNode.TYPE_DOT=0;cc.DrawNode.TYPE_SEGMENT=1;cc.DrawNode.TYPE_POLY=2;
cc.game.addEventListener(cc.game.EVENT_RENDERER_INITED,function(){if(cc._renderType===cc.game.RENDER_TYPE_CANVAS)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.extend(cc.DrawNode.prototype,{_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.SRC_ALPHA,cc.ONE_MINUS_SRC_ALPHA);this.init();this._localBB=new cc.Rect},setLocalBB:function(a,b,c,d){var e=this._localBB;void 0===b?(e.x=a.x,e.y=a.y,e.width=a.width,e.height=a.height):(e.x=a,e.y=b,e.width=c,e.height=d)},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";if(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;m<=d;m++){var n=m*h;k.push(cc.p(b*Math.cos(n+c)+a.x,b*Math.sin(n+c)+a.y))}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;k<d;k++)g.push(cc.p(Math.pow(1-h,2)*a.x+2*(1-h)*h*b.x+h*h*c.x,Math.pow(1-h,2)*a.y+2*(1-h)*h*b.y+h*h*c.y)),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;m<e;m++)h.push(cc.p(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,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)),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,.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;m<c+1;m++)h=m/c,1===h?(g=a.length-1,h=1):(g=0|h/k,h=(h-k*g)/k),g=cc.cardinalSplineAt(cc.getControlPointAt(a,g-1),cc.getControlPointAt(a,g-0),cc.getControlPointAt(a,g+1),cc.getControlPointAt(a,g+2),b,h),f.push(g);a=new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY);a.verts=f;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;d<e;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)}});
else if(cc._renderType===cc.game.RENDER_TYPE_WEBGL){var a=null,b=[],c=cc.p(),d=cc.p(),e=new Uint32Array(1),f=cc.p(),g=cc.p(),h=cc.p(),k=cc.p(),m=[];cc.extend(cc.DrawNode.prototype,{_bufferCapacity:0,_vertexCount:0,_offset:0,_occupiedSize:0,_f32Buffer:null,_ui32Buffer:null,_dirty:!1,_className:"DrawNodeWebGL",manualRelease:!1,ctor:function(b,c){cc.Node.prototype.ctor.call(this);a||(a=new GlobalVertexBuffer(cc._renderContext,20*cc.DRAWNODE_TOTAL_VERTICES));this._renderCmd._shaderProgram=cc.shaderCache.programForKey(cc.SHADER_POSITION_LENGTHTEXTURECOLOR);
this._blendFunc=new cc.BlendFunc(cc.SRC_ALPHA,cc.ONE_MINUS_SRC_ALPHA);this._drawColor=cc.color(255,255,255,255);this._bufferCapacity=b||64;this.manualRelease=c;this._dirty=!0},onEnter:function(){cc.Node.prototype.onEnter.call(this);this._occupiedSize<this._bufferCapacity&&this._ensureCapacity(this._bufferCapacity)},onExit:function(){this.manualRelease||this.release();cc.Node.prototype.onExit.call(this)},release:function(){0<this._occupiedSize&&(this._vertexCount=0,a.freeBuffer(this._offset,20*this._occupiedSize),
this._occupiedSize=0)},_ensureCapacity:function(b){var c=this._occupiedSize,d=this._offset;if(b>c||this._bufferCapacity>c){var e=Math.max(Math.min(c+c,200),b,this._bufferCapacity);0!==c&&(a.freeBuffer(d,20*c),this._occupiedSize=0);b=this._offset=a.requestBuffer(20*e);if(0<=b){this._occupiedSize=this._bufferCapacity=e;this._f32Buffer=new Float32Array(a.data,b,5*this._occupiedSize);this._ui32Buffer=new Uint32Array(a.data,b,5*this._occupiedSize);if(0!==c&&d!==b)for(c=d/4+5*c,b/=4,d/=4;d<c;b++,d++)a.dataArray[b]=
a.dataArray[d];return!0}cc.warn("Failed to allocate buffer for DrawNode: buffer for "+e+" vertices requested");return!1}return!0},drawRect:function(a,c,d,e,f){e=null==e?this._lineWidth:e;f=f||this._drawColor;b.length=0;b.push(a.x,a.y,c.x,a.y,c.x,c.y,a.x,c.y);null==d?this._drawSegments(b,e,f,!0):this.drawPoly(b,d,e,f);b.length=0},drawCircle:function(a,e,f,g,h,k,m){k=k||this._lineWidth;m=m||this._drawColor;var n=2*Math.PI/g,p;for(p=b.length=0;p<=g;p++){var t=p*n;b.push(e*Math.cos(t+f)+a.x,e*Math.sin(t+
f)+a.y)}h&&b.push(a.x,a.y);k*=.5;p=0;for(a=b.length-2;p<a;p+=2)c.x=b[p],c.y=b[p+1],d.x=b[p+2],d.y=b[p+3],this.drawSegment(c,d,k,m);b.length=0},drawQuadBezier:function(a,c,d,e,f,g){f=f||this._lineWidth;g=g||this._drawColor;for(var h=0,k=b.length=0;k<e;k++)b.push(Math.pow(1-h,2)*a.x+2*(1-h)*h*c.x+h*h*d.x,Math.pow(1-h,2)*a.y+2*(1-h)*h*c.y+h*h*d.y),h+=1/e;b.push(d.x,d.y);this._drawSegments(b,f,g,!1);b.length=0},drawCubicBezier:function(a,c,d,e,f,g,h){g=g||this._lineWidth;h=h||this._drawColor;for(var k=
0,m=b.length=0;m<f;m++)b.push(Math.pow(1-k,3)*a.x+3*Math.pow(1-k,2)*k*c.x+3*(1-k)*k*k*d.x+k*k*k*e.x,Math.pow(1-k,3)*a.y+3*Math.pow(1-k,2)*k*c.y+3*(1-k)*k*k*d.y+k*k*k*e.y),k+=1/f;b.push(e.x,e.y);this._drawSegments(b,g,h,!1);b.length=0},drawCatmullRom:function(a,b,c,d){this.drawCardinalSpline(a,.5,b,c,d)},drawCardinalSpline:function(a,e,f,g,h){g=g||this._lineWidth;h=h||this._drawColor;for(var k,m,n=1/a.length,p=b.length=0;p<f+1;p++)m=p/f,1===m?(k=a.length-1,m=1):(k=0|m/n,m=(m-n*k)/n),cc.cardinalSplineAt(cc.getControlPointAt(a,
k-1),cc.getControlPointAt(a,k-0),cc.getControlPointAt(a,k+1),cc.getControlPointAt(a,k+2),e,m,c),b.push(c.x,c.y);g*=.5;a=0;for(e=b.length-2;a<e;a+=2)c.x=b[a],c.y=b[a+1],d.x=b[a+2],d.y=b[a+3],this.drawSegment(c,d,g,h);b.length=0},drawDots:function(a,b,c){if(a&&0!==a.length){c=c||this._drawColor;for(var d=0,e=a.length;d<e;d++)this.drawDot(a[d],b,c)}},_render:function(){var b=cc._renderContext;0>this._offset||0>=this._vertexCount||(this._dirty?(a.updateSubData(this._offset,this._f32Buffer),this._dirty=
!1):b.bindBuffer(b.ARRAY_BUFFER,a.vertexBuffer),b.enableVertexAttribArray(cc.VERTEX_ATTRIB_POSITION),b.enableVertexAttribArray(cc.VERTEX_ATTRIB_COLOR),b.enableVertexAttribArray(cc.VERTEX_ATTRIB_TEX_COORDS),b.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,2,b.FLOAT,!1,20,0),b.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR,4,b.UNSIGNED_BYTE,!0,20,8),b.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS,2,b.FLOAT,!1,20,12),b.drawArrays(b.TRIANGLES,this._offset/20,this._vertexCount),cc.incrementGLDraws(1))},appendVertexData:function(a,
b,c,d,f){var g=this._f32Buffer,h=5*this._vertexCount;g[h]=a;g[h+1]=b;e[0]=c.a<<24|c.b<<16|c.g<<8|c.r;this._ui32Buffer[h+2]=e[0];g[h+3]=d;g[h+4]=f;this._vertexCount++},drawDot:function(a,b,c){c=c||this._drawColor;null==c.a&&(c.a=255);var d=a.x-b,e=a.y-b,f=a.x+b;a=a.y+b;this._ensureCapacity(this._vertexCount+6)&&(this.appendVertexData(d,e,c,-1,-1),this.appendVertexData(d,a,c,-1,1),this.appendVertexData(f,a,c,1,1),this.appendVertexData(d,e,c,-1,-1),this.appendVertexData(f,a,c,1,1),this.appendVertexData(f,
e,c,1,-1),this._dirty=!0)},drawSegment:function(a,b,c,d){d=d||this.getDrawColor();null==d.a&&(d.a=255);c=c||.5*this._lineWidth;if(this._ensureCapacity(this._vertexCount+18)){f.x=a.y-b.y;f.y=b.x-a.x;cc.pNormalizeIn(f);g.x=-f.y;g.y=f.x;var e=c;h.x=f.x*e;h.y=f.y*e;k.x=g.x*c;k.y=g.y*c;c=b.x+h.x-k.x;e=b.y+h.y-k.y;var m=f.x-g.x,n=f.y-g.y,p=b.x-h.x,t=b.y-h.y,r=-f.x,A=-f.y,B=b.x+h.x,C=b.y+h.y,D=f.x,E=f.y,J=a.x-h.x,I=a.y-h.y,G=a.x+h.x,H=a.y+h.y,F=f.x,K=f.y,L=a.x-h.x+k.x,M=a.y-h.y+k.y,O=g.x-f.x,P=g.y-f.y,N=
a.x+h.x+k.x;a=a.y+h.y+k.y;var S=f.x+g.x,R=f.y+g.y;this.appendVertexData(b.x-h.x-k.x,b.y-h.y-k.y,d,-(f.x+g.x),-(f.y+g.y));this.appendVertexData(c,e,d,m,n);this.appendVertexData(p,t,d,r,A);this.appendVertexData(B,C,d,D,E);this.appendVertexData(c,e,d,m,n);this.appendVertexData(p,t,d,r,A);this.appendVertexData(B,C,d,D,E);this.appendVertexData(J,I,d,r,A);this.appendVertexData(p,t,d,r,A);this.appendVertexData(B,C,d,D,E);this.appendVertexData(J,I,d,r,A);this.appendVertexData(G,H,d,F,K);this.appendVertexData(L,
M,d,O,P);this.appendVertexData(J,I,d,r,A);this.appendVertexData(G,H,d,F,K);this.appendVertexData(L,M,d,O,P);this.appendVertexData(N,a,d,S,R);this.appendVertexData(G,H,d,F,K);this._dirty=!0}},drawPoly:function(a,c,d,e){if("object"===typeof a[0]){for(var g=b.length=0;g<a.length;g++)b.push(a[g].x,a[g].y);a=b}if(null==c)this._drawSegments(a,d,e,!0);else{null==c.a&&(c.a=255);null==e.a&&(e.a=255);d=null==d?this._lineWidth:d;d*=.5;var k=a.length;for(g=m.length=0;g<k;g+=2){var n=a[(g-2+k)%k];var p=a[(g-1+
k)%k];var t=a[g];var r=a[g+1];var A=a[(g+2)%k];var B=a[(g+3)%k];f.x=p-r;f.y=t-n;h.x=r-B;h.y=A-t;cc.pNormalizeIn(f);cc.pNormalizeIn(h);r=f.x*h.x+f.y*h.y+1;var C=(f.x+h.x)/r;r=(f.y+h.y)/r;m.push(C,r,h.x,h.y)}k/=2;C=0<d;if(this._ensureCapacity(this._vertexCount+3*(3*k-2))){var D=0==C?.5:0;for(g=0;g<k-2;g++)n=a[0]-m[0]*D,p=a[1]-m[1]*D,t=a[2*g+2]-m[4*(g+1)]*D,r=a[2*g+3]-m[4*(g+1)+1]*D,A=a[2*g+4]-m[4*(g+2)]*D,B=a[2*g+5]-m[4*(g+2)+1]*D,this.appendVertexData(n,p,c,0,0),this.appendVertexData(t,r,c,0,0),this.appendVertexData(A,
B,c,0,0);d=C?d:.5;c=C?e:c;for(g=0;g<k;g++){e=(g+1)%k;n=a[2*g];p=a[2*g+1];t=a[2*e];r=a[2*e+1];f.x=m[4*g+2];f.y=m[4*g+3];h.x=C?-f.x:0;h.y=C?-f.y:0;var E=m[4*g];var J=m[4*g+1];var I=m[4*e];var G=m[4*e+1];e=n-E*d;A=p-J*d;B=t-I*d;D=r-G*d;n+=E*d;p+=J*d;t+=I*d;r+=G*d;this.appendVertexData(e,A,c,h.x,h.y);this.appendVertexData(B,D,c,h.x,h.y);this.appendVertexData(t,r,c,f.x,f.y);this.appendVertexData(e,A,c,h.x,h.y);this.appendVertexData(n,p,c,f.x,f.y);this.appendVertexData(t,r,c,f.x,f.y)}m.length=0;b.length=
0;this._dirty=!0}}},_drawSegments:function(a,b,c,d){b=null==b?this._lineWidth:b;if(!(0>=b)){c=c||this._drawColor;null==c.a&&(c.a=255);b*=.5;var e,g=a.length;for(e=m.length=0;e<g;e+=2){var k=a[(e-2+g)%g];var n=a[(e-1+g)%g];var p=a[e];var t=a[e+1];var r=a[(e+2)%g];var B=a[(e+3)%g];f.x=n-t;f.y=p-k;h.x=t-B;h.y=r-p;cc.pNormalizeIn(f);cc.pNormalizeIn(h);p=f.x*h.x+f.y*h.y+1;t=(f.x+h.x)/p;p=(f.y+h.y)/p;m.push(t,p,h.x,h.y)}g/=2;if(this._ensureCapacity(this._vertexCount+3*(3*g-2))){d=d?g:g-1;for(e=0;e<d;e++){r=
(e+1)%g;k=a[2*e];n=a[2*e+1];p=a[2*r];t=a[2*r+1];f.x=m[4*e+2];f.y=m[4*e+3];var C=m[4*e];var D=m[4*e+1];var E=m[4*r];var J=m[4*r+1];r=k-C*b;B=n-D*b;var I=p-E*b;var G=t-J*b;k+=C*b;n+=D*b;p+=E*b;t+=J*b;this.appendVertexData(r,B,c,-f.x,-f.y);this.appendVertexData(I,G,c,-f.x,-f.y);this.appendVertexData(p,t,c,f.x,f.y);this.appendVertexData(r,B,c,-f.x,-f.y);this.appendVertexData(k,n,c,f.x,f.y);this.appendVertexData(p,t,c,f.x,f.y)}m.length=0;this._dirty=!0}}},clear:function(){this.release();this._dirty=!0},
_createRenderCmd:function(){return new cc.DrawNode.WebGLRenderCmd(this)}})}});(function(){cc.DrawNode.CanvasRenderCmd=function(a){this._rootCtor(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.getLocalBB=function(){return this._node._localBB};cc.extend(cc.DrawNode.CanvasRenderCmd.prototype,{rendering:function(a,b,c){a=a||cc._renderContext;a.getContext();
var d=this._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");d=this._buffer;for(var e=0,f=d.length;e<f;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)}}}},_drawDot:function(a,b){var c=b.fillColor,
d=b.verts[0],e=b.lineWidth,f=a.getContext();a.setFillStyle("rgba("+(0|c.r)+","+(0|c.g)+","+(0|c.b)+","+c.a/255+")");f.beginPath();f.arc(d.x,-d.y,e,0,2*Math.PI,!1);f.closePath();f.fill()},_drawSegment:function(a,b,c){var d=b.lineColor,e=b.verts[0],f=b.verts[1],g=b.lineWidth;b=b.lineCap;var h=a.getContext();a.setStrokeStyle("rgba("+(0|d.r)+","+(0|d.g)+","+(0|d.b)+","+d.a/255+")");h.lineWidth=g*c;h.beginPath();h.lineCap=b;h.moveTo(e.x,-e.y);h.lineTo(f.x,-f.y);h.stroke()},_drawPoly:function(a,b,c){var d=
b.verts,e=b.lineCap;if(null!=d){var f=b.fillColor,g=b.lineWidth,h=b.lineColor,k=b.isClosePolygon,m=b.isFill;b=b.isStroke;var n=a.getContext(),p=d[0];n.lineCap=e;f&&a.setFillStyle("rgba("+(0|f.r)+","+(0|f.g)+","+(0|f.b)+","+f.a/255+")");g&&(n.lineWidth=g*c);h&&a.setStrokeStyle("rgba("+(0|h.r)+","+(0|h.g)+","+(0|h.b)+","+h.a/255+")");n.beginPath();n.moveTo(p.x,-p.y);a=1;for(c=d.length;a<c;a++)n.lineTo(d[a].x,-d[a].y);k&&n.closePath();m&&n.fill();b&&n.stroke()}}})})();(function(){cc.DrawNode.WebGLRenderCmd=function(a){this._rootCtor(a);this._needDraw=!0;this._matrix=new cc.math.Matrix4;this._matrix.identity()};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;if(0<a._vertexCount){var b=this._worldTransform;this._matrix.mat[0]=b.a;this._matrix.mat[4]=b.c;this._matrix.mat[12]=b.tx;this._matrix.mat[1]=
b.b;this._matrix.mat[5]=b.d;this._matrix.mat[13]=b.ty;cc.glBlendFunc(a._blendFunc.src,a._blendFunc.dst);this._glProgramState.apply(this._matrix);a._render()}}})();cc.stencilBits=-1;
cc.ClippingNode=cc.Node.extend({inverted:!1,_alphaThreshold:0,_stencil:null,_className:"ClippingNode",_originStencilProgram:null,ctor:function(a){a=a||null;cc.Node.prototype.ctor.call(this);if(this._stencil=a)this._originStencilProgram=a.getShaderProgram();this.alphaThreshold=1;this.inverted=!1;this._renderCmd.initStencilBits()},onEnter:function(){cc.Node.prototype.onEnter.call(this);this._stencil&&this._stencil._performRecursive(cc.Node._stateCallbackType.onEnter)},onEnterTransitionDidFinish:function(){cc.Node.prototype.onEnterTransitionDidFinish.call(this);this._stencil&&
this._stencil._performRecursive(cc.Node._stateCallbackType.onEnterTransitionDidFinish)},onExitTransitionDidStart:function(){this._stencil._performRecursive(cc.Node._stateCallbackType.onExitTransitionDidStart);cc.Node.prototype.onExitTransitionDidStart.call(this)},onExit:function(){this._stencil._performRecursive(cc.Node._stateCallbackType.onExit);cc.Node.prototype.onExit.call(this)},visit:function(a){this._renderCmd.clippingVisit(a&&a._renderCmd)},_visitChildren:function(){this._reorderChildDirty&&
this.sortAllChildren();for(var a=this._children,b,c=0,d=a.length;c<d;c++)(b=a[c])&&b._visible&&b.visit(this);this._renderCmd._dirtyFlag=0},getAlphaThreshold:function(){return this._alphaThreshold},setAlphaThreshold:function(a){1===a&&a!==this._alphaThreshold&&this._renderCmd.resetProgramByStencil();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&&(a&&(this._originStencilProgram=
a.getShaderProgram()),this._renderCmd.setStencil(a))},_createRenderCmd:function(){return cc._renderType===cc.game.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);cc.defineGetterSetter(_p,"alphaThreshold",_p.getAlphaThreshold,_p.setAlphaThreshold);cc.ClippingNode.create=function(a){return new cc.ClippingNode(a)};(function(){cc.ClippingNode.CanvasRenderCmd=function(a){this._rootCtor(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.resetProgramByStencil=
function(){};a.initStencilBits=function(){};a.setStencil=function(a){if(null!=a)if(this._node._stencil=a,a instanceof cc.DrawNode){if(a._buffer)for(var b=0;b<a._buffer.length;b++)a._buffer[b].isFill=!1,a._buffer[b].isStroke=!1;a._renderCmd.rendering=function(a,b,c){};a._renderCmd._canUseDirtyRegion=!0;this._rendererSaveCmd._canUseDirtyRegion=!0;this._rendererClipCmd._canUseDirtyRegion=!0;this._rendererRestoreCmd._canUseDirtyRegion=!0}else a._parent=this._node};a._saveCmdCallback=function(a,c,d){var b=
a||cc._renderContext;a=b.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)):(b.save(),b.setTransform(this._worldTransform,c,d),this._node.inverted&&(a.beginPath(),a.rect(0,0,a.canvas.width,-a.canvas.height),a.clip()))};a._setStencilCompositionOperation=function(a){if(a){var b=this._node;a._renderCmd&&a._renderCmd._blendFuncStr&&(a._renderCmd._blendFuncStr=b.inverted?"destination-out":
"destination-in");if(a._children){a=a._children;b=0;for(var d=a.length;b<d;b++)this._setStencilCompositionOperation(a[b])}}};a._clipCmdCallback=function(a){var b=this._node;a=(a||cc._renderContext).getContext();if(this._clipElemType)this._setStencilCompositionOperation(b._stencil);else{b=this._node._stencil;if(b instanceof cc.DrawNode){a.beginPath();var d=b._renderCmd._transform;a.transform(d.a,d.b,d.c,d.d,d.tx,-d.ty);for(d=0;d<b._buffer.length;d++){var e=b._buffer[d].verts,f=e[0];a.moveTo(f.x,-f.y);
for(f=e.length-1;0<f;f--)a.lineTo(e[f].x,-e[f].y)}}a.clip()}};a._restoreCmdCallback=function(a){var b=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(b,0,0),d.restore(),this._dirtyFlag=0):a.restore()};a.transform=function(a,c){this.originTransform(a,c);var b=this._node;b._stencil&&b._stencil._renderCmd&&(b._stencil._renderCmd.transform(this,
!0),b._stencil._dirtyFlag&=~cc.Node._dirtyFlags.transformDirty)};a._cangodhelpme=function(a){if(!0===a||!1===a)cc.ClippingNode.CanvasRenderCmd.prototype._godhelpme=a;return cc.ClippingNode.CanvasRenderCmd.prototype._godhelpme};a.clippingVisit=function(a){var b=this._node;a=a||this.getParentRenderCmd();this.visit(a);this._clipElemType=!(!this._cangodhelpme()&&b._stencil instanceof cc.DrawNode);if(b._stencil&&b._stencil.visible){cc.renderer.pushRenderCommand(this._rendererSaveCmd);this._clipElemType?
b._visitChildren():b._stencil.visit(b);cc.renderer.pushRenderCommand(this._rendererClipCmd);if(this._clipElemType)b._stencil.visit(b);else{this._cangodhelpme(!0);a=b._children;var d,e=a.length;if(0<e)for(b.sortAllChildren(),d=0;d<e;d++)a[d].visit(b);this._cangodhelpme(!1)}cc.renderer.pushRenderCommand(this._rendererRestoreCmd);this._dirtyFlag=0}else this.inverted&&b._visitChildren()};cc.ClippingNode.CanvasRenderCmd._sharedCache=null;cc.ClippingNode.CanvasRenderCmd._getSharedCache=function(){return cc.ClippingNode.CanvasRenderCmd._sharedCache||
(cc.ClippingNode.CanvasRenderCmd._sharedCache=document.createElement("canvas"))}})();function setProgram(a,b){a.shaderProgram=b;var c=a.children;if(c)for(var d=0;d<c.length;d++)setProgram(c[d],b)}
(function(){cc.ClippingNode.WebGLRenderCmd=function(a){this._rootCtor(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._currentStencilEnabled=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 b=this._node;this.originTransform(a,
c);b._stencil&&(b._stencil._renderCmd.transform(this,!0),b._stencil._dirtyFlag&=~cc.Node._dirtyFlags.transformDirty)};a.clippingVisit=function(a){var b=this._node;a=a||this.getParentRenderCmd();this.visit(a);if(1>cc.stencilBits)b._visitChildren();else if(b._stencil&&b._stencil.visible)if(cc.ClippingNode.WebGLRenderCmd._layer+1===cc.stencilBits)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),b._visitChildren();else{cc.renderer.pushRenderCommand(this._beforeVisitCmd);b._stencil.visit(b);cc.renderer.pushRenderCommand(this._afterDrawStencilCmd);if((a=b._children)&&0<a.length){var d=a.length;b.sortAllChildren();for(var e=0;e<d;e++)a[e].visit(b)}cc.renderer.pushRenderCommand(this._afterVisitCmd);this._dirtyFlag=0}else b.inverted&&b._visitChildren()};a.setStencil=function(a){var b=this._node;b._stencil&&(b._stencil._parent=null);b._stencil=a;b._stencil&&
(b._stencil._parent=b)};a.resetProgramByStencil=function(){var a=this._node;a._stencil&&setProgram(a._stencil,a._originStencilProgram)};a._onBeforeVisit=function(a){var b=a||cc._renderContext;a=this._node;cc.ClippingNode.WebGLRenderCmd._layer++;var d=1<<cc.ClippingNode.WebGLRenderCmd._layer;this._mask_layer_le=d|d-1;this._currentStencilEnabled=b.isEnabled(b.STENCIL_TEST);b.clear(b.DEPTH_BUFFER_BIT);b.enable(b.STENCIL_TEST);b.depthMask(!1);b.stencilFunc(b.NEVER,d,d);b.stencilOp(b.REPLACE,b.KEEP,b.KEEP);
b.stencilMask(d);b.clear(b.STENCIL_BUFFER_BIT);1>a.alphaThreshold&&(b=cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLORALPHATEST),cc.glUseProgram(b.getProgram()),b.setUniformLocationWith1f(cc.UNIFORM_ALPHA_TEST_VALUE_S,a.alphaThreshold),b.setUniformLocationWithMatrix4fv(cc.UNIFORM_MVMATRIX_S,cc.renderer.mat4Identity.mat),cc.setProgram(a._stencil,b))};a._onAfterDrawStencil=function(a){a=a||cc._renderContext;a.depthMask(!0);a.stencilFunc(this._node.inverted?a.NOTEQUAL: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;cc.ClippingNode.WebGLRenderCmd._layer--;if(this._currentStencilEnabled){var b=1<<cc.ClippingNode.WebGLRenderCmd._layer,d=b|b-1;a.stencilMask(b);a.stencilFunc(a.EQUAL,d,d)}else a.disable(a.STENCIL_TEST)}})();cc.GridBase=cc.Class.extend({_active:!1,_reuseGrid:0,_gridSize:null,_gridRect:null,_texture:null,_step:null,_grabber:null,_isTextureFlipped:!1,_glProgramState:null,_directorProjection:0,_dirty:!1,ctor:function(a,b,c,d){cc.sys._checkWebGLRenderMode();this._active=!1;this._reuseGrid=0;this._gridSize=null;this._gridRect=new cc.rect;this._texture=null;this._step=cc.p(0,0);this._grabber=null;this._isTextureFlipped=!1;this._glProgramState=null;this._directorProjection=0;this._dirty=!1;void 0!==a&&this.initWithSize(a,
b,c,d)},isActive:function(){return this._active},setActive:function(a){this._active=a;if(!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)},setGridRect:function(a){this._gridRect=a},getGridRect:function(){return this._gridRect},
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,d){if(!b){var e=cc.director.getWinSizeInPixels(),f=cc.NextPOT(e.width),g=cc.NextPOT(e.height),h=new Uint8Array(f*g*4);if(!h)return cc.log("cocos2d: CCGrid: not enough memory."),!1;b=new cc.Texture2D;
b.initWithData(h,cc.Texture2D.PIXEL_FORMAT_RGBA8888,f,g,e);if(!b)return cc.log("cocos2d: CCGrid: error creating texture"),!1}this._active=!1;this._reuseGrid=0;this._gridSize=a;this._texture=b;this._isTextureFlipped=c||!1;if(void 0===d||cc._rectEqualToZero(d))b=this._texture.getContentSize(),d=new cc.rect(0,0,b.width,b.height);this._gridRect=d;this._step.x=this._gridRect.width/a.width;this._step.y=this._gridRect.height/a.height;this._grabber=new cc.Grabber;if(!this._grabber)return!1;this._grabber.grab(this._texture);
this._glProgramState=cc.GLProgramState.getOrCreateWithGLProgram(cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURE));this.calculateVertexPoints();return!0},beforeDraw:function(){this._directorProjection=cc.director.getProjection();var a=cc.director.getWinSizeInPixels();gl.viewport(0,0,a.width,a.height);this._grabber.beforeRender(this._texture)},afterDraw:function(a){this._grabber.afterRender(this._texture);cc.director.setViewport();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,d){return new cc.GridBase(a,b,c,d)};
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,d){cc.GridBase.prototype.ctor.call(this);this._indicesBuffer=this._verticesBuffer=this._texCoordinateBuffer=this._indices=this._originalVertices=this._vertices=this._texCoordinates=null;this._matrix=new cc.math.Matrix4;this._matrix.identity();
void 0!==a&&this.initWithSize(a,b,c,d)},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;a=a._renderCmd._worldTransform;this._matrix.mat[0]=a.a;this._matrix.mat[4]=a.c;this._matrix.mat[12]=a.tx;this._matrix.mat[1]=a.b;this._matrix.mat[5]=a.d;this._matrix.mat[13]=a.ty;this._glProgramState.apply(this._matrix);a=cc._renderContext;
var c=this._dirty;a.enableVertexAttribArray(cc.VERTEX_ATTRIB_POSITION);a.enableVertexAttribArray(cc.VERTEX_ATTRIB_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,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;c<d;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(e.width*e.height*6);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();var g,h=this._indices,k=
this._texCoordinates,m=this._isTextureFlipped,n=this._vertices;for(f=0;f<e.width;++f)for(g=0;g<e.height;++g){var p=g*e.width+f;var r=f*this._step.x+this._gridRect.x;var t=r+this._step.x,u=g*this._step.y+this._gridRect.y,v=u+this._step.y,x=f*(e.height+1)+g,w=(f+1)*(e.height+1)+g,y=(f+1)*(e.height+1)+(g+1),z=f*(e.height+1)+(g+1);h[6*p]=x;h[6*p+1]=w;h[6*p+2]=z;h[6*p+3]=w;h[6*p+4]=y;h[6*p+5]=z;p=[3*x,3*w,3*y,3*z];var A=[{x:r,y:u,z:0},{x:t,y:u,z:0},{x:t,y:v,z:0},{x:r,y:v,z:0}];x=[2*x,2*w,2*y,2*z];t=[cc.p(r,
u),cc.p(t,u),cc.p(t,v),cc.p(r,v)];for(r=0;4>r;++r)n[p[r]]=A[r].x,n[p[r]+1]=A[r].y,n[p[r]+2]=A[r].z,k[x[r]]=t[r].x/b,k[x[r]+1]=m?(d-t[r].y)/c:t[r].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,d){cc.GridBase.prototype.ctor.call(this);this._indicesBuffer=this._verticesBuffer=this._texCoordinateBuffer=this._indices=this._originalVertices=this._vertices=this._texCoordinates=null;this._matrix=new cc.math.Matrix4;this._matrix.identity();void 0!==a&&this.initWithSize(a,b,c,d)},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;a=a._renderCmd._worldTransform;this._matrix.mat[0]=a.a;this._matrix.mat[4]=a.c;this._matrix.mat[12]=a.tx;this._matrix.mat[1]=a.b;this._matrix.mat[5]=a.d;this._matrix.mat[13]=a.ty;this._glProgramState.apply(this._matrix);a=cc._renderContext;var c=this._dirty;a.enableVertexAttribArray(cc.VERTEX_ATTRIB_POSITION);a.enableVertexAttribArray(cc.VERTEX_ATTRIB_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 t=
g*m.x,u=t+m.x,v=h*m.y,x=v+m.y;n[12*k]=t;n[12*k+1]=v;n[12*k+2]=0;n[12*k+3]=u;n[12*k+4]=v;n[12*k+5]=0;n[12*k+6]=t;n[12*k+7]=x;n[12*k+8]=0;n[12*k+9]=u;n[12*k+10]=x;n[12*k+11]=0;var w=v,y=x;r&&(w=c-v,y=c-x);p[8*k]=t/a;p[8*k+1]=w/b;p[8*k+2]=u/a;p[8*k+3]=w/b;p[8*k+4]=t/a;p[8*k+5]=y/b;p[8*k+6]=u/a;p[8*k+7]=y/b;k++}a=this._indices;for(g=0;g<e;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.sys._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.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(){cc.log("copy is deprecated. Please use clone instead.");return this.clone()},clone:function(){var a=new cc.Action;a.originalTarget=null;a.target=null;a.tag=this.tag;return 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(){cc.log("cocos2d: FiniteTimeAction#reverse: Implement me");return 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 Error("cc.Speed.initWithAction(): action must be non nil");this._innerAction=a;this._speed=b;return!0},clone:function(){var a=new cc.Speed;a.initWithAction(this._innerAction.clone(),this._speed);return 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);a.initWithTarget(this._followedNode,b);return a},isBoundarySet:function(){return this._boundarySet},setBoudarySet:function(a){this._boundarySet=a},initWithTarget:function(a,b){if(!a)throw Error("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();this._fullScreenSize=cc.p(c.width,c.height);this._halfScreenSize=cc.pMult(this._fullScreenSize,.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));return!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){this._duration=0===a?cc.FLT_EPSILON:a;this._elapsed=
0;return this._firstTick=!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);
this._cloneDecoration(a);return 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;c<d;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(){cc.log("cc.IntervalAction: reverse not implemented.");return null},setAmplitudeRate:function(a){cc.log("cc.ActionInterval.setAmplitudeRate(): it should be overridden in subclass.")},
getAmplitudeRate:function(){cc.log("cc.ActionInterval.getAmplitudeRate(): it should be overridden in subclass.");return 0},speed:function(a){if(0>=a)return cc.log("The speed parameter error"),this;this._speedMethod=!0;this._speed*=a;return this},getSpeed:function(){return this._speed},setSpeed:function(a){this._speed=a;return this},repeat:function(a){a=Math.round(a);if(isNaN(a)||1>a)return cc.log("The repeat parameter error"),this;this._repeatMethod=!0;this._timesForRepeat*=a;return this},repeatForever:function(){this._repeatMethod=
!0;this._timesForRepeat=this.MAX_VALUE;this._repeatForever=!0;return 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;0<=c&&null==b[c]&&cc.log("parameters should not be ending with null in Javascript");if(0<=c){for(var d=b[0],e=1;e<c;e++)b[e]&&(d=cc.Sequence._actionOneTwo(d,b[e]));this.initWithTwoActions(d,b[c])}},initWithTwoActions:function(a,b){if(!a||!b)throw Error("cc.Sequence.initWithTwoActions(): arguments must all be non nil");
this.initWithDuration(a._duration+b._duration);this._actions[0]=a;this._actions[1]=b;return!0},clone:function(){var a=new cc.Sequence;this._cloneDecoration(a);a.initWithTwoActions(this._actions[0].clone(),this._actions[1].clone());return 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=
0,c=this._split,d=this._actions,e=this._last;a=this._computeEaseTime(a);a<c?(a=0!==c?a/c:1,0===b&&1===e&&(d[1].update(0),d[1].stop())):(b=1,a=1===c?1:(a-c)/(1-c),-1===e&&(d[0].startWithTarget(this.target),d[0].update(1),d[0].stop()),e||(d[0].update(1),d[0].stop()));d=d[b];e===b&&d.isDone()||(e!==b&&d.startWithTarget(this.target),a*=d._timesForRepeat,d.update(1<a?a%1:a),this._last=b)},reverse:function(){var a=cc.Sequence._actionOneTwo(this._actions[1].reverse(),this._actions[0].reverse());this._cloneDecoration(a);
this._reverseEaseList(a);return 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;)for(d=Array.prototype.shift.call(b),f=d._timesForRepeat||1,d._repeatMethod=!1,d._timesForRepeat=1,e=0,c||(c=d,e=1),e;e<f;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;c.initWithTwoActions(a,b);return 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),this._total=0,!0):!1},clone:function(){var a=new cc.Repeat;this._cloneDecoration(a);a.initWithAction(this._innerAction.clone(),
this._times);return 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);this._cloneDecoration(a);this._reverseEaseList(a);return 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 Error("cc.RepeatForever.initWithAction(): action must be non null");this._innerAction=a;return!0},clone:function(){var a=new cc.RepeatForever;this._cloneDecoration(a);a.initWithAction(this._innerAction.clone());return 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());this._cloneDecoration(a);this._reverseEaseList(a);return 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;if(a instanceof Array)var c=a;else for(c=Array(arguments.length),b=0;b<arguments.length;++b)c[b]=arguments[b];var d=c.length-1;0<=d&&null==c[d]&&cc.log("parameters should not be ending with null in Javascript");if(0<=d){var e=c[0];for(b=1;b<d;b++)c[b]&&(e=cc.Spawn._actionOneTwo(e,c[b]));this.initWithTwoActions(e,c[d])}},initWithTwoActions:function(a,b){if(!a||
!b)throw Error("cc.Spawn.initWithTwoActions(): arguments must all be non null");var c=!1,d=a._duration,e=b._duration;this.initWithDuration(Math.max(d,e))&&(this._one=a,this._two=b,d>e?this._two=cc.Sequence._actionOneTwo(b,cc.delayTime(d-e)):d<e&&(this._one=cc.Sequence._actionOneTwo(a,cc.delayTime(e-d))),c=!0);return c},clone:function(){var a=new cc.Spawn;this._cloneDecoration(a);a.initWithTwoActions(this._one.clone(),this._two.clone());return 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());this._cloneDecoration(a);this._reverseEaseList(a);return 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;c.initWithTwoActions(a,b);return 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=void 0!==c?c:this._dstAngleX,!0):!1},clone:function(){var a=new cc.RotateTo;this._cloneDecoration(a);a.initWithDuration(this._duration,this._dstAngleX,
this._dstAngleY);return 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;this._cloneDecoration(a);a.initWithDuration(this._duration,this._angleX,this._angleY);return 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);this._cloneDecoration(a);this._reverseEaseList(a);return 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;this._cloneDecoration(a);a.initWithDuration(this._duration,this._positionDelta);return 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){a=this._computeEaseTime(a);if(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));this._cloneDecoration(a);this._reverseEaseList(a);return 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;this._cloneDecoration(a);a.initWithDuration(this._duration,this._endPosition);return 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){var d=!1;cc.ActionInterval.prototype.initWithDuration.call(this,a)&&(this._endSkewX=b,this._endSkewY=c,d=!0);return d},clone:function(){var a=new cc.SkewTo;this._cloneDecoration(a);a.initWithDuration(this._duration,this._endSkewX,this._endSkewY);
return 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){var d=!1;cc.SkewTo.prototype.initWithDuration.call(this,a,b,c)&&(this._skewX=b,this._skewY=c,d=!0);return d},clone:function(){var a=new cc.SkewBy;this._cloneDecoration(a);a.initWithDuration(this._duration,this._skewX,this._skewY);return 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);this._cloneDecoration(a);this._reverseEaseList(a);return 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;this._cloneDecoration(a);a.initWithDuration(this._duration,this._delta,this._height,this._jumps);return 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){a=this._computeEaseTime(a);if(this.target){var b=a*this._jumps%1;b=4*this._height*b*(1-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);this._cloneDecoration(a);this._reverseEaseList(a);return 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;this._cloneDecoration(a);a.initWithDuration(this._duration,this._endPosition,this._height,this._jumps);return 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))}a.initWithDuration(this._duration,b);return 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){a=this._computeEaseTime(a);if(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){d=this.target.getPositionX();e=this.target.getPositionY();var 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);this._cloneDecoration(a);this._reverseEaseList(a);return 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;this._cloneDecoration(a);a.initWithDuration(this._duration,this._toConfig);return 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;this._cloneDecoration(a);a.initWithDuration(this._duration,this._endScaleX,
this._endScaleY);return 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);this._cloneDecoration(a);this._reverseEaseList(a);return a},clone:function(){var a=new cc.ScaleBy;this._cloneDecoration(a);a.initWithDuration(this._duration,this._endScaleX,
this._endScaleY);return 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;this._cloneDecoration(a);a.initWithDuration(this._duration,this._times);return a},update:function(a){a=this._computeEaseTime(a);if(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);this._cloneDecoration(a);this._reverseEaseList(a);return 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;this._cloneDecoration(a);a.initWithDuration(this._duration,this._toOpacity);return 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;a.initWithDuration(this._duration,0);this._cloneDecoration(a);this._reverseEaseList(a);return a},clone:function(){var a=new cc.FadeIn;this._cloneDecoration(a);a.initWithDuration(this._duration,this._toOpacity);return 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;a._reverseAction=this;a.initWithDuration(this._duration,255);this._cloneDecoration(a);this._reverseEaseList(a);return a},clone:function(){var a=new cc.FadeOut;this._cloneDecoration(a);a.initWithDuration(this._duration,this._toOpacity);return 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;a.initWithDuration(this._duration,b.r,b.g,b.b);return 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.setColor(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;this._cloneDecoration(a);a.initWithDuration(this._duration,this._deltaR,this._deltaG,this._deltaB);return 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);this._cloneDecoration(a);this._reverseEaseList(a);return 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);this._cloneDecoration(a);this._reverseEaseList(a);return a},clone:function(){var a=new cc.DelayTime;this._cloneDecoration(a);a.initWithDuration(this._duration);return 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 Error("cc.ReverseTime.initWithAction(): action must be non null");if(a===this._other)throw Error("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;
this._cloneDecoration(a);a.initWithAction(this._other.clone());return 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,_currFrameIndex:0,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},getCurrentFrameIndex:function(){return this._currFrameIndex},initWithAnimation:function(a){if(!a)throw Error("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+=a[f].getDelayUnits();c.push(g)}return!0}return!1},clone:function(){var a=new cc.Animate;this._cloneDecoration(a);a.initWithAnimation(this._animation.clone());return a},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,
a);this._animation.getRestoreOriginalFrame()&&(this._origFrame=a.getSpriteFrame());this._executedLoops=this._nextFrame=0},update:function(a){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;e<c;e++)if(d[e]<=a)_currFrameIndex=e,this.target.setSpriteFrame(b[_currFrameIndex].getSpriteFrame()),this._nextFrame=e+1;else break},reverse:function(){var a=
this._animation,b=a.getFrames(),c=[];cc.arrayVerifyType(b,cc.AnimationFrame);if(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);this._cloneDecoration(a);this._reverseEaseList(a);return 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;this._cloneDecoration(a);a.initWithTarget(this._forcedTarget,this._action.clone());return 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){this._isNeedCleanUp=a;return!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){this._flippedX=a;return!0},update:function(a){this.target.flippedX=this._flippedX},reverse:function(){return new cc.FlipX(!this._flippedX)},clone:function(){var a=new cc.FlipX;a.initWithFlipX(this._flippedX);return 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){this._flippedY=a;return!0},update:function(a){this.target.flippedY=this._flippedY},reverse:function(){return new cc.FlipY(!this._flippedY)},clone:function(){var a=new cc.FlipY;a.initWithFlipY(this._flippedY);return 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){this._x=a;this._y=b;return!0},update:function(a){this.target.setPosition(this._x,this._y)},clone:function(){var a=new cc.Place;a.initWithPosition(this._x,this._y);return a}});cc.place=function(a,b){return new cc.Place(a,b)};cc.Place.create=cc.place;
cc.CallFunc=cc.ActionInstant.extend({_selectorTarget:null,_function:null,_data:null,ctor:function(a,b,c){cc.FiniteTimeAction.prototype.ctor.call(this);this.initWithFunction(a,b,c)},initWithFunction:function(a,b,c){a&&(this._function=a);b&&(this._selectorTarget=b);void 0!==c&&(this._data=c);return!0},execute:function(){this._function&&this._function.call(this._selectorTarget,this.target,this._data)},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;a.initWithFunction(this._function,this._selectorTarget,this._data);return a}});cc.callFunc=function(a,b,c){return new cc.CallFunc(a,b,c)};cc.CallFunc.create=cc.callFunc;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 Error("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;a.initWithAction(this._inner.clone());return 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;a.initWithAction(this._inner.clone(),this._rate);return 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;a.initWithAction(this._inner.clone(),this._rate);return 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;a.initWithAction(this._inner.clone(),this._rate);return 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;1>a?this._inner.update(.5*Math.pow(a,this._rate)):this._inner.update(1-.5*Math.pow(2-a,this._rate))},clone:function(){var a=new cc.EaseInOut;a.initWithAction(this._inner.clone(),this._rate);return 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){a*=2;return 1>a?.5*Math.pow(a,this._rate):1-.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;a.initWithAction(this._inner.clone());return 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;a.initWithAction(this._inner.clone());return 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?.5*Math.pow(2,10*(a-1)):.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;a.initWithAction(this._inner.clone());return 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?.5*Math.pow(2,10*(a-1)):.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;a.initWithAction(this._inner.clone());return 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;a.initWithAction(this._inner.clone());return 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:-.5*(Math.cos(Math.PI*a)-1);this._inner.update(a)},clone:function(){var a=new cc.EaseSineInOut;a.initWithAction(this._inner.clone());return 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:-.5*(Math.cos(Math.PI*a)-1)},reverse:function(){return cc._easeSineInOutObj}};
cc.easeSineInOut=function(){return cc._easeSineInOutObj};
cc.EaseElastic=cc.ActionEase.extend({_period:.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){cc.ActionEase.prototype.initWithAction.call(this,a);this._period=null==b?.3:b;return!0},reverse:function(){cc.log("cc.EaseElastic.reverse(): it should be overridden in subclass.");return null},clone:function(){var a=new cc.EaseElastic;a.initWithAction(this._inner.clone(),
this._period);return a}});cc.EaseElastic.create=function(a,b){return new cc.EaseElastic(a,b)};cc.EaseElasticIn=cc.EaseElastic.extend({update:function(a){if(0!==a&&1!==a){var b=this._period/4;--a;a=-Math.pow(2,10*a)*Math.sin((a-b)*Math.PI*2/this._period)}this._inner.update(a)},reverse:function(){return new cc.EaseElasticOut(this._inner.reverse(),this._period)},clone:function(){var a=new cc.EaseElasticIn;a.initWithAction(this._inner.clone(),this._period);return a}});
cc.EaseElasticIn.create=function(a,b){return new cc.EaseElasticIn(a,b)};cc._easeElasticInObj={easing:function(a){if(0===a||1===a)return a;--a;return-Math.pow(2,10*a)*Math.sin((a-.075)*Math.PI*2/.3)},reverse:function(){return cc._easeElasticOutObj}};cc.easeElasticIn=function(a){return a&&.3!==a?{_period:a,easing:function(a){if(0===a||1===a)return a;--a;return-Math.pow(2,10*a)*Math.sin((a-this._period/4)*Math.PI*2/this._period)},reverse:function(){return cc.easeElasticOut(this._period)}}:cc._easeElasticInObj};
cc.EaseElasticOut=cc.EaseElastic.extend({update:function(a){this._inner.update(0===a||1===a?a:Math.pow(2,-10*a)*Math.sin((a-this._period/4)*Math.PI*2/this._period)+1)},reverse:function(){return new cc.EaseElasticIn(this._inner.reverse(),this._period)},clone:function(){var a=new cc.EaseElasticOut;a.initWithAction(this._inner.clone(),this._period);return 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((a-.075)*Math.PI*2/.3)+1},reverse:function(){return cc._easeElasticInObj}};cc.easeElasticOut=function(a){return a&&.3!==a?{_period:a,easing:function(a){return 0===a||1===a?a:Math.pow(2,-10*a)*Math.sin((a-this._period/4)*Math.PI*2/this._period)+1},reverse:function(){return cc.easeElasticIn(this._period)}}:cc._easeElasticOutObj};
cc.EaseElasticInOut=cc.EaseElastic.extend({update:function(a){var b=this._period;if(0!==a&&1!==a){b||(b=this._period=.3*1.5);var c=b/4;a=2*a-1;a=0>a?-.5*Math.pow(2,10*a)*Math.sin((a-c)*Math.PI*2/b):Math.pow(2,-10*a)*Math.sin((a-c)*Math.PI*2/b)*.5+1}this._inner.update(a)},reverse:function(){return new cc.EaseElasticInOut(this._inner.reverse(),this._period)},clone:function(){var a=new cc.EaseElasticInOut;a.initWithAction(this._inner.clone(),this._period);return a}});
cc.EaseElasticInOut.create=function(a,b){return new cc.EaseElasticInOut(a,b)};cc.easeElasticInOut=function(a){return{_period:a||.3,easing:function(a){var b=this._period;if(0!==a&&1!==a){b||(b=this._period=.3*1.5);var d=b/4;a=2*a-1;a=0>a?-.5*Math.pow(2,10*a)*Math.sin((a-d)*Math.PI*2/b):Math.pow(2,-10*a)*Math.sin((a-d)*Math.PI*2/b)*.5+1}return a},reverse:function(){return cc.easeElasticInOut(this._period)}}};
cc.EaseBounce=cc.ActionEase.extend({bounceTime:function(a){if(a<1/2.75)return 7.5625*a*a;if(a<2/2.75)return a-=1.5/2.75,7.5625*a*a+.75;if(a<2.5/2.75)return a-=2.25/2.75,7.5625*a*a+.9375;a-=2.625/2.75;return 7.5625*a*a+.984375},clone:function(){var a=new cc.EaseBounce;a.initWithAction(this._inner.clone());return 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;a.initWithAction(this._inner.clone());return a}});cc.EaseBounceIn.create=function(a){return new cc.EaseBounceIn(a)};
cc._bounceTime=function(a){if(a<1/2.75)return 7.5625*a*a;if(a<2/2.75)return a-=1.5/2.75,7.5625*a*a+.75;if(a<2.5/2.75)return a-=2.25/2.75,7.5625*a*a+.9375;a-=2.625/2.75;return 7.5625*a*a+.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;a.initWithAction(this._inner.clone());return 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){a=.5>a?.5*(1-this.bounceTime(1-2*a)):.5*this.bounceTime(2*a-1)+.5;this._inner.update(a)},clone:function(){var a=new cc.EaseBounceInOut;a.initWithAction(this._inner.clone());return 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){return.5>a?.5*(1-cc._bounceTime(1-2*a)):.5*cc._bounceTime(2*a-1)+.5},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;a.initWithAction(this._inner.clone());return 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;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;a.initWithAction(this._inner.clone());return a}});
cc.EaseBackOut.create=function(a){return new cc.EaseBackOut(a)};cc._easeBackOutObj={easing:function(a){--a;return 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;a.initWithAction(this._inner.clone());return 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){a*=2;if(1>a)return a*a*(3.5949095*a-2.5949095)/2;a-=2;return 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;a.initWithAction(this._inner.clone());a.setBezierParamer(this._p0,this._p1,this._p2,this._p3);return a},
reverse:function(){var a=new cc.EaseBezierAction(this._inner.reverse());a.setBezierParamer(this._p3,this._p2,this._p1,this._p0);return 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;a.initWithAction(this._inner.clone());return 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;a.initWithAction();return 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){a*=2;1>a?a=a*a*.5:(--a,a=-.5*(a*(a-2)-1));return a},update:function(a){this._inner.update(this._updateTime(a))},clone:function(){var a=new cc.EaseQuadraticActionInOut;a.initWithAction(this._inner.clone());return 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;a.initWithAction(this._inner.clone());return 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){--a;return-(a*a*a*a-1)},update:function(a){this._inner.update(this._updateTime(a))},clone:function(){var a=new cc.EaseQuarticActionOut;a.initWithAction(this._inner.clone());return 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){a*=2;if(1>a)return.5*a*a*a*a;a-=2;return-.5*(a*a*a*a-2)},update:function(a){this._inner.update(this._updateTime(a))},clone:function(){var a=new cc.EaseQuarticActionInOut;a.initWithAction(this._inner.clone());return 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;a.initWithAction(this._inner.clone());return 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){--a;return a*a*a*a*a+1},update:function(a){this._inner.update(this._updateTime(a))},clone:function(){var a=new cc.EaseQuinticActionOut;a.initWithAction(this._inner.clone());return 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){a*=2;if(1>a)return.5*a*a*a*a*a;a-=2;return.5*(a*a*a*a*a+2)},update:function(a){this._inner.update(this._updateTime(a))},clone:function(){var a=new cc.EaseQuinticActionInOut;a.initWithAction(this._inner.clone());return 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;a.initWithAction(this._inner.clone());return 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){--a;return Math.sqrt(1-a*a)},update:function(a){this._inner.update(this._updateTime(a))},clone:function(){var a=new cc.EaseCircleActionOut;a.initWithAction(this._inner.clone());return 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){a*=2;if(1>a)return-.5*(Math.sqrt(1-a*a)-1);a-=2;return.5*(Math.sqrt(1-a*a)+1)},update:function(a){this._inner.update(this._updateTime(a))},clone:function(){var a=new cc.EaseCircleActionInOut;a.initWithAction(this._inner.clone());return 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;a.initWithAction(this._inner.clone());return 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){--a;return a*a*a+1},update:function(a){this._inner.update(this._updateTime(a))},clone:function(){var a=new cc.EaseCubicActionOut;a.initWithAction(this._inner.clone());return 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){a*=2;if(1>a)return.5*a*a*a;a-=2;return.5*(a*a*a+2)},update:function(a){this._inner.update(this._updateTime(a))},clone:function(){var a=new cc.EaseCubicActionInOut;a.initWithAction(this._inner.clone());return 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,g){var h=f*f,k=h*f,m=(1-e)/2;e=m*(-k+2*h-f);var n=m*(-k+h)+(2*k-3*h+1);f=m*(k-2*h+f)+(-2*k+3*h);k=m*(k-h);h=a.x*e+b.x*n+c.x*f+d.x*k;a=a.y*e+b.y*n+c.y*f+d.y*k;if(void 0!==g)g.x=h,g.y=a;else return cc.p(h,a)};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){return a[Math.min(a.length-1,Math.max(b,0))]};cc.reverseControlPointsInline=function(a){for(var b=a.length,c=0|b/2,d=0;d<c;++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 Error("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;a.initWithDuration(this._duration,cc.copyControlPoints(this._points),this._tension);return 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=this._points;if(1===a){var c=b.length-1;a=1}else{var d=this._deltaT;c=0|a/d;a=(a-d*c)/d}c=cc.cardinalSplineAt(cc.getControlPointAt(b,
c-1),cc.getControlPointAt(b,c-0),cc.getControlPointAt(b,c+1),cc.getControlPointAt(b,c+2),this._tension,a);cc.ENABLE_STACKABLE_ACTIONS&&(b=this.target.getPositionX()-this._previousPosition.x,a=this.target.getPositionY()-this._previousPosition.y,0!==b||0!==a)&&(d=this._accumulatedDiff,b=d.x+b,a=d.y+a,d.x=b,d.y=a,c.x+=b,c.y+=a);this.updatePosition(c)},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=this._points.slice(),b,c=a[0],d=1;d<a.length;++d)b=a[d],a[d]=cc.pSub(b,c),c=b;a=cc.reverseControlPoints(a);
c=a[a.length-1];a.pop();c.x=-c.x;c.y=-c.y;a.unshift(c);for(d=1;d<a.length;++d)b=a[d],b.x=-b.x,b.y=-b.y,b.x+=c.x,b.y+=c.y,c=a[d]=b;return cc.cardinalSplineBy(this._duration,a,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;a.initWithDuration(this._duration,cc.copyControlPoints(this._points),this._tension);return 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,.5)},clone:function(){var a=new cc.CatmullRomTo;a.initWithDuration(this._duration,cc.copyControlPoints(this._points));return 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,.5)},clone:function(){var a=new cc.CatmullRomBy;a.initWithDuration(this._duration,cc.copyControlPoints(this._points));return 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 Error("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;a.initWithDuration(this._duration,this.key,this.from,this.to);return a}});cc.actionTween=function(a,b,c,d){return new cc.ActionTween(a,b,c,d)};cc.ActionTween.create=cc.actionTween;cc.GridAction=cc.ActionInterval.extend({_gridSize:null,_gridNodeTarget:null,ctor:function(a,b){cc.sys._checkWebGLRenderMode();cc.ActionInterval.prototype.ctor.call(this);this._gridSize=cc.size(0,0);b&&this.initWithDuration(a,b)},_cacheTargetAsGridNode:function(a){this._gridNodeTarget=a},clone:function(){var a=new cc.GridAction,b=this._gridSize;a.initWithDuration(this._duration,cc.size(b.width,b.height));return a},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,a);
cc.renderer.childrenOrderDirty=!0;this._cacheTargetAsGridNode(a);var b=this.getGrid();(a=this._gridNodeTarget.getGrid())&&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),this._gridNodeTarget.setGrid(b),this._gridNodeTarget.getGrid().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,void 0,void 0,this._gridNodeTarget.getGridRect())},getGridRect:function(){return this._gridNodeTarget.getGridRect()},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,void 0,void 0,this._gridNodeTarget.getGridRect())}});
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){this._times=a;return!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(Math.PI*a*f*2+.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;
var d=cc.p(0,0);d.x=d.y=1;var e=this.originalVertex(d);d.x=d.y=0;d=this.originalVertex(d);var f=e.x,g=d.x;if(f>g){e=cc.p(0,0);d=cc.p(0,1);var h=cc.p(1,0);var k=cc.p(1,1)}else h=cc.p(0,0),k=cc.p(0,1),e=cc.p(1,0),d=cc.p(1,1),f=g;b.x=f-f*c;b.z=Math.abs(parseFloat(f*a/4));a=this.originalVertex(e);a.x=b.x;a.z+=b.z;this.setVertex(e,a);a=this.originalVertex(d);a.x=b.x;a.z+=b.z;this.setVertex(d,a);a=this.originalVertex(h);a.x-=b.x;a.z-=b.z;this.setVertex(h,a);a=this.originalVertex(k);a.x-=b.x;a.z-=b.z;this.setVertex(k,
a)}});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;var d=cc.p(0,0);d.x=d.y=1;var e=this.originalVertex(d);d.x=d.y=0;d=this.originalVertex(d);var f=e.y,g=d.y;if(f>g){e=cc.p(0,0);d=cc.p(0,1);var h=cc.p(1,0);var k=cc.p(1,1)}else d=cc.p(0,0),e=cc.p(0,1),k=cc.p(1,0),h=cc.p(1,1),f=g;b.y=f-f*c;b.z=Math.abs(parseFloat(f*
a)/4);a=this.originalVertex(e);a.y=b.y;a.z+=b.z;this.setVertex(e,a);a=this.originalVertex(d);a.y-=b.y;a.z-=b.z;this.setVertex(d,a);a=this.originalVertex(h);a.y=b.y;a.z+=b.z;this.setVertex(h,a);a=this.originalVertex(k);a.y-=b.y;a.z-=b.z;this.setVertex(k,a)}});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=.7,this._dirty=!0):!1},update:function(a){if(this._dirty){a=this._gridSize.width;for(var b=this._gridSize.height,c=this._radius,d=this._lensEffect,e=cc.p(0,0),f=cc.p(0,0),g,h,k,m=0;m<a+1;++m)for(var n=0;n<b+1;++n)e.x=m,e.y=n,g=this.originalVertex(e),f.x=this._position.x-g.x,f.y=this._position.y-g.y,h=cc.pLength(f),h<c&&(h=c-h,
h/=c,0===h&&(h=.001),h=Math.log(h)*d,k=Math.exp(h)*c,h=cc.pLength(f),0<h&&(f.x/=h,f.y/=h,f.x*=k,f.y*=k,g.z+=cc.pLength(f)*d)),this.setVertex(e,g);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=this._gridSize.width,c=this._gridSize.height,d=cc.p(0,0),e=this._radius,f=this._waves,g=this._amplitude,h=this._amplitudeRate,k,m,n=cc.p(0,0),p=0;p<b+1;++p)for(var r=0;r<c+1;++r)d.x=p,d.y=r,k=this.originalVertex(d),n.x=
this._position.x-k.x,n.y=this._position.y-k.y,m=cc.pLength(n),m<e&&(m=e-m,k.z+=Math.sin(a*Math.PI*f*2+.1*m)*g*h*Math.pow(m/e,2)),this.setVertex(d,k)}});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){a=this._gridSize.width;for(var b=this._gridSize.height,c=this._randRange,d=this._shakeZ,e=cc.p(0,0),f,g=0;g<a+1;++g)for(var h=0;h<b+1;++h)e.x=g,e.y=h,f=this.originalVertex(e),
f.x+=cc.rand()%(2*c)-c,f.y+=cc.rand()%(2*c)-c,d&&(f.z+=cc.rand()%(2*c)-c),this.setVertex(e,f)}});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=this._gridSize.width,c=this._gridSize.height,d=cc.p(0,0),e=this._waves,f=this._amplitude,g=this._amplitudeRate,h,k=1;k<b;++k)for(var m=1;m<c;++m)d.x=k,d.y=m,h=this.originalVertex(d),h.x+=Math.sin(a*Math.PI*e*2+.01*h.x)*f*g,h.y+=Math.sin(a*Math.PI*e*2+.01*h.y)*f*g,this.setVertex(d,h)}});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=this._gridSize.width,c=this._gridSize.height,d=cc.p(0,0),e=this._vertical,f=this._horizontal,g=this._waves,h=this._amplitude,k=this._amplitudeRate,m,n=0;n<b+1;++n)for(var p=0;p<c+1;++p)d.x=n,d.y=p,m=this.originalVertex(d),e&&(m.x+=Math.sin(a*Math.PI*g*2+.01*m.y)*h*k),f&&(m.y+=Math.sin(a*Math.PI*g*2+.01*m.x)*h*k),this.setVertex(d,m)}});
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=this._position,c=this._gridSize.width,d=this._gridSize.height,e=cc.p(0,0),f=.1*this._amplitude*this._amplitudeRate,g=this._twirls,h,k,m,n=cc.p(0,0),p=0;p<c+1;++p)for(var r=0;r<d+1;++r)e.x=p,e.y=r,h=this.originalVertex(e),n.x=p-c/2,n.y=r-d/2,k=cc.pLength(n)*Math.cos(Math.PI/2+a*Math.PI*
g*2)*f,m=Math.sin(k)*(h.y-b.y)+Math.cos(k)*(h.x-b.x),k=Math.cos(k)*(h.y-b.y)-Math.sin(k)*(h.x-b.x),h.x=b.x+m,h.y=b.y+k,this.setVertex(e,h)}});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){a=this._gridSize;for(var b=this._randRange,c,d=cc.p(0,0),e=0;e<a.width;++e)for(var f=0;f<a.height;++f)d.x=e,
d.y=f,c=this.originalTile(d),c.bl.x+=cc.rand()%(2*b)-b,c.br.x+=cc.rand()%(2*b)-b,c.tl.x+=cc.rand()%(2*b)-b,c.tr.x+=cc.rand()%(2*b)-b,c.bl.y+=cc.rand()%(2*b)-b,c.br.y+=cc.rand()%(2*b)-b,c.tl.y+=cc.rand()%(2*b)-b,c.tr.y+=cc.rand()%(2*b)-b,this._shatterZ&&(c.bl.z+=cc.rand()%(2*b)-b,c.br.z+=cc.rand()%(2*b)-b,c.tl.z+=cc.rand()%(2*b)-b,c.tr.z+=cc.rand()%(2*b)-b),this.setTile(d,c);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);b=this._tiles;c=b.length=0;for(var 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=0,c=this._gridSize,d=this._tiles,e,f=cc.p(0,0),g=0;g<c.width;++g)for(var h=0;h<c.height;++h)f.x=g,f.y=h,e=d[b],e.position.x=
e.delta.width*a,e.position.y=e.delta.height*a,this.placeTile(f,e),++b}});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 c===this._gridSize.width&&d===this._gridSize.height?0:0===c+d?1:Math.pow((a.x+a.y)/(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=this._gridSize,c=cc.p(0,0),d,e=0;e<b.width;++e)for(var f=0;f<b.height;++f)c.x=e,c.y=f,d=this.testFunc(c,a),0===d?this.turnOffTile(c):1>d?this.transformTile(c,d):this.turnOnTile(c)}});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===c+d?0:0===a.x+a.y?1:Math.pow((c+d)/(a.x+a.y),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 c===this._gridSize.height?0:0===c?1:Math.pow(a.y/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===c?0:0===a.y?1:Math.pow(c/a.y,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){a=0|a*this._tilesCount;for(var b=this._gridSize,c,d=cc.p(0,0),e=this._tilesOrder,f=0;f<this._tilesCount;f++)c=e[f],d.x=0|c/b.height,d.y=c%(0|b.height),f<a?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=this._gridSize,c=this._waves,d=this._amplitude,e=this._amplitudeRate,f=cc.p(0,0),g,h=0;h<b.width;h++)for(var k=0;k<b.height;k++)f.x=h,f.y=k,g=this.originalTile(f),g.bl.z=Math.sin(a*Math.PI*c*2+.01*(g.bl.y+g.bl.x))*d*e,g.br.z=g.bl.z,g.tl.z=g.bl.z,g.tr.z=g.bl.z,this.setTile(f,g)}});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){var b=Math.sin(Math.PI*a*this._jumps*2)*this._amplitude*this._amplitudeRate;a=Math.sin(Math.PI*(a*this._jumps*2+1))*this._amplitude*this._amplitudeRate;for(var c=this._gridSize,d=this.target.grid,e,f=cc.p(0,0),g=0;g<c.width;g++)for(var h=0;h<c.height;h++)f.x=g,f.y=h,e=d.originalTile(f),0===(g+h)%2?(e.bl.z+=b,e.br.z+=b,e.tl.z+=b,e.tr.z+=b):(e.bl.z+=a,e.br.z+=a,e.tl.z+=a,e.tr.z+=a),d.setTile(f,e)}});
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){this._rows=b;return cc.TiledGrid3DAction.prototype.initWithDuration.call(this,a,cc.size(1,b))},update:function(a){for(var b=this._gridSize,c=this._winSize.width,d,e,f=cc.p(0,0),g=0;g<b.height;++g)f.y=g,d=this.originalTile(f),e=1,0===g%2&&(e=-1),d.bl.x+=e*c*a,d.br.x+=e*c*a,d.tl.x+=e*c*a,d.tr.x+=e*c*a,this.setTile(f,
d)},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){this._cols=b;return cc.TiledGrid3DAction.prototype.initWithDuration.call(this,a,cc.size(b,1))},update:function(a){for(var b=this._gridSize.width,c=this._winSize.height,d,e,f=cc.p(0,0),g=0;g<b;++g)f.x=g,d=this.originalTile(f),e=1,0===g%2&&(e=-1),d.bl.y+=e*c*a,d.br.y+=e*c*a,d.tl.y+=e*c*a,d.tr.y+=e*c*a,this.setTile(f,
d);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,void 0,void 0,this._gridNodeTarget.getGridRect());a.setNeedDepthTestForBlit(!0);return a},clone:function(){var a=new cc.PageTurn3D;a.initWithDuration(this._duration,this._gridSize);return a},update:function(a){var b=Math.max(0,a-.25);b=-100-b*b*500;var c=Math.sqrt(a),d=.5<c?Math.PI/2*c:Math.PI/2*(1-c);a=(2-a)*Math.PI;c=Math.sin(d);d=Math.cos(d);for(var e=this._gridSize,f=cc.p(0,0),g=0;g<=e.width;++g)for(var h=
0;h<=e.height;++h){f.x=g;f.y=h;var k=this.getOriginalVertex(f);k.x-=this.getGridRect().x;var m=Math.sqrt(k.x*k.x+(k.y-b)*(k.y-b)),n=m*c,p=Math.asin(k.x/m)/c,r=Math.cos(p);k.x=p<=Math.PI?n*Math.sin(p):0;k.y=m+b-n*(1-r)*c;k.z=n*(1-r)*d;k.x=k.z*Math.sin(a)+k.x*Math.cos(a);k.z=k.z*Math.cos(a)-k.x*Math.cos(a);k.z/=7;.5>k.z&&(k.z=.5);k.x+=this.getGridRect().x;this.setVertex(f,k)}}});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)},onEnter:function(){this._super();cc._renderType===cc.game.RENDER_TYPE_WEBGL&&(this._renderCmd.initCmd(),this._renderCmd._updateProgress())},
cleanup:function(){cc._renderType===cc.game.RENDER_TYPE_WEBGL&&this._renderCmd.releaseData();this._super()},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.resetVertexData())},setSprite:function(a){this._sprite!==a&&((this._sprite=a)?(this.setContentSize(a.width,a.height),a.ignoreAnchorPointForPosition(!0)):this.setContentSize(0,0),this._renderCmd.resetVertexData())},setType:function(a){a!==this._type&&(this._type=a,this._renderCmd.resetVertexData())},setReverseDirection:function(a){this._reverseDirection!==
a&&(this._reverseDirection=a,this._renderCmd.resetVertexData())},initWithSprite:function(a){this.percentage=0;this.setAnchorPoint(.5,.5);this._type=cc.ProgressTimer.TYPE_RADIAL;this._reverseDirection=!1;this.midPoint=cc.p(.5,.5);this.barChangeRate=cc.p(1,1);this.setSprite(a);this._renderCmd.resetVertexData();return!0},_createRenderCmd:function(){return cc._renderType===cc.game.RENDER_TYPE_CANVAS?new cc.ProgressTimer.CanvasRenderCmd(this):new cc.ProgressTimer.WebGLRenderCmd(this)}});_p=cc.ProgressTimer.prototype;
cc.defineGetterSetter(_p,"midPoint",_p.getMidpoint,_p.setMidpoint);cc.defineGetterSetter(_p,"barChangeRate",_p.getBarChangeRate,_p.setBarChangeRate);cc.defineGetterSetter(_p,"type",_p.getType,_p.setType);cc.defineGetterSetter(_p,"percentage",_p.getPercentage,_p.setPercentage);cc.defineGetterSetter(_p,"sprite",_p.getSprite,_p.setSprite);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;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;a.initWithDuration(this._duration,this._to);return a},reverse:function(){cc.log("cc.ProgressTo.reverse(): reverse hasn't been supported.");return 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;a.initWithDuration(this._duration,this._from,this._to);return 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.CanvasRenderCmd=function(a){this._rootCtor(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;this._canUseDirtyRegion=!0};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 b=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;c=n.x;d=-n.y-m.height;k=m.width;m=m.height;a.save();g._flippedX&&(c=-c-k,b.scale(-1,1));g._flippedY&&(d=n.y,b.scale(1,-1));f._type===cc.ProgressTimer.TYPE_BAR?(f=this._barRect,b.beginPath(),b.rect(f.x,f.y,f.width,f.height),b.clip(),
b.closePath()):f._type===cc.ProgressTimer.TYPE_RADIAL&&(f=this._origin.x,n=this._origin.y,b.beginPath(),b.arc(f,n,this._radius,this._PI180*this._startAngle,this._PI180*this._endAngle,this._counterClockWise),b.lineTo(f,n),b.clip(),b.closePath());f=(g._renderCmd._textureToRender||g._texture).getHtmlElementObj();g._renderCmd._colorized?b.drawImage(f,0,0,h.width,h.height,c,d,k,m):b.drawImage(f,h.renderX,h.renderY,h.width,h.height,c,d,k,m);a.restore();cc.g_NumberOfDraws++}};a.releaseData=function(){};
a.resetVertexData=function(){};a._updateProgress=function(){this.setDirtyFlag(cc.Node._dirtyFlags.contentDirty);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=!1,h=this._origin;h.x=d*f.x;h.y=-e*f.y;if(a._reverseDirection){var k=270;f=270-3.6*a._percentage}else f=-90,k=-90+3.6*a._percentage;c._flippedX&&(h.x-=2*d*a._midPoint.x,f=-f-180,k=-k-180,g=!g);c._flippedY&&(h.y+=2*e*a._midPoint.y,g=
!g,f=-f,k=-k);this._startAngle=f;this._endAngle=k;this._counterClockWise=g}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,.5<f.x&&g.width/2>=d-k.x&&(h=d-g.width),d=k.y-g.height/2,.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._syncStatus=function(a){var b=this._node;if(b._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;b=b._sprite._renderCmd;var g=b._dirtyFlag;f=g&d.colorDirty;g&=d.opacityDirty;f&&(b._syncDisplayColor(),b._dirtyFlag&=~d.colorDirty,
this._dirtyFlag&=~d.colorDirty);g&&(b._syncDisplayOpacity(),b._dirtyFlag&=~d.opacityDirty,this._dirtyFlag&=~d.opacityDirty);(f||g)&&b._updateColor();e&d.transformDirty&&this.transform(a);e&d.orderDirty&&(this._dirtyFlag&=~d.orderDirty)}};a.updateStatus=function(){var a=this._node;if(a._sprite){var c=cc.Node._dirtyFlags,d=this._dirtyFlag;a=a._sprite._renderCmd;var e=a._dirtyFlag,f=e&c.colorDirty;e&=c.opacityDirty;f&&(a._updateDisplayColor(),a._dirtyFlag^=a._dirtyFlag&c.colorDirty,this._dirtyFlag^=
this._dirtyFlag&c.colorDirty);e&&(a._updateDisplayOpacity(),a._dirtyFlag^=a._dirtyFlag&c.opacityDirty,this._dirtyFlag^=this._dirtyFlag&c.opacityDirty);(f||e)&&a._updateColor();d&c.transformDirty&&this.transform(this.getParentRenderCmd(),!0);d&c.contentDirty&&this._notifyRegionStatus&&this._notifyRegionStatus(cc.Node.CanvasRenderCmd.RegionStatus.Dirty);this._dirtyFlag=0}}})();(function(){cc.ProgressTimer.WebGLRenderCmd=function(a){this._rootCtor(a);this._progressDirty=this._needDraw=!0;this._bl=cc.p();this._tr=cc.p();this._transformUpdating=!1;this.initCmd()};var a=cc.ProgressTimer.WebGLRenderCmd.prototype=Object.create(cc.Node.WebGLRenderCmd.prototype);a.constructor=cc.ProgressTimer.WebGLRenderCmd;a.transform=function(a,c){this.originTransform(a,c);var b=this._node._sprite;b._renderCmd.transform(this,c);var e=b._offsetPosition.x,f=e+b._rect.width,g=b._offsetPosition.y;
b=g+b._rect.height;var h=this._worldTransform;this._bl.x=e*h.a+g*h.c+h.tx;this._bl.y=e*h.b+g*h.d+h.ty;this._tr.x=f*h.a+b*h.c+h.tx;this._tr.y=f*h.b+b*h.d+h.ty;this._transformUpdating=!0;this._updateProgressData();this._transformUpdating=!1};a.rendering=function(a){var b=this._node;a=a||cc._renderContext;if(0!==this._vertexDataCount&&b._sprite){this._glProgramState.apply();this._shaderProgram._updateProjectionUniform();var d=b._sprite._blendFunc;cc.glBlendFunc(d.src,d.dst);cc.glBindTexture2D(b._sprite.texture);
a.bindBuffer(a.ARRAY_BUFFER,this._vertexWebGLBuffer);a.enableVertexAttribArray(cc.VERTEX_ATTRIB_POSITION);a.enableVertexAttribArray(cc.VERTEX_ATTRIB_COLOR);a.enableVertexAttribArray(cc.VERTEX_ATTRIB_TEX_COORDS);this._vertexDataDirty&&(a.bufferSubData(a.ARRAY_BUFFER,0,this._float32View),this._vertexDataDirty=!1);d=cc.V3F_C4B_T2F.BYTES_PER_ELEMENT;a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,3,a.FLOAT,!1,d,0);a.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR,4,a.UNSIGNED_BYTE,!0,d,12);a.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS,
2,a.FLOAT,!1,d,16);b._type===cc.ProgressTimer.TYPE_RADIAL?a.drawArrays(a.TRIANGLE_FAN,0,this._vertexDataCount):b._type===cc.ProgressTimer.TYPE_BAR&&(b._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 b=this._node;if(b._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;b=b._sprite._renderCmd;var g=b._dirtyFlag;f=(e|g)&d.colorDirty;g=(e|g)&d.opacityDirty;f&&(b._syncDisplayColor(),b._dirtyFlag&=~d.colorDirty,this._dirtyFlag&=~d.colorDirty);g&&(b._syncDisplayOpacity(),b._dirtyFlag&=~d.opacityDirty,this._dirtyFlag&=~d.opacityDirty);(f||g)&&this._updateColor();
e&d.transformDirty&&this.transform(a);e&d.textureDirty&&(this._updateProgressData(),this._dirtyFlag&=~d.textureDirty);b._dirtyFlag=0}};a.updateStatus=function(){var a=this._node;if(a._sprite){var c=cc.Node._dirtyFlags,d=this._dirtyFlag;a=a._sprite._renderCmd;var e=a._dirtyFlag,f=(d|e)&c.colorDirty;e=(d|e)&c.opacityDirty;f&&(a._updateDisplayColor(),a._dirtyFlag^=a._dirtyFlag&c.colorDirty,this._dirtyFlag^=this._dirtyFlag&c.colorDirty);e&&(a._updateDisplayOpacity(),a._dirtyFlag^=a._dirtyFlag&c.opacityDirty,
this._dirtyFlag^=this._dirtyFlag&c.opacityDirty);(f||e)&&this._updateColor();d&c.transformDirty&&this.transform(this.getParentRenderCmd(),!0);d&c.orderDirty&&(this._dirtyFlag^=this._dirtyFlag&c.orderDirty);d&c.textureDirty&&(this._updateProgressData(),this._dirtyFlag^=this._dirtyFlag&c.textureDirty)}};a.releaseData=function(){if(this._vertexData){var a=this._vertexWebGLBuffer;setTimeout(function(){cc._renderContext.deleteBuffer(a)},.1);this._vertexArrayBuffer=this._float32View=this._vertexData=this._vertexWebGLBuffer=
null;this._vertexDataCount=0}};a.initCmd=function(){if(!this._vertexData){this._vertexWebGLBuffer=cc._renderContext.createBuffer();var a=cc.V3F_C4B_T2F.BYTES_PER_ELEMENT;this._vertexArrayBuffer=new ArrayBuffer(8*a);this._float32View=new Float32Array(this._vertexArrayBuffer);this._vertexData=[];for(var c=0;8>c;c++)this._vertexData[c]=new cc.V3F_C4B_T2F(null,null,null,this._vertexArrayBuffer,c*a);gl.bindBuffer(gl.ARRAY_BUFFER,this._vertexWebGLBuffer);gl.bufferData(gl.ARRAY_BUFFER,this._float32View,
gl.DYNAMIC_DRAW);this._vertexDataCount=0;this._vertexDataDirty=!0;this._shaderProgram=cc.shaderCache.programForKey(cc.SHADER_SPRITE_POSITION_TEXTURECOLOR)}};a.resetVertexData=function(){this._vertexDataCount=0};a._updateProgressData=function(){var a=this._node._type;a===cc.ProgressTimer.TYPE_RADIAL?this._updateRadial():a===cc.ProgressTimer.TYPE_BAR&&this._updateBar();this._vertexDataDirty=!0};a._updateProgress=function(){this.setDirtyFlag(cc.Node._dirtyFlags.textureDirty)};a._updateBar=function(){var a=
this._node;if(a._sprite){var c=a._percentage/100,d=a._barChangeRate;d=cc.pMult(cc.p(1-d.x+c*d.x,1-d.y+c*d.y),.5);c=cc.pSub(a._midPoint,d);a=cc.pAdd(a._midPoint,d);0>c.x&&(a.x+=-c.x,c.x=0);1<a.x&&(c.x-=a.x-1,a.x=1);0>c.y&&(a.y+=-c.y,c.y=0);1<a.y&&(c.y-=a.y-1,a.y=1);this._reverseDirection?(d=this._vertexData,this._vertexDataCount||(this._vertexDataCount=8,this._textureCoordFromAlphaPoint(d[0].texCoords,0,1),this._vertexFromAlphaPoint(d[0].vertices,0,1),this._textureCoordFromAlphaPoint(d[1].texCoords,
0,0),this._vertexFromAlphaPoint(d[1].vertices,0,0),this._textureCoordFromAlphaPoint(d[6].texCoords,1,1),this._vertexFromAlphaPoint(d[6].vertices,1,1),this._textureCoordFromAlphaPoint(d[7].texCoords,1,0),this._vertexFromAlphaPoint(d[7].vertices,1,0)),this._textureCoordFromAlphaPoint(d[2].texCoords,c.x,a.y),this._vertexFromAlphaPoint(d[2].vertices,c.x,a.y),this._textureCoordFromAlphaPoint(d[3].texCoords,c.x,c.y),this._vertexFromAlphaPoint(d[3].vertices,c.x,c.y),this._textureCoordFromAlphaPoint(d[4].texCoords,
a.x,a.y),this._vertexFromAlphaPoint(d[4].vertices,a.x,a.y),this._textureCoordFromAlphaPoint(d[5].texCoords,a.x,c.y),this._vertexFromAlphaPoint(d[5].vertices,a.x,c.y)):(this._vertexDataCount||(this._vertexDataCount=4),d=this._vertexData,this._textureCoordFromAlphaPoint(d[0].texCoords,c.x,a.y),this._vertexFromAlphaPoint(d[0].vertices,c.x,a.y),this._textureCoordFromAlphaPoint(d[1].texCoords,c.x,c.y),this._vertexFromAlphaPoint(d[1].vertices,c.x,c.y),this._textureCoordFromAlphaPoint(d[2].texCoords,a.x,
a.y),this._vertexFromAlphaPoint(d[2].vertices,a.x,a.y),this._textureCoordFromAlphaPoint(d[3].texCoords,a.x,c.y),this._vertexFromAlphaPoint(d[3].vertices,a.x,c.y));this._updateColor()}};a._updateRadial=function(){var a=this._node;if(a._sprite){var c=a._midPoint;var d=a._percentage/100;var e=2*cc.PI*(a._reverseDirection?d:1-d);a=cc.p(c.x,1);var f=cc.pRotateByAngle(a,c,e);e=0;if(0===d)f=a,e=0;else if(1===d)f=a,e=4;else{var g=cc.FLT_MAX,h=cc.ProgressTimer.TEXTURE_COORDS_COUNT;for(d=0;d<=h;++d){var k=
(d+(h-1))%h,m=this._boundaryTexCoord(d%h);k=this._boundaryTexCoord(k);0===d?k=cc.pLerp(m,k,1-c.x):4===d&&(m=cc.pLerp(m,k,1-c.x));var n=cc.p(0,0);cc.pLineIntersect(m,k,c,f,n)&&(0!==d&&4!==d||0<=n.x&&1>=n.x)&&0<=n.y&&n.y<g&&(g=n.y,e=d)}f=cc.pAdd(c,cc.pMult(cc.pSub(f,c),g))}d=!0;this._vertexDataCount!==e+3&&(d=!1,this._vertexDataCount=e+3);this._updateColor();g=this._vertexData;if(this._transformUpdating||!d)for(this._textureCoordFromAlphaPoint(g[0].texCoords,c.x,c.y),this._vertexFromAlphaPoint(g[0].vertices,
c.x,c.y),this._textureCoordFromAlphaPoint(g[1].texCoords,a.x,a.y),this._vertexFromAlphaPoint(g[1].vertices,a.x,a.y),d=0;d<e;d++)c=this._boundaryTexCoord(d),this._textureCoordFromAlphaPoint(g[d+2].texCoords,c.x,c.y),this._vertexFromAlphaPoint(g[d+2].vertices,c.x,c.y);this._textureCoordFromAlphaPoint(g[this._vertexDataCount-1].texCoords,f.x,f.y);this._vertexFromAlphaPoint(g[this._vertexDataCount-1].vertices,f.x,f.y)}};a._boundaryTexCoord=function(a){if(a<cc.ProgressTimer.TEXTURE_COORDS_COUNT){var b=
cc.ProgressTimer.TEXTURE_COORDS;return this._node._reverseDirection?cc.p(b>>7-(a<<1)&1,b>>7-((a<<1)+1)&1):cc.p(b>>(a<<1)+1&1,b>>(a<<1)&1)}return cc.p(0,0)};a._textureCoordFromAlphaPoint=function(a,c,d){var b=this._node._sprite;if(b){var f=b._renderCmd._vertices,g=f[1];f=f[2];g=cc.p(g.u,g.v);f=cc.p(f.u,f.v);b.textureRectRotated&&(b=c,c=d,d=b);a.u=g.x*(1-c)+f.x*c;a.v=g.y*(1-d)+f.y*d}else a.u=0,a.v=0};a._vertexFromAlphaPoint=function(a,c,d){a.x=this._bl.x*(1-c)+this._tr.x*c;a.y=this._bl.y*(1-d)+this._tr.y*
d;a.z=this._node._vertexZ};a._updateColor=function(){var a=this._node._sprite;if(this._vertexDataCount&&a){var c=this._displayedColor,d=a._renderCmd._displayedColor,e=d.r,f=d.g;d=d.b;var g=a._renderCmd._displayedOpacity/255;a._opacityModifyRGB&&(e*=g,f*=g,d*=g);c.r=e;c.g=f;c.b=d;c.a=a._renderCmd._displayedOpacity;a=this._vertexData;e=0;for(f=this._vertexDataCount;e<f;++e)a[e].colors=c;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._performRecursive(cc.Node._stateCallbackType.onExitTransitionDidStart);this._inScene._performRecursive(cc.Node._stateCallbackType.onEnter)},onExit:function(){cc.Node.prototype.onExit.call(this);cc.eventManager.setEnabled(!0);this._outScene._performRecursive(cc.Node._stateCallbackType.onExit);
this._inScene._performRecursive(cc.Node._stateCallbackType.onEnterTransitionDidFinish)},cleanup:function(){cc.Node.prototype.cleanup.call(this);this._isSendCleanupToScene&&this._outScene._performRecursive(cc.Node._stateCallbackType.cleanup)},initWithDuration:function(a,b){if(!b)throw Error("cc.TransitionScene.initWithDuration(): Argument scene must be non-nil");if(this.init()){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());if(this._inScene===this._outScene)throw Error("cc.TransitionScene.initWithDuration(): Incoming scene must be different from the outgoing scene");this._sceneOrder();return!0}return!1},finish:function(){this._inScene.attr({visible:!0,x:0,y:0,scale:1,rotation:0});this._outScene.attr({visible:!1,x:0,y:0,scale:1,rotation:0});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){cc.TransitionScene.prototype.initWithDuration.call(this,a,b)&&(this._orientation=c);return!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:.001,anchorX:.5,anchorY:.5});this._outScene.attr({scale:1,anchorX:.5,anchorY:.5});var a=cc.sequence(cc.spawn(cc.scaleBy(this._duration/2,.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:.5,x:a.width,y:0,anchorX:.5,anchorY:.5});this._outScene.anchorX=.5;this._outScene.anchorY=.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,.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=.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=cc.sequence(this.easeActionWithAction(a),cc.callFunc(this.finish,this));b=this.easeActionWithAction(b);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:.001,anchorX:2/3,anchorY:.5});this._outScene.attr({scale:1,anchorX:1/3,anchorY:.5});var a=cc.scaleTo(this._duration,.01),b=cc.scaleTo(this._duration,1);this._inScene.runAction(cc.sequence(this.easeActionWithAction(b),cc.callFunc(this.finish,this)));this._outScene.runAction(this.easeActionWithAction(a))},
easeActionWithAction:function(a){return new cc.EaseOut(a,2)}});cc.TransitionShrinkGrow.create=function(a,b){return new cc.TransitionShrinkGrow(a,b)};
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);a=this.getChildByTag(cc.SCENE_FADE);var 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){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);return!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);var c=new cc.RenderTexture(b.width,b.height);c.sprite.anchorX=.5;c.sprite.anchorY=.5;c.attr({x:b.width/2,y:b.height/2,anchorX:.5,anchorY:.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=.5;d.sprite.anchorY=d.anchorY=.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)}});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._performRecursive(cc.Node._stateCallbackType.onEnter);var a=cc.director.getWinSize();a=cc.turnOffTiles(this._duration,cc.size(0|a.width/
a.height*12,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._performRecursive(cc.Node._stateCallbackType.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._performRecursive(cc.Node._stateCallbackType.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._performRecursive(cc.Node._stateCallbackType.onEnter);var a=cc.director.getWinSize();a=this.actionWithSize(cc.size(0|a.width/a.height*12,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:.5,anchorY:.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=.5;b.sprite.anchorY=.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){cc.log("cc.TransitionProgress._progressTimerNodeWithRenderTexture(): should be overridden in subclass");return 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);cc._renderType===cc.game.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);return 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);cc._renderType===cc.game.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);return 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);cc._renderType===cc.game.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);return 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);cc._renderType===cc.game.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);return 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);cc._renderType===cc.game.RENDER_TYPE_WEBGL&&(a.sprite.flippedY=!0);a.type=cc.ProgressTimer.TYPE_BAR;a.midPoint=cc.p(.5,.5);a.barChangeRate=cc.p(1,1);a.percentage=0;this._setAttrs(a,b.width/2,b.height/2);return 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);cc._renderType===cc.game.RENDER_TYPE_WEBGL&&(a.sprite.flippedY=!0);a.type=cc.ProgressTimer.TYPE_BAR;a.midPoint=cc.p(.5,.5);a.barChangeRate=cc.p(1,1);a.percentage=100;this._setAttrs(a,b.width/2,b.height/2);return 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){this._back=c;cc.TransitionScene.prototype.initWithDuration.call(this,a,b);return!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=cc.director.getWinSize();if(a.width>a.height){a=16;var b=12}else a=12,b=16;a=this.actionWithSize(cc.size(a,b));b=this._gridProxy;this._back?(b.setTarget(this._inScene),b._performRecursive(cc.Node._stateCallbackType.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._performRecursive(cc.Node._stateCallbackType.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=this.unzipBase64(a),d=[],e,f;var g=0;for(f=c.length/b;g<f;g++)for(d[g]=0,e=b-1;0<=e;--e)d[g]+=c.charCodeAt(g*b+e)<<8*e;return d};
cc.unzipAsArray=function(a,b){b=b||1;var c=this.unzip(a),d=[],e,f;var g=0;for(f=c.length/b;g<f;g++)for(d[g]=0,e=b-1;0<=e;--e)d[g]+=c.charCodeAt(g*b+e)<<8*e;return d};cc.StringToArray=function(a){a=a.split(",");var b=[],c;for(c=0;c<a.length;c++)b.push(parseInt(a[c]));return b};cc.Codec.Base64={name:"Jacob__Codec__Base64"};cc.Codec.Base64._keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
cc.Codec.Base64.decode=function(a){var b=[],c=0;for(a=a.replace(/[^A-Za-z0-9\+\/\=]/g,"");c<a.length;){var d=this._keyStr.indexOf(a.charAt(c++));var e=this._keyStr.indexOf(a.charAt(c++));var f=this._keyStr.indexOf(a.charAt(c++));var g=this._keyStr.indexOf(a.charAt(c++));d=d<<2|e>>4;e=(e&15)<<4|f>>2;var h=(f&3)<<6|g;b.push(String.fromCharCode(d));64!==f&&b.push(String.fromCharCode(e));64!==g&&b.push(String.fromCharCode(h))}return b=b.join("")};
cc.Codec.Base64.decodeAsArray=function(a,b){var c=this.decode(a),d=[],e,f;var g=0;for(f=c.length/b;g<f;g++)for(d[g]=0,e=b-1;0<=e;--e)d[g]+=c.charCodeAt(g*b+e)<<8*e;return d};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;d<b;d++){var e=4*d;c[d]=a[e]+256*a[e+1]+65536*a[e+2]+16777216*a[e+3]}return c};cc.PNGReader=cc.Class.extend({ctor:function(a){var b,c,d;this.data=a;this.pos=8;this.palette=[];this.imgData=[];this.transparency={};this.animation=null;this.text={};for(c=null;;){var e=this.readUInt32();a=[];for(d=0;4>d;++d)a.push(String.fromCharCode(this.data[this.pos++]));a=a.join("");switch(a){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()||Infinity,frames:[]};break;case "PLTE":this.palette=this.read(e);break;case "fcTL":c&&this.animation.frames.push(c);this.pos+=4;c={width:this.readUInt32(),height:this.readUInt32(),xOffset:this.readUInt32(),yOffset:this.readUInt32()};a=this.readUInt16();e=this.readUInt16()||100;c.delay=1E3*a/e;c.disposeOp=this.data[this.pos++];c.blendOp=this.data[this.pos++];
c.data=[];break;case "IDAT":case "fdAT":"fdAT"===a&&(this.pos+=4,e-=4);a=(null!=c?c.data:void 0)||this.imgData;for(d=0;0<=e?d<e:d>e;0<=e?++d:--d)a.push(this.data[this.pos++]);break;case "tRNS":this.transparency={};switch(this.colorType){case 3:this.transparency.indexed=this.read(e);e=255-this.transparency.indexed.length;if(0<e)for(a=0;0<=e?a<e:a>e;0<=e?++a:--a)this.transparency.indexed.push(255);break;case 0:this.transparency.grayscale=this.read(e)[0];break;case 2:this.transparency.rgb=this.read(e)}break;
case "tEXt":d=this.read(e);e=d.indexOf(0);a=String.fromCharCode.apply(String,d.slice(0,e));this.text[a]=String.fromCharCode.apply(String,d.slice(e+1));break;case "IEND":c&&this.animation.frames.push(c);a:{switch(this.colorType){case 0:case 3:case 4:c=1;break a;case 2:case 6:c=3;break a}c=void 0}this.colors=c;this.hasAlphaChannel=4===(b=this.colorType)||6===b;b=this.colors+(this.hasAlphaChannel?1:0);this.pixelBitlength=this.bits*b;a:{switch(this.colors){case 1:b="DeviceGray";break a;case 3:b="DeviceRGB";
break a}b=void 0}this.colorSpace=b;Uint8Array!=Array&&(this.imgData=new Uint8Array(this.imgData));return;default:this.pos+=e}this.pos+=4;if(this.pos>this.data.length)throw Error("Incomplete or corrupt PNG file");}},read:function(a){var b;var c=[];for(b=0;0<=a?b<a:b>a;0<=a?++b:--b)c.push(this.data[this.pos++]);return c},readUInt32:function(){var a=this.data[this.pos++]<<24;var b=this.data[this.pos++]<<16;var c=this.data[this.pos++]<<8;var d=this.data[this.pos++];return a|b|c|d},readUInt16:function(){var a=
this.data[this.pos++]<<8;var b=this.data[this.pos++];return a|b},decodePixels:function(a){var b,c,d,e,f,g,h,k;null==a&&(a=this.imgData);if(0===a.length)return new Uint8Array(0);a=(new Zlib.Inflate(a,{index:0,verify:!1})).decompress();var m=this.pixelBitlength/8;var n=m*this.width;var p=new Uint8Array(n*this.height);var r=a.length;for(c=e=f=0;e<r;){switch(a[e++]){case 0:for(b=0;b<n;b+=1)p[c++]=a[e++];break;case 1:for(d=g=0;g<n;d=g+=1){b=a[e++];var t=d<m?0:p[c-m];p[c++]=(b+t)%256}break;case 2:for(d=
t=0;t<n;d=t+=1){b=a[e++];var u=(d-d%m)/m;g=f&&p[(f-1)*n+u*m+d%m];p[c++]=(g+b)%256}break;case 3:for(d=k=0;k<n;d=k+=1)b=a[e++],u=(d-d%m)/m,t=d<m?0:p[c-m],g=f&&p[(f-1)*n+u*m+d%m],p[c++]=(b+Math.floor((t+g)/2))%256;break;case 4:for(d=k=0;k<n;d=k+=1){b=a[e++];u=(d-d%m)/m;t=d<m?0:p[c-m];0===f?g=h=0:(g=p[(f-1)*n+u*m+d%m],h=u&&p[(f-1)*n+(u-1)*m+d%m]);var v=t+g-h;d=Math.abs(v-t);u=Math.abs(v-g);v=Math.abs(v-h);t=d<=u&&d<=v?t:u<=v?g:h;p[c++]=(b+t)%256}break;default:throw Error("Invalid filter algorithm: "+
a[e-1]);}f++}return p},copyToImageData:function(a,b){var c,d;var e=this.colors;var f=null;var g=this.hasAlphaChannel;this.palette.length&&(f=null!=(c=this._decodedPalette)?c:this._decodedPalette=this.decodePalette(),e=4,g=!0);c=a.data||a;var h=c.length;var k=f||b;var m=d=0;if(1===e)for(;m<h;)e=f?4*b[m/4]:d,d=k[e++],c[m++]=d,c[m++]=d,c[m++]=d,c[m++]=g?k[e++]:255,d=e;else for(;m<h;)e=f?4*b[m/4]:d,c[m++]=k[e++],c[m++]=k[e++],c[m++]=k[e++],c[m++]=g?k[e++]:255,d=e},decodePalette:function(){var a,b,c,d,
e;var f=this.palette;var g=this.transparency.indexed||[];var h=new Uint8Array((g.length||0)+f.length);var k=c=a=b=0;for(d=f.length;c<d;k=c+=3)h[b++]=f[k],h[b++]=f[k+1],h[b++]=f[k+2],h[b++]=null!=(e=g[a++])?e:255;return h},render:function(a){a.width=this.width;a.height=this.height;a=a.getContext("2d");var b=a.createImageData(this.width,this.height);this.copyToImageData(b,this.decodePixels());return a.putImageData(b,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)this.littleEndian=
!1;else throw console.log(a),TypeError("Invalid byte order value.");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;if(a in b)return b[a];console.log("Unknown Field Tag:",a);return"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)!1===this.littleEndian?a.push(d>>>8*(4-e)):a.push(d);else for(var f=0;f<c;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))}"ASCII"===b&&a.forEach(function(a,
b,c){c[b]=String.fromCharCode(a)});return 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;b+=Math.floor(c/8);var d=c+a;a=32-a;if(0>=d)console.log("No bits requested");else if(8>=d){var e=24+c;var f=this.getUint8(b)}else 16>=d?(e=16+c,f=this.getUint16(b)):32>=d?(e=c,f=this.getUint32(b)):
console.log("Too many bits requested");return{bits:f<<e>>>a,byteOffset:b+Math.floor(d/8),bitOffset:d%8}},parseFileDirectory:function(a){var b=this.getUint16(a),c=[];a+=2;for(var d=0;d<b;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){var c,d;b=b||document.createElement("canvas");this._tiffData=a;this.canvas=b;this.checkLittleEndian();if(this.hasTowel()){var e=this.getUint32(4);this._fileDirectories.length=0;this.parseFileDirectory(e);var f=this._fileDirectories[0];e=f.ImageWidth.values[0];var g=f.ImageLength.values[0];this.canvas.width=e;this.canvas.height=g;var h=[],k=f.Compression?f.Compression.values[0]:1,m=f.SamplesPerPixel.values[0],n=[],p=0,r=
!1;f.BitsPerSample.values.forEach(function(a,b,c){n[b]={bitsPerSample:a,hasBytesPerSample:!1,bytesPerSample:void 0};0===a%8&&(n[b].hasBytesPerSample=!0,n[b].bytesPerSample=a/8);p+=a},this);if(0===p%8){r=!0;var t=p/8}var u=f.StripOffsets.values,v=u.length;if(f.StripByteCounts)var x=f.StripByteCounts.values;else if(cc.log("Missing StripByteCounts!"),1===v)x=[Math.ceil(e*g*p/8)];else throw Error("Cannot recover from missing StripByteCounts");for(var w=0;w<v;w++){var y=u[w];h[w]=[];for(var z=x[w],A=0,
B=0,C=1,D=!0,E=[],J=0,I=0,G=0;A<z;A+=C)switch(k){case 1:C=0;for(E=[];C<m;C++)if(n[C].hasBytesPerSample)E.push(this.getBytes(n[C].bytesPerSample,y+A+n[C].bytesPerSample*C));else{var H=this.getBits(n[C].bitsPerSample,y+A,B);E.push(H.bits);A=H.byteOffset-y;B=H.bitOffset;throw RangeError("Cannot handle sub-byte bits per sample");}h[w].push(E);if(r)C=t;else throw C=0,RangeError("Cannot handle sub-byte bits per pixel");break;case 32773:if(D){D=!1;var F=d=1;C=this.getInt8(y+A);0<=C&&127>=C?d=C+1:-127<=C&&
-1>=C?F=-C+1:D=!0}else{var K=this.getUint8(y+A);for(C=0;C<F;C++){if(n[I].hasBytesPerSample)G=G<<8*J|K,J++,J===n[I].bytesPerSample&&(E.push(G),G=J=0,I++);else throw RangeError("Cannot handle sub-byte bits per sample");I===m&&(h[w].push(E),E=[],I=0)}d--;0===d&&(D=!0)}C=1}}if(b.getContext){F=this.canvas.getContext("2d");F.fillStyle="rgba(255, 255, 255, 0)";w=f.RowsPerStrip?f.RowsPerStrip.values[0]:g;d=h.length;g%=w;g=0===g?w:g;t=w;x=0;y=f.PhotometricInterpretation.values[0];A=[];E=0;f.ExtraSamples&&
(A=f.ExtraSamples.values,E=A.length);if(f.ColorMap){var L=f.ColorMap.values;H=Math.pow(2,n[0].bitsPerSample)}for(w=0;w<d;w++){w+1===d&&(t=g);f=h[w].length;x*=w;for(m=k=0;k<t,m<f;k++)for(r=0;r<e;r++,m++){v=h[w][m];D=B=z=0;u=1;if(0<E)for(z=0;z<E;z++)if(1===A[z]||2===A[z]){u=v[3+z]/256;break}switch(y){case 0:n[0].hasBytesPerSample&&(c=Math.pow(16,2*n[0].bytesPerSample)),v.forEach(function(a,b,d){d[b]=c-a});case 1:z=B=D=this.clampColorSample(v[0],n[0].bitsPerSample);break;case 2:z=this.clampColorSample(v[0],
n[0].bitsPerSample);B=this.clampColorSample(v[1],n[1].bitsPerSample);D=this.clampColorSample(v[2],n[2].bitsPerSample);break;case 3:if(void 0===L)throw Error("Palette image missing color map");v=v[0];z=this.clampColorSample(L[v],16);B=this.clampColorSample(L[H+v],16);D=this.clampColorSample(L[2*H+v],16);break;default:throw RangeError("Unknown Photometric Interpretation:",y);}F.fillStyle="rgba("+z+", "+B+", "+D+", "+u+")";F.fillRect(r,x+k,1,1)}x=t}}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._particleIdx=this._emitCounter=0;this._batchNode=null;this.atlasIndex=0;this._transformSystemDirty=!1;this._allocatedParticles=0;this._isActive=!1;this._totalParticles=this.emissionRate=this.endSpinVar=this.endSpin=this.startSpinVar=
this.startSpin=this.endSizeVar=this.endSize=this.startSizeVar=this.startSize=this.angleVar=this.angle=this.lifeVar=this.life=this.duration=this.particleCount=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.game.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.x=a.x;
this._sourcePosition.y=a.y},getPosVar:function(){return{x:this._posVar.x,y:this._posVar.y}},setPosVar:function(a){this._posVar.x=a.x;this._posVar.y=a.y},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(){this.emitterMode!==cc.ParticleSystem.MODE_GRAVITY&&cc.log("cc.ParticleBatchNode.getSpeed() : Particle Mode should be Gravity");return 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(){this.emitterMode!==cc.ParticleSystem.MODE_GRAVITY&&cc.log("cc.ParticleBatchNode.getSpeedVar() : Particle Mode should be Gravity");return 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(){this.emitterMode!==cc.ParticleSystem.MODE_GRAVITY&&cc.log("cc.ParticleBatchNode.getTangentialAccel() : Particle Mode should be Gravity");return 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(){this.emitterMode!==cc.ParticleSystem.MODE_GRAVITY&&
cc.log("cc.ParticleBatchNode.getTangentialAccelVar() : Particle Mode should be Gravity");return 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(){this.emitterMode!==cc.ParticleSystem.MODE_GRAVITY&&cc.log("cc.ParticleBatchNode.getRadialAccel() : Particle Mode should be Gravity");return 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(){this.emitterMode!==cc.ParticleSystem.MODE_GRAVITY&&cc.log("cc.ParticleBatchNode.getRadialAccelVar() : Particle Mode should be Gravity");return 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(){this.emitterMode!==cc.ParticleSystem.MODE_GRAVITY&&cc.log("cc.ParticleBatchNode.getRotationIsDir() : Particle Mode should be Gravity");return 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(){this.emitterMode!==cc.ParticleSystem.MODE_RADIUS&&cc.log("cc.ParticleBatchNode.getStartRadius() : Particle Mode should be Radius");
return 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(){this.emitterMode!==cc.ParticleSystem.MODE_RADIUS&&cc.log("cc.ParticleBatchNode.getStartRadiusVar() : Particle Mode should be Radius");return 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(){this.emitterMode!==cc.ParticleSystem.MODE_RADIUS&&cc.log("cc.ParticleBatchNode.getEndRadius() : Particle Mode should be Radius");return 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(){this.emitterMode!==cc.ParticleSystem.MODE_RADIUS&&cc.log("cc.ParticleBatchNode.getEndRadiusVar() : Particle Mode should be Radius");
return 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(){this.emitterMode!==cc.ParticleSystem.MODE_RADIUS&&cc.log("cc.ParticleBatchNode.getRotatePerSecond() : Particle Mode should be Radius");return 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(){this.emitterMode!==cc.ParticleSystem.MODE_RADIUS&&cc.log("cc.ParticleBatchNode.getRotatePerSecondVar() : Particle Mode should be Radius");return 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.r=a.r;this._startColor.g=a.g;this._startColor.b=a.b;this._startColor.a=a.a},getStartColorVar:function(){return cc.color(this._startColorVar.r,this._startColorVar.g,this._startColorVar.b,this._startColorVar.a)},
setStartColorVar:function(a){this._startColorVar.r=a.r;this._startColorVar.g=a.g;this._startColorVar.b=a.b;this._startColorVar.a=a.a},getEndColor:function(){return cc.color(this._endColor.r,this._endColor.g,this._endColor.b,this._endColor.a)},setEndColor:function(a){this._endColor.r=a.r;this._endColor.g=a.g;this._endColor.b=a.b;this._endColor.a=a.a},getEndColorVar:function(){return cc.color(this._endColorVar.r,this._endColorVar.g,this._endColorVar.b,this._endColorVar.a)},setEndColorVar:function(a){this._endColorVar.r=
a.r;this._endColorVar.g=a.g;this._endColorVar.b=a.b;this._endColorVar.a=a.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){if(void 0===
b)this._blendFunc!==a&&(this._blendFunc=a,this._updateBlendFunc());else if(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;a=cc.loader.getRes(a);
return 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;var d=this._valueForKey;var e=parseInt(d("maxParticles",a));if(this.initWithTotalParticles(e)){this.angle=parseFloat(d("angle",a));this.angleVar=parseFloat(d("angleVariance",a));this.duration=parseFloat(d("duration",a));this._blendFunc.src=parseInt(d("blendFuncSource",
a));this._blendFunc.dst=parseInt(d("blendFuncDestination",a));c=this._startColor;c.r=255*parseFloat(d("startColorRed",a));c.g=255*parseFloat(d("startColorGreen",a));c.b=255*parseFloat(d("startColorBlue",a));c.a=255*parseFloat(d("startColorAlpha",a));c=this._startColorVar;c.r=255*parseFloat(d("startColorVarianceRed",a));c.g=255*parseFloat(d("startColorVarianceGreen",a));c.b=255*parseFloat(d("startColorVarianceBlue",a));c.a=255*parseFloat(d("startColorVarianceAlpha",a));c=this._endColor;c.r=255*parseFloat(d("finishColorRed",
a));c.g=255*parseFloat(d("finishColorGreen",a));c.b=255*parseFloat(d("finishColorBlue",a));c.a=255*parseFloat(d("finishColorAlpha",a));c=this._endColorVar;c.r=255*parseFloat(d("finishColorVarianceRed",a));c.g=255*parseFloat(d("finishColorVarianceGreen",a));c.b=255*parseFloat(d("finishColorVarianceBlue",a));c.a=255*parseFloat(d("finishColorVarianceAlpha",a));this.startSize=parseFloat(d("startParticleSize",a));this.startSizeVar=parseFloat(d("startParticleSizeVariance",a));this.endSize=parseFloat(d("finishParticleSize",
a));this.endSizeVar=parseFloat(d("finishParticleSizeVariance",a));this.setPosition(parseFloat(d("sourcePositionx",a)),parseFloat(d("sourcePositiony",a)));this._posVar.x=parseFloat(d("sourcePositionVariancex",a));this._posVar.y=parseFloat(d("sourcePositionVariancey",a));this.startSpin=parseFloat(d("rotationStart",a));this.startSpinVar=parseFloat(d("rotationStartVariance",a));this.endSpin=parseFloat(d("rotationEnd",a));this.endSpinVar=parseFloat(d("rotationEndVariance",a));this.emitterMode=parseInt(d("emitterType",
a));if(this.emitterMode===cc.ParticleSystem.MODE_GRAVITY)c=this.modeA,c.gravity.x=parseFloat(d("gravityx",a)),c.gravity.y=parseFloat(d("gravityy",a)),c.speed=parseFloat(d("speed",a)),c.speedVar=parseFloat(d("speedVariance",a)),e=d("radialAcceleration",a),c.radialAccel=e?parseFloat(e):0,e=d("radialAccelVariance",a),c.radialAccelVar=e?parseFloat(e):0,e=d("tangentialAcceleration",a),c.tangentialAccel=e?parseFloat(e):0,e=d("tangentialAccelVariance",a),c.tangentialAccelVar=e?parseFloat(e):0,e=d("rotationIsDir",
a),null!==e?(e=e.toString().toLowerCase(),c.rotationIsDir="true"===e||"1"===e):c.rotationIsDir=!1;else if(this.emitterMode===cc.ParticleSystem.MODE_RADIUS)c=this.modeB,c.startRadius=parseFloat(d("maxRadius",a)),c.startRadiusVar=parseFloat(d("maxRadiusVariance",a)),c.endRadius=parseFloat(d("minRadius",a)),c.endRadiusVar=0,c.rotatePerSecond=parseFloat(d("rotatePerSecond",a)),c.rotatePerSecondVar=parseFloat(d("rotatePerSecondVariance",a));else return cc.log("cc.ParticleSystem.initWithDictionary(): Invalid emitterType in config file"),
!1;this.life=parseFloat(d("particleLifespan",a));this.lifeVar=parseFloat(d("particleLifespanVariance",a));this.emissionRate=this._totalParticles/this.life;if(!this._batchNode)if(this._opacityModifyRGB=!1,c=d("textureFileName",a),c=cc.path.changeBasename(this._plistFile,c),e=cc.textureCache.getTextureForKey(c))this.setTexture(e);else if((d=d("textureImageData",a))&&0!==d.length){d=cc.unzipBase64AsArray(d,1);if(!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;var f=document.createElement("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{e=cc.textureCache.addImage(c);if(!e)return!1;this.setTexture(e)}c=!0}return c},
initWithTotalParticles:function(a){this._totalParticles=a;var b,c=this._particles;for(b=c.length=0;b<a;b++)c[b]=new cc.Particle;if(!c)return cc.log("Particle system: not enough memory"),!1;this._allocatedParticles=a;if(this._batchNode)for(b=0;b<this._totalParticles;b++)c[b].atlasIndex=b;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._transformSystemDirty=this.autoRemoveOnFinish=
!1;this.scheduleUpdateWithPriority(1);this._renderCmd._initWithTotalParticles(a);return!0},destroyParticleSystem:function(){this.unscheduleUpdate()},addParticle:function(){if(this.isFull())return!1;var a=this._renderCmd.addParticle();this.initParticle(a);++this.particleCount;return!0},initParticle:function(a){var b=cc.randomMinus1To1;a.timeToLive=this.life+this.lifeVar*b();a.timeToLive=Math.max(0,a.timeToLive);a.pos.x=this._sourcePosition.x+this._posVar.x*b();a.pos.y=this._sourcePosition.y+this._posVar.y*
b();var c=this._startColor;var d=this._startColorVar,e=this._endColor;var f=this._endColorVar;c={r:cc.clampf(c.r+d.r*b(),0,255),g:cc.clampf(c.g+d.g*b(),0,255),b:cc.clampf(c.b+d.b*b(),0,255),a:cc.clampf(c.a+d.a*b(),0,255)};f={r:cc.clampf(e.r+f.r*b(),0,255),g:cc.clampf(e.g+f.g*b(),0,255),b:cc.clampf(e.b+f.b*b(),0,255),a:cc.clampf(e.a+f.a*b(),0,255)};a.color=c;d=a.deltaColor;e=a.timeToLive;d.r=(f.r-c.r)/e;d.g=(f.g-c.g)/e;d.b=(f.b-c.b)/e;d.a=(f.a-c.a)/e;c=this.startSize+this.startSizeVar*b();c=Math.max(0,
c);a.size=c;this.endSize===cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE?a.deltaSize=0:(f=this.endSize+this.endSizeVar*b(),f=Math.max(0,f),a.deltaSize=(f-c)/e);c=this.startSpin+this.startSpinVar*b();f=this.endSpin+this.endSpinVar*b();a.rotation=c;a.deltaRotation=(f-c)/e;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);c=
cc.degreesToRadians(this.angle+this.angleVar*b());if(this.emitterMode===cc.ParticleSystem.MODE_GRAVITY)e=this.modeA,f=a.modeA,d=e.speed+e.speedVar*b(),f.dir.x=Math.cos(c),f.dir.y=Math.sin(c),cc.pMultIn(f.dir,d),f.radialAccel=e.radialAccel+e.radialAccelVar*b(),f.tangentialAccel=e.tangentialAccel+e.tangentialAccelVar*b(),e.rotationIsDir&&(a.rotation=-cc.radiansToDegrees(cc.pToAngle(f.dir)));else{f=this.modeB;a=a.modeB;d=f.startRadius+f.startRadiusVar*b();var g=f.endRadius+f.endRadiusVar*b();a.radius=
d;a.deltaRadius=f.endRadius===cc.ParticleSystem.START_RADIUS_EQUAL_TO_END_RADIUS?0:(g-d)/e;a.angle=c;a.degreesPerSecond=cc.degreesToRadians(f.rotatePerSecond+f.rotatePerSecondVar*b())}},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;this.particleCount<this._totalParticles&&(this._emitCounter+=a);for(;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];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);if(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];g.timeToLive-=
a;if(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){this.unscheduleUpdate();this._parent.removeChild(this,!0);return}}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)cc.log("Can't change blending functions when the particle is being batched");else{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()));a.setLife(this.getLife());a.setLifeVar(this.getLifeVar());a.setEmissionRate(this.getEmissionRate());if(!this.getBatchNode()&&
(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;cc.defineGetterSetter(_p,"opacityModifyRGB",_p.isOpacityModifyRGB,_p.setOpacityModifyRGB);cc.defineGetterSetter(_p,"batchNode",_p.getBatchNode,_p.setBatchNode);cc.defineGetterSetter(_p,"drawMode",_p.getDrawMode,_p.setDrawMode);cc.defineGetterSetter(_p,"shapeType",_p.getShapeType,_p.setShapeType);cc.defineGetterSetter(_p,"active",_p.isActive);cc.defineGetterSetter(_p,"sourcePos",_p.getSourcePosition,_p.setSourcePosition);
cc.defineGetterSetter(_p,"posVar",_p.getPosVar,_p.setPosVar);cc.defineGetterSetter(_p,"gravity",_p.getGravity,_p.setGravity);cc.defineGetterSetter(_p,"speed",_p.getSpeed,_p.setSpeed);cc.defineGetterSetter(_p,"speedVar",_p.getSpeedVar,_p.setSpeedVar);cc.defineGetterSetter(_p,"tangentialAccel",_p.getTangentialAccel,_p.setTangentialAccel);cc.defineGetterSetter(_p,"tangentialAccelVar",_p.getTangentialAccelVar,_p.setTangentialAccelVar);cc.defineGetterSetter(_p,"radialAccel",_p.getRadialAccel,_p.setRadialAccel);
cc.defineGetterSetter(_p,"radialAccelVar",_p.getRadialAccelVar,_p.setRadialAccelVar);cc.defineGetterSetter(_p,"rotationIsDir",_p.getRotationIsDir,_p.setRotationIsDir);cc.defineGetterSetter(_p,"startRadius",_p.getStartRadius,_p.setStartRadius);cc.defineGetterSetter(_p,"startRadiusVar",_p.getStartRadiusVar,_p.setStartRadiusVar);cc.defineGetterSetter(_p,"endRadius",_p.getEndRadius,_p.setEndRadius);cc.defineGetterSetter(_p,"endRadiusVar",_p.getEndRadiusVar,_p.setEndRadiusVar);
cc.defineGetterSetter(_p,"rotatePerS",_p.getRotatePerSecond,_p.setRotatePerSecond);cc.defineGetterSetter(_p,"rotatePerSVar",_p.getRotatePerSecondVar,_p.setRotatePerSecondVar);cc.defineGetterSetter(_p,"startColor",_p.getStartColor,_p.setStartColor);cc.defineGetterSetter(_p,"startColorVar",_p.getStartColorVar,_p.setStartColorVar);cc.defineGetterSetter(_p,"endColor",_p.getEndColor,_p.setEndColor);cc.defineGetterSetter(_p,"endColorVar",_p.getEndColorVar,_p.setEndColorVar);
cc.defineGetterSetter(_p,"totalParticles",_p.getTotalParticles,_p.setTotalParticles);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){this._rootCtor(a);this._needDraw=!0;this._drawMode=cc.ParticleSystem.TEXTURE_MODE;this._shapeType=cc.ParticleSystem.BALL_SHAPE;this._pointRect=cc.rect(0,0,0,0);this._tintCache=null};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 b=a.getContext(),f=this._node,g=this._pointRect;a.setTransform(this._worldTransform,c,d);a.save();f.isBlendAdditive()?b.globalCompositeOperation="lighter":b.globalCompositeOperation="source-over";d=this._node.particleCount;var h=
this._node._particles;if(f.drawMode!==cc.ParticleSystem.SHAPE_MODE&&f._texture){if(!f._texture._textureLoaded){a.restore();return}var k=f._texture.getHtmlElementObj();if(!k.width||!k.height){a.restore();return}for(c=0;c<d;c++){var m=h[c];var n=m.color.a/255;if(0!==n){b.globalAlpha=n;b.save();b.translate(0|m.drawPos.x,-(0|m.drawPos.y));var p=4*Math.floor(m.size/4);n=g.width;var r=g.height;b.scale(Math.max(1/n*p,1E-6),Math.max(1/r*p,1E-6));m.rotation&&b.rotate(cc.degreesToRadians(m.rotation));m=m.isChangeColor?
this._changeTextureColor(f._texture,m.color,this._pointRect):k;b.drawImage(m,-(0|n/2),-(0|r/2));b.restore()}}}else for(k=cc._drawingUtil,c=0;c<d;c++)m=h[c],g=0|.5*m.size,n=m.color.a/255,0!==n&&(b.globalAlpha=n,b.save(),b.translate(0|m.drawPos.x,-(0|m.drawPos.y)),f.shapeType===cc.ParticleSystem.STAR_SHAPE?(m.rotation&&b.rotate(cc.degreesToRadians(m.rotation)),k.drawStar(a,g,m.color)):k.drawColorBall(a,g,m.color),b.restore());a.restore();cc.g_NumberOfDraws++};a._changeTextureColor=function(a,c,d){this._tintCache||
(this._tintCache=document.createElement("canvas"));var b=this._tintCache,f=a.getContentSize();b.width=f.width;b.height=f.height;return a._generateColorTexture(c.r,c.g,c.b,d,b)};a.initTexCoordsWithRect=function(a){this._pointRect=a};a.setTotalParticles=function(a){this._node._totalParticles=200>a?a:200};a.addParticle=function(){var a=this._node,c=a._particles;a.particleCount<c.length?a=c[a.particleCount]:(a=new cc.Particle,c.push(a));return 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){if(!this._node._dontTint){var b=a.deltaColor;a.color.r+=b.r*c;a.color.g+=b.g*c;a.color.b+=b.b*c;a.color.a+=b.a*c;a.isChangeColor=0!==b.r||0!==b.g||0!==b.b}}})();(function(){cc.ParticleSystem.WebGLRenderCmd=function(a){this._rootCtor(a);this._needDraw=!0;this._matrix=null;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 b=this._node;if(b._batchNode!==
a){var d=b._batchNode;if(b._batchNode=a)for(var e=b._particles,f=0;f<b._totalParticles;f++)e[f].atlasIndex=f;a?d||(b._batchNode.textureAtlas._copyQuadsToTextureAtlas(this._quads,b.atlasIndex),cc._renderContext.deleteBuffer(this._buffersVBO[1])):(this._allocMemory(),this.initIndices(b._totalParticles),b.setTexture(d.getTexture()),this._setupVBO())}};a.initIndices=function(a){for(var b=this._indices,d=0;d<a;++d){var e=6*d,f=4*d;b[e+0]=f+0;b[e+1]=f+1;b[e+2]=f+2;b[e+5]=f+1;b[e+4]=f+2;b[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 b=this._node;if(b._batchNode){var e=b._batchNode.textureAtlas.quads[b.atlasIndex+a.atlasIndex];b._batchNode.textureAtlas.dirty=!0}else e=this._quads[b._particleIdx];if(b._opacityModifyRGB){b=0|a.color.r*a.color.a/255;var f=0|a.color.g*a.color.a/255;var g=0|a.color.b*a.color.a/255}else b=0|a.color.r,f=0|a.color.g,g=0|a.color.b;var h=0|a.color.a;var k=e.bl.colors,
m=e.br.colors,n=e.tl.colors,p=e.tr.colors;k.r=m.r=n.r=p.r=b;k.g=m.g=n.g=p.g=f;k.b=m.b=n.b=p.b=g;k.a=m.a=n.a=p.a=h;b=a.size/2;a.rotation?(f=-b,g=-b,h=c.x,k=c.y,n=-cc.degreesToRadians(a.rotation),m=Math.cos(n),n=Math.sin(n),e.bl.vertices.x=f*m-g*n+h,e.bl.vertices.y=f*n+g*m+k,e.br.vertices.x=b*m-g*n+h,e.br.vertices.y=b*n+g*m+k,e.tl.vertices.x=f*m-b*n+h,e.tl.vertices.y=f*n+b*m+k,e.tr.vertices.x=b*m-b*n+h,e.tr.vertices.y=b*n+b*m+k):(e.bl.vertices.x=c.x-b,e.bl.vertices.y=c.y-b,e.br.vertices.x=c.x+b,e.br.vertices.y=
c.y-b,e.tl.vertices.x=c.x-b,e.tl.vertices.y=c.y+b,e.tr.vertices.x=c.x+b,e.tr.vertices.y=c.y+b)};a.rendering=function(a){var b=this._node;if(b._texture){a=a||cc._renderContext;this._matrix||(this._matrix=new cc.math.Matrix4,this._matrix.identity());var d=this._worldTransform;this._matrix.mat[0]=d.a;this._matrix.mat[4]=d.c;this._matrix.mat[12]=d.tx;this._matrix.mat[1]=d.b;this._matrix.mat[5]=d.d;this._matrix.mat[13]=d.ty;this._glProgramState.apply(this._matrix);cc.glBindTexture2D(b._texture);cc.glBlendFuncForParticle(b._blendFunc.src,
b._blendFunc.dst);a.enableVertexAttribArray(cc.VERTEX_ATTRIB_POSITION);a.enableVertexAttribArray(cc.VERTEX_ATTRIB_COLOR);a.enableVertexAttribArray(cc.VERTEX_ATTRIB_TEX_COORDS);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*b._particleIdx,a.UNSIGNED_SHORT,0)}};a.initTexCoordsWithRect=function(a){var b=this._node,d=b.texture,e=cc.contentScaleFactor(),f=cc.rect(a.x*e,a.y*e,a.width*e,a.height*e);e=a.width;var g=a.height;d&&(e=d.pixelsWidth,g=d.pixelsHeight);cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL?(d=(2*f.x+1)/(2*e),a=(2*f.y+1)/(2*g),e=d+(2*f.width-2)/(2*e),f=a+(2*f.height-2)/(2*g)):(d=f.x/e,a=f.y/g,e=d+f.width/e,f=a+f.height/g);g=f;f=a;a=g;if(b._batchNode){g=b._batchNode.textureAtlas.quads;var h=b.atlasIndex;b=b.atlasIndex+
b._totalParticles}else g=this._quads,h=0,b=b._totalParticles;for(;h<b;h++){g[h]||(g[h]=cc.V3F_C4B_T2F_QuadZero());var k=g[h];k.bl.texCoords.u=d;k.bl.texCoords.v=a;k.br.texCoords.u=e;k.br.texCoords.v=a;k.tl.texCoords.u=d;k.tl.texCoords.v=f;k.tr.texCoords.u=e;k.tr.texCoords.v=f}};a.setTotalParticles=function(a){var b=this._node;if(a>b._allocatedParticles){var d=cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT;this._indices=new Uint16Array(6*a);var e=new ArrayBuffer(a*d),f=b._particles;f.length=0;for(var g=this._quads,
h=g.length=0;h<a;h++)f[h]=new cc.Particle,g[h]=new cc.V3F_C4B_T2F_Quad(null,null,null,null,e,h*d);b._allocatedParticles=a;b._totalParticles=a;if(b._batchNode)for(d=0;d<a;d++)f[d].atlasIndex=d;this._quadsArrayBuffer=e;this.initIndices(a);this._setupVBO();b._texture&&this.initTexCoordsWithRect(cc.rect(0,0,b._texture.width,b._texture.height))}else b._totalParticles=a;b.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;var d=this._quads;d.length=0;this._indices=new Uint16Array(6*a);for(var e=new ArrayBuffer(c*a),f=0;f<a;f++)d[f]=new cc.V3F_C4B_T2F_Quad(null,null,null,null,e,f*c);if(!d||!this._indices)return cc.log("cocos2d: Particle system: not enough memory"),!1;this._quadsArrayBuffer=e;return!0};a.postStep=function(){var a=cc._renderContext;a.bindBuffer(a.ARRAY_BUFFER,this._buffersVBO[0]);a.bufferSubData(a.ARRAY_BUFFER,0,this._quadsArrayBuffer)};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){if(!this._allocMemory())return!1;this.initIndices(a);this._setupVBO();this._shaderProgram=cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR)};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.ParticleFire=cc.ParticleSystem.extend({ctor:function(){cc.ParticleSystem.prototype.ctor.call(this,cc._renderType===cc.game.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(.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.game.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.game.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(.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.game.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.game.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.game.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.game.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.game.RENDER_TYPE_WEBGL?700:300)},initWithTotalParticles:function(a){return cc.ParticleSystem.prototype.initWithTotalParticles.call(this,a)?(this.setDuration(.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.game.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.game.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.game.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.game.RENDER_TYPE_CANVAS?new cc.ParticleBatchNode.CanvasRenderCmd(this):new cc.ParticleBatchNode.WebGLRenderCmd(this)},initWithTexture:function(a,b){this.textureAtlas=
new cc.TextureAtlas;this.textureAtlas.initWithTexture(a,b);this._children.length=0;this._renderCmd._initWithTexture();return!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)},visit:function(a){var b=this._renderCmd;a=a?a._renderCmd:null;this._visible?(b.visit(a),cc.renderer.pushRenderCommand(b),b._dirtyFlag=0):b._propagateFlagsDown(a)},addChild:function(a,b,c){if(!a)throw Error("cc.ParticleBatchNode.addChild() : child should be non-null");
if(!(a instanceof cc.ParticleSystem))throw Error("cc.ParticleBatchNode.addChild() : only supports cc.ParticleSystem as children");b=null==b?a.zIndex:b;c=null==c?a.tag:c;if(a.getTexture()!==this.textureAtlas.texture)throw Error("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){cc.log("cc.ParticleSystem.addChild() : Can't add a ParticleSystem that uses a different blending function");
return}b=this._addChildHelper(a,b,c);0!==b?(b=this._children[b-1],b=b.getAtlasIndex()+b.getTotalParticles()):b=0;this.insertChild(a,b);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 Error("cc.ParticleBatchNode.removeChild(): only supports cc.ParticleSystem as children");if(-1===this._children.indexOf(a))cc.log("cc.ParticleBatchNode.removeChild(): doesn't contain the sprite. Can't remove it");else{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 Error("cc.ParticleBatchNode.reorderChild(): child should be non-null");if(!(a instanceof cc.ParticleSystem))throw Error("cc.ParticleBatchNode.reorderChild(): only supports cc.QuadParticleSystems as children");if(-1===this._children.indexOf(a))cc.log("cc.ParticleBatchNode.reorderChild(): Child doesn't belong to batch");else{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;d<c;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;m<k;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}d||(e=k);return{newIndex:e+g,oldIndex:f}},_addChildHelper:function(a,
b,c){if(!a)throw Error("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);this._children.splice(d,0,a);a.tag=c;a._setLocalZOrder(b);a.parent=this;this._running&&(a._performRecursive(cc.Node._stateCallbackType.onEnter),a._performRecursive(cc.Node._stateCallbackType.onEnterTransitionDidFinish));
return 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;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){this._rootCtor(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){this._rootCtor(a);this._needDraw=!0;this._matrix=new cc.math.Matrix4;this._matrix.identity()};var a=cc.ParticleBatchNode.WebGLRenderCmd.prototype=Object.create(cc.Node.WebGLRenderCmd.prototype);a.constructor=cc.ParticleBatchNode.WebGLRenderCmd;a.rendering=function(a){a=this._node;if(0!==a.textureAtlas.totalQuads){var b=this._worldTransform;this._matrix.mat[0]=b.a;this._matrix.mat[4]=b.c;this._matrix.mat[12]=b.tx;this._matrix.mat[1]=b.b;this._matrix.mat[5]=
b.d;this._matrix.mat[13]=b.ty;this._glProgramState.apply(this._matrix);cc.glBlendFuncForParticle(a._blendFunc.src,a._blendFunc.dst);a.textureAtlas.drawQuads()}};a._initWithTexture=function(){this._shaderProgram=cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR)}})();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||(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;this._domInputControl.addEventListener("input",function(){a._processDomInputString(a._domInputControl.value)},!1);this._domInputControl.addEventListener("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)&&this._domInputControl.addEventListener("keyup",function(b){b.keyCode===cc.KEY.backspace&&a._processDomInputString(a._domInputControl.value)},!1);window.addEventListener("mousedown",function(b){var c=b.pageY||0;a._lastClickPosition.x=b.pageX||0;a._lastClickPosition.y=c},!1)}},_processDomInputString:function(a){var b;var c=this._currentInputString.length<
a.length?this._currentInputString.length:a.length;for(b=0;b<c&&a[b]===this._currentInputString[b];b++);var d=this._currentInputString.length-b,e=a.length-b;for(c=0;c<d;c++)this.dispatchDeleteBackward();for(c=0;c<e;c++)this.dispatchInsertText(a[b+c],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;this.impl._delegateWithIme=null;b.didDetachWithIME();this._focusDomInput(a);return!0}if(!a.canAttachWithIME())return!1;this._focusDomInput(a);return!0},_focusDomInput:function(a){if(cc.sys.isMobile){this.impl._delegateWithIme=a;a.didAttachWithIME();this._currentInputString=a.string||"";a=a.getTipMessage?a.getTipMessage():"please enter your word:";var b=window.Window;a=b&&b.prototype.prompt&&b.prototype.prompt!=prompt?b.prototype.prompt.call(window,
a,this._currentInputString):prompt(a,this._currentInputString);null!=a&&this._processDomInputString(a);this.dispatchInsertText("\n",1)}else 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){if(!this.impl||!a||this.impl._delegateWithIme!==a||!a.canDetachWithIME())return!1;this.impl._delegateWithIme=null;a.didDetachWithIME();cc._canvas.focus();return!0},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):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():window.addEventListener("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.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))},onEnter:function(){cc.LabelTTF.prototype.onEnter.call(this);
cc.imeDispatcher.addDelegate(this)},onExit:function(){cc.LabelTTF.prototype.onExit.call(this);cc.imeDispatcher.removeDelegate(this)},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 Error("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.game.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)},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;0===a||this.delegate&&this.delegate.onTextFieldDeleteBackward(this,this._inputText[a-1],1)||(1>=a?(this._inputText="",this._charCount=0,cc.LabelTTF.prototype.setString.call(this,this._placeHolder),this.setColor(this.colorSpaceHolder)):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");-1<d&&(c=c.substring(0,d));if(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;cc.defineGetterSetter(_p,"charCount",_p.getCharCount);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._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,.5,.5);this._target=b||null;if(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){this.anchorY=this.anchorX=.5;this._target=b;this._callback=a;this._enabled=!0;this._isSelected=!1;return!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;if(b)if(a&&cc.isString(b))a[b](this);else a&&cc.isFunction(b)?b.call(a,this):b(this)}}});_p=cc.MenuItem.prototype;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),a.textureLoaded&&!a.textureLoaded()&&a.addEventListener("load",function(a){this.width=a.width;this.height=a.height;this.parent instanceof cc.Menu&&this.parent.updateAlign()},
this),this.setCascadeColorEnabled(!0),this.setCascadeOpacityEnabled(!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,a.setCascadeColorEnabled(!0));this._label&&this.removeChild(this._label,!0);this._label=a},setEnabled:function(a){this._enabled!==a&&(a?this.setColor(this._colorBackup):(this._colorBackup=
this.color,this.setColor(this._disabledColor)));cc.MenuItem.prototype.setEnabled.call(this,a)},initWithLabel:function(a,b,c){this.initWithCallback(b,c);this._originalScale=1;this._colorBackup=cc.color.WHITE;this._disabledColor=cc.color(126,126,126);this.setLabel(a);this.setCascadeColorEnabled(!0);this.setCascadeOpacityEnabled(!0);return!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(.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(.1,
this._originalScale);a.setTag(cc.ZOOM_ACTION_TAG);this.runAction(a)}}});_p=cc.MenuItemLabel.prototype;cc.defineGetterSetter(_p,"string",_p.getString,_p.setString);cc.defineGetterSetter(_p,"disabledColor",_p.getDisabledColor,_p.setDisabledColor);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 Error("cc.MenuItemAtlasFont.initWithString(): value should be non-null and its length should be greater than 0");var h=new cc.LabelAtlas;h.initWithString(a,b,c,d,e);this.initWithLabel(h,f,g);return!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){if(a&&0<a.length){this._fontName=cc._globalFontName;this._fontSize=cc._globalFontSize;var d=new cc.LabelTTF(a,this._fontName,this._fontSize)}else 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 Error("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);this.initWithLabel(a,b,c);return!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;cc.defineGetterSetter(_p,"fontSize",_p.getFontSize,_p.setFontSize);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){cc.MenuItem.prototype.ctor.call(this);this._disabledImage=this._selectedImage=this._normalImage=null;this._loader=new cc.Sprite.LoadManager;if(void 0!==a){b=b||null;if(void 0!==e){var f=c;var g=d;var h=e}else void 0!==d&&cc.isFunction(d)?(f=c,g=d):void 0!==d&&cc.isFunction(c)?(h=d,g=c,f=null):void 0===c&&(f=null);this._loader.clear();if(a.textureLoaded&&!a.textureLoaded())return this._loader.once(a,
function(){this.initWithNormalSprite(a,b,f,g,h)},this),!1;this.initWithNormalSprite(a,b,f,g,h);return!0}},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.parent instanceof cc.Menu&&this.parent.updateAlign()},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._loader.clear();if(a.textureLoaded&&!a.textureLoaded())return this._loader.once(a,function(){this.initWithNormalSprite(a,b,c,d,e)},this),!1;this.initWithCallback(d,e);this.setNormalImage(a);this.setSelectedImage(b);this.setDisabledImage(c);var f=this._normalImage;f&&(this.width=
f.width,this.height=f.height);this.setCascadeColorEnabled(!0);this.setCascadeOpacityEnabled(!0);return!0},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;
cc.defineGetterSetter(_p,"normalImage",_p.getNormalImage,_p.setNormalImage);cc.defineGetterSetter(_p,"selectedImage",_p.getSelectedImage,_p.setSelectedImage);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;void 0===a||null===a?cc.MenuItemSprite.prototype.ctor.call(this):(a=new cc.Sprite(a),b&&(f=new cc.Sprite(b)),void 0===d?h=c:void 0===e?(h=c,k=d):e&&(g=new cc.Sprite(c),h=d,k=e),cc.MenuItemSprite.prototype.ctor.call(this,a,f,g,h,k))},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;a&&(f=new cc.Sprite(a));b&&(g=new cc.Sprite(b));c&&(h=new cc.Sprite(c));return 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){this._opacity=a;if(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;b.r=a.r;b.g=a.g;b.b=a.b;if(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):this.initWithCallback(null,null);for(var c=this.subItems,d=c.length=
0;d<b;d++)a[d]&&c.push(a[d]);this._selectedIndex=cc.UINT_MAX;this.setSelectedIndex(0);this.setCascadeColorEnabled(!0);this.setCascadeOpacityEnabled(!0);return!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;
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;a.initWithItems(Array.prototype.slice.apply(arguments));return 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});var b=
arguments.length;if(a instanceof Array)var c=a;else if(0===b)c=[];else if(0<b){c=[];for(var d=0;d<b;d++)arguments[d]&&c.push(arguments[d])}this.initWithArray(c)},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;this.setPosition(b.width/2,b.height/2);this.setContentSize(b);this.setAnchorPoint(.5,.5);this.ignoreAnchorPointForPosition(!0);if(a)for(b=0;b<a.length;b++)this.addChild(a[b],b);this._selectedItem=null;this._state=cc.MENU_STATE_WAITING;return this.cascadeOpacity=this.cascadeColor=!0}return!1},addChild:function(a,b,c){if(!(a instanceof cc.MenuItem))throw Error("cc.Menu.addChild() : Menu only supports MenuItem objects as children");cc.Layer.prototype.addChild.call(this,a,b,c)},updateAlign:function(){switch(this._align){case "vertically":this.alignItemsVertically();
break;case "horizontally":this.alignItemsHorizontally()}},alignItemsVertically:function(){this.alignItemsVerticallyWithPadding(cc.DEFAULT_PADDING)},alignItemsVerticallyWithPadding:function(a){this._align="vertically";var b=-a,c=this._children,d;if(c&&0<c.length){var e=0;for(d=c.length;e<d;e++)b+=c[e].height*c[e].scaleY+a;var f=b/2;e=0;for(d=c.length;e<d;e++){var g=c[e];var h=g.height;b=g.scaleY;g.setPosition(0,f-h*b/2);f-=h*b+a}}},alignItemsHorizontally:function(){this.alignItemsHorizontallyWithPadding(cc.DEFAULT_PADDING)},
alignItemsHorizontallyWithPadding:function(a){this._align="horizontally";var b=-a,c=this._children,d;if(c&&0<c.length){var e=0;for(d=c.length;e<d;e++)b+=c[e].width*c[e].scaleX+a;var f=-b/2;e=0;for(d=c.length;e<d;e++){var g=c[e];b=g.scaleX;var h=c[e].width;g.setPosition(f+h*b/2,0);f+=h*b+a}}},alignItemsInColumns: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=-5,d=0,e=0,f=0,g,h,k=this._children;if(k&&0<k.length)for(a=0,h=k.length;a<h;a++)if(!(d>=b.length)&&(g=b[d])){var m=k[a].height;e=e>=m||isNaN(m)?e:m;++f;f>=g&&(c+=e+5,e=f=0,++d)}var n=cc.director.getWinSize(),p=g=e=d=0,r=0;c/=2;if(k&&0<k.length)for(a=0,h=k.length;a<h;a++){var t=k[a];0===g&&(g=b[d],r=p=n.width/(1+g));m=t._getHeight();e=e>=m||isNaN(m)?e:m;t.setPosition(r-n.width/2,c-m/2);r+=p;++f;f>=g&&(c-=e+5,e=g=f=0,++d)}},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=-10,f=-5,g=0,h=0,k=0,m,n,p=this._children;if(p&&0<p.length)for(a=0,n=p.length;a<n;a++){var r=p[a];if(!(g>=b.length)&&(m=b[g])){var t=r.width;h=h>=t||isNaN(t)?h:t;f+=r.height+5;++k;k>=m&&(c.push(h),d.push(f),e+=h+10,h=k=0,f=-5,++g)}}f=cc.director.getWinSize();m=h=g=0;e=-e/2;var u=0;if(p&&0<p.length)for(a=0,n=p.length;a<n;a++)r=p[a],0===m&&(m=b[g],u=d[g]),
t=r._getWidth(),h=h>=t||isNaN(t)?h:t,r.setPosition(e+c[g]/2,u-f.height/2),u-=r.height+10,++k,k>=m&&(e+=h+5,h=m=k=0,++g)},removeChild:function(a,b){null!=a&&(a instanceof cc.MenuItem?(this._selectedItem===a&&(this._selectedItem=null),cc.Node.prototype.removeChild.call(this,a,b)):cc.log("cc.Menu.removeChild():Menu only supports MenuItem objects as children"))},_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;c._selectedItem=c._itemForTouch(a);return 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();c._state!==cc.MENU_STATE_TRACKING_TOUCH?cc.log("cc.Menu.onTouchEnded(): invalid state"):(c._selectedItem&&(c._selectedItem.unselected(),c._selectedItem.setNodeDirty(),c._selectedItem.activate()),c._state=cc.MENU_STATE_WAITING)},_onTouchCancelled:function(a,
b){var c=b.getCurrentTarget();c._state!==cc.MENU_STATE_TRACKING_TOUCH?cc.log("cc.Menu.onTouchCancelled(): invalid state"):(c._selectedItem&&(c._selectedItem.unselected(),c._selectedItem.setNodeDirty()),c._state=cc.MENU_STATE_WAITING)},_onTouchMoved:function(a,b){var c=b.getCurrentTarget();if(c._state!==cc.MENU_STATE_TRACKING_TOUCH)cc.log("cc.Menu.onTouchMoved(): invalid state");else{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){a=a.getLocation();var b=this._children;if(b&&0<b.length)for(var c=b.length-1;0<=c;c--){var d=
b[c];if(d.isVisible()&&d.isEnabled()){var e=d.convertToNodeSpace(a),f=d.rect();f.x=0;f.y=0;if(cc.rectContainsPoint(f,e))return d}}return null}});_p=cc.Menu.prototype;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:1===b?new cc.Menu(a):new cc.Menu(Array.prototype.slice.call(arguments,0))};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){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(){this.outputArr=[];this.nextFile();return this.unzipped};cc.Codec.GZip.prototype.readByte=function(){this.bits+=8;return 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(){this.bits++;var a=this.bb&1;this.bb>>=1;0===this.bb&&(this.bb=this.readByte(),a=this.bb&1,this.bb=this.bb>>1|128);return a};
cc.Codec.GZip.prototype.readBits=function(a){for(var b=0,c=a;c--;)b=b<<1|this.readBit();a&&(b=cc.Codec.GZip.bitReverse[b]>>8-a);return 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=this.Places[this.treepos];if(17===this.len)return-1;this.treepos++;this.len++;var b=this.IsPat();if(0<=b)a.b0=b;else if(a.b0=32768,this.Rec())return-1;b=this.IsPat();if(0<=b)a.b1=b,a.jump=null;else if(a.b1=32768,a.jump=this.Places[this.treepos],a.jumppos=this.treepos,this.Rec())return-1;this.len--;return 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;this.len=0;return this.Rec()?-1:0};cc.Codec.GZip.prototype.DecodeValue=function(a){for(var b,c,d=0,e=a[d];;)if(b=this.readBit()){if(!(e.b1&32768))return e.b1;e=e.jump;b=a.length;for(c=0;c<b;c++)if(a[c]===e){d=c;break}}else{if(!(e.b0&32768))return e.b0;d++;e=a[d]}};
cc.Codec.GZip.prototype.DeflateLoop=function(){do{var a=this.readBit();var b=this.readBits(2);if(0===b){this.byteAlign();b=this.readByte();b|=this.readByte()<<8;var c=this.readByte();c|=this.readByte()<<8;for((b^~c)&65535&&document.write("BlockLen checksum mismatch\n");b--;)c=this.readByte(),this.addBuffer(c)}else if(1===b)for(;;)if(b=cc.Codec.GZip.bitReverse[this.readBits(7)]>>1,23<b?(b=b<<1|this.readBit(),199<b?(b-=128,b=b<<1|this.readBit()):(b-=48,143<b&&(b+=136))):b+=256,256>b)this.addBuffer(b);
else if(256===b)break;else{b-=257;var d=this.readBits(cc.Codec.GZip.cplext[b])+cc.Codec.GZip.cplens[b];b=cc.Codec.GZip.bitReverse[this.readBits(5)]>>3;if(8<cc.Codec.GZip.cpdext[b]){var e=this.readBits(8);e|=this.readBits(cc.Codec.GZip.cpdext[b]-8)<<8}else e=this.readBits(cc.Codec.GZip.cpdext[b]);e+=cc.Codec.GZip.cpdist[b];for(b=0;b<d;b++)c=this.buf32k[this.bIdx-e&32767],this.addBuffer(c)}else if(2===b){var f=Array(320);c=257+this.readBits(5);e=1+this.readBits(5);var g=4+this.readBits(4);for(b=0;19>
b;b++)f[b]=0;for(b=0;b<g;b++)f[cc.Codec.GZip.border[b]]=this.readBits(3);d=this.distanceTree.length;for(g=0;g<d;g++)this.distanceTree[g]=new cc.Codec.GZip.HufNode;if(this.CreateTree(this.distanceTree,19,f,0))return this.flushBuffer(),1;d=c+e;g=0;for(var h=-1;g<d;)if(h++,b=this.DecodeValue(this.distanceTree),16>b)f[g++]=b;else if(16===b){var k;b=3+this.readBits(2);if(g+b>d)return this.flushBuffer(),1;for(k=g?f[g-1]:0;b--;)f[g++]=k}else{b=17===b?3+this.readBits(3):11+this.readBits(7);if(g+b>d)return this.flushBuffer(),
1;for(;b--;)f[g++]=0}d=this.literalTree.length;for(g=0;g<d;g++)this.literalTree[g]=new cc.Codec.GZip.HufNode;if(this.CreateTree(this.literalTree,c,f,0))return this.flushBuffer(),1;d=this.literalTree.length;for(g=0;g<d;g++)this.distanceTree[g]=new cc.Codec.GZip.HufNode;b=[];for(g=c;g<f.length;g++)b[g-c]=f[g];if(this.CreateTree(this.distanceTree,e,b,0))return this.flushBuffer(),1;for(;;)if(b=this.DecodeValue(this.literalTree),256<=b){b-=256;if(0===b)break;b--;d=this.readBits(cc.Codec.GZip.cplext[b])+
cc.Codec.GZip.cplens[b];b=this.DecodeValue(this.distanceTree);8<cc.Codec.GZip.cpdext[b]?(e=this.readBits(8),e|=this.readBits(cc.Codec.GZip.cpdext[b]-8)<<8):e=this.readBits(cc.Codec.GZip.cpdext[b]);for(e+=cc.Codec.GZip.cpdist[b];d--;)c=this.buf32k[this.bIdx-e&32767],this.addBuffer(c)}else this.addBuffer(b)}}while(!a);this.flushBuffer();this.byteAlign();return 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=[];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++);if(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;var b=this.readByte();b|=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 c=this.readByte();c|=this.readByte()<<8;var d=this.readByte();d|=this.readByte()<<8;e=0;for(this.nameBuf=[];c--;)a=this.readByte(),"/"===a|":"===a?e=0:e<cc.Codec.GZip.NAMEMAX-1&&(this.nameBuf[e++]=String.fromCharCode(a));
this.fileout||(this.fileout=this.nameBuf);for(var e=0;e<d;)this.readByte(),e++;8===b&&(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;this.gpflags&8&&(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();if(8!==a[0])return 0;this.gpflags=this.readByte();this.readByte();this.readByte();this.readByte();this.readByte();this.readByte();this.readByte();if(this.gpflags&4)for(a[0]=
this.readByte(),a[2]=this.readByte(),this.len=a[0]+256*a[1],a=0;a<this.len;a++)this.readByte();if(this.gpflags&8)for(a=0,this.nameBuf=[];b=this.readByte();){if("7"===b||":"===b)a=0;a<cc.Codec.GZip.NAMEMAX-1&&(this.nameBuf[a++]=b)}if(this.gpflags&16)for(;this.readByte(););this.gpflags&2&&(this.readByte(),this.readByte());this.DeflateLoop();this.readByte();this.readByte();this.readByte();this.readByte();this.modeZIP&&this.nextFile()};/*
 zlib.js 2012 - imaya [ https://github.com/imaya/zlib.js ] The MIT License */
(function(){function a(a){throw a;}function b(a,b){var c=a.split("."),d=y;c[0]in d||!d.execScript||d.execScript("var "+c[0]);for(var e;c.length&&(e=c.shift());)c.length||void 0===b?d=d[e]?d[e]:d[e]={}:d[e]=b}function c(a){if("string"===typeof a){a=a.split("");var b;var c=0;for(b=a.length;c<b;c++)a[c]=(a[c].charCodeAt(0)&255)>>>0}c=1;b=0;for(var d=a.length,e,f=0;0<d;){e=1024<d?1024:d;d-=e;do c+=a[f++],b+=c;while(--e);c%=65521;b%=65521}return(b<<16|c)>>>0}function d(b,c){this.index="number"===typeof c?
c:0;this.i=0;this.buffer=b instanceof(z?Uint8Array:Array)?b:new (z?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 (z?Uint16Array:Array)(2*a);this.length=0}function f(a){var b=a.length,c=0,d=Number.POSITIVE_INFINITY,e,f,g;for(f=0;f<b;++f)a[f]>c&&(c=a[f]),a[f]<d&&(d=a[f]);var h=1<<c;var k=new (z?Uint32Array:Array)(h);var m=1;var n=0;for(e=2;m<=c;){for(f=0;f<b;++f)if(a[f]===m){var p=0;var t=n;
for(g=0;g<m;++g)p=p<<1|t&1,t>>=1;for(g=p;g<h;g+=e)k[g]=m<<16|f;++n}++m;n<<=1;e<<=1}return[k,c,d]}function g(a,b){this.h=I;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=z&&b.outputBuffer instanceof Array?new Uint8Array(b.outputBuffer):b.outputBuffer),"number"===typeof b.outputIndex&&(this.b=b.outputIndex));this.a||(this.a=new (z?Uint8Array:Array)(32768))}function h(a,b){this.length=a;this.G=b}function k(){var b=
H;switch(!0){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 d=b.G,e=[],f=0;var g=F[b.length];e[f++]=g&65535;e[f++]=
g>>16&255;e[f++]=g>>24;switch(!0){case 1===d:var h=[0,d-1,0];break;case 2===d:h=[1,d-2,0];break;case 3===d:h=[2,d-3,0];break;case 4===d:h=[3,d-4,0];break;case 6>=d:h=[4,d-5,1];break;case 8>=d:h=[5,d-7,1];break;case 12>=d:h=[6,d-9,2];break;case 16>=d:h=[7,d-13,2];break;case 24>=d:h=[8,d-17,3];break;case 32>=d:h=[9,d-25,3];break;case 48>=d:h=[10,d-33,4];break;case 64>=d:h=[11,d-49,4];break;case 96>=d:h=[12,d-65,5];break;case 128>=d:h=[13,d-97,5];break;case 192>=d:h=[14,d-129,6];break;case 256>=d:h=
[15,d-193,6];break;case 384>=d:h=[16,d-257,7];break;case 512>=d:h=[17,d-385,7];break;case 768>=d:h=[18,d-513,8];break;case 1024>=d:h=[19,d-769,8];break;case 1536>=d:h=[20,d-1025,9];break;case 2048>=d:h=[21,d-1537,9];break;case 3072>=d:h=[22,d-2049,10];break;case 4096>=d:h=[23,d-3073,10];break;case 6144>=d:h=[24,d-4097,11];break;case 8192>=d:h=[25,d-6145,11];break;case 12288>=d:h=[26,d-8193,12];break;case 16384>=d:h=[27,d-12289,12];break;case 24576>=d:h=[28,d-16385,13];break;case 32768>=d:h=[29,d-
24577,13];break;default:a("invalid distance")}g=h;e[f++]=g[0];e[f++]=g[1];e[f++]=g[2];d=0;for(f=e.length;d<f;++d)p[t++]=e[d];v[e[0]]++;u[e[3]]++;r=b.length+c-1;n=null}var e,f,g,k,m={},n,p=z?new Uint16Array(2*c.length):[],t=0,r=0,v=new (z?Uint32Array:Array)(286),u=new (z?Uint32Array:Array)(30),x=b.w;if(!z){for(f=0;285>=f;)v[f++]=0;for(f=0;29>=f;)u[f++]=0}v[256]=1;var w=0;for(e=c.length;w<e;++w){f=k=0;for(g=3;f<g&&w+f!==e;++f)k=k<<8|c[w+f];void 0===m[k]&&(m[k]=[]);f=m[k];if(!(0<r--)){for(;0<f.length&&
32768<w-f[0];)f.shift();if(w+3>=e){n&&d(n,-1);f=0;for(g=e-w;f<g;++f){var y=c[w+f];p[t++]=y;++v[y]}break}if(0<f.length){k=g=void 0;var A=0,B=void 0,C=void 0,T=B=void 0,U=c.length;C=0;T=f.length;a:for(;C<T;C++){g=f[T-C-1];B=3;if(3<A){for(B=A;3<B;B--)if(c[g+B-1]!==c[w+B-1])continue a;B=A}for(;258>B&&w+B<U&&c[g+B]===c[w+B];)++B;B>A&&(k=g,A=B);if(258===B)break}g=new h(A,w-k);n?n.length<g.length?(y=c[w-1],p[t++]=y,++v[y],d(g,0)):d(n,-1):g.length<x?n=g:d(g,0)}else n?d(n,-1):(y=c[w],p[t++]=y,++v[y])}f.push(w)}p[t++]=
256;v[256]++;b.L=v;b.K=u;return z?p.subarray(0,t):p}function n(a,b){function c(a){var b=t[a][r[a]];b===n?(c(a+1),c(a+1)):--p[b];++r[a]}var d=a.length,f=new e(572),g=new (z?Uint8Array:Array)(d),h,k;if(!z)for(h=0;h<d;h++)g[h]=0;for(h=0;h<d;++h)0<a[h]&&f.push(h,a[h]);d=Array(f.length/2);var m=new (z?Uint32Array:Array)(f.length/2);if(1===d.length)return g[f.pop().index]=1,g;h=0;for(k=f.length/2;h<k;++h)d[h]=f.pop(),m[h]=d[h].value;var n=m.length;h=new (z?Uint16Array:Array)(b);f=new (z?Uint8Array:Array)(b);
var p=new (z?Uint8Array:Array)(n);k=Array(b);var t=Array(b),r=Array(b),v=(1<<b)-n,u=1<<b-1,x;h[b-1]=n;for(x=0;x<b;++x)v<u?f[x]=0:(f[x]=1,v-=u),v<<=1,h[b-2-x]=(h[b-1-x]/2|0)+n;h[0]=f[0];k[0]=Array(h[0]);t[0]=Array(h[0]);for(x=1;x<b;++x)h[x]>2*h[x-1]+f[x]&&(h[x]=2*h[x-1]+f[x]),k[x]=Array(h[x]),t[x]=Array(h[x]);for(v=0;v<n;++v)p[v]=b;for(u=0;u<h[b-1];++u)k[b-1][u]=m[u],t[b-1][u]=u;for(v=0;v<b;++v)r[v]=0;1===f[b-1]&&(--p[0],++r[b-1]);for(x=b-2;0<=x;--x){var w=v=0;var y=r[x+1];for(u=0;u<h[x];u++)w=k[x+
1][y]+k[x+1][y+1],w>m[v]?(k[x][u]=w,t[x][u]=n,y+=2):(k[x][u]=m[v],t[x][u]=v,++v);r[x]=0;1===f[x]&&c(x)}m=p;h=0;for(k=d.length;h<k;++h)g[d[h].index]=m[h];return g}function p(b){var c=new (z?Uint16Array:Array)(b.length),d=[],e=[],f=0,g,h;var k=0;for(g=b.length;k<g;k++)d[b[k]]=(d[b[k]]|0)+1;k=1;for(g=16;k<=g;k++)e[k]=f,f+=d[k]|0,f>1<<k&&a("overcommitted"),f<<=1;65536>f&&a("undercommitted");k=0;for(g=b.length;k<g;k++)for(f=e[b[k]],e[b[k]]+=1,d=c[k]=0,h=b[k];d<h;d++)c[k]=c[k]<<1|f&1,f>>>=1;return c}function r(a,
b){this.input=a;this.a=new (z?Uint8Array:Array)(32768);this.h=K.j;var c={},d;!b&&(b={})||"number"!==typeof b.compressionType||(this.h=b.compressionType);for(d in b)c[d]=b[d];c.outputBuffer=this.a;this.z=new g(this.input,c)}function t(b,c){this.k=[];this.l=32768;this.e=this.g=this.c=this.q=0;this.input=z?new Uint8Array(b):b;this.s=!1;this.m=M;this.B=!1;if(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);switch(this.m){case L:this.b=
32768;this.a=new (z?Uint8Array:Array)(32768+this.l+258);break;case M:this.b=0;this.a=new (z?Uint8Array:Array)(this.l);this.f=this.J;this.t=this.H;this.o=this.I;break;default:a(Error("invalid inflate mode"))}}function u(b,c){for(var d=b.g,e=b.e,f=b.input,g=b.c,h;e<c;)h=f[g++],void 0===h&&a(Error("input buffer is broken")),d|=h<<e,e+=8;b.g=d>>>c;b.e=e-c;b.c=g;return d&(1<<c)-1}function v(b,c){for(var d=b.g,e=b.e,f=b.input,g=b.c,h=c[0],k=c[1],m;e<k;)m=f[g++],void 0===m&&a(Error("input buffer is broken")),
d|=m<<e,e+=8;f=h[d&(1<<k)-1];h=f>>>16;b.g=d>>h;b.e=e-h;b.c=g;return f&65535}function x(a){function b(a,b,c){var d,e,f;for(f=0;f<a;)switch(d=v(this,b),d){case 16:for(e=3+u(this,2);e--;)c[f++]=g;break;case 17:for(e=3+u(this,3);e--;)c[f++]=0;var g=0;break;case 18:for(e=11+u(this,7);e--;)c[f++]=0;g=0;break;default:g=c[f++]=d}return c}var c=u(a,5)+257,d=u(a,5)+1,e=u(a,4)+4,g=new (z?Uint8Array:Array)(O.length),h;for(h=0;h<e;++h)g[O[h]]=u(a,3);e=f(g);g=new (z?Uint8Array:Array)(c);h=new (z?Uint8Array:Array)(d);
a.o(f(b.call(a,c,e,g)),f(b.call(a,d,e,h)))}function w(b,c){this.input=b;this.c=0;if(c||!(c={}))c.index&&(this.c=c.index),c.verify&&(this.M=c.verify);var d=b[this.c++];var e=b[this.c++];switch(d&15){case Q:this.method=Q;break;default:a(Error("unsupported compression method"))}0!==((d<<8)+e)%31&&a(Error("invalid fcheck flag:"+((d<<8)+e)%31));e&32&&a(Error("fdict flag is not supported"));this.A=new t(b,{index:this.c,bufferSize:c.bufferSize,bufferType:c.bufferType,resize:c.resize})}var y=this,z="undefined"!==
typeof Uint8Array&&"undefined"!==typeof Uint16Array&&"undefined"!==typeof Uint32Array;d.prototype.f=function(){var a=this.buffer,b,c=a.length,d=new (z?Uint8Array:Array)(c<<1);if(z)d.set(a);else for(b=0;b<c;++b)d[b]=a[b];return this.buffer=d};d.prototype.d=function(a,b,c){var d=this.buffer,e=this.index,f=this.i,g=d[e];c&&1<b&&(a=8<b?(J[a&255]<<24|J[a>>>8&255]<<16|J[a>>>16&255]<<8|J[a>>>24&255])>>32-b:J[a]>>8-b);if(8>b+f)g=g<<b|a,f+=b;else for(c=0;c<b;++c)g=g<<1|a>>b-c-1&1,8===++f&&(f=0,d[e++]=J[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=this.buffer,b=this.index,c;0<this.i&&(a[b]<<=8-this.i,a[b]=J[a[b]],b++);z?c=a.subarray(0,b):(a.length=b,c=a);return c};var A=new (z?Uint8Array:Array)(256),B;for(B=0;256>B;++B){var C=B,D=C,E=7;for(C>>>=1;C;C>>>=1)D<<=1,D|=C&1,--E;A[B]=(D<<E&255)>>>0}var J=A;A=[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];z&&new Uint32Array(A);e.prototype.getParent=function(a){return 2*((a-2)/4|0)};e.prototype.push=function(a,b){var c,d=this.buffer;var e=this.length;d[this.length++]=b;for(d[this.length++]=a;0<e;)if(c=this.getParent(e),d[e]>d[c]){var f=d[e];d[e]=d[c];d[c]=f;f=d[e+1];d[e+1]=d[c+1];d[c+1]=f;e=c}else break;return this.length};e.prototype.pop=function(){var a=this.buffer,b;var c=a[0];var d=a[1];this.length-=2;a[0]=a[this.length];
a[1]=a[this.length+1];for(b=0;;){var e=2*b+2;if(e>=this.length)break;e+2<this.length&&a[e+2]>a[e]&&(e+=2);if(a[e]>a[b]){var f=a[b];a[b]=a[e];a[e]=f;f=a[b+1];a[b+1]=a[e+1];a[e+1]=f}else break;b=e}return{index:d,value:c,length:this.length}};var I=2;A={NONE:0,r:1,j:I,N:3};var G=[];for(B=0;288>B;B++)switch(!0){case 143>=B:G.push([B+48,8]);break;case 255>=B:G.push([B-144+400,9]);break;case 279>=B:G.push([B-256+0,7]);break;case 287>=B:G.push([B-280+192,8]);break;default:a("invalid literal: "+B)}g.prototype.n=
function(){var b,c=this.input;switch(this.h){case 0:var e=0;for(b=c.length;e<b;){var f=z?c.subarray(e,e+65535):c.slice(e,e+65535);e+=f.length;var g=e===b,h=this.a,k=this.b;if(z){for(h=new Uint8Array(this.a.buffer);h.length<=k+f.length+5;)h=new Uint8Array(h.length<<1);h.set(this.a)}g=g?1:0;h[k++]=g|0;g=f.length;var t=~g+65536&65535;h[k++]=g&255;h[k++]=g>>>8&255;h[k++]=t&255;h[k++]=t>>>8&255;if(z)h.set(f,k),k+=f.length,h=h.subarray(0,k);else{g=0;for(t=f.length;g<t;++g)h[k++]=f[g];h.length=k}this.b=
k;this.a=h}break;case 1:e=new d(new Uint8Array(this.a.buffer),this.b);e.d(1,1,!0);e.d(1,2,!0);c=m(this,c);f=0;for(h=c.length;f<h;f++)if(b=c[f],d.prototype.d.apply(e,G[b]),256<b)e.d(c[++f],c[++f],!0),e.d(c[++f],5),e.d(c[++f],c[++f],!0);else if(256===b)break;this.a=e.finish();this.b=this.a.length;break;case I:b=new d(new Uint8Array(this.a),this.b);var r,v,u,x=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];t=Array(19);var w;k=I;b.d(1,1,!0);b.d(k,2,!0);c=m(this,c);var y=n(this.L,15);var B=p(y);k=n(this.K,
7);g=p(k);for(r=286;257<r&&0===y[r-1];r--);for(v=30;1<v&&0===k[v-1];v--);var A=r,C=v;var D=new (z?Uint32Array:Array)(A+C);var E=new (z?Uint32Array:Array)(316),J;var F=new (z?Uint8Array:Array)(19);for(w=u=0;w<A;w++)D[u++]=y[w];for(w=0;w<C;w++)D[u++]=k[w];if(!z)for(w=0,C=F.length;w<C;++w)F[w]=0;w=J=0;for(C=D.length;w<C;w+=u){for(u=1;w+u<C&&D[w+u]===D[w];++u);A=u;if(0===D[w])if(3>A)for(;0<A--;)E[J++]=0,F[0]++;else for(;0<A;){var H=138>A?A:138;H>A-3&&H<A&&(H=A-3);10>=H?(E[J++]=17,E[J++]=H-3,F[17]++):
(E[J++]=18,E[J++]=H-11,F[18]++);A-=H}else if(E[J++]=D[w],F[D[w]]++,A--,3>A)for(;0<A--;)E[J++]=D[w],F[D[w]]++;else for(;0<A;)H=6>A?A:6,H>A-3&&H<A&&(H=A-3),E[J++]=16,E[J++]=H-3,F[16]++,A-=H}D=z?E.subarray(0,J):E.slice(0,J);F=n(F,7);for(w=0;19>w;w++)t[w]=F[x[w]];for(u=19;4<u&&0===t[u-1];u--);x=p(F);b.d(r-257,5,!0);b.d(v-1,5,!0);b.d(u-4,4,!0);for(w=0;w<u;w++)b.d(t[w],3,!0);w=0;for(t=D.length;w<t;w++)if(f=D[w],b.d(x[f],F[f],!0),16<=f){w++;switch(f){case 16:h=2;break;case 17:h=3;break;case 18:h=7;break;
default:a("invalid code: "+f)}b.d(D[w],h,!0)}h=[B,y];g=[g,k];f=h[0];h=h[1];k=g[0];B=g[1];g=0;for(t=c.length;g<t;++g)if(e=c[g],b.d(f[e],h[e],!0),256<e)b.d(c[++g],c[++g],!0),y=c[++g],b.d(k[y],B[y],!0),b.d(c[++g],c[++g],!0);else if(256===e)break;this.a=b.finish();this.b=this.a.length;break;default:a("invalid compression type")}return this.a};B=[];var H;for(H=3;258>=H;H++)C=k(),B[H]=C[2]<<24|C[1]<<16|C[0];var F=z?new Uint32Array(B):B,K=A;r.prototype.n=function(){var b=0;var d=this.a;var e=Q;switch(e){case Q:var f=
Math.LOG2E*Math.log(32768)-8;break;default:a(Error("invalid compression method"))}f=f<<4|e;d[b++]=f;switch(e){case Q:switch(this.h){case K.NONE:var g=0;break;case K.r:g=1;break;case K.j:g=2;break;default:a(Error("unsupported compression type"))}break;default:a(Error("invalid compression method"))}e=g<<6|0;d[b++]=e|31-(256*f+e)%31;e=c(this.input);this.z.b=b;d=this.z.n();b=d.length;z&&(d=new Uint8Array(d.buffer),d.length<=b+4&&(this.a=new Uint8Array(d.length+4),this.a.set(d),d=this.a),d=d.subarray(0,
b+4));d[b++]=e>>24&255;d[b++]=e>>16&255;d[b++]=e>>8&255;d[b++]=e&255;return d};b("Zlib.Deflate",r);b("Zlib.Deflate.compress",function(a,b){return(new r(a,b)).n()});b("Zlib.Deflate.CompressionType",K);b("Zlib.Deflate.CompressionType.NONE",K.NONE);b("Zlib.Deflate.CompressionType.FIXED",K.r);b("Zlib.Deflate.CompressionType.DYNAMIC",K.j);var L=0,M=1;A={D:L,C:M};t.prototype.p=function(){for(;!this.s;){var b=u(this,3);b&1&&(this.s=!0);b>>>=1;switch(b){case 0:b=this.input;var c=this.c,d=this.a,e=this.b,
f=d.length;this.e=this.g=0;var g=b[c++];void 0===g&&a(Error("invalid uncompressed block header: LEN (first byte)"));var h=g;g=b[c++];void 0===g&&a(Error("invalid uncompressed block header: LEN (second byte)"));h|=g<<8;g=b[c++];void 0===g&&a(Error("invalid uncompressed block header: NLEN (first byte)"));var k=g;g=b[c++];void 0===g&&a(Error("invalid uncompressed block header: NLEN (second byte)"));k|=g<<8;h===~k&&a(Error("invalid uncompressed block header: length verify"));c+h>b.length&&a(Error("input buffer is broken"));
switch(this.m){case L:for(;e+h>d.length;){g=f-e;h-=g;if(z)d.set(b.subarray(c,c+g),e),e+=g,c+=g;else for(;g--;)d[e++]=b[c++];this.b=e;d=this.f();e=this.b}break;case M:for(;e+h>d.length;)d=this.f({v:2});break;default:a(Error("invalid inflate mode"))}if(z)d.set(b.subarray(c,c+h),e),e+=h,c+=h;else for(;h--;)d[e++]=b[c++];this.c=c;this.b=e;this.a=d;break;case 1:this.o(ea,W);break;case 2:x(this);break;default:a(Error("unknown BTYPE: "+b))}}return this.t()};B=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,
15];var O=z?new Uint16Array(B):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];var P=z?new Uint16Array(B):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];var N=z?new Uint8Array(B):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];var S=z?new Uint16Array(B):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];var R=z?new Uint8Array(B):B;B=
new (z?Uint8Array:Array)(288);C=0;for(D=B.length;C<D;++C)B[C]=143>=C?8:255>=C?9:279>=C?7:8;var ea=f(B);B=new (z?Uint8Array:Array)(30);C=0;for(D=B.length;C<D;++C)B[C]=5;var W=f(B);t.prototype.o=function(a,b){var c=this.a,d=this.b;this.u=a;for(var e=c.length-258,f,g,h;256!==(f=v(this,a));)if(256>f)d>=e&&(this.b=d,c=this.f(),d=this.b),c[d++]=f;else for(f-=257,h=P[f],0<N[f]&&(h+=u(this,N[f])),f=v(this,b),g=S[f],0<R[f]&&(g+=u(this,R[f])),d>=e&&(this.b=d,c=this.f(),d=this.b);h--;)c[d]=c[d++-g];for(;8<=
this.e;)this.e-=8,this.c--;this.b=d};t.prototype.I=function(a,b){var c=this.a,d=this.b;this.u=a;for(var e=c.length,f,g,h;256!==(f=v(this,a));)if(256>f)d>=e&&(c=this.f(),e=c.length),c[d++]=f;else for(f-=257,h=P[f],0<N[f]&&(h+=u(this,N[f])),f=v(this,b),g=S[f],0<R[f]&&(g+=u(this,R[f])),d+h>e&&(c=this.f(),e=c.length);h--;)c[d]=c[d++-g];for(;8<=this.e;)this.e-=8,this.c--;this.b=d};t.prototype.f=function(){var a=new (z?Uint8Array:Array)(this.b-32768),b=this.b-32768,c,d=this.a;if(z)a.set(d.subarray(32768,
a.length));else{var e=0;for(c=a.length;e<c;++e)a[e]=d[e+32768]}this.k.push(a);this.q+=a.length;if(z)d.set(d.subarray(b,b+32768));else for(e=0;32768>e;++e)d[e]=d[b+e];this.b=32768;return d};t.prototype.J=function(a){var b,c=this.input.length/this.c+1|0,d,e,f,g=this.input,h=this.a;a&&("number"===typeof a.v&&(c=a.v),"number"===typeof a.F&&(c+=a.F));2>c?(d=(g.length-this.c)/this.u[2],f=d/2*258|0,e=f<h.length?h.length+f:h.length<<1):e=h.length*c;z?(b=new Uint8Array(e),b.set(h)):b=h;return this.a=b};t.prototype.t=
function(){var a=0,b=this.a,c=this.k,d=new (z?Uint8Array:Array)(this.q+(this.b-32768)),e,f;if(0===c.length)return z?this.a.subarray(32768,this.b):this.a.slice(32768,this.b);var g=0;for(e=c.length;g<e;++g){var h=c[g];var k=0;for(f=h.length;k<f;++k)d[a++]=h[k]}g=32768;for(e=this.b;g<e;++g)d[a++]=b[g];this.k=[];return this.buffer=d};t.prototype.H=function(){var a,b=this.b;z?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);return this.buffer=
a};w.prototype.p=function(){var b=this.input,d;var e=this.A.p();this.c=this.A.c;this.M&&(d=(b[this.c++]<<24|b[this.c++]<<16|b[this.c++]<<8|b[this.c++])>>>0,d!==c(e)&&a(Error("invalid adler-32 checksum")));return e};b("Zlib.Inflate",w);b("Zlib.Inflate.BufferType",A);A.ADAPTIVE=A.C;A.BLOCK=A.D;b("Zlib.Inflate.prototype.decompress",w.prototype.p);A=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];z&&new Uint16Array(A);A=[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];z&&new Uint16Array(A);A=[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];z&&new Uint8Array(A);A=[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];z&&new Uint16Array(A);A=[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];z&&new Uint8Array(A);A=new (z?Uint8Array:Array)(288);B=0;for(C=A.length;B<C;++B)A[B]=143>=B?8:255>=B?9:279>=B?7:8;f(A);A=new (z?Uint8Array:Array)(30);B=0;for(C=A.length;B<
C;++B)A[B]=5;f(A);var Q=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.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);a.setOffset(d);c.type=a.readByte();d+=10;if(d+4+1>b)return!1;a.setOffset(d);c.width=a.readUnsignedShort();c.height=a.readUnsignedInteger();c.pixelDepth=a.readByte();if(d+5+1>b)return!1;b=a.readByte();c.flipped=0;b&32&&(c.flipped=1);return!0};
cc.tgaLoadImageData=function(a,b,c){var d=0|c.pixelDepth/2;var e=c.height*c.width*d;if(18+e>b)return!1;c.imageData=cc.__getSubArray(a,18,18+e);if(3<=d)for(a=0;a<e;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]=.3*a.imageData[b]+.59*a.imageData[b+1]+.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=0,f=0,g=[],h=0,k=18;var m=c.pixelDepth/8;var n=c.height*c.width;for(d=0;d<n;d++){if(0!==h){h--;var p=0!==f}else{if(k+1>b)break;h=a[k];k+=1;(f=h&128)&&(h-=128);p=0}if(!p){if(k+m>b)break;g=cc.__getSubArray(a,k,k+m);k+=m;3<=m&&(p=g[0],g[0]=g[2],g[2]=p)}for(p=0;p<m;p++)c.imageData[e+p]=g[p];e+=m}return!0};
cc.tgaFlipImage=function(a){for(var b=a.pixelDepth/8*a.width,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;var d=c>>3;this._checkSize(c);var e=Math.pow(2,b-1)-1,f=this._readBits(a+b,1,d),g=this._readBits(a,b,d),h=0,k=2,m=0;do{var n=this._readByte(++m,
d);c=a%8||8;for(var p=1<<c;p>>=1;)n&p&&(h+=1/k),k*=2}while(a-=c);this._offset+=d;return g===(e<<1)+1?h?NaN:f?-Infinity:Infinity:(1+-2*f)*(g||h?g?Math.pow(2,g-e)*(1+h):Math.pow(2,-e+1)*h: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);this._offset+=a/8;return b&&c>=d/2?c-d:c},_shl:function(a,b){for(++b;--b;a=1073741824===((a%=2147483648)&1073741824)?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];this._offset+=1;return 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 Error("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();b&&0!==b.length||cc.log("cc.TMXTiledMap.initWithTMXFile(): Map not found. Please check the filename.");this._buildWithMapInfo(a);return!0},initWithXML:function(a,b){this.height=this.width=0;var c=new cc.TMXMapInfo(a,b),d=c.getTilesets();d&&0!==d.length||cc.log("cc.TMXTiledMap.initWithXML(): Map not found. Please check the filename.");this._buildWithMapInfo(c);return!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,e=0,f=c.length;e<f;e++)(d=c[e])&&d.visible&&(d=this._parseLayer(d,a),this.addChild(d,b,b),this.width=Math.max(this.width,d.width),this.height=Math.max(this.height,d.height),b++)},allLayers:function(){for(var a=[],b=this._children,c=0,d=b.length;c<d;c++){var e=b[c];e&&e instanceof cc.TMXLayer&&a.push(e)}return a},getLayer:function(a){if(!a||
0===a.length)throw Error("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 Error("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){cc.log("propertiesForGID is deprecated. Please use getPropertiesForGID instead.");return 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);a.ownTiles=!1;return 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}}cc.log("cocos2d: Warning: TMX Layer "+a.name+" has no tiles");return null}});_p=cc.TMXTiledMap.prototype;cc.defineGetterSetter(_p,"mapWidth",_p._getMapWidth,_p._setMapWidth);cc.defineGetterSetter(_p,"mapHeight",_p._getMapHeight,_p._setMapHeight);cc.defineGetterSetter(_p,"tileWidth",_p._getTileWidth,_p._setTileWidth);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._tiles=this._layerSize=null;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,b){var c=b||cc.rect(0,0,0,0);c.width=this._tileSize.width;c.height=this._tileSize.height;a&=cc.TMX_TILE_FLIPPED_MASK;a-=parseInt(this.firstGid,10);var d=parseInt((this.imageSize.width-2*this.margin+this.spacing)/(this._tileSize.width+this.spacing),10);c.x=parseInt(a%d*(this._tileSize.width+
this.spacing)+this.margin,10);c.y=parseInt(parseInt(a/d,10)*(this._tileSize.height+this.spacing)+this.margin,10);return c}});
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){this._internalInit(a,null);return this.parseXMLFile(a)},initWithXML:function(a,b){this._internalInit(null,b);return this.parseXMLString(a)},parseXMLFile:function(a,b){var c=(b=b||!1)?a:cc.loader.getRes(a);if(!c)throw Error("Please load the resource first : "+a);c=this._parseXML(c).documentElement;var d=c.getAttribute("version");
var 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 > properties >  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;h=e.getElementsByTagName("image")[0].getAttribute("source");var 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 > 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++){k=f[d];
m=k.getElementsByTagName("data")[0];g=new cc.TMXLayerInfo;g.name=k.getAttribute("name");e=cc.size(0,0);e.width=parseFloat(k.getAttribute("width"));e.height=parseFloat(k.getAttribute("height"));g._layerSize=e;e=k.getAttribute("visible");g.visible="0"!=e;e=k.getAttribute("opacity")||1;g._opacity=e?parseInt(255*parseFloat(e)):255;g.offset=cc.p(parseFloat(k.getAttribute("x"))||0,parseFloat(k.getAttribute("y"))||0);n="";for(e=0;e<m.childNodes.length;e++)n+=m.childNodes[e].nodeValue;n=n.trim();e=m.getAttribute("compression");
p=m.getAttribute("encoding");if(e&&"gzip"!==e&&"zlib"!==e)return cc.log("cc.TMXMapInfo.parseXMLFile(): unsupported compression method"),null;switch(e){case "gzip":h=cc.unzipBase64AsArray(n,4);break;case "zlib":h=new Zlib.Inflate(cc.Codec.Base64.decodeAsArray(n,1));h=cc.uint8ArrayToUint32Array(h.decompress());break;case null:case "":if("base64"===p)h=cc.Codec.Base64.decodeAsArray(n,4);else if("csv"===p)for(h=[],e=n.split(","),m=0;m<e.length;m++)h.push(parseInt(e[m]));else for(e=m.getElementsByTagName("tile"),
h=[],m=0;m<e.length;m++)h.push(parseInt(e[m].getAttribute("gid")));break;default:this.layerAttrs===cc.TMXLayerInfo.ATTRIB_NONE&&cc.log("cc.TMXMapInfo.parseXMLFile(): Only base64 and/or gzip/zlib maps are supported")}h&&(g._tiles=new Uint32Array(h));if(k=k.querySelectorAll("properties > property")){m={};for(e=0;e<k.length;e++)m[k[e].getAttribute("name")]=k[e].getAttribute("value");g.properties=m}this.setLayers(g)}if(h=c.getElementsByTagName("objectgroup"))for(d=0;d<h.length;d++){g=h[d];f=new cc.TMXObjectGroup;
f.groupName=g.getAttribute("name");f.setPositionOffset(cc.p(parseFloat(g.getAttribute("x"))*this.getTileSize().width||0,parseFloat(g.getAttribute("y"))*this.getTileSize().height||0));if(k=g.querySelectorAll("objectgroup > properties > property"))for(e=0;e<k.length;e++)m={},m[k[e].getAttribute("name")]=k[e].getAttribute("value"),f.properties=m;g=g.querySelectorAll("object");k=cc.director.getContentScaleFactor();if(g)for(e=0;e<g.length;e++){n=g[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=(((n.getAttribute("x")||0)|0)+f.getPositionOffset().x)/k;p=((n.getAttribute("y")||0)|0)+f.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 > property"))for(var r=0;r<p.length;r++)m[p[r].getAttribute("name")]=p[r].getAttribute("value");
(p=n.querySelectorAll("polygon"))&&0<p.length&&(p=p[0].getAttribute("points"))&&(m.points=this._parsePointsString(p));(n=n.querySelectorAll("polyline"))&&0<n.length&&(n=n[0].getAttribute("points"))&&(m.polylinePoints=this._parsePointsString(n));f.setObjects(m)}this.setObjectGroups(f)}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;cc.defineGetterSetter(_p,"mapWidth",_p._getMapWidth,_p._setMapWidth);cc.defineGetterSetter(_p,"mapHeight",_p._getMapHeight,_p._setMapHeight);cc.defineGetterSetter(_p,"tileWidth",_p._getTileWidth,_p._setTileWidth);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){return this.getObject(a)},getObject:function(a){if(this._objects&&0<this._objects.length)for(var b=this._objects,c=0,d=b.length;c<d;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:"",_textures:null,_texGrids:null,_spriteTiles:null,_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);this._spriteTiles={};void 0!==c&&this.initWithTilesetInfo(a,b,c)},_createRenderCmd:function(){return cc._renderType===cc.game.RENDER_TYPE_CANVAS?new cc.TMXLayer.CanvasRenderCmd(this):new cc.TMXLayer.WebGLRenderCmd(this)},_fillTextureGrids:function(a,b){var c=this._textures[b];if(c.isLoaded()){a.imageSize.width&&a.imageSize.height||(a.imageSize.width=c.width,a.imageSize.height=c.height);var d=a._tileSize.width,e=a._tileSize.height,f=c._contentSize.width;c=c._contentSize.height;var g=a.spacing,h=
a.margin,k=a.firstGid;g=a.firstGid+Math.floor((c-2*h+g)/(e+g))*Math.floor((f-2*h+g)/(d+g));h=this._texGrids;for(var m=null,n=h[k]?!0:!1;k<g;++k){n&&!h[k]&&(n=!1);if(!n&&h[k])break;m={texId:b,x:0,y:0,width:d,height:e,t:0,l:0,r:0,b:0};a.rectForGID(k,m);m.t=m.y/c;m.l=m.x/f;m.r=(m.x+m.width)/f;m.b=(m.y+m.height)/c;h[k]=m}}else c.addEventListener("load",function(){this._fillTextureGrids(a,b)},this)},initWithTilesetInfo:function(a,b,c){var d=b._layerSize;parseInt(d.width*d.height);this.layerName=b.name;
this.tiles=b._tiles;this.properties=b.properties;this._layerSize=d;this._minGID=b._minGID;this._maxGID=b._maxGID;this._opacity=b._opacity;this.tileset=a;this.layerOrientation=c.orientation;this._mapTileSize=c.getTileSize();if(c=c._tilesets){this._textures=[];this._texGrids=[];var e=c.length;for(d=0;d<e;++d){var f=c[d];var g=cc.textureCache.addImage(f.sourceImage);this._textures.push(g);this._fillTextureGrids(f,d);f===a&&(this._texture=g)}}a=this._calculateLayerOffset(b.offset);this.setPosition(cc.pointPixelsToPoints(a));
this._parseInternalProperties();this.setContentSize(cc.sizePixelsToPoints(cc.size(this._layerSize.width*this._mapTileSize.width,this._layerSize.height*this._mapTileSize.height)));this._useAutomaticVertexZ=!1;this._vertexZvalue=0;return!0},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},getProperty:function(a){return this.properties[a]},getLayerName:function(){return this.layerName},setLayerName:function(a){this.layerName=
a},releaseMap:function(){this._spriteTiles={}},getTileAt:function(a,b){if(void 0===a)throw Error("cc.TMXLayer.getTileAt(): pos should be non-null");var c=a;void 0===b&&(c=a.x,b=a.y);if(c>=this._layerSize.width||b>=this._layerSize.height||0>c||0>b)throw Error("cc.TMXLayer.getTileAt(): invalid position");if(!this.tiles)return cc.log("cc.TMXLayer.getTileAt(): TMXLayer: the tiles map has been released"),null;var d=null,e=this.getTileGIDAt(c,b);if(0===e)return d;var f=0|c+b*this._layerSize.width;d=this._spriteTiles[f];
d||(d=this._texGrids[e],e=this._textures[d.texId],d=cc.rectPixelsToPoints(d),d=new cc.Sprite(e,d),d.setPosition(this.getPositionAt(c,b)),c=this._vertexZForPos(c,b),d.setVertexZ(c),d.setAnchorPoint(0,0),d.setOpacity(this._opacity),this.addChild(d,c,f));return d},getTileGIDAt:function(a,b){if(void 0===a)throw Error("cc.TMXLayer.getTileGIDAt(): pos should be non-null");var c=a;void 0===b&&(c=a.x,b=a.y);if(c>=this._layerSize.width||b>=this._layerSize.height||0>c||0>b)throw Error("cc.TMXLayer.getTileGIDAt(): invalid position");
return this.tiles?(this.tiles[0|c+b*this._layerSize.width]&cc.TMX_TILE_FLIPPED_MASK)>>>0:(cc.log("cc.TMXLayer.getTileGIDAt(): TMXLayer: the tiles map has been released"),null)},setTileGID:function(a,b,c,d){if(void 0===b)throw Error("cc.TMXLayer.setTileGID(): pos should be non-null");void 0!==d?b=cc.p(b,c):d=c;if(b.x>=this._layerSize.width||b.y>=this._layerSize.height||0>b.x||0>b.y)throw Error("cc.TMXLayer.setTileGID(): invalid position");if(this.tiles)if(0!==a&&a<this.tileset.firstGid)cc.log("cc.TMXLayer.setTileGID(): invalid gid:"+
a);else{d=d||0;c=this.getTileFlagsAt(b);var e=this.getTileGIDAt(b);if(e!==a||c!==d)if(c=(a|d)>>>0,0===a)this.removeTileAt(b);else if(0===e)this._updateTileForGID(c,b);else{e=b.x+b.y*this._layerSize.width;var f=this.getChildByTag(e);if(f){a=this._texGrids[a];var g=this._textures[a.texId];a=cc.rectPixelsToPoints(a);f.setTexture(g);f.setTextureRect(a,!1);null!=d&&this._setupTileSprite(f,b,c);this.tiles[e]=c}else this._updateTileForGID(c,b)}}else cc.log("cc.TMXLayer.setTileGID(): TMXLayer: the tiles map has been released")},
addChild:function(a,b,c){cc.Node.prototype.addChild.call(this,a,b,c);void 0!==c&&(this._spriteTiles[c]=a,a._vertexZ=this._vertexZ+cc.renderer.assignedZStep*c/this.tiles.length)},removeChild:function(a,b){this._spriteTiles[a.tag]&&(this._spriteTiles[a.tag]=null);cc.Node.prototype.removeChild.call(this,a,b)},getTileFlagsAt:function(a,b){if(!a)throw Error("cc.TMXLayer.getTileFlagsAt(): pos should be non-null");void 0!==b&&(a=cc.p(a,b));if(a.x>=this._layerSize.width||a.y>=this._layerSize.height||0>a.x||
0>a.y)throw Error("cc.TMXLayer.getTileFlagsAt(): invalid position");return this.tiles?(this.tiles[0|a.x+a.y*this._layerSize.width]&cc.TMX_TILE_FLIPPED_ALL)>>>0:(cc.log("cc.TMXLayer.getTileFlagsAt(): TMXLayer: the tiles map has been released"),null)},removeTileAt:function(a,b){if(!a)throw Error("cc.TMXLayer.removeTileAt(): pos should be non-null");void 0!==b&&(a=cc.p(a,b));if(a.x>=this._layerSize.width||a.y>=this._layerSize.height||0>a.x||0>a.y)throw Error("cc.TMXLayer.removeTileAt(): invalid position");
if(!this.tiles)cc.log("cc.TMXLayer.removeTileAt(): TMXLayer: the tiles map has been released");else if(0!==this.getTileGIDAt(a)){var c=0|a.x+a.y*this._layerSize.width;this.tiles[c]=0;(c=this._spriteTiles[c])&&this.removeChild(c,!0)}},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)},
_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(a.x*this._mapTileSize.width*3/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},_updateTileForGID:function(a,b){if(this._texGrids[a]){var c=0|b.x+b.y*this._layerSize.width;c<this.tiles.length&&(this.tiles[c]=a)}},
_parseInternalProperties:function(){var a=this.getProperty("cc_vertexz");if(a)if("automatic"===a){this._useAutomaticVertexZ=!0;a=this.getProperty("cc_alpha_func");var b=0;a&&(b=parseFloat(a));cc._renderType===cc.game.RENDER_TYPE_WEBGL&&(this.shaderProgram=cc.shaderCache.programForKey(cc.SHADER_SPRITE_POSITION_TEXTURECOLORALPHATEST),this.shaderProgram.use(),this.shaderProgram.setUniformLocationWith1f(cc.UNIFORM_ALPHA_TEST_VALUE_S,b))}else this._vertexZvalue=parseInt(a,10)},_setupTileSprite:function(a,
b,c){var d=this.getPositionAt(b);a.setPosition(d);a.setVertexZ(this._vertexZForPos(b));a.setAnchorPoint(0,0);a.setOpacity(this._opacity);a.setFlippedX(!1);a.setFlippedY(!1);a.setRotation(0);(c&cc.TMX_TILE_DIAGONAL_FLAG)>>>0?(a.setAnchorPoint(.5,.5),a.setPosition(d.x+a.width/2,d.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.setRotation(90):b===cc.TMX_TILE_VERTICAL_FLAG?a.setRotation(270):(b===(cc.TMX_TILE_VERTICAL_FLAG|cc.TMX_TILE_HORIZONTAL_FLAG)>>>
0?a.setRotation(90):a.setRotation(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,b){void 0===b&&(b=a.y,a=a.x);var c=0;if(this._useAutomaticVertexZ)switch(this.layerOrientation){case cc.TMX_ORIENTATION_ISO:c=this._layerSize.width+this._layerSize.height;c=-(c-(a+b));break;case cc.TMX_ORIENTATION_ORTHO:c=-(this._layerSize.height-b);break;case cc.TMX_ORIENTATION_HEX:cc.log("TMX Hexa zOrder not supported");
break;default:cc.log("TMX invalid value")}else c=this._vertexZvalue;return c}});_p=cc.TMXLayer.prototype;cc.defineGetterSetter(_p,"layerWidth",_p._getLayerWidth,_p._setLayerWidth);cc.defineGetterSetter(_p,"layerHeight",_p._getLayerHeight,_p._setLayerHeight);cc.defineGetterSetter(_p,"tileWidth",_p._getTileWidth,_p._setTileWidth);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){this._rootCtor(a);this._needDraw=!0};var a=cc.TMXLayer.CanvasRenderCmd.prototype=Object.create(cc.Node.CanvasRenderCmd.prototype);a.constructor=cc.TMXLayer.CanvasRenderCmd;a.visit=function(a){var b=this._node,d=cc.renderer;if(a=a||this.getParentRenderCmd())this._curLevel=a._curLevel+1;if(b._visible){isNaN(b._customZ)&&(b._vertexZ=d.assignedZ,d.assignedZ+=d.assignedZStep);this._syncStatus(a);a=b._children;var e=b._spriteTiles,f,g=a.length;if(0<g){b.sortAllChildren();
for(f=0;f<g;f++)if(b=a[f],0>b._localZOrder)b._renderCmd.visit(this);else break;for(d.pushRenderCommand(this);f<g;f++)b=a[f],0===b._localZOrder&&e[b.tag]?(isNaN(b._customZ)&&(b._vertexZ=d.assignedZ,d.assignedZ+=d.assignedZStep),b._renderCmd.updateStatus()):b._renderCmd.visit(this)}else d.pushRenderCommand(this);this._dirtyFlag=0}};a.rendering=function(a,c,d){var b=this._node,f=b._rotationX||b._rotationY,g=b.layerOrientation,h=b._opacity/255;if(b.tiles&&!(0>=h)){var k=b._mapTileSize.width,m=b._mapTileSize.height,
n=b.tileset._tileSize.width/cc.director._contentScaleFactor,p=b.tileset._tileSize.height/cc.director._contentScaleFactor,r=n-k,t=p-m,u=cc.winSize.width,v=cc.winSize.height,x=b._layerSize.height,w=b._layerSize.width,y=b._texGrids,z=b._spriteTiles,A=this._worldTransform,B=-b._contentSize.width*b._anchorPoint.x,C=-b._contentSize.height*b._anchorPoint.y,D=A.a,E=A.d,J=B*D+C*A.c+A.tx;B=B*A.b+C*E+A.ty;C=a||cc._renderContext;var I=C.getContext(),G=0,H=0,F=w,K=x;f||g!==cc.TMX_ORIENTATION_ORTHO||(G=Math.floor(-(J-
r*D)/(k*D)),H=Math.floor((B-t*E+m*x*E-v)/(m*E)),F=Math.ceil((u-J+r*D)/(k*D)),K=x-Math.floor(-(B+t*E)/(m*E)),0>G&&(G=0),0>H&&(H=0),F>w&&(F=w),K>x&&(K=x));var L,M;r=H*w;var O,P,N=cc.TMX_TILE_FLIPPED_MASK,S=n*D,R=p*E,ea=!1,W=!1;t=r+G;for(L in z)if(L<t&&z[L]){var Q=z[L]._renderCmd;0===z[L]._localZOrder&&Q.rendering&&Q.rendering(a,c,d)}else if(L>=t)break;C.setTransform(A,c,d);for(C.setGlobalAlpha(h);H<K;++H){for(M=G;M<F;++M)if(t=r+M,z[t])Q=z[t]._renderCmd,0===z[t]._localZOrder&&Q.rendering&&(Q.rendering(a,
c,d),C.setTransform(A,c,d),C.setGlobalAlpha(h));else if(Q=b.tiles[t],(O=y[(Q&N)>>>0])&&(P=b._textures[O.texId])&&P._htmlElementObj){switch(g){case cc.TMX_ORIENTATION_ORTHO:var U=M*k;var T=-(x-H-1)*m;break;case cc.TMX_ORIENTATION_ISO:U=k/2*(w+M-H-1);T=-m/2*(2*x-M-H-2);break;case cc.TMX_ORIENTATION_HEX:U=M*k*3/4,T=-(x-H-1)*m+(1===M%2?-m/2:0)}var ba=U+n;var aa=T-p;if(!f&&g===cc.TMX_ORIENTATION_ISO){var V=-B+T*E;if(V<-v-R){M+=Math.floor(2*(-v-V)/R)-1;continue}V=J+ba*D;if(V<-S){M+=Math.floor(2*-V/S)-1;
continue}var ca=J+U*D;V=-B+aa*E;if(ca>u||0<V){M=F;continue}}Q>cc.TMX_TILE_DIAGONAL_FLAG&&(ea=(Q&cc.TMX_TILE_HORIZONTAL_FLAG)>>>0,W=(Q&cc.TMX_TILE_VERTICAL_FLAG)>>>0);ea&&(U=-ba,I.scale(-1,1));W&&(aa=-T,I.scale(1,-1));I.drawImage(P._htmlElementObj,O.x,O.y,O.width,O.height,U,aa,n,p);ea&&I.scale(-1,1);W&&I.scale(1,-1);cc.g_NumberOfDraws++}r+=w}for(L in z)L>t&&z[L]&&(Q=z[L]._renderCmd,0===z[L]._localZOrder&&Q.rendering&&Q.rendering(a,c,d))}}})();(function(){cc.TMXLayer.WebGLRenderCmd=function(a){this._rootCtor(a);this._needDraw=!0;this._vertices=[{x:0,y:0},{x:0,y:0},{x:0,y:0},{x:0,y:0}];this._color=new Uint32Array(1);this._shaderProgram=cc.shaderCache.programForKey(cc.SHADER_SPRITE_POSITION_TEXTURECOLORALPHATEST);a=90*Math.PI/180;this._sin90=Math.sin(a);this._cos90=Math.cos(a);a*=3;this._sin270=Math.sin(a);this._cos270=Math.cos(a)};var a=cc.TMXLayer.WebGLRenderCmd.prototype=Object.create(cc.Node.WebGLRenderCmd.prototype);a.constructor=cc.TMXLayer.WebGLRenderCmd;
a.uploadData=function(a,c,d){var b=this._node,f=b._rotationX||b._rotationY,g=b.layerOrientation,h=b.tiles;if(!h)return 0;var k=b._mapTileSize.width,m=b._mapTileSize.height,n=b.tileset._tileSize.width/cc.director._contentScaleFactor,p=b.tileset._tileSize.height/cc.director._contentScaleFactor,r=n-k,t=p-m,u=cc.winSize.width,v=cc.winSize.height,x=b._layerSize.height,w=b._layerSize.width,y=b._texGrids,z=b._spriteTiles,A=this._worldTransform,B=A.a,C=A.b,D=A.c,E=A.d,J=A.tx;A=A.ty;var I=-b._contentSize.width*
b._anchorPoint.x,G=-b._contentSize.height*b._anchorPoint.y,H=I*B+G*D+J;I=I*C+G*E+A;G=b._opacity;var F=this._displayedColor.r,K=this._displayedColor.g,L=this._displayedColor.b;if(b._opacityModifyRGB){var M=G/255;F*=M;K*=M;L*=M}this._color[0]=G<<24|L<<16|K<<8|F;var O=G=0;F=w;K=x;f||g!==cc.TMX_ORIENTATION_ORTHO||(G=Math.floor(-(H-r*B)/(k*B)),O=Math.floor((I-t*E+m*x*E-v)/(m*E)),F=Math.ceil((u-H+r*B)/(k*B)),K=x-Math.floor(-(I+t*E)/(m*E)),0>G&&(G=0),0>O&&(O=0),F>w&&(F=w),K>x&&(K=x));var P;r=d;t=O*w;var N;
L=cc.TMX_TILE_FLIPPED_MASK;M=n*B;for(var S=p*E,R,ea,W=B,Q=C,U=D,T=E,ba=J,aa=A,V=!1,ca=!1,ha=!1,X=this._vertices;O<K;++O){for(P=G;P<F;++P){r+24>a.length&&(cc.renderer._increaseBatchingSize((r-d)/6),cc.renderer._batchRendering(),r=d=0);var fa=t+P;if(!z[fa]){var Y=b.tiles[fa];if(N=y[(Y&L)>>>0]){switch(g){case cc.TMX_ORIENTATION_ORTHO:var da=P*k;var Z=(x-O-1)*m;fa=b._vertexZ+cc.renderer.assignedZStep*fa/h.length;break;case cc.TMX_ORIENTATION_ISO:da=k/2*(w+P-O-1);Z=m/2*(2*x-P-O-2);fa=b._vertexZ+cc.renderer.assignedZStep*
(b.height-Z)/b.height;break;case cc.TMX_ORIENTATION_HEX:da=P*k*3/4,Z=(x-O-1)*m+(1===P%2?-m/2:0),fa=b._vertexZ+cc.renderer.assignedZStep*(b.height-Z)/b.height}var ia=da+n;var ja=Z+p;if(!f&&g===cc.TMX_ORIENTATION_ISO){R=I+Z*E;if(R>v+S){P+=Math.floor(2*(R-v)/S)-1;continue}R=H+ia*B;if(R<-M){P+=Math.floor(2*-R/M)-1;continue}ea=H+da*B;R=I+ja*E;if(ea>u||0>R){P=F;continue}}Y>cc.TMX_TILE_DIAGONAL_FLAG&&(V=!0,ca=(Y&cc.TMX_TILE_HORIZONTAL_FLAG)>>>0,ha=(Y&cc.TMX_TILE_VERTICAL_FLAG)>>>0);X[0].x=da*W+ja*U+ba;X[0].y=
da*Q+ja*T+aa;X[1].x=da*W+Z*U+ba;X[1].y=da*Q+Z*T+aa;X[2].x=ia*W+ja*U+ba;X[2].y=ia*Q+ja*T+aa;X[3].x=ia*W+Z*U+ba;X[3].y=ia*Q+Z*T+aa;for(Y=0;4>Y;++Y){a[r]=X[Y].x;a[r+1]=X[Y].y;a[r+2]=fa;c[r+3]=this._color[0];switch(Y){case 0:a[r+4]=ca?N.r:N.l;a[r+5]=ha?N.b:N.t;break;case 1:a[r+4]=ca?N.r:N.l;a[r+5]=ha?N.t:N.b;break;case 2:a[r+4]=ca?N.l:N.r;a[r+5]=ha?N.b:N.t;break;case 3:a[r+4]=ca?N.l:N.r,a[r+5]=ha?N.t:N.b}r+=6}V&&(W=B,Q=C,U=D,T=E,ba=J,aa=A,V=ha=ca=!1)}}}t+=w}return(r-d)/6}})();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){this._ratio=a;this._offset=b;this._child=null;return!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)cc.log("ParallaxNode: use addChild(child, z, ratio, offset) instead");else{if(!a)throw Error("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;c<d;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.game.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){this._rootCtor(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();this.originUpdateStatus()};a._syncStatus=function(a){this._node._updateParallaxPosition();this._originSyncStatus(a)}})();
cc.game.addEventListener(cc.game.EVENT_RENDERER_INITED,function(){if(cc._renderType===cc.game.RENDER_TYPE_WEBGL){cc.ParallaxNode.WebGLRenderCmd=function(a){this._rootCtor(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();this.originUpdateStatus()};a._syncStatus=function(a){this._node._updateParallaxPosition();this._originSyncStatus(a)}}});(function(){var a=cc.sys,b={ONLY_ONE:!1,WEB_AUDIO:!!(window.AudioContext||window.webkitAudioContext||window.mozAudioContext),DELAY_CREATE_CTX:!1,ONE_SOURCE:!0};a.browserType===a.BROWSER_TYPE_FIREFOX&&(b.DELAY_CREATE_CTX=!0,b.USE_LOADER_EVENT="canplay");a.os===a.OS_IOS&&(b.USE_LOADER_EVENT="loadedmetadata");a.os===a.OS_ANDROID&&a.browserType===a.BROWSER_TYPE_UC&&(b.ONE_SOURCE=!0);window.__audioSupport=b})();
cc.Audio=cc.Class.extend({interruptPlay:!1,src:null,_element:null,_AUDIO_TYPE:"AUDIO",ctor:function(a){this.src=a},setBuffer:function(a){this._AUDIO_TYPE="WEBAUDIO";this._element=new cc.Audio.WebAudio(a)},setElement:function(a){this._AUDIO_TYPE="AUDIO";this._element=a;a.addEventListener("ended",function(){a.loop||(a.paused=!0)})},play:function(a,b){this._element?(this._element.loop=b,this._element.play(),"AUDIO"===this._AUDIO_TYPE&&this._element.paused&&(this.stop(),cc.Audio.touchPlayList.push({loop:b,
offset:a,audio:this._element})),!1===cc.Audio.bindTouch&&(cc.Audio.bindTouch=!0,cc.game.canvas.addEventListener("touchstart",cc.Audio.touchStart))):this.interruptPlay=!1},getPlaying:function(){return this._element?!this._element.paused:!0},stop:function(){if(this._element){this._element.pause();try{this._element.currentTime=0}catch(a){}}else this.interruptPlay=!0},pause:function(){this._element?this._element.pause():this.interruptPlay=!0},resume:function(){this._element?this._element.play():this.interruptPlay=
!1},setVolume:function(a){this._element&&(this._element.volume=a)},getVolume:function(){if(this._element)return this._element.volume},cloneNode:function(){var a=new cc.Audio(this.src);if("AUDIO"===this._AUDIO_TYPE){for(var b=document.createElement("audio"),c=b.getElementsByTagName("source"),d=0;d<c.length;d++)b.appendChild(c[d]);b.src=this.src;a.setElement(b)}else a.setBuffer(this._element.buffer);return a}});cc.Audio.touchPlayList=[];cc.Audio.bindTouch=!1;
cc.Audio.touchStart=function(){for(var a=cc.Audio.touchPlayList,b;b=a.pop();)b.audio.loop=!!b.loop,b.audio.play(b.offset)};cc.Audio.WebAudio=function(a){this.buffer=a;(this.context=cc.Audio._context)&&"suspended"==this.context.state&&this.context.resume();a=this.context.createGain();a.gain.value=1;a.connect(this.context.destination);this._volume=a;this._loop=!1;this._startTime=-1;this._currentSource=null;this.playedLength=0;this._currextTimer=null};
cc.Audio.WebAudio.prototype={constructor:cc.Audio.WebAudio,get paused(){return this._currentSource&&this._currentSource.loop?!1:-1===this._startTime?!0:this.context.currentTime-this._startTime>this.buffer.duration},set paused(a){},get loop(){return this._loop},set loop(a){return this._loop=a},get volume(){return this._volume.gain.value},set volume(a){return this._volume.gain.value=a},get currentTime(){return this.playedLength},set currentTime(a){return this.playedLength=a},play:function(a){this._currentSource&&
!this.paused&&(this._currentSource.stop(0),this.playedLength=0);var b=this.context.createBufferSource();b.buffer=this.buffer;b.connect(this._volume);b.loop=this._loop;this._startTime=this.context.currentTime;a=a||this.playedLength;var c=this.buffer.duration;this._loop?b.start?b.start(0):b.notoGrainOn?b.noteGrainOn(0):b.noteOn(0):b.start?b.start(0,a,c-a):b.notoGrainOn?b.noteGrainOn(0,a,c-a):b.noteOn(0,a,c-a);this._currentSource=b;if(0===this.context.currentTime){var d=this;clearTimeout(this._currextTimer);
this._currextTimer=setTimeout(function(){0===d.context.currentTime&&cc.Audio.touchPlayList.push({offset:a,audio:d})},10)}},pause:function(){this.playedLength=this.context.currentTime-this._startTime;this.playedLength%=this.buffer.duration;var a=this._currentSource;this._currentSource=null;this._startTime=-1;a&&a.stop(0)}};
(function(a){var b=a.WEB_AUDIO,c=a.ONLY_ONE,d=[];(function(){var a=document.createElement("audio");if(a.canPlayType){var b=a.canPlayType('audio/ogg; codecs="vorbis"');b&&""!==b&&d.push(".ogg");(b=a.canPlayType("audio/mpeg"))&&""!==b&&d.push(".mp3");(b=a.canPlayType('audio/wav; codecs="1"'))&&""!==b&&d.push(".wav");(b=a.canPlayType("audio/mp4"))&&""!==b&&d.push(".mp4");(a=a.canPlayType("audio/x-m4a"))&&""!==a&&d.push(".m4a")}})();try{if(b){var e=new (window.AudioContext||window.webkitAudioContext||
window.mozAudioContext);cc.Audio._context=e;if(!(e.createBufferSource&&e.createGain&&e.destination&&e.decodeAudioData))throw"context is incomplete";a.DELAY_CREATE_CTX&&setTimeout(function(){e=new (window.AudioContext||window.webkitAudioContext||window.mozAudioContext);cc.Audio._context=e},0)}}catch(g){b=!1,cc.log("browser don't support web audio")}var f={cache:{},useWebAudio:!0,loadBuffer:function(a,c){if(b){var d=cc.loader.getXMLHttpRequest();d.open("GET",a,!0);d.responseType="arraybuffer";d.onload=
function(){0<=d._timeoutId&&clearTimeout(d._timeoutId);e.decodeAudioData(d.response,function(a){c(null,a)},function(){c("decode error - "+a)})};d.onerror=function(){c("request error - "+a)};void 0===d.ontimeout&&(d._timeoutId=setTimeout(function(){d.ontimeout()},d.timeout));d.ontimeout=function(){c("request timeout - "+a)};d.send()}},load:function(a,b,c,e){if(0===d.length)return e("can not support audio!");var f=cc.loader.getRes(b);if(f)return e(null,f);cc.loader.audioPath&&(a=cc.path.join(cc.loader.audioPath,
a));f=cc.path.extname(a);c=[f];for(var g=0;g<d.length;g++)f!==d[g]&&c.push(d[g]);f=new cc.Audio(a);cc.loader.cache[b]=f;this.loadAudioFromExtList(a,c,f,e);return f},loadAudioFromExtList:function(c,e,f,m){if(0===e.length){var g="can not found the resource of audio! Last match url is : ";g+=c.replace(/\.(.*)?$/,"(");d.forEach(function(a){g+=a+"|"});g=g.replace(/\|$/,")");return m({status:520,errorMessage:g},null)}if(b&&this.useWebAudio)this.loadBuffer(c,function(a,b){a&&cc.log(a);b&&f.setBuffer(b);
m(null,f)});else{for(var h=a.ONE_SOURCE?1:e.length,k=document.createElement("audio"),t=0;t<h;t++){var u=document.createElement("source");u.src=cc.path.changeExtname(c,e[t]);k.appendChild(u)}f.setElement(k);var v=setTimeout(function(){0===k.readyState?w():x()},8E3),x=function(){k.removeEventListener("canplaythrough",x,!1);k.removeEventListener("error",w,!1);k.removeEventListener("emptied",x,!1);a.USE_LOADER_EVENT&&k.removeEventListener(a.USE_LOADER_EVENT,x,!1);clearTimeout(v);m(null,f)},w=function(){cc.log("load audio failure - "+
c);x()};k.addEventListener("canplaythrough",x,!1);k.addEventListener("error",w,!1);a.USE_LOADER_EVENT&&k.addEventListener(a.USE_LOADER_EVENT,x,!1)}}};cc.loader.register(["mp3","ogg","wav","mp4","m4a"],f);cc.audioEngine={_currMusic:null,_musicVolume:1,features:a,willPlayMusic:function(){return!1},playMusic:function(a,b){var c=this._currMusic;c&&c.getPlaying()&&c.stop();var d=this._musicVolume,e=cc.loader.getRes(a);e||(cc.loader.load(a,function(){e.getPlaying()||e.interruptPlay||(e.setVolume(d),e.play(0,
b||!1))}),e=cc.loader.getRes(a));e.setVolume(d);e.play(0,b||!1);this._currMusic=e},stopMusic:function(a){var b=this._currMusic;if(b){for(var c=cc.Audio.touchPlayList,d=c.length-1;0<=d;--d)this[d]&&this[d].audio===b._element&&c.splice(d,1);b.stop();this._currMusic=null;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:10,_effectVolume:1,playEffect:function(a,d){if(c&&this._currMusic&&this._currMusic.getPlaying())return cc.log("Browser is only allowed to play one audio"),null;var e=this._audioPool[a];e||(e=this._audioPool[a]=[]);for(var g=0;g<e.length&&e[g].getPlaying();g++);!b&&
g>this._maxAudioInstance&&(g=e.shift(),g.stop(),e.push(g),g=e.length-1);if(e[g]){var h=e[g];h.setVolume(this._effectVolume);h.play(0,d||!1);return h}(h=cc.loader.getRes(a))&&b&&"AUDIO"===h._AUDIO_TYPE&&(cc.loader.release(a),h=null);if(h)if(b&&"AUDIO"===h._AUDIO_TYPE)f.loadBuffer(a,function(a,b){h.setBuffer(b);h.setVolume(cc.audioEngine._effectVolume);h.getPlaying()||h.play(0,d||!1)});else return h=h.cloneNode(),h.setVolume(this._effectVolume),h.play(0,d||!1),e.push(h),h;g=f.useWebAudio;f.useWebAudio=
!0;cc.loader.load(a,function(b){b=cc.loader.getRes(a);b=b.cloneNode();b.setVolume(cc.audioEngine._effectVolume);b.play(0,d||!1);e.push(b)});f.useWebAudio=g;return h},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<c.length;d++)c[d].stop();c.length=0}a.length=0},unloadEffect:function(a){if(a){cc.loader.release(a);var b=this._audioPool[a];if(b){for(var c=0;c<
b.length;c++)b[c].stop();b.length=0}delete this._audioPool[a]}},end:function(){this.stopMusic();this.stopAllEffects()},_pauseCache:[],_pausePlaying:function(){var a=this._currMusic;a&&a.getPlaying()&&(a.pause(),this._pauseCache.push(a));a=this._audioPool;for(var 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}}})(window.__audioSupport);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;c<d;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(){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});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;return!0},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;b<c;b++)if(a&1<<b)for(var d=this._dispatchListforControlEvent(1<<b),e=0,f=d.length;e<f;e++)d[e].invoke(this)},addTargetWithActionForControlEvents:function(a,b,c){for(var d=0,e=cc.CONTROL_EVENT_TOTAL_NUMBER;d<e;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;d<e;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();a=this.getParent().convertToNodeSpace(a);return cc.rectContainsPoint(this.getBoundingBox(),a)},_invocationWithTargetAndActionForControlEvent:function(a,b,c){return null},_dispatchListforControlEvent:function(a){a=
a.toString();this._dispatchTable[a]||(this._dispatchTable[a]=[]);return 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;
cc.defineGetterSetter(_p,"state",_p.getState);cc.defineGetterSetter(_p,"enabled",_p.isEnabled,_p.setEnabled);cc.defineGetterSetter(_p,"selected",_p.isSelected,_p.setSelected);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 Error("cc.ControlButton.initWithLabelAndBackgroundSprite(): label should be non-null");if(!b)throw Error("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(.5,.5);this._titleLabel=a;this._backgroundSprite=b;this.setOpacity(255);this.setOpacityModifyRGB(!0);var c=a.getString();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(.5,.5);this.setPreferredSize(cc.size(0,0));this.needsLayout();return!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))&&this.stopAction(a);this.zoomOnTouchDown&&(a=this.isHighlighted()&&
this.isEnabled()&&!this.isSelected()?1.1:1,a=cc.scaleTo(.05,a),a.setTag(cc.CONTROL_ZOOM_ACTION_TAG),this.runAction(a))},onTouchBegan:function(a,b){if(!(this.isTouchInside(a)&&this.isEnabled()&&this.isVisible()&&this.hasVisibleParents()))return!1;this._isPushed=!0;this.setHighlighted(!0);this.sendActionsForControlEvents(cc.CONTROL_EVENT_TOUCH_DOWN);return!0},onTouchMoved:function(a,b){if(this._enabled&&this._isPushed&&!this._selected){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)}else this._highlighted&&this.setHighlighted(!1)},onTouchEnded:function(a,b){this._isPushed=!1;this.setHighlighted(!1);this.isTouchInside(a)?
this.sendActionsForControlEvents(cc.CONTROL_EVENT_TOUCH_UP_INSIDE):this.sendActionsForControlEvents(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: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(.5,
.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(.5,.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;cc.defineGetterSetter(_p,"adjustBackground",_p.getAdjustBackgroundImage,_p.setAdjustBackgroundImage);
cc.defineGetterSetter(_p,"preferredSize",_p.getPreferredSize,_p.setPreferredSize);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){a=new cc.Sprite("#"+a);if(!a)return null;a.setPosition(c);a.setAnchorPoint(d);b.addChild(a);return a};
cc.ControlUtils.HSVfromRGB=function(a){var b=new cc.HSV;var c=a.r<a.g?a.r:a.g;c=c<a.b?c:a.b;var d=a.r>a.g?a.r:a.g;d=d>a.b?d:a.b;b.v=d;c=d-c;if(0<d)b.s=c/d;else return b.s=0,b.h=-1,b;b.h=a.r>=d?(a.g-a.b)/c:a.g>=d?2+(a.b-a.r)/c:4+(a.r-a.g)/c;b.h*=60;0>b.h&&(b.h+=360);return b};
cc.ControlUtils.RGBfromHSV=function(a){var b=new cc.RGBA;b.a=1;if(0>=a.s){if(!a.h)return b.r=a.v,b.g=a.v,b.b=a.v,b;b.r=0;b.g=0;b.b=0;return b}var c=a.h;360<=c&&(c=0);c/=60;var d=0|c;var e=c-d;c=a.v*(1-a.s);var f=a.v*(1-a.s*e);e=a.v*(1-a.s*(1-e));switch(d){case 0:b.r=a.v;b.g=e;b.b=c;break;case 1:b.r=f;b.g=a.v;b.b=c;break;case 2:b.r=c;b.g=a.v;b.b=e;break;case 3:b.r=c;b.g=f;b.b=a.v;break;case 4:b.r=e;b.g=c;b.b=a.v;break;default:b.r=a.v,b.g=c,b.b=f}return b};
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){if(this._target&&this._action)if(cc.isString(this._action))this._target[this._action](a,this._controlEvent);else this._action.call(this._target,a,this._controlEvent)}});cc.Spacer=cc.Layer.extend({});cc.Spacer.verticalSpacer=function(a){var b=new cc.Spacer;b.init();b.setContentSize(0,a);return b};cc.Spacer.horizontalSpacer=function(a){var b=new cc.Spacer;b.init();b.setContentSize(a,0);return 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;b.r=a.r;b.g=a.g;b.b=a.b;if(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){this._opacity=a;if(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(.5,.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=-a,c;if(this._children&&0<this._children.length)for(c=0;c<this._children.length;c++)this._children[c]&&(b+=this._children[c].getContentSize().height*this._children[c].getScaleY()+a);var d=0,e=b/2;if(this._children&&0<this._children.length)for(c=0;c<this._children.length;c++)this._children[c]&&(d=Math.max(d,this._children[c].getContentSize().width),this._children[c].setPosition(0,e-this._children[c].getContentSize().height*this._children[c].getScaleY()/
2),e-=this._children[c].getContentSize().height*this._children[c].getScaleY()+a);this.setContentSize(d,b)},alignItemsHorizontally:function(){this.alignItemsHorizontallyWithPadding(cc.DEFAULT_PADDING)},alignItemsHorizontallyWithPadding:function(a){var b=-a,c;if(this._children&&0<this._children.length)for(c=0;c<this._children.length;c++)this._children[c]&&(b+=this._children[c].getContentSize().width*this._children[c].getScaleX()+a);var d=0,e=-b/2;if(this._children&&0<this._children.length)for(c=0;c<
this._children.length;c++)this._children[c]&&(d=Math.max(d,this._children[c].getContentSize().height),this._children[c].setPosition(e+this._children[c].getContentSize().width*this._children[c].getScaleX()/2,0),e+=this._children[c].getContentSize().width*this._children[c].getScaleX()+a);this.setContentSize(b,d)},alignItemsInColumns:function(a){var b=[],c;for(c=1;c<arguments.length;c++)b.push(arguments[c]);var d=-5,e=0,f=0,g=0,h;if(this._children&&0<this._children.length)for(c=0;c<this._children.length;c++)if(this._children[c])if(e>=
b.length)cc.log("cc.MenuPassive.alignItemsInColumns(): invalid row index");else if(h=b[e]){var k=this._children[c].getContentSize().height;f=0|(f>=k||null==k?f:k);++g;g>=h&&(d+=f+5,f=g=0,++e)}else cc.log("cc.MenuPassive.alignItemsInColumns(): can not have zero columns on a row");var m=cc.director.getWinSize(),n=h=f=e=0,p=0;d/=2;if(this._children&&0<this._children.length)for(c=0;c<this._children.length;c++)this._children[c]&&(0===h&&(h=b[e],p=n=m.width/(1+h)),k=this._children[c].getContentSize().height,
f=0|(f>=k||null==k?f:k),this._children[c].setPosition(p-m.width/2,d-this._children[c].getContentSize().height/2),p+=n,++g,g>=h&&(d-=f+5,f=h=g=0,++e))},alignItemsInRows:function(a){var b=[],c;for(c=1;c<arguments.length;c++)b.push(arguments[c]);var d=[],e=[],f=-10,g=-5,h=0,k=0,m=0,n;if(this._children&&0<this._children.length)for(c=0;c<this._children.length;c++)if(this._children[c])if(h>=b.length)cc.log("cc.MenuPassive.alignItemsInRows(): invalid row index");else if(n=b[h]){var p=this._children[c].getContentSize().width;
k=0|(k>=p||null==p?k:p);g+=0|this._children[c].getContentSize().height+5;++m;m>=n&&(d.push(k),e.push(g),f+=k+10,k=m=0,g=-5,++h)}else cc.log("cc.MenuPassive.alignItemsInColumns(): can't have zero rows on a column");g=cc.director.getWinSize();k=h=0;n=null;f=-f/2;var r=0;if(this._children&&0<this._children.length)for(c=0;c<this._children.length;c++)this._children[c]&&(null==n&&(n=b[h],r=e[h]),p=this._children[c].getContentSize().width,k=0|(k>=p||null==p?k:p),this._children[c].setPosition(f+d[h]/2,r-
g.height/2),r-=this._children[c].getContentSize().height+10,++m,m>=n&&(f+=k+5,k=n=m=0,++h))},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(.5,.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+.5*this._background.getBoundingBox().width,c=this._startPos.y+.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=.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+
.5*this._background.getBoundingBox().width,c=this._startPos.y+.5*this._background.getBoundingBox().height;b=a.x-b;c=a.y-c;return Math.sqrt(b*b+c*c)<=.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;cc.defineGetterSetter(_p,"saturation",_p.getSaturation);cc.defineGetterSetter(_p,"brightness",_p.getBrightness);cc.defineGetterSetter(_p,"background",_p.getBackground);cc.defineGetterSetter(_p,"overlay",_p.getOverlay);cc.defineGetterSetter(_p,"shadow",_p.getShadow);cc.defineGetterSetter(_p,"slider",_p.getSlider);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();
a=this._startPos.x+.5*b.width;var c=this._startPos.y+.5*b.height;b=.5*b.width-15;var d=cc.degreesToRadians(360*this._huePercentage-180);this._slider.setPosition(a+b*Math.cos(d),c+b*Math.sin(d))},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(.5,.5)),this._slider.setPosition(b.x,b.y+.5*this._background.getBoundingBox().height),this._startPos=b,this._huePercentage=this._hue=0,!0):!1},_updateSliderPosition:function(a){var b=this._background.getBoundingBox();a=cc.radiansToDegrees(Math.atan2(a.y-(this._startPos.y+.5*b.height),a.x-(this._startPos.x+
.5*b.width)))+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;
cc.defineGetterSetter(_p,"hue",_p.getHue,_p.setHue);cc.defineGetterSetter(_p,"huePercent",_p.getHuePercentage,_p.setHuePercentage);cc.defineGetterSetter(_p,"background",_p.getBackground);cc.defineGetterSetter(_p,"slider",_p.getSlider);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(.5,.5));var b=cc.pSub(this._background.getPosition(),cc.p(this._background.getContentSize().width/2,this._background.getContentSize().height/
2));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());
return!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;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){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();b.width+=this._thumbSprite.getContentSize().width;b.x-=this._thumbSprite.getContentSize().width/2;return cc.rectContainsPoint(b,a)},locationFromTouch:function(a){a=a.getLocation();a=this.convertToNodeSpace(a);0>a.x?a.x=0:a.x>this._backgroundSprite.getContentSize().width&&(a.x=this._backgroundSprite.getContentSize().width);return 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(.5,.5),this._backgroundSprite.setPosition(a.width/2,a.height/2),this.addChild(this._backgroundSprite),this._progressSprite.setAnchorPoint(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();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);return a},onTouchBegan:function(a,b){if(!this.isTouchInside(a)||!this.isEnabled()||!this.isVisible())return!1;var c=this.locationFromTouch(a);this.sliderBegan(c);return!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;cc.defineGetterSetter(_p,"value",_p.getValue,_p.setValue);cc.defineGetterSetter(_p,"minValue",_p.getMinimumValue,_p.setMinimumValue);cc.defineGetterSetter(_p,"maxValue",_p.getMaximumValue,_p.setMaximumValue);cc.defineGetterSetter(_p,"minAllowedValue",_p.getMinimumAllowedValue,_p.setMinimumAllowedValue);
cc.defineGetterSetter(_p,"maxAllowedValue",_p.getMaximumAllowedValue,_p.setMaximumAllowedValue);cc.defineGetterSetter(_p,"thumbSprite",_p.getThumbSprite);cc.defineGetterSetter(_p,"progressSprite",_p.getProgressSprite);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 Error("cc.ControlSwitch.initWithMaskSprite(): maskSprite should be non-null.");if(!b)throw Error("cc.ControlSwitch.initWithMaskSprite(): onSprite should be non-null.");if(!c)throw Error("cc.ControlSwitch.initWithMaskSprite(): offSprite should be non-null.");
if(!d)throw Error("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(.5,.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(.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 a=this.convertToNodeSpace(a)},onTouchBegan:function(a,b){if(!this.isTouchInside(a)||!this.isEnabled()||!this.isVisible())return!1;this._moved=!1;this._initialTouchXPosition=this.locationFromTouch(a).x-this._switchSprite.getSliderXPosition();this._switchSprite.getThumbSprite().setColor(cc.color.GRAY);this._switchSprite.needsLayout();return!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(.5,.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;
cc.defineGetterSetter(_p,"sliderX",_p.getSliderXPosition,_p.setSliderXPosition);cc.defineGetterSetter(_p,"onPos",_p.getOnPosition,_p.setOnPosition);cc.defineGetterSetter(_p,"offPos",_p.getOffPosition,_p.setOffPosition);cc.defineGetterSetter(_p,"maskTexture",_p.getMaskTexture,_p.setMaskTexture);cc.defineGetterSetter(_p,"maskPos",_p.getMaskLocation,_p.setMaskLocation);cc.defineGetterSetter(_p,"onSprite",_p.getOnSprite,_p.setOnSprite);cc.defineGetterSetter(_p,"offSprite",_p.getOffSprite,_p.setOffSprite);
cc.defineGetterSetter(_p,"thumbSprite",_p.getThumbSprite,_p.setThumbSprite);cc.defineGetterSetter(_p,"onLabel",_p.getOnLabel,_p.setOnLabel);cc.defineGetterSetter(_p,"offLabel",_p.getOffLabel,_p.setOffLabel);cc.defineGetterSetter(_p,"onSideWidth",_p._getOnSideWidth);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=.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 Error("cc.ControlStepper.initWithMinusSpriteAndPlusSprite(): Minus sprite should be non-null.");if(!b)throw Error("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());this.setContentSize(this._minusSprite.getContentSize().width+this._plusSprite.getContentSize().height,c.height);return!0}return!1},setWraps:function(a){if(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 Error("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 Error("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 Error("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);this.updateLayoutUsingTouchLocation(c);this._touchInsideFlag=!0;this._autorepeat&&this.startAutorepeat();return!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){this._minusSprite.setColor(cc.color.WHITE);this._plusSprite.setColor(cc.color.WHITE);this._autorepeat&&this.stopAutorepeat();if(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;cc.defineGetterSetter(_p,"wraps",_p.getWraps,_p.setWraps);
cc.defineGetterSetter(_p,"value",_p.getValue,_p.setValue);cc.defineGetterSetter(_p,"minValue",_p.getMinimumValue,_p.setMinimumValue);cc.defineGetterSetter(_p,"maxValue",_p.getMaximumValue,_p.setMaximumValue);cc.defineGetterSetter(_p,"stepValue",_p.getStepValue,_p.setStepValue);cc.defineGetterSetter(_p,"continuous",_p.isContinuous);cc.defineGetterSetter(_p,"minusSprite",_p.getMinusSprite,_p.setMinusSprite);cc.defineGetterSetter(_p,"plusSprite",_p.getPlusSprite,_p.setPlusSprite);
cc.defineGetterSetter(_p,"minusLabel",_p.getMinusLabel,_p.setMinusLabel);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){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){if(!this.isTouchInside(a)||!this.isEnabled()||!this.isVisible())return!1;this._previousLocation=this.getTouchLocation(a);this.potentiometerBegan(this._previousLocation);
return!0},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){return 180*(Math.atan2(b.x-a.x,b.y-a.y)-Math.atan2(d.x-c.x,d.y-c.y))/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;cc.defineGetterSetter(_p,"value",_p.getValue,_p.setValue);cc.defineGetterSetter(_p,"minValue",_p.getMinimumValue,_p.setMinimumValue);cc.defineGetterSetter(_p,"maxValue",_p.getMaximumValue,_p.setMaximumValue);
cc.defineGetterSetter(_p,"progressTimer",_p.getProgressTimer,_p.setProgressTimer);cc.defineGetterSetter(_p,"thumbSprite",_p.getThumbSprite,_p.setThumbSprite);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=.95,SCROLL_DEACCEL_DIST=1,BOUNCE_DURATION=.15,INSET_RATIO=.2,MOVE_INCH=.04375,BOUNCE_BACK_FACTOR=.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)?
(b||this._container||(b=new cc.Layer),b&&this.setContainer(b),this.setViewSize(a),this.setTouchEnabled(!0),this._touches.length=0,this._delegate=null,this._clippingToBounds=this._bounceable=!0,this._direction=cc.SCROLLVIEW_DIRECTION_BOTH,this._container.setPosition(c),this._touchLength=0,this._minScale=this._maxScale=1,!0):!1},visit:function(a){var b=this._renderCmd,c=a?a._renderCmd:null;if(this._visible){a=cc.renderer;b.visit(c);this._clippingToBounds&&a.pushRenderCommand(b.startCmd);var d=this._children,
e=d.length;if(0<e)for(this._reorderChildDirty&&this.sortAllChildren(),c=0;c<e;c++)d[c].visit(this);this._clippingToBounds&&a.pushRenderCommand(b.endCmd);b._dirtyFlag=0}else b._propagateFlagsDown(c)},setContentOffset:function(a,b){if(b)this.setContentOffsetInDuration(a,BOUNCE_DURATION);else{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)this.setZoomScaleInDuration(a,BOUNCE_DURATION);else{var c=this._container;if(c.getScale()!==a){if(0===this._touchLength){var d=this._viewSize;
d=cc.p(.5*d.width,.5*d.height);d=this.convertToWorldSpace(d)}else d=this._touchPoint;var e=c.convertToNodeSpace(d);c.setScale(Math.max(this._minScale,Math.min(this._maxScale,a)));e=c.convertToWorldSpace(e);d=cc.pSub(d,e);this._delegate&&this._delegate.scrollViewDidZoom&&this._delegate.scrollViewDidZoom(this);this.setContentOffset(cc.pAdd(c.getPosition(),d))}}},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;b<c;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){for(var c=this;null!=c;c=c.parent)if(!c.isVisible())return!1;
c=this._getViewRect();var d=this._container,e=d.convertToWorldSpace(d.convertTouchToNodeSpace(a)),f=this._touches;if(2<f.length||this._touchMoved||!cc.rectContainsPoint(c,e))return!1;f.push(a);1===f.length?(this._touchPoint=this.convertTouchToNodeSpace(a),this._touchMoved=!1,this._dragging=!0,this._scrollDistance.x=0,this._touchLength=this._scrollDistance.y=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);return!0},onTouchMoved:function(a,b){if(this.isVisible())if(this.setNodeDirty(),1===this._touches.length&&this._dragging){this._touchMoved=!0;this._getViewRect();var c=this.convertTouchToNodeSpace(a),d=cc.pSub(c,this._touchPoint),e=this._direction;if(e===cc.SCROLLVIEW_DIRECTION_VERTICAL){var f=d.y;var g=this._container.getPositionY();this.minContainerOffset().y<=g&&g<=this.maxContainerOffset().y||(d.y*=BOUNCE_BACK_FACTOR)}else if(e===cc.SCROLLVIEW_DIRECTION_HORIZONTAL)f=
d.x,g=this._container.getPositionX(),this.minContainerOffset().x<=g&&g<=this.maxContainerOffset().x||(d.x*=BOUNCE_BACK_FACTOR);else{f=Math.sqrt(d.x*d.x+d.y*d.y);g=this._container.getPositionY();var h=this.minContainerOffset(),k=this.maxContainerOffset();h.y<=g&&g<=k.y||(d.y*=BOUNCE_BACK_FACTOR);g=this._container.getPositionX();h.x<=g&&g<=k.x||(d.x*=BOUNCE_BACK_FACTOR)}if(this._touchMoved||!(Math.abs(cc.convertDistanceFromPointToInch(f))<MOVE_INCH))if(this._touchMoved||(d.x=0,d.y=0),this._touchPoint=
c,this._touchMoved=!0,this._dragging){switch(e){case cc.SCROLLVIEW_DIRECTION_VERTICAL:d.x=0;break;case cc.SCROLLVIEW_DIRECTION_HORIZONTAL:d.y=0}f=this._container.getPosition();c=f.x+d.x;f=f.y+d.y;this._scrollDistance=d;this.setContentOffset(cc.p(c,f))}}else 2!==this._touches.length||this._dragging||(d=cc.pDistance(this._container.convertTouchToNodeSpace(this._touches[0]),this._container.convertTouchToNodeSpace(this._touches[1])),this.setZoomScale(this.getZoomScale()*d/this._touchLength))},onTouchEnded:function(a,
b){this.isVisible()&&(1===this._touches.length&&this._touchMoved&&this.schedule(this._deaccelerateScrolling),this._touches.length=0,this._touchMoved=this._dragging=!1)},onTouchCancelled:function(a,b){this.isVisible()&&(this._touches.length=0,this._touchMoved=this._dragging=!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},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;if(d===cc.SCROLLVIEW_DIRECTION_BOTH||d===cc.SCROLLVIEW_DIRECTION_HORIZONTAL)f=Math.max(f,b.x),f=Math.min(f,c.x);if(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)this.unschedule(this._deaccelerateScrolling);
else{var b=this._container.getPosition();a=this._scrollDistance;this._container.setPosition(b.x+a.x,b.y+a.y);if(this._bounceable){b=this._maxInset;var c=this._minInset}else 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));if(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){this._dragging?this.unschedule(this._performedAnimatedScroll):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;e.x=a.x;e.y=a.y;e.width=b.width*c;e.height=b.height*d;return e},_createRenderCmd:function(){return cc._renderType===cc.game.RENDER_TYPE_CANVAS?new cc.ScrollView.CanvasRenderCmd(this):new cc.ScrollView.WebGLRenderCmd(this)}});_p=cc.ScrollView.prototype;
cc.defineGetterSetter(_p,"minOffset",_p.minContainerOffset);cc.defineGetterSetter(_p,"maxOffset",_p.maxContainerOffset);cc.defineGetterSetter(_p,"bounceable",_p.isBounceable,_p.setBounceable);cc.defineGetterSetter(_p,"viewSize",_p.getViewSize,_p.setViewSize);cc.defineGetterSetter(_p,"container",_p.getContainer,_p.setContainer);cc.defineGetterSetter(_p,"direction",_p.getDirection,_p.setDirection);cc.defineGetterSetter(_p,"delegate",_p.getDelegate,_p.setDelegate);
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){this._layerCmdCtor(a);this._needDraw=!1;this.startCmd=new cc.CustomRenderCmd(this,this._startCmd);this.startCmd._canUseDirtyRegion=!0;this.endCmd=new cc.CustomRenderCmd(this,this._endCmd);this.endCmd._canUseDirtyRegion=!0};var a=cc.ScrollView.CanvasRenderCmd.prototype=Object.create(cc.Layer.CanvasRenderCmd.prototype);a.constructor=cc.ScrollView.CanvasRenderCmd;a._startCmd=function(a,c,d){var b=this._node,f=a||cc._renderContext;a=f.getContext();
f.save();b._clippingToBounds&&(this._scissorRestored=!1,f.setTransform(this._worldTransform,c,d),d=b.getScaleX(),c=b.getScaleY(),d*=b._viewSize.width,b=b._viewSize.height*c,a.beginPath(),a.rect(0,0,d,-b),a.closePath(),a.clip())};a._endCmd=function(a){a=a||cc._renderContext;a.restore()}})();(function(){cc.ScrollView.WebGLRenderCmd=function(a){this._layerCmdCtor(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)){a=a._parentScissorRect;var e=Math.max(d.x,a.x),f=Math.max(d.y,a.y);c.setScissorInPoints(e,f,Math.min(d.x+d.width,a.x+a.width)-e,Math.min(d.y+d.height,a.y+a.height)-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))}})();/*
 Removes an object in array.

 Removes an object with given key and value. If no object is found in array
 with the key and value, no action is taken.

 @function
 @param {Object} delObject    Object to remove
 Sets a new value of the key for the given object.

 In case where sorting value must be changed, this message must be sent to
 keep consistency of being sorted. If it is changed externally, it must be
 sorted completely again.

 @function
 @param {Number} tag          Tag to set
 @param {Object} setObject    The object which would be set
 Returns an object with given key and value.

 Returns an object with given key and value. If no object is found,
 it returns nil.

 @function
 @param {Number} tag  Tag to locate object
 @return {Object|null}
 Returns an index of the object with given key and value.

 Returns the index of an object with given key and value.
 If no object is found, it returns an index at which the given object value
 would have been located. If object must be located at the end of array,
 it returns the length of the array, which is out of bound.

 @function
 @param {Number} idxObj   Id to locate object
 @return {Number} index of an object found
*/
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 Error("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);c<this.count()&&c!==cc.INVALID_INDEX&&(b=this.objectAtIndex(c),b.getObjectID()!==a&&(b=null));return 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&&a<f)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;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&&a<=g)return e;a<f?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);-1!==b&&(b=Math.max(0,b),b>a&&(b=cc.INVALID_INDEX));
return 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);this._vOrdering===cc.TABLEVIEW_FILL_TOPDOWN&&(b.y=this.getContainer().getContentSize().height-b.y-a.height);return b},_updateCellPositions:function(){var a=this._dataSource.numberOfCellsInTableView(this),
b=this._cellsPositions;if(0<a){for(var c=0,d,e=this._dataSource,f=0;f<a;f++)switch(b[f]=c,d=e.tableCellSizeForIndex(this,f),this.getDirection()){case cc.SCROLLVIEW_DIRECTION_HORIZONTAL:c+=d.width;break;default:c+=d.height}this._cellsPositions[a]=c}},_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._direction===cc.SCROLLVIEW_DIRECTION_HORIZONTAL?this.setContentOffset(cc.p(0,0)):this.setContentOffset(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();d<e;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);this.setNodeDirty()},dequeueCell:function(){if(0===this._cellsFreed.count())return null;var a=this._cellsFreed.objectAtIndex(0);this._cellsFreed.removeObjectAtIndex(0);return 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=this._viewSize,d=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+=c.height/d.getScaleY());a=this._indexFromOffset(e);a===cc.INVALID_INDEX&&(a=b-1);e.y=this._vOrdering===cc.TABLEVIEW_FILL_TOPDOWN?
e.y-c.height/d.getScaleY():e.y+c.height/d.getScaleY();e.x+=c.width/d.getScaleX();c=this._indexFromOffset(e);c===cc.INVALID_INDEX&&(c=b-1);e=this._cellsUsed;if(0<e.count())for(d=e.objectAtIndex(0),b=d.getIdx();b<a;)if(this._moveCellOutOfSight(d),0<e.count())d=e.objectAtIndex(0),b=d.getIdx();else break;if(0<e.count())for(d=e.lastObject(),b=d.getIdx();b<=f&&b>c;)if(this._moveCellOutOfSight(d),0<e.count())d=e.lastObject(),b=d.getIdx();else break;for(f=this._indices;a<=c;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){for(var c=this;null!=c;c=c.parent)if(!c.isVisible())return!1;c=cc.ScrollView.prototype.onTouchBegan.call(this,a,b);if(1===this._touches.length){var d=this.getContainer().convertTouchToNodeSpace(a);d=this._indexFromOffset(d);(this._touchedCell=d===cc.INVALID_INDEX?null:this.cellAtIndex(d))&&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;cc.defineGetterSetter(_p,"dataSource",_p.getDataSource,_p.setDataSource);cc.defineGetterSetter(_p,"delegate",_p.getDelegate,_p.setDelegate);cc.defineGetterSetter(_p,"verticalFillOrder",_p.getVerticalFillOrder,_p.setVerticalFillOrder);_p=null;
cc.TableView.create=function(a,b,c){return new cc.TableView(a,b,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+"'!")};
function BlockData(a,b){this.selMenuHander=a;this.target=b}function BlockCCControlData(a,b,c){this.selCCControlHandler=a;this.target=b;this.controlEvents=c}
cc.NodeLoader=cc.Class.extend({_customProperties:null,_pt:null,_size:null,_arr2:null,ctor:function(){this._customProperties=new cc._Dictionary;this._pt=cc.p();this._size=cc.size();this._arr2=Array(2);this._blockControlData={selCCControlHandler:null,target:null,controlEvents:null}},loadCCNode:function(a,b){return this._createCCNode(a,b)},parseProperties:function(a,b,c){var d=c.readInt(!1),e=c.readInt(!1);e=d+e;for(var f=0;f<e;f++){var g=f>=d,h=c.readInt(!1),k=c.readCachedString(),m=!1,n=c._data[c._currentByte++];
if(n===CCB_PLATFORM_ALL||n===CCB_PLATFORM_IOS||n===CCB_PLATFORM_MAC)m=!0;g&&(a.ccbFileNode?(a=a.ccbFileNode,m=-1!==a.userObject.indexOf(k)):a===c._animationManager.getRootNode()&&(g=a.userObject,g||(g=[],a.userObject=g),g.push(k)));switch(h){case CCB_PROPTYPE_POSITION:h=this.parsePropTypePosition(a,b,c,k);if(m)this.onHandlePropTypePosition(a,b,k,h,c);break;case CCB_PROPTYPE_POINT:h=this.parsePropTypePoint(a,b,c);if(m)this.onHandlePropTypePoint(a,b,k,h,c);break;case CCB_PROPTYPE_POINTLOCK:h=this.parsePropTypePointLock(a,
b,c);if(m)this.onHandlePropTypePointLock(a,b,k,h,c);break;case CCB_PROPTYPE_SIZE:h=this.parsePropTypeSize(a,b,c);if(m)this.onHandlePropTypeSize(a,b,k,h,c);break;case CCB_PROPTYPE_SCALELOCK:h=this.parsePropTypeScaleLock(a,b,c,k);if(m)this.onHandlePropTypeScaleLock(a,b,k,h,c);break;case CCB_PROPTYPE_FLOATXY:h=this.parsePropTypeFloatXY(a,b,c);if(m)this.onHandlePropTypeFloatXY(a,b,k,h,c);break;case CCB_PROPTYPE_FLOAT:h=this.parsePropTypeFloat(a,b,c);if(m)this.onHandlePropTypeFloat(a,b,k,h,c);break;case CCB_PROPTYPE_DEGREES:h=
this.parsePropTypeDegrees(a,b,c,k);if(m)this.onHandlePropTypeDegrees(a,b,k,h,c);break;case CCB_PROPTYPE_FLOATSCALE:h=this.parsePropTypeFloatScale(a,b,c);if(m)this.onHandlePropTypeFloatScale(a,b,k,h,c);break;case CCB_PROPTYPE_INTEGER:h=this.parsePropTypeInteger(a,b,c);if(m)this.onHandlePropTypeInteger(a,b,k,h,c);break;case CCB_PROPTYPE_INTEGERLABELED:h=this.parsePropTypeIntegerLabeled(a,b,c);if(m)this.onHandlePropTypeIntegerLabeled(a,b,k,h,c);break;case CCB_PROPTYPE_FLOATVAR:h=this.parsePropTypeFloatVar(a,
b,c);if(m)this.onHandlePropTypeFloatVar(a,b,k,h,c);break;case CCB_PROPTYPE_CHECK:h=this.parsePropTypeCheck(a,b,c,k);if(m)this.onHandlePropTypeCheck(a,b,k,h,c);break;case CCB_PROPTYPE_SPRITEFRAME:h=this.parsePropTypeSpriteFrame(a,b,c,k);if(m)this.onHandlePropTypeSpriteFrame(a,b,k,h,c);break;case CCB_PROPTYPE_ANIMATION:h=this.parsePropTypeAnimation(a,b,c);if(m)this.onHandlePropTypeAnimation(a,b,k,h,c);break;case CCB_PROPTYPE_TEXTURE:h=this.parsePropTypeTexture(a,b,c);if(m)this.onHandlePropTypeTexture(a,
b,k,h,c);break;case CCB_PROPTYPE_BYTE:h=this.parsePropTypeByte(a,b,c,k);if(m)this.onHandlePropTypeByte(a,b,k,h,c);break;case CCB_PROPTYPE_COLOR3:h=this.parsePropTypeColor3(a,b,c,k);if(m)this.onHandlePropTypeColor3(a,b,k,h,c);break;case CCB_PROPTYPE_COLOR4VAR:h=this.parsePropTypeColor4FVar(a,b,c);if(m)this.onHandlePropTypeColor4FVar(a,b,k,h,c);break;case CCB_PROPTYPE_FLIP:h=this.parsePropTypeFlip(a,b,c);if(m)this.onHandlePropTypeFlip(a,b,k,h,c);break;case CCB_PROPTYPE_BLENDMODE:h=this.parsePropTypeBlendFunc(a,
b,c);if(m)this.onHandlePropTypeBlendFunc(a,b,k,h,c);break;case CCB_PROPTYPE_FNTFILE:h=c.getCCBRootPath()+this.parsePropTypeFntFile(a,b,c);if(m)this.onHandlePropTypeFntFile(a,b,k,h,c);break;case CCB_PROPTYPE_FONTTTF:h=this.parsePropTypeFontTTF(a,b,c);if(m)this.onHandlePropTypeFontTTF(a,b,k,h,c);break;case CCB_PROPTYPE_STRING:h=this.parsePropTypeString(a,b,c);if(m)this.onHandlePropTypeString(a,b,k,h,c);break;case CCB_PROPTYPE_TEXT:h=this.parsePropTypeText(a,b,c);if(m)this.onHandlePropTypeText(a,b,k,
h,c);break;case CCB_PROPTYPE_BLOCK:h=this.parsePropTypeBlock(a,b,c);if(m)this.onHandlePropTypeBlock(a,b,k,h,c);break;case CCB_PROPTYPE_BLOCKCCCONTROL:h=this.parsePropTypeBlockCCControl(a,b,c);if(m&&null!=h)this.onHandlePropTypeBlockCCControl(a,b,k,h,c);break;case CCB_PROPTYPE_CCBFILE:h=this.parsePropTypeCCBFile(a,b,c);if(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);cc.getAbsolutePosition(e,f,g,b?b._contentSize:c._animationManager._rootContainerSize,d,this._pt);a.setPosition(this._pt);-1<c._animatedProps.indexOf(d)&&c._animationManager.setBaseValue([e,f,g],a,d);return this._pt},parsePropTypePoint:function(a,b,c){this._pt.x=c.readFloat();this._pt.y=c.readFloat();return this._pt},parsePropTypePointLock:function(a,b,c){this._pt.x=c.readFloat();this._pt.y=
c.readFloat();return this._pt},parsePropTypeSize:function(a,b,c){a=c.readFloat();var d=c.readFloat(),e=c.readInt(!1);b=b?b._contentSize:c._animationManager._rootContainerSize;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.")}this._size.width=a;this._size.height=d;return this._size},parsePropTypeScaleLock:function(a,b,c,d){b=c.readFloat();var e=c.readFloat(),f=c.readInt(!1);-1<c._animatedProps.indexOf(d)&&c._animationManager.setBaseValue([b,e,f],a,d);f===CCB_SCALETYPE_MULTIPLY_RESOLUTION&&(a=cc.BuilderReader.getResolutionScale(),b*=a,e*=a);this._pt.x=b;this._pt.y=e;return this._pt},parsePropTypeFloat:function(a,b,c){return c.readFloat()},
parsePropTypeDegrees:function(a,b,c,d){b=c.readFloat();-1<c._animatedProps.indexOf(d)&&c._animationManager.setBaseValue(b,a,d);return b},parsePropTypeFloatScale:function(a,b,c){a=c.readFloat();c.readInt(!1)===CCB_SCALETYPE_MULTIPLY_RESOLUTION&&(a*=cc.BuilderReader.getResolutionScale());return a},parsePropTypeInteger:function(a,b,c){return c.readInt(!0)},parsePropTypeIntegerLabeled:function(a,b,c){return c.readInt(!0)},parsePropTypeFloatVar:function(a,b,c){this._arr2[0]=c.readFloat();this._arr2[1]=
c.readFloat();return this._arr2},parsePropTypeCheck:function(a,b,c,d){b=!!c._data[c._currentByte++];-1<c._animatedProps.indexOf(d)&&c._animationManager.setBaseValue(b,a,d);return b},parsePropTypeSpriteFrame:function(a,b,c,d){b=c.readCachedString();var e=c.readCachedString();if(e){if(0===b.length){e=c._ccbRootPath+e;b=cc.textureCache.addImage(e);e=b.getContentSize();e=cc.rect(0,0,e.width,e.height);var f=new cc.SpriteFrame(b,e)}else f=cc.spriteFrameCache,b=c._ccbRootPath+b,-1===c._loadedSpriteSheets.indexOf(b)&&
(f.addSpriteFrames(b),c._loadedSpriteSheets.push(b)),f=f.getSpriteFrame(e);-1<c._animatedProps.indexOf(d)&&c._animationManager.setBaseValue(f,a,d)}return f},parsePropTypeAnimation:function(a,b,c){a=c._ccbRootPath+c.readCachedString();c=c.readCachedString();b=null;c=cc.BuilderReader.lastPathComponent(c);a=cc.BuilderReader.lastPathComponent(a);c&&(b=cc.animationCache,b.addAnimations(a),b=b.getAnimation(c));return b},parsePropTypeTexture:function(a,b,c){return(a=c._ccbRootPath+c.readCachedString())?
cc.textureCache.addImage(a):null},parsePropTypeByte:function(a,b,c,d){b=c._data[c._currentByte++];-1<c._animatedProps.indexOf(d)&&c._animationManager.setBaseValue(b,a,d);return b},parsePropTypeColor3:function(a,b,c,d){b=c._data[c._currentByte++];var e=c._data[c._currentByte++],f=c._data[c._currentByte++];b=cc.color(b,e,f);-1<c._animatedProps.indexOf(d)&&c._animationManager.setBaseValue(b,a,d);return 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;var f=0|255*c.readFloat(),g=0|255*c.readFloat(),h=0|255*c.readFloat();c=c.readFloat();this._arr2[0]={r:a,g:b,b:d,a:e};this._arr2[1]={r:f,g:g,b:h,a:1>=c?0|255*c:c};return this._arr2},parsePropTypeFlip:function(a,b,c){this._arr2[0]=!!c._data[c._currentByte++];this._arr2[1]=!!c._data[c._currentByte++];return this._arr2},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._jsControlled)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._animationManager._rootNode:d===CCB_TARGETTYPE_OWNER&&(e=c._owner),null!==e)if(0<b.length)if(a=0,e.onResolveCCBCCMenuItemSelector&&(a=e.onResolveCCBCCMenuItemSelector(e,b)),0===a&&(c=c._ccbSelectorResolver)&&(a=c.onResolveCCBCCMenuItemSelector(e,b)),0===a)cc.log("Skipping selector '"+b+"' since no CCBSelectorResolver is present.");else return new BlockData(a,e);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._jsControlled)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._animationManager._rootNode:
d===CCB_TARGETTYPE_OWNER&&(a=c._owner),null!==a)if(0<b.length)if(d=0,a.onResolveCCBCCControlSelector&&(d=a.onResolveCCBCCControlSelector(a,b)),0===d&&(c=c._ccbSelectorResolver,null!=c&&(d=c.onResolveCCBCCControlSelector(a,b))),0===d)cc.log("Skipping selector '"+b+"' since no CCBSelectorResolver is present.");else return this._blockControlData.selCCControlHandler=d,this._blockControlData.target=a,this._blockControlData.controlEvents=e,this._blockControlData;else cc.log("Unexpected empty selector.");
else cc.log("Unexpected NULL target for selector.");return null},parsePropTypeCCBFile:function(a,b,c){var d=c._ccbRootPath+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=hlddz.convertToDownloadURL(e),e=cc.loader.loadBinarySync(e),cc.loader.cache[d]=e);a.initWithData(e,c._owner);a._animationManager.setRootContainerSize(b._contentSize);a.setAnimationManagers(c._animationManagers);a._animationManager.setOwner(c._owner);
b=a.readFileWithCleanUp(!1);c.setAnimationManagers(a._animationManagers);b&&-1!==a._animationManager._autoPlaySequenceId&&a._animationManager.runAnimations(a._animationManager._autoPlaySequenceId,0);return b},parsePropTypeFloatXY:function(a,b,c){this._pt.x=c.readFloat();this._pt.y=c.readFloat();return this._pt},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.setScale(d.x,d.y):ASSERT_FAIL_UNEXPECTED_PROPERTY(c)},onHandlePropTypeFloatXY:function(a,b,c,d,e){c===PROPERTY_SKEW?(a._skewX=d.x,a._skewY=d.y):(b=c+"X",e=c+"Y",a[b]&&a[e]||ASSERT_FAIL_UNEXPECTED_PROPERTY(c),
a[b](d.x),a[e](d.y))},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.tag=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._visible=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){var c=new cc.Node;c.ccbFileNode=null;return c},onHandlePropTypeCCBFile:function(a,b,c,d,e){c===PROPERTY_CCBFILE?a.ccbFileNode=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.zoomOnTouchDown=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};
PROPERTY_CONTENTSIZE="contentSize";var 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;c.setAnchorPoint(0,0);return 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;c.setContentSize(0,0);return 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;c.setContentSize(0,0);return 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(){null==cc.NodeLoaderLibrary.sSharedCCNodeLoaderLibrary&&(cc.NodeLoaderLibrary.sSharedCCNodeLoaderLibrary=new cc.NodeLoaderLibrary,cc.NodeLoaderLibrary.sSharedCCNodeLoaderLibrary.registerDefaultCCNodeLoaders());return cc.NodeLoaderLibrary.sSharedCCNodeLoaderLibrary};
cc.NodeLoaderLibrary.purgeSharedCCNodeLoaderLibrary=function(){cc.NodeLoaderLibrary.sSharedCCNodeLoaderLibrary=null};cc.NodeLoaderLibrary.newDefaultCCNodeLoaderLibrary=function(){var a=cc.NodeLoaderLibrary.library();a.registerDefaultCCNodeLoaders();return 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.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){this._stringCache=[];this._loadedSpriteSheets=[];this._currentByte=this._currentBit=-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){this._animationManager=new cc.BuilderAnimationManager;
this._data=a;this._bytes=a.length;this._currentByte=this._currentBit=0;this._owner=b;this._animationManager.setRootContainerSize(cc.director.getWinSize());return!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)){b.setRequestHeader("Accept-Charset","x-user-defined");b.send(null);if(200!==b.status)return cc.log(c),null;if(b=cc._convertResponseBodyToText(b.responseBody))d=
this._stringConvertToArray(b),this._fileDataCache[a]=d}else{b.overrideMimeType&&b.overrideMimeType("text/plain; charset=x-user-defined");b.send(null);if(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))&&-1!==a.getAutoPlaySequenceId()&&a.runAnimations(a.getAutoPlaySequenceId(),0);if(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;b.addChild(a);return 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,c=this._data[this._currentByte],d=!!(c&1<<this._currentBit++);!d;)if(b++,d=!!(c&1<<this._currentBit++),8<=this._currentBit&&(this._currentBit=0,this._currentByte++,c=this._data[this._currentByte],this._currentByte>this._data.length))throw Error("out of the data bound");
for(var e=0,f=b-1;0<=f;f--){d=!!(c&1<<this._currentBit++);if(8<=this._currentBit&&(this._currentBit=0,this._currentByte++,c=this._data[this._currentByte],this._currentByte>this._data.length))throw Error("out of the data bound");d&&(e|=1<<f)}e|=1<<b;this._currentBit&&(this._currentBit=0,this._currentByte++);return a?e%2?0|e/2:0|-e/2:e-1},readByte:function(){var a=this._data[this._currentByte];this._currentByte++;return a},readBool:function(){return!!this._data[this._currentByte++]},readFloat:function(){switch(this._data[this._currentByte++]){case CCB_FLOAT0:return 0;
case CCB_FLOAT1:return 1;case CCB_FLOAT_MINUS1:return-1;case CCB_FLOAT05:return.5;case CCB_FLOAT_INTEGER:return this.readInt(!0);default:return this._decodeFloat(23,8)}},_decodeFloat:function(a,b){var c=a+b+1>>3;if(this._currentByte+c>=this._data.length)throw Error("Index out of bound");var d=Math.pow(2,b-1)-1,e=this._readBitsOnly(a+b,1,c),f=this._readBitsOnly(a,b,c),g=0,h=2,k=0;do{var m=this._data[this._currentByte+c-++k-1];var n=a%8||8;for(var p=1<<n;p>>=1;)m&p&&(g+=1/h),h*=2}while(a-=n);this._currentByte+=
c;return f===(d<<1)+1?g?NaN:e?-Infinity:Infinity:(1+-2*e)*(f||g?f?Math.pow(2,f-d)*(1+g):Math.pow(2,-d+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._data[this._currentByte+c-f-1]>>e&(1<<(g?8-e:b))-1;g&&d&&(b+=(this._data[this._currentByte+c-a-1]&(1<<d)-1)<<(g--<<3)-e,a++);for(;g;)b+=this._shl(this._data[this._currentByte+c-a-1],(g--<<3)-e),a++;return b},_shl:function(a,b){for(++b;--b;a=1073741824===((a%=2147483648)&1073741824)?2*a:2*(a-1073741824)+
2147483648);return a},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();this._animationManagers.setObject(this._animationManager,b);a&&this._cleanUpNodeGraph(b);return 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;b<c;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;g<b;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)}a.setCallbackChannel(c);return!0},_readSoundKeyframesForSeq:function(a){var b=this.readInt(!1);if(!b)return!0;for(var c=new cc.BuilderSequenceProperty,d=c.getKeyframes(),e=0;e<b;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)}a.setSoundChannel(c);return!0},_readSequences:function(){for(var a=this._animationManager.getSequences(),b=this.readInt(!1),
c=0;c<b;c++){var d=new cc.BuilderSequence;d.setDuration(this.readFloat());d.setName(this.readCachedString());d.setSequenceId(this.readInt(!1));d.setChainedSequenceId(this.readInt(!0));if(!this._readCallbackKeyframesForSeq(d)||!this._readSoundKeyframesForSeq(d))return!1;a.push(d)}this._animationManager.setAutoPlaySequenceId(this.readInt(!0));return!0},readKeyframe:function(a){var b=new cc.BuilderKeyframe;b.setTime(this.readFloat());var c=this.readInt(!1),d=0,e=null;if(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._data[this._currentByte++]:a===CCB_PROPTYPE_BYTE?e=this._data[this._currentByte++]:a===CCB_PROPTYPE_COLOR3?e=cc.color(this._data[this._currentByte++],this._data[this._currentByte++],this._data[this._currentByte++]):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)));b.setValue(e);return b},_readHeader:function(){if(!this._data)return!1;var a=this._readStringFromBytes(this._currentByte,4,!0);this._currentByte+=4;if("ccbi"!==a)return!1;a=this.readInt(!1);if(a!==CCB_VERSION)return cc.log("WARNING! Incompatible ccbi file version (file: "+a+" reader: "+CCB_VERSION+")"),!1;this._jsControlled=!!this._data[this._currentByte++];this._animationManager._jsControlled=this._jsControlled;return!0},
_readStringFromBytes:function(a,b,c){var d="",e=this._data;if(c)for(c=b-1;0<=c;c--)d+=String.fromCharCode(e[a+c]);else for(c=0;c<b;c++)d+=String.fromCharCode(e[a+c]);return d},_readStringCache:function(){for(var a=this.readInt(!1),b=0;b<a;b++)this._readStringCacheEntry();return!0},_readStringCacheEntry:function(){var a=this._data[this._currentByte++],b=this._data[this._currentByte++];a=a<<8|b;b="";for(var c=this._data,d=this._currentByte,e=0;e<a;e++){var f=c[d+e].toString("16").toUpperCase();f=1<
f.length?f:"0"+f;b+="%"+f}b=decodeURIComponent(b);this._currentByte+=a;this._stringCache.push(b)},_readNodeGraph:function(a){var b=this.readCachedString(),c,d=this._jsControlled,e=this._animationManager;d&&(c=this.readCachedString());var f=this.readInt(!1),g;f!==CCB_TARGETTYPE_NONE&&(g=this.readCachedString());(b=this._ccNodeLoaderLibrary.getCCNodeLoader(b))||(b=this._ccNodeLoaderLibrary.getCCNodeLoader("CCNode"));var h=b.loadCCNode(a,this);e.getRootNode()||e.setRootNode(h);d&&h===e.getRootNode()&&
e.setDocumentControllerName(c);var k=new cc._Dictionary,m=this._animatedProps=[],n=this.readInt(!1);for(c=0;c<n;++c){for(var p=this.readInt(!1),r=new cc._Dictionary,t=this.readInt(!1),u=0;u<t;++u){var v=new cc.BuilderSequenceProperty;v.setName(this.readCachedString());v.setType(this.readInt(!1));m.push(v.getName());for(var x=this.readInt(!1),w=v.getKeyframes(),y=0;y<x;++y){var z=this.readKeyframe(v.getType());w.push(z)}r.setObject(v,v.getName())}k.setObject(r,p)}0<k.count()&&e.addNode(h,k);b.parseProperties(h,
a,this);if(a=!!h.ccbFileNode)c=h.ccbFileNode,c.setPosition(h.getPosition()),c.setRotation(h.getRotation()),c.setScaleX(h.getScaleX()),c.setScaleY(h.getScaleY()),c.setTag(h.getTag()),c.setVisible(!0),e.moveAnimationsFromNode(h,c),h.ccbFileNode=null,h=c;k=null;if(f!==CCB_TARGETTYPE_NONE)if(d)f===CCB_TARGETTYPE_DOCUMENTROOT?(e.addDocumentOutletName(g),e.addDocumentOutletNode(h)):(this._ownerOutletNames.push(g),this._ownerOutletNodes.push(h));else if(f===CCB_TARGETTYPE_DOCUMENTROOT?k=e.getRootNode():
f===CCB_TARGETTYPE_OWNER&&(k=this._owner),!k&&(c=!1,k.onAssignCCBMemberVariable&&(c=k.onAssignCCBMemberVariable(k,g,h)),e=this._ccbMemberVariableAssigner,!c&&null!=e&&e.onAssignCCBMemberVariable))e.onAssignCCBMemberVariable(k,g,h);if(0<b.getCustomProperties().length&&!d&&(k=h,null!=k&&null!=k.onAssignCCBCustomProperty))for(g=b.getCustomProperties(),f=g.allKeys(),c=0;c<f.length;c++)if(m=g.objectForKey(f[c]),d=k.onAssignCCBCustomProperty(k,f[c],m),e=this._ccbMemberVariableAssigner,!d&&null!=e&&null!=
e.onAssignCCBCustomProperty)e.onAssignCCBCustomProperty(k,f[c],m);this._animatedProps=null;d=this.readInt(!1);for(c=0;c<d;c++)g=this._readNodeGraph(h),h.addChild(g);if(!a)if(null!=h&&h.onNodeLoaded)h.onNodeLoaded(h,b);else if(null!=this._ccNodeLoaderListener)this._ccNodeLoaderListener.onNodeLoaded(h,b);return h},_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;b.addChild(a);return 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);if(5>a.length||a.toLowerCase().lastIndexOf(".ccbi")!==a.length-5)a+=".ccbi";a=e.readNodeGraphFromFile(a,b,c);if(b){d=e.getOwnerCallbackNames();var f=e.getOwnerCallbackNodes(),g=e.getOwnerCallbackControlEvents();for(c=0;c<d.length;c++){var h=d[c];var k=f[c];var m=g[c];k instanceof cc.ControlButton?k.addTargetWithActionForControlEvents(b,
b[h],m):k.setCallback(b[h],b)}d=e.getOwnerOutletNames();f=e.getOwnerOutletNodes();for(c=0;c<d.length;c++)h=d[c],k=f[c],b[h]=k}d=e.getNodesWithAnimationManagers();e=e.getAnimationManagersForNodes();if(!d||!e)return a;f=cc.BuilderReader._controllerClassCache;for(c=0;c<d.length;c++){var n=d[c];var p=e[c];n.animationManager=p;if(h=p.getDocumentControllerName()){g=f[h];if(!g)throw Error("Can not find controller : "+h);g=new g;g.controllerName=h;n.controller=g;g.rootNode=n;var r=p.getDocumentCallbackNames(),
t=p.getDocumentCallbackNodes(),u=p.getDocumentCallbackControlEvents();for(n=0;n<r.length;n++)h=r[n],k=t[n],m=u[n],k instanceof cc.ControlButton?k.addTargetWithActionForControlEvents(g,g[h],m):k.setCallback(g[h],g);m=p.getDocumentOutletNames();r=p.getDocumentOutletNodes();for(n=0;n<m.length;n++)h=m[n],k=r[n],g[h]=k;if(g.onDidLoadFromCCB&&cc.isFunction(g.onDidLoadFromCCB))g.onDidLoadFromCCB();h=p.getKeyframeCallbacks();for(n=0;n<h.length;n++)m=h[n].split(":"),k=m[0],m=m[1],1==k?p.setCallFunc(cc.callFunc(g[m],
g),h[n]):2==k&&b&&p.setCallFunc(cc.callFunc(b[m],b),h[n])}}p.runAnimations(p.getAutoPlaySequenceId(),0);return a};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.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,e,f){e=f||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 Error("cc.setRelativeScale(): node should be non-null");d===CCB_POSITIONTYPE_MULTIPLY_RESOLUTION&&(d=cc.BuilderReader.getResolutionScale(),b*=d,c*=d);a.setScale(b,c)};(function(){var a=cc.p();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(){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={};return!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,c){this._nodeSequences.setObject(c,a)},setBaseValue:function(a,c,d){var b=this._baseValues.objectForKey(c);b||(b=new cc._Dictionary,this._baseValues.setObject(b,c));b.setObject(a,d)},moveAnimationsFromNode:function(a,
c){var b=this._baseValues,e=b.objectForKey(a);null!==e&&(b.setObject(e,c),b.removeObjectForKey(a));b=this._nodeSequences;e=b.objectForKey(a);null!=e&&(b.setObject(e,c),b.removeObjectForKey(a))},getActionForCallbackChannel:function(a){var b=0,d=[];a=a.getKeyframes();for(var e=a.length,f=0;f<e;++f){var g=a[f],h=g.getTime()-b;b=g.getTime();0<h&&d.push(cc.delayTime(h));h=g.getValue();g=h[0];h=h[1];if(this._jsControlled)g=this._keyframeCallFuncs[h+":"+g],null!=g&&d.push(g);else{if(h===CCB_TARGETTYPE_DOCUMENTROOT)var k=
this._rootNode;else h===CCB_TARGETTYPE_OWNER&&(k=this._owner);null!=k&&(0<g.length?(h=0,null!=k.onResolveCCBCCCallFuncSelector&&(h=k.onResolveCCBCCCallFuncSelector(k,g)),0===h?cc.log("Skipping selector '"+g+"' since no CCBSelectorResolver is present."):d.push(cc.callFunc(h,k))):cc.log("Unexpected empty selector."))}}return 1>d.length?null:cc.sequence(d)},getActionForSoundChannel:function(a){var b=0,d=[];a=a.getKeyframes();for(var e=a.length,f=0;f<e;++f){var g=a[f],h=g.getTime()-b;b=g.getTime();0<
h&&d.push(cc.delayTime(h));var k=g.getValue();g=cc.BuilderReader.getResourcePath()+k[0];h=parseFloat(k[1]);var m=parseFloat(k[2]);k=parseFloat(k[3]);d.push(cc.BuilderSoundEffect.create(g,h,m,k))}return 1>d.length?null:cc.sequence(d)},runAnimationsForSequenceNamed:function(a){this.runAnimationsForSequenceIdTweenDuration(this._getSequenceId(a),0)},runAnimationsForSequenceNamedTweenDuration:function(a,c){this.runAnimationsForSequenceIdTweenDuration(this._getSequenceId(a),c)},runAnimationsForSequenceIdTweenDuration:function(a,
c){if(-1===a)throw Error("cc.BuilderAnimationManager.runAnimationsForSequenceIdTweenDuration(): Sequence id should not be -1");c=c||0;this._rootNode.stopAllActions();for(var b=this._nodeSequences.allKeys(),e=0,f=b.length;e<f;e++){var g=b[e];g.stopAllActions();var h=this._nodeSequences.objectForKey(g).objectForKey(a),k,m=[];if(h){var n=h.allKeys();for(k=0;k<n.length;k++){var p=n[k],r=h.objectForKey(p);m.push(p);this._setFirstFrame(g,r,c);this._runAction(g,r,c)}}if(h=this._baseValues.objectForKey(g))for(n=
h.allKeys(),k=0;k<n.length;k++)p=n[k],-1===m.indexOf(p)&&(r=h.objectForKey(p),null!=r&&this._setAnimatedProperty(p,g,r,c))}b=this._getSequence(a);e=cc.sequence(cc.delayTime(b.getDuration()+c),cc.callFunc(this._sequenceCompleted,this));this._rootNode.runAction(e);b.getCallbackChannel()&&(e=this.getActionForCallbackChannel(b.getCallbackChannel()))&&this._rootNode.runAction(e);b.getSoundChannel()&&(e=this.getActionForSoundChannel(b.getSoundChannel()))&&this._rootNode.runAction(e);this._runningSequence=
this._getSequence(a)},runAnimations:function(a,c){c=c||0;var b=cc.isString(a)?this._getSequenceId(a):a;this.runAnimationsForSequenceIdTweenDuration(b,c)},setAnimationCompletedCallback:function(a,c){this._target=a;this._animationCompleteCallbackFunc=c},setCompletedAnimationCallback:function(a,c){this.setAnimationCompletedCallback(a,c)},setCallFunc:function(a,c){this._keyframeCallFuncs[c]=a},debug:function(){},_getBaseValue:function(a,c){var b=this._baseValues.objectForKey(a);return b?b.objectForKey(c):
null},_getSequenceId:function(a){for(var b,d=this._sequences,e=0,f=d.length;e<f;e++)if((b=d[e])&&b.getName()===a)return b.getSequenceId();return-1},_getSequence:function(a){for(var b,d=this._sequences,e=0,f=d.length;e<f;e++)if((b=d[e])&&b.getSequenceId()===a)return b;return null},_getAction:function(a,c,d,e){a=c.getTime()-(a?a.getTime():0);if("rotation"===d)return cc.BuilderRotateTo.create(a,c.getValue());if("rotationX"===d)return cc.BuilderRotateXTo.create(a,c.getValue());if("rotationY"===d)return cc.BuilderRotateYTo.create(a,
c.getValue());if("opacity"===d)return cc.fadeTo(a,c.getValue());if("color"===d)return d=c.getValue(),cc.tintTo(a,d.r,d.g,d.b);if("visible"===d)return c.getValue()?cc.sequence(cc.delayTime(a),cc.show()):cc.sequence(cc.delayTime(a),cc.hide());if("displayFrame"===d)return cc.sequence(cc.delayTime(a),cc.BuilderSetSpriteFrame.create(c.getValue()));if("position"===d){var b=this._getBaseValue(e,d);b=b[2];var g=c.getValue();c=g[0];g=g[1];e=this.getContainerSize(e.getParent());d=cc.getAbsolutePosition(c,g,
b,e,d);return cc.moveTo(a,d)}if("scale"===d)return b=this._getBaseValue(e,d),b=b[2],g=c.getValue(),c=g[0],g=g[1],b===CCB_SCALETYPE_MULTIPLY_RESOLUTION&&(d=cc.BuilderReader.getResolutionScale(),c*=d,g*=d),cc.scaleTo(a,c,g);if("skew"===d)return g=c.getValue(),c=g[0],g=g[1],cc.skewTo(a,c,g);cc.log("BuilderReader: Failed to create animation for property: "+d);return null},_setAnimatedProperty:function(b,c,d,e){if(0<e){var f=new cc.BuilderKeyframe;f.setValue(d);f.setTime(e);f.setEasingType(CCB_KEYFRAME_EASING_LINEAR);
b=this._getAction(null,f,b,c);c.runAction(b)}else{if("position"===b)e=this._getBaseValue(c,b),e=e[2],f=d[0],d=d[1],cc.getAbsolutePosition(f,d,e,this.getContainerSize(c.getParent()),b,a),c._position.x=a.x,c._position.y=a.y;else if("scale"===b)e=this._getBaseValue(c,b),e=e[2],f=d[0],d=d[1],cc.setRelativeScale(c,f,d,e,b);else if("skew"===b)f=d[0],d=d[1],c._skewX=f,c._skewY=d;else if("rotation"===b)c.setRotation(d);else if("rotationX"===b)c._rotationX=d;else if("rotationY"===b)c._rotationY=d;else if("opacity"===
b)c._realOpacity=d;else if("displayFrame"===b)c.setSpriteFrame(d);else if("color"===b)255===d.r&&255===d.g&&255===d.b||c.setColor(d);else if("visible"===b)c.setVisible(d||!1);else{cc.log("unsupported property name is "+b);return}c.setNodeDirty()}},_setFirstFrame:function(a,c,d){var b=c.getKeyframes();0===b.length?((b=this._getBaseValue(a,c.getName()))||cc.log("cc.BuilderAnimationManager._setFirstFrame(): No baseValue found for property"),this._setAnimatedProperty(c.getName(),a,b,d)):(b=b[0],this._setAnimatedProperty(c.getName(),
a,b.getValue(),d))},_getEaseAction:function(a,c,d){if(c===CCB_KEYFRAME_EASING_LINEAR||c===CCB_KEYFRAME_EASING_INSTANT)return a;if(c===CCB_KEYFRAME_EASING_CUBIC_IN)return a.easing(cc.easeIn(d));if(c===CCB_KEYFRAME_EASING_CUBIC_OUT)return a.easing(cc.easeOut(d));if(c===CCB_KEYFRAME_EASING_CUBIC_INOUT)return a.easing(cc.easeInOut(d));if(c===CCB_KEYFRAME_EASING_BACK_IN)return a.easing(cc.easeBackIn());if(c===CCB_KEYFRAME_EASING_BACK_OUT)return a.easing(cc.easeBackOut());if(c===CCB_KEYFRAME_EASING_BACK_INOUT)return a.easing(cc.easeBackInOut());
if(c===CCB_KEYFRAME_EASING_BOUNCE_IN)return a.easing(cc.easeBounceIn());if(c===CCB_KEYFRAME_EASING_BOUNCE_OUT)return a.easing(cc.easeBounceOut());if(c===CCB_KEYFRAME_EASING_BOUNCE_INOUT)return a.easing(cc.easeBounceInOut());if(c===CCB_KEYFRAME_EASING_ELASTIC_IN)return a.easing(cc.easeElasticIn(d));if(c===CCB_KEYFRAME_EASING_ELASTIC_OUT)return a.easing(cc.easeElasticOut(d));if(c===CCB_KEYFRAME_EASING_ELASTIC_INOUT)return a.easing(cc.easeElasticInOut(d));cc.log("BuilderReader: Unknown easing type "+
c);return a},_runAction:function(a,c,d){var b=c.getKeyframes(),f=b.length;if(1<f){var g=[];d=b[0].getTime()+d;0<d&&g.push(cc.delayTime(d));for(d=0;d<f-1;++d){var h=b[d],k=this._getAction(h,b[d+1],c.getName(),a);k&&(k=this._getEaseAction(k,h.getEasingType(),h.getEasingOpt()),g.push(k))}a.runAction(cc.sequence(g))}},_sequenceCompleted:function(){var a=this._runningSequence,c=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(c);this._target&&this._animationCompleteCallbackFunc&&this._animationCompleteCallbackFunc.call(this._target)}});cc.BuilderSetSpriteFrame=cc.ActionInstant.extend({_spriteFrame:null,initWithSpriteFrame:function(a){this._spriteFrame=a;return!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,c){return cc.ActionInterval.prototype.initWithDuration.call(this,a)?(this._dstAngle=c,!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,c){var b=new cc.BuilderRotateTo;return b&&b.initWithDuration(a,c)?b:null};cc.BuilderRotateXTo=cc.ActionInterval.extend({});cc.BuilderRotateXTo.create=function(a,c){throw Error("rotationX has not been implemented in cocos2d-html5");};cc.BuilderRotateYTo=cc.ActionInterval.extend({});cc.BuilderRotateYTo.create=function(a,c){throw Error("rotationY has not been implemented in cocos2d-html5");};cc.BuilderSoundEffect=cc.ActionInstant.extend({init:function(a){this._file=
a;return!0},update:function(a){cc.audioEngine.playEffect(this._file)}});cc.BuilderSoundEffect.create=function(a,c,d,e){return(c=new cc.BuilderSoundEffect,c.init(a))?c:null}})();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.Node.extend({_backgroundSprite:null,_delegate:null,_editBoxInputMode:cc.EDITBOX_INPUT_MODE_ANY,_editBoxInputFlag:cc.EDITBOX_INPUT_FLAG_SENSITIVE,_keyboardReturnType:cc.KEYBOARD_RETURNTYPE_DEFAULT,_maxLength:50,_text:"",_textColor:null,_placeholderText:"",_placeholderFontName:"",_placeholderFontSize:14,_placeholderColor:null,_className:"EditBox",_touchListener:null,_touchEnabled:!0,ctor:function(a,b){cc.Node.prototype.ctor.call(this);this._anchorPoint=cc.p(.5,.5);this._textColor=cc.color.WHITE;
this._placeholderColor=cc.color.GRAY;this._renderCmd._createLabels();this.createDomElementIfNeeded();this.initWithSizeAndBackgroundSprite(a,b);this._touchListener=cc.EventListener.create({event:cc.EventListener.TOUCH_ONE_BY_ONE,swallowTouches:!0,onTouchBegan:this._onTouchBegan.bind(this),onTouchEnded:this._onTouchEnded.bind(this)});cc.eventManager.addListener(this._touchListener,this);this.setInputFlag(this._editBoxInputFlag)},setTouchEnabled:function(a){this._touchEnabled!==a&&((this._touchEnabled=
a)?cc.eventManager.addListener(this._touchListener,this):cc.eventManager.removeListener(this._touchListener))},_createRenderCmd:function(){return cc._renderType===cc.game.RENDER_TYPE_CANVAS?new cc.EditBox.CanvasRenderCmd(this):new cc.EditBox.WebGLRenderCmd(this)},setContentSize:function(a,b){void 0!==a.width&&void 0!==a.height&&(b=a.height,a=a.width);cc.Node.prototype.setContentSize.call(this,a,b);this._updateEditBoxSize(a,b)},setVisible:function(a){cc.Node.prototype.setVisible.call(this,a);this._renderCmd.updateVisibility()},
createDomElementIfNeeded:function(){this._renderCmd._edTxt||this._renderCmd._createDomTextArea()},setTabIndex:function(a){this._renderCmd._edTxt&&(this._renderCmd._edTxt.tabIndex=a)},getTabIndex:function(){if(this._renderCmd._edTxt)return this._renderCmd._edTxt.tabIndex;cc.warn("The dom control is not created!");return-1},setFocus:function(){this._renderCmd._edTxt&&this._renderCmd._edTxt.focus()},isFocused:function(){if(this._renderCmd._edTxt)return document.activeElement===this._renderCmd._edTxt;
cc.warn("The dom control is not created!");return!1},stayOnTop:function(a){this._alwaysOnTop!==a&&(this._alwaysOnTop=a,this._renderCmd.stayOnTop(this._alwaysOnTop))},cleanup:function(){this._super();this._renderCmd._removeDomFromGameContainer()},_isAncestorsVisible:function(a){return null==a?!0:(a=a.getParent())&&!a.isVisible()?!1:this._isAncestorsVisible(a)},_onTouchBegan:function(a){if(this.isVisible()&&this._isAncestorsVisible(this)){a=a.getLocation();var b=cc.rect(0,0,this._contentSize.width,
this._contentSize.height);if(cc.rectContainsPoint(b,this.convertToNodeSpace(a)))return!0;this._renderCmd._endEditing();return!1}},_onTouchEnded:function(){this.isVisible()&&this._isAncestorsVisible(this)&&this._renderCmd._beginEditing()},_updateBackgroundSpriteSize:function(a,b){this._backgroundSprite&&this._backgroundSprite.setContentSize(a,b)},_updateEditBoxSize:function(a,b){var c="number"===typeof a.width?a.width:a,d="number"===typeof a.height?a.height:b;this._updateBackgroundSpriteSize(c,d);
this._renderCmd.updateSize(c,d)},setLineHeight:function(a){this._renderCmd.setLineHeight(a)},setFont:function(a,b){this._renderCmd.setFont(a,b)},_setFont:function(a){this._renderCmd._setFont(a)},getBackgroundSprite:function(){return this._backgroundSprite},setFontName:function(a){this._renderCmd.setFontName(a)},setFontSize:function(a){this._renderCmd.setFontSize(a)},setString:function(a){a.length>=this._maxLength&&(a=a.slice(0,this._maxLength));this._text=a;this._renderCmd.setString(a)},setFontColor:function(a){this._textColor=
a;this._renderCmd.setFontColor(a)},setMaxLength:function(a){isNaN(a)||(0>a&&(a=65535),this._maxLength=a,this._renderCmd.setMaxLength(a))},getMaxLength:function(){return this._maxLength},setPlaceHolder:function(a){null!==a&&(this._renderCmd.setPlaceHolder(a),this._placeholderText=a)},setPlaceholderFont:function(a,b){this._placeholderFontName=a;this._placeholderFontSize=b;this._renderCmd._updateDOMPlaceholderFontStyle()},_setPlaceholderFont:function(a){if(a=cc.LabelTTF._fontStyleRE.exec(a))this._placeholderFontName=
a[2],this._placeholderFontSize=parseInt(a[1]),this._renderCmd._updateDOMPlaceholderFontStyle()},setPlaceholderFontName:function(a){this._placeholderFontName=a;this._renderCmd._updateDOMPlaceholderFontStyle()},setPlaceholderFontSize:function(a){this._placeholderFontSize=a;this._renderCmd._updateDOMPlaceholderFontStyle()},setPlaceholderFontColor:function(a){this._placeholderColor=a;this._renderCmd.setPlaceholderFontColor(a)},setInputFlag:function(a){this._editBoxInputFlag=a;this._renderCmd.setInputFlag(a)},
getString:function(){return this._text},initWithSizeAndBackgroundSprite:function(a,b){this._backgroundSprite&&this._backgroundSprite.removeFromParent();this._backgroundSprite=b;this.setContentSize(a);this._backgroundSprite&&!this._backgroundSprite.parent&&(this._backgroundSprite.setAnchorPoint(cc.p(0,0)),this.addChild(this._backgroundSprite),this._updateBackgroundSpriteSize(a.width,a.height));this.y=this.x=0;return!0},setDelegate:function(a){this._delegate=a},getPlaceHolder:function(){return this._placeholderText},
setInputMode:function(a){if(this._editBoxInputMode!==a){var b=this.getString();this._editBoxInputMode=a;this._renderCmd.setInputMode(a);this._renderCmd.transform();this.setString(b);this._renderCmd._updateLabelPosition(this.getContentSize())}},setReturnType:function(a){this._keyboardReturnType=a;this._renderCmd._updateDomInputType()},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;cc.defineGetterSetter(_p,"font",null,_p._setFont);cc.defineGetterSetter(_p,"fontName",null,_p.setFontName);cc.defineGetterSetter(_p,"fontSize",null,_p.setFontSize);cc.defineGetterSetter(_p,"fontColor",null,_p.setFontColor);cc.defineGetterSetter(_p,"string",_p.getString,_p.setString);cc.defineGetterSetter(_p,"maxLength",_p.getMaxLength,_p.setMaxLength);cc.defineGetterSetter(_p,"placeholder",_p.getPlaceHolder,_p.setPlaceHolder);
cc.defineGetterSetter(_p,"placeholderFont",null,_p._setPlaceholderFont);cc.defineGetterSetter(_p,"placeholderFontName",null,_p.setPlaceholderFontName);cc.defineGetterSetter(_p,"placeholderFontSize",null,_p.setPlaceholderFontSize);cc.defineGetterSetter(_p,"placeholderFontColor",null,_p.setPlaceholderFontColor);cc.defineGetterSetter(_p,"inputFlag",null,_p.setInputFlag);cc.defineGetterSetter(_p,"delegate",null,_p.setDelegate);cc.defineGetterSetter(_p,"inputMode",null,_p.setInputMode);
cc.defineGetterSetter(_p,"returnType",null,_p.setReturnType);_p=null;cc.EditBox.create=function(a,b,c,d){return new cc.EditBox(a,b,c,d)};(function(a){a._polyfill={zoomInvalid:!1};cc.sys.OS_ANDROID!==cc.sys.os||cc.sys.browserType!==cc.sys.BROWSER_TYPE_SOUGOU&&cc.sys.browserType!==cc.sys.BROWSER_TYPE_360||(a._polyfill.zoomInvalid=!0)})(cc.EditBox);
(function(a){function b(a){var b=a.convertToWorldSpace(cc.p(0,0)),c=cc.visibleRect.height,d=.5;cc.visibleRect.width>c&&(d=.7);setTimeout(function(){if(40>window.scrollY&&b.y<c*d){var a=c*d-b.y-window.scrollY;35>a&&(a=35);320<a&&(a=320);window.scrollTo(a,a)}},400)}var c=function(a){return a.replace(/(?:^|\s)\S/g,function(a){return a.toUpperCase()})},d=function(){}.prototype=Object.create(Object.prototype);d.updateMatrix=function(){if(this._edTxt){var b=this._node,c=cc.view._scaleX,d=cc.view._scaleY,
e=cc.view._devicePixelRatio,m=this._worldTransform;c/=e;d/=e;var n=cc.game.container;e=m.a*c;var p=m.b,r=m.c,t=m.d*d,u=n&&n.style.paddingLeft&&parseInt(n.style.paddingLeft);n=n&&n.style.paddingBottom&&parseInt(n.style.paddingBottom);c=m.tx*c+u;d=m.ty*d+n;a.zoomInvalid&&(this.updateSize(b._contentSize.width*e,b._contentSize.height*t),t=e=1);b="matrix("+e+","+-p+","+-r+","+t+","+c+","+-d+")";this._edTxt.style.transform=b;this._edTxt.style["-webkit-transform"]=b;this._edTxt.style["transform-origin"]=
"0px 100% 0px";this._edTxt.style["-webkit-transform-origin"]="0px 100% 0px"}};d.updateVisibility=function(){this._edTxt&&(this._edTxt.style.visibility=this._node.visible?"visible":"hidden")};d.stayOnTop=function(a){a?(this._removeLabels(),this._edTxt.style.display=""):(this._createLabels(),this._edTxt.style.display="none",this._showLabels())};d._beginEditingOnMobile=function(a){this.__orientationChanged=function(){b(a)};window.addEventListener("orientationchange",this.__orientationChanged);cc.view.isAutoFullScreenEnabled()?
(this.__fullscreen=!0,cc.view.enableAutoFullScreen(!1),cc.screen.exitFullScreen()):this.__fullscreen=!1;this.__autoResize=cc.view.__resizeWithBrowserSize;cc.view.resizeWithBrowserSize(!1)};d._endEditingOnMobile=function(){if(this.__rotateScreen){var a=cc.game.container.style;a["-webkit-transform"]="rotate(90deg)";a.transform="rotate(90deg)";a=cc.view;var b=a._originalDesignResolutionSize.width,c=a._originalDesignResolutionSize.height;0<b&&a.setDesignResolutionSize(b,c,a._resolutionPolicy);this.__rotateScreen=
!1}window.removeEventListener("orientationchange",this.__orientationChanged);window.scrollTo(0,0);this.__fullscreen&&cc.view.enableAutoFullScreen(!0);this.__autoResize&&cc.view.resizeWithBrowserSize(!0)};d._onFocusOnMobile=function(a){if(cc.view._isRotated){var c=cc.game.container.style;c["-webkit-transform"]="rotate(0deg)";c.transform="rotate(0deg)";c.margin="0px";window.scrollTo(35,35);this.__rotateScreen=!0}else this.__rotateScreen=!1;b(a)};d._createDomInput=function(){this._removeDomFromGameContainer();
var a=this,b=this._edTxt=document.createElement("input");b.type="text";b.style.fontFamily=this._edFontName;b.style.fontSize=this._edFontSize+"px";b.style.color="#000000";b.style.border=0;b.style.background="transparent";b.style.width="100%";b.style.height="100%";b.style.active=0;b.style.outline="medium";b.style.padding="0";b.style.textTransform="uppercase";b.style.display="none";b.style.position="absolute";b.style.bottom="0px";b.style.left="2px";b.style.className="cocosEditBox";this.setMaxLength(a._editBox._maxLength);
b.addEventListener("input",function(){var b=a._editBox;this.value.length>this.maxLength&&(this.value=this.value.slice(0,this.maxLength));b._delegate&&b._delegate.editBoxTextChanged&&b._text!==this.value&&(b._text=this.value,a._updateDomTextCases(),b._delegate.editBoxTextChanged(b,b._text))});b.addEventListener("keypress",function(b){var c=a._editBox;b.keyCode===cc.KEY.enter&&(b.stopPropagation(),b.preventDefault(),""===this.value&&(this.style.fontSize=c._placeholderFontSize+"px",this.style.color=
cc.colorToHex(c._placeholderColor)),c._text=this.value,a._updateDomTextCases(),a._endEditing(),c._delegate&&c._delegate.editBoxReturn&&c._delegate.editBoxReturn(c),cc._canvas.focus())});b.addEventListener("focus",function(){var b=a._editBox;this.style.fontSize=a._edFontSize+"px";this.style.color=cc.colorToHex(b._textColor);a._hiddenLabels();cc.sys.isMobile&&a._onFocusOnMobile(b);b._delegate&&b._delegate.editBoxEditingDidBegin&&b._delegate.editBoxEditingDidBegin(b)});b.addEventListener("blur",function(){var b=
a._editBox;b._text=this.value;a._updateDomTextCases();b._delegate&&b._delegate.editBoxEditingDidEnd&&b._delegate.editBoxEditingDidEnd(b);""===this.value&&(this.style.fontSize=b._placeholderFontSize+"px",this.style.color=cc.colorToHex(b._placeholderColor));a._endEditing()});this._addDomToGameContainer();return b};d._createDomTextArea=function(){this._removeDomFromGameContainer();var a=this,b=this._edTxt=document.createElement("textarea");b.type="text";b.style.fontFamily=this._edFontName;b.style.fontSize=
this._edFontSize+"px";b.style.color="#000000";b.style.border=0;b.style.background="transparent";b.style.width="100%";b.style.height="100%";b.style.active=0;b.style.outline="medium";b.style.padding="0";b.style.resize="none";b.style.textTransform="uppercase";b.style.overflow_y="scroll";b.style.display="none";b.style.position="absolute";b.style.bottom="0px";b.style.left="2px";b.style.className="cocosEditBox";this.setMaxLength(a._editBox._maxLength);b.addEventListener("input",function(){this.value.length>
this.maxLength&&(this.value=this.value.slice(0,this.maxLength));var b=a._editBox;b._delegate&&b._delegate.editBoxTextChanged&&b._text.toLowerCase()!==this.value.toLowerCase()&&(b._text=this.value,a._updateDomTextCases(),b._delegate.editBoxTextChanged(b,b._text))});b.addEventListener("focus",function(){var b=a._editBox;a._hiddenLabels();this.style.fontSize=a._edFontSize+"px";this.style.color=cc.colorToHex(b._textColor);cc.sys.isMobile&&a._onFocusOnMobile(b);b._delegate&&b._delegate.editBoxEditingDidBegin&&
b._delegate.editBoxEditingDidBegin(b)});b.addEventListener("keypress",function(b){var c=a._editBox;b.keyCode===cc.KEY.enter&&(b.stopPropagation(),c._delegate&&c._delegate.editBoxReturn&&c._delegate.editBoxReturn(c))});b.addEventListener("blur",function(){var b=a._editBox;b._text=this.value;a._updateDomTextCases();b._delegate&&b._delegate.editBoxEditingDidEnd&&b._delegate.editBoxEditingDidEnd(b);""===this.value&&(this.style.fontSize=b._placeholderFontSize+"px",this.style.color=cc.colorToHex(b._placeholderColor));
a._endEditing()});this._addDomToGameContainer();return b};d._createLabels=function(){var a=this._editBox.getContentSize();this._textLabel||(this._textLabel=new cc.LabelTTF,this._textLabel.setAnchorPoint(cc.p(0,1)),this._editBox.addChild(this._textLabel,100));this._placeholderLabel||(this._placeholderLabel=new cc.LabelTTF,this._placeholderLabel.setAnchorPoint(cc.p(0,1)),this._placeholderLabel.setColor(cc.color.GRAY),this._editBox.addChild(this._placeholderLabel,100));this._updateLabelPosition(a)};
d._removeLabels=function(){this._textLabel&&(this._editBox.removeChild(this._textLabel),this._textLabel=null)};d._updateLabelPosition=function(a){if(this._textLabel&&this._placeholderLabel){var b=cc.size(a.width-2,a.height);this._textLabel.setContentSize(b);this._textLabel.setDimensions(b);this._placeholderLabel.setLineHeight(a.height);b=this._placeholderLabel.getContentSize();this._editBox._editBoxInputMode===cc.EDITBOX_INPUT_MODE_ANY?(this._textLabel.setPosition(2,a.height),this._placeholderLabel.setPosition(2,
a.height),this._placeholderLabel.setVerticalAlignment(cc.VERTICAL_TEXT_ALIGNMENT_TOP),this._textLabel.setVerticalAlignment(cc.VERTICAL_TEXT_ALIGNMENT_TOP)):(this._textLabel.setPosition(2,a.height),this._placeholderLabel.setPosition(2,(a.height+b.height)/2),this._placeholderLabel.setVerticalAlignment(cc.VERTICAL_TEXT_ALIGNMENT_CENTER),this._textLabel.setVerticalAlignment(cc.VERTICAL_TEXT_ALIGNMENT_CENTER))}};d.setLineHeight=function(a){this._textLabel&&this._textLabel.setLineHeight(a)};d._hiddenLabels=
function(){this._textLabel&&this._textLabel.setVisible(!1);this._placeholderLabel&&this._placeholderLabel.setVisible(!1)};d._updateDomTextCases=function(){var a=this._editBox._editBoxInputFlag;if(a===cc.EDITBOX_INPUT_FLAG_INITIAL_CAPS_ALL_CHARACTERS)this._editBox._text=this._editBox._text.toUpperCase();else if(a===cc.EDITBOX_INPUT_FLAG_INITIAL_CAPS_WORD)this._editBox._text=c(this._editBox._text);else if(a===cc.EDITBOX_INPUT_FLAG_INITIAL_CAPS_SENTENCE){a=this._editBox;var b=this._editBox._text;b=b.charAt(0).toUpperCase()+
b.slice(1);a._text=b}};d._updateLabelStringStyle=function(){if("password"===this._edTxt.type){for(var a="",b=this._editBox._text.length,c=0;c<b;++c)a+="●";this._textLabel&&this._textLabel.setString(a)}else this._updateDomTextCases(),this._textLabel&&this._textLabel.setString(this._editBox._text)};d._showLabels=function(){this._hiddenLabels();""===this._edTxt.value?this._placeholderLabel&&(this._placeholderLabel.setVisible(!0),this._placeholderLabel.setString(this._editBox._placeholderText)):this._textLabel&&
(this._textLabel.setVisible(!0),this._textLabel.setString(this._editBox._text));this._updateLabelStringStyle()};d._beginEditing=function(){this._editBox._alwaysOnTop||"none"!==this._edTxt.style.display||(this._edTxt.style.display="",this._edTxt.focus());cc.sys.isMobile&&!this._editingMode&&this._beginEditingOnMobile(this._editBox);this._editingMode=!0};d._endEditing=function(){this._editBox._alwaysOnTop||(this._edTxt.style.display="none");this._showLabels();if(cc.sys.isMobile&&this._editingMode){var a=
this;setTimeout(function(){a._endEditingOnMobile()},400)}this._editingMode=!1};d._setFont=function(a){a=cc.LabelTTF._fontStyleRE.exec(a);var b=a[2],c=parseInt(a[1]);a&&this.setFont(b,c)};d.setFont=function(a,b){this._edFontName=a||this._edFontName;this._edFontSize=b||this._edFontSize;this._updateDOMFontStyle()};d.setFontName=function(a){this._edFontName=a||this._edFontName;this._updateDOMFontStyle()};d.setFontSize=function(a){this._edFontSize=a||this._edFontSize;this._updateDOMFontStyle()};d.setFontColor=
function(a){this._edTxt&&(this._edTxt.value!==this._editBox._placeholderText&&(this._edTxt.style.color=cc.colorToHex(a)),this._textLabel&&this._textLabel.setColor(a))};d.setPlaceHolder=function(a){this._placeholderLabel.setString(a)};d.setMaxLength=function(a){this._edTxt&&(this._edTxt.maxLength=a)};d._updateDOMPlaceholderFontStyle=function(){this._placeholderLabel.setFontName(this._editBox._placeholderFontName);this._placeholderLabel.setFontSize(this._editBox._placeholderFontSize)};d.setPlaceholderFontColor=
function(a){this._placeholderLabel.setColor(a)};d._updateDomInputType=function(){var a=this._editBox._editBoxInputMode;a===cc.EDITBOX_INPUT_MODE_EMAILADDR?this._edTxt.type="email":a===cc.EDITBOX_INPUT_MODE_DECIMAL||a===cc.EDITBOX_INPUT_MODE_NUMERIC?this._edTxt.type="number":a===cc.EDITBOX_INPUT_MODE_PHONENUMBER?(this._edTxt.type="number",this._edTxt.pattern="[0-9]*"):a===cc.EDITBOX_INPUT_MODE_URL?this._edTxt.type="url":(this._edTxt.type="text",this._editBox._keyboardReturnType===cc.KEYBOARD_RETURNTYPE_SEARCH&&
(this._edTxt.type="search"));this._editBox._editBoxInputFlag===cc.EDITBOX_INPUT_FLAG_PASSWORD&&(this._edTxt.type="password")};d.setInputFlag=function(a){this._edTxt&&(this._updateDomInputType(),this._edTxt.style.textTransform="none",a===cc.EDITBOX_INPUT_FLAG_INITIAL_CAPS_ALL_CHARACTERS?this._edTxt.style.textTransform="uppercase":a===cc.EDITBOX_INPUT_FLAG_INITIAL_CAPS_WORD&&(this._edTxt.style.textTransform="capitalize"),this._updateLabelStringStyle())};d.setInputMode=function(a){a===cc.EDITBOX_INPUT_MODE_ANY?
this._createDomTextArea():this._createDomInput();this._updateDomInputType();a=this._node.getContentSize();this.updateSize(a.width,a.height)};d.setString=function(a){this._edTxt&&null!==a&&(this._edTxt.value=a,""===a?(this._placeholderLabel&&(this._placeholderLabel.setString(this._editBox._placeholderText),this._placeholderLabel.setColor(this._editBox._placeholderColor)),this._editingMode||(this._placeholderLabel&&this._placeholderLabel.setVisible(!0),this._textLabel&&this._textLabel.setVisible(!1))):
(this._edTxt.style.color=cc.colorToHex(this._editBox._textColor),this._textLabel&&this._textLabel.setColor(this._editBox._textColor),this._editingMode||(this._placeholderLabel&&this._placeholderLabel.setVisible(!1),this._textLabel&&this._textLabel.setVisible(!0)),this._updateLabelStringStyle()))};d._updateDOMFontStyle=function(){this._edTxt&&(""!==this._edTxt.value&&(this._edTxt.style.fontFamily=this._edFontName,this._edTxt.style.fontSize=this._edFontSize+"px"),this._textLabel&&(this._textLabel.setFontSize(this._edFontSize),
this._textLabel.setFontName(this._edFontName)))};d.updateSize=function(a,b){var c=this._edTxt;c&&(c.style.width=a+"px",c.style.height=b+"px",this._updateLabelPosition(cc.size(a,b)))};d._addDomToGameContainer=function(){cc.game.container.appendChild(this._edTxt)};d._removeDomFromGameContainer=function(){var a=this._edTxt;a&&("contains"in cc.game.container?cc.game.container.contains(a):cc.game.container.compareDocumentPosition(a)%16)&&cc.game.container.removeChild(a);this._edTxt=null};d.initializeRenderCmd=
function(a){this._editBox=a;this._edFontSize=14;this._edFontName="Arial";this._placeholderLabel=this._textLabel=null;this.__rotateScreen=this.__autoResize=this.__fullscreen=this._editingMode=!1;this.__orientationChanged=null};cc.EditBox.CanvasRenderCmd=function(a){this._rootCtor(a);this.initializeRenderCmd(a)};var e=cc.EditBox.CanvasRenderCmd.prototype=Object.create(cc.Node.CanvasRenderCmd.prototype);cc.inject(d,e);e.constructor=cc.EditBox.CanvasRenderCmd;e.transform=function(a,b){this.originTransform(a,
b);this.updateMatrix()};cc.EditBox.WebGLRenderCmd=function(a){this._rootCtor(a);this.initializeRenderCmd(a)};e=cc.EditBox.WebGLRenderCmd.prototype=Object.create(cc.Node.WebGLRenderCmd.prototype);cc.inject(d,e);e.constructor=cc.EditBox.WebGLRenderCmd;e.transform=function(a,b){this.originTransform(a,b);this.updateMatrix()}})(cc.EditBox._polyfill);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=[]},visit:function(a){var b=this._renderCmd,c=a?a._renderCmd:null;if(this._visible){a=cc.renderer;var d=this._children,e=d.length,f=this._protectedChildren,g=f.length,h;b.visit(c);var k=this.grid;k&&k._active&&k.beforeDraw();
this._reorderChildDirty&&this.sortAllChildren();this._reorderProtectedChildDirty&&this.sortAllProtectedChildren();for(c=0;c<e;c++){var m=d[c];if(0>m._localZOrder)m.visit(this);else break}for(m=0;m<g;m++)if((h=f[m])&&0>h._localZOrder)b._changeProtectedChild(h),h.visit(this);else break;for(a.pushRenderCommand(b);c<e;c++)d[c].visit(this);for(;m<g;m++)if(h=f[m])b._changeProtectedChild(h),h.visit(this);k&&k._active&&k.afterDraw(this);b._dirtyFlag=0}else b._propagateFlagsDown(c)},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._performRecursive(cc.Node._stateCallbackType.onEnter),this._isTransitionFinished&&a._performRecursive(cc.Node._stateCallbackType.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;c<d;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._performRecursive(cc.Node._stateCallbackType.onExitTransitionDidStart),a._performRecursive(cc.Node._stateCallbackType.onExit)),
b&&a._performRecursive(cc.Node._stateCallbackType.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 = %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;c<d;c++){var e=b[c];this._running&&(e._performRecursive(cc.Node._stateCallbackType.onExitTransitionDidStart),e._performRecursive(cc.Node._stateCallbackType.onExit));a&&e._performRecursive(cc.Node._stateCallbackType.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=
this._protectedChildren,b,c,d=a.length;for(b=1;b<d;b++){var e=a[b];for(c=b-1;0<=c;){if(e._localZOrder<a[c]._localZOrder)a[c+1]=a[c];else if(e._localZOrder===a[c]._localZOrder&&e.arrivalOrder<a[c].arrivalOrder)a[c+1]=a[c];else break;c--}a[c+1]=e}this._reorderProtectedChildDirty=!1}},_changePosition:function(){},_createRenderCmd:function(){return cc._renderType===cc.game.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 b=this._node,d=this._displayedColor,e=b._realColor,f;if(this._cascadeColorEnabledDirty&&!b._cascadeColorEnabled){d.r=e.r;d.g=e.g;d.b=e.b;d=new cc.Color(255,255,255,255);var g=b._children;e=0;for(a=g.length;e<a;e++)(f=g[e])&&f._renderCmd&&f._renderCmd._updateDisplayColor(d);this._cascadeColorEnabledDirty=!1}else{void 0===a&&(a=(a=b._parent)&&a._cascadeColorEnabled?a.getDisplayedColor():cc.color.WHITE);d.r=0|e.r*a.r/255;d.g=
0|e.g*a.g/255;d.b=0|e.b*a.b/255;if(b._cascadeColorEnabled)for(g=b._children,e=0,a=g.length;e<a;e++)(f=g[e])&&f._renderCmd&&(f._renderCmd._updateDisplayColor(d),f._renderCmd._updateColor());g=b._protectedChildren;e=0;for(a=g.length;e<a;e++)(f=g[e])&&f._renderCmd&&(f._renderCmd._updateDisplayColor(d),f._renderCmd._updateColor())}this._dirtyFlag^=this._dirtyFlag&cc.Node._dirtyFlags.colorDirty},_updateDisplayOpacity:function(a){var b=this._node,d,e;if(this._cascadeOpacityEnabledDirty&&!b._cascadeOpacityEnabled){this._displayedOpacity=
b._realOpacity;var f=b._children;a=0;for(d=f.length;a<d;a++)(e=f[a])&&e._renderCmd&&e._renderCmd._updateDisplayOpacity(255);this._cascadeOpacityEnabledDirty=!1}else{void 0===a&&(d=b._parent,a=255,d&&d._cascadeOpacityEnabled&&(a=d.getDisplayedOpacity()));this._displayedOpacity=b._realOpacity*a/255;if(b._cascadeOpacityEnabled)for(f=b._children,a=0,d=f.length;a<d;a++)(e=f[a])&&e._renderCmd&&(e._renderCmd._updateDisplayOpacity(this._displayedOpacity),e._renderCmd._updateColor());f=b._protectedChildren;
a=0;for(d=f.length;a<d;a++)(e=f[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 b=a._dirtyFlag,d=cc.Node._dirtyFlags;this._dirtyFlag&d.colorDirty&&(b|=d.colorDirty);this._dirtyFlag&d.opacityDirty&&(b|=d.opacityDirty);var e=b&d.colorDirty;b&=d.opacityDirty;e&&a._updateDisplayColor(this._displayedColor);b&&a._updateDisplayOpacity(this._displayedOpacity);
(e||b)&&a._updateColor()}};cc.ProtectedNode.CanvasRenderCmd=function(a){this._rootCtor(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._pNodeCmdCtor=cc.ProtectedNode.CanvasRenderCmd;a.transform=function(a,c){var b=this._node;b._changePosition&&b._changePosition();this.originTransform(a,c);var e,f=b._protectedChildren;
if(c&&f&&0!==f.length)for(b=0,e=f.length;b<e;b++)f[b]._renderCmd.transform(this,c)};a.pNodeTransform=a.transform})();(function(){if(cc.Node.WebGLRenderCmd){cc.ProtectedNode.WebGLRenderCmd=function(a){this._rootCtor(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._pNodeCmdCtor=cc.ProtectedNode.WebGLRenderCmd;a.transform=function(a,c){this.originTransform(a,c);var b,e=this._node._protectedChildren;if(c&&e&&0!==e.length){var f=0;for(b=e.length;f<b;f++)e[f]._renderCmd.transform(this,
c)}};a.pNodeTransform=a.transform}})();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)?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,_inViewRect:!0,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;ccui.Widget.prototype.init.call(this)},init:function(){this._layoutParameterDictionary={};this._initRenderer();this.setBright(!0);this.onFocusChanged=this.onFocusChange;this.onNextFocusedWidget=null;this.setAnchorPoint(cc.p(.5,.5));this.ignoreContentAdaptWithSize(!0);
return!0},onEnter:function(){var a=this._touchListener;a&&!a._isRegistered()&&this._touchEnabled&&cc.eventManager.addListener(a,this);this._usingLayoutComponent||this.updateSizeAndPosition();this._sizeDirty&&this._onSizeChanged();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);null==a&&(a=new ccui.LayoutComponent,this.addComponent(a));
return a},getWidgetParent:function(){var a=this.getParent();return a instanceof ccui.Widget?a:null},_updateContentSizeWithTextureSize:function(a){this._unifySize?this.setContentSize(a):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)},setEnabled:function(a){this._enabled=
a;this.setBright(a)},_initRenderer:function(){},setContentSize:function(a,b){cc.Node.prototype.setContentSize.call(this,a,b);var c=this._contentSize.width,d=this._contentSize.height;this._customSize.width=c;this._customSize.height=d;!this._unifySize&&this._ignoreSize&&(this._contentSize=this.getVirtualRendererSize());if(!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._running?this._onSizeChanged():this._sizeDirty=!0},_setWidth:function(a){a!==this._contentSize.width&&(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._running?this._onSizeChanged():this._sizeDirty=!0)},_setHeight:function(a){a!==
this._contentSize.height&&(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._running?this._onSizeChanged():this._sizeDirty=!0)},setSizePercent:function(a){if(this._usingLayoutComponent){var b=this._getOrCreateLayoutComponent();b.setUsingPercentContentSize(!0);
b.setPercentContentSize(a);b.refreshLayout()}else{this._sizePercent.x=a.x;this._sizePercent.y=a.y;b=this._customSize.width;var c=this._customSize.height;this._running&&((c=this.getWidgetParent())?(b=c.width*a.x,c=c.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._ignoreSize?this._setWidth(this.getVirtualRendererSize().width):this._setWidth(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._ignoreSize?this._setHeight(this.getVirtualRendererSize().height):this._setHeight(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._ignoreSize?this.setContentSize(this.getVirtualRendererSize()):this.setContentSize(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._ignoreSize?this.setContentSize(this.getVirtualRendererSize()):
this.setContentSize(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){this._unifySize?this.setContentSize(this._customSize):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;b<c;b++){var d=a[b];d instanceof ccui.Widget&&d.updateSizeAndPosition()}this._sizeDirty=!1}},setTouchEnabled:function(a){this._touchEnabled!==a&&((this._touchEnabled=a)?(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._highlight?this.setBrightStyle(ccui.Widget.BRIGHT_STYLE_HIGH_LIGHT):
this.setBrightStyle(ccui.Widget.BRIGHT_STYLE_NORMAL):this._onPressStateChangedToDisabled())},isFocused:function(){return this._focused},setFocused:function(a){if(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);this.dispatchFocusEvent(this,c);return 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);if(b!==a){if(b&&b.onFocusChanged)b.onFocusChanged(a,b);if(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(this._brightStyle=a=a||ccui.Widget.BRIGHT_STYLE_NORMAL,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){this._hit=!1;if(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)}if(!this._hit)return!1;this.setHighlighted(!0);this._propagateTouchEvents&&this.propagateTouchEvent(ccui.Widget.TOUCH_BEGAN,
this,a);this._pushDownEvent();return!0},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:!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,this._positionPercent.x=0>=b?0:a/b)}cc.Node.prototype.setPositionX.call(this,a)},setPositionY:function(a){if(this._running){var b=this.getWidgetParent();b&&(b=b.height,this._positionPercent.y=0>=b?0:a/b)}cc.Node.prototype.setPositionY.call(this,a)},setPositionPercent:function(a){if(this._usingLayoutComponent){var b=this._getOrCreateLayoutComponent();b.setPositionPercentX(a.x);b.setPositionPercentY(a.y);b.refreshLayout()}else 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();b.setPositionPercentX(a.x);b.refreshLayout()}else this._positionPercent.x=a,this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)},_setYPercent:function(a){if(this._usingLayoutComponent){var b=this._getOrCreateLayoutComponent();b.setPositionPercentY(a.x);b.refreshLayout()}else this._positionPercent.y=a,this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)},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){this._positionType=a;if(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){a=a||this._layoutParameterType;return this._layoutParameterDictionary[a]},getDescription:function(){return"Widget"},clone:function(){var a=this._createCloneInstance();a._copyProperties(this);a._copyClonedWidgetChildren(this);return 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())}},setActionTag:function(a){this._actionTag=a},getActionTag:function(){return this._actionTag},getLeftInParent:function(){cc.log("getLeftInParent is deprecated. Please use getLeftBoundary instead.");return this.getLeftBoundary()},getBottomInParent:function(){cc.log("getBottomInParent is deprecated. Please use getBottomBoundary instead.");return this.getBottomBoundary()},getRightInParent:function(){cc.log("getRightInParent is deprecated. Please use getRightBoundary instead.");
return this.getRightBoundary()},getTopInParent:function(){cc.log("getTopInParent is deprecated. Please use getTopBoundary instead.");return this.getTopBoundary()},getTouchEndPos:function(){cc.log("getTouchEndPos is deprecated. Please use getTouchEndPosition instead.");return this.getTouchEndPosition()},getTouchMovePos:function(){cc.log("getTouchMovePos is deprecated. Please use getTouchMovePosition instead.");return this.getTouchMovePosition()},clippingParentAreaContainPoint:function(a){cc.log("clippingParentAreaContainPoint is deprecated. Please use isClippingParentContainsPoint instead.");
this.isClippingParentContainsPoint(a)},getTouchStartPos:function(){cc.log("getTouchStartPos is deprecated. Please use getTouchBeganPosition instead.");return this.getTouchBeganPosition()},setSize:function(a){this.setContentSize(a)},getSize:function(){return this.getContentSize()},addNode:function(a,b,c){a instanceof ccui.Widget?cc.log("Please use addChild to add a Widget."):(cc.Node.prototype.addChild.call(this,a,b,c),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)},_getNormalGLProgram:function(){return cc.shaderCache.programForKey(cc.SHADER_SPRITE_POSITION_TEXTURECOLOR)},_getGrayGLProgram:function(){return cc.shaderCache.programForKey(cc.SHADER_SPRITE_POSITION_TEXTURECOLOR_GRAY)},removeNodeByTag:function(a,b){var c=this.getChildByTag(a);c?this.removeChild(c,b):cc.log("cocos2d: removeNodeByTag(tag = %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}else 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);this._flippedX&&(a*=-1);return a},getScaleY:function(){var a=cc.Node.prototype.getScaleY.call(this);this._flippedY&&(a*=-1);return a},getScale:function(){this.getScaleX()!==this.getScaleY()&&cc.log("Widget#scale. ScaleX != ScaleY. Don't know which one to return");
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.game.RENDER_TYPE_WEBGL?new ccui.Widget.WebGLRenderCmd(this):new ccui.Widget.CanvasRenderCmd(this)}});
_p=ccui.Widget.prototype;cc.defineGetterSetter(_p,"xPercent",_p._getXPercent,_p._setXPercent);cc.defineGetterSetter(_p,"yPercent",_p._getYPercent,_p._setYPercent);cc.defineGetterSetter(_p,"widthPercent",_p._getWidthPercent,_p._setWidthPercent);cc.defineGetterSetter(_p,"heightPercent",_p._getHeightPercent,_p._setHeightPercent);cc.defineGetterSetter(_p,"widgetParent",_p.getWidgetParent);cc.defineGetterSetter(_p,"enabled",_p.isEnabled,_p.setEnabled);cc.defineGetterSetter(_p,"focused",_p.isFocused,_p.setFocused);
cc.defineGetterSetter(_p,"sizeType",_p.getSizeType,_p.setSizeType);cc.defineGetterSetter(_p,"widgetType",_p.getWidgetType);cc.defineGetterSetter(_p,"touchEnabled",_p.isTouchEnabled,_p.setTouchEnabled);cc.defineGetterSetter(_p,"updateEnabled",_p.isUpdateEnabled,_p.setUpdateEnabled);cc.defineGetterSetter(_p,"bright",_p.isBright,_p.setBright);cc.defineGetterSetter(_p,"name",_p.getName,_p.setName);cc.defineGetterSetter(_p,"actionTag",_p.getActionTag,_p.setActionTag);
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.game.addEventListener(cc.game.EVENT_RENDERER_INITED,function(){if(cc._renderType===cc.game.RENDER_TYPE_CANVAS){ccui.Widget.CanvasRenderCmd=function(a){this._pNodeCmdCtor(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 b=this._node,d=cc.renderer;if(a=a||this.getParentRenderCmd())this._curLevel=a._curLevel+1;isNaN(b._customZ)&&(b._vertexZ=d.assignedZ,d.assignedZ+=
d.assignedZStep);b._adaptRenderers();this._syncStatus(a)};a.transform=function(a,c){this._transform||(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});var b=this._node;if(b._visible&&b._running){b._adaptRenderers();if(!this._usingLayoutComponent){var e=b.getWidgetParent();e&&(e=e.getContentSize(),0!==e.width&&0!==e.height&&(b._position.x=e.width*b._positionPercent.x,b._position.y=e.height*b._positionPercent.y))}this.pNodeTransform(a,c)}}}else ccui.Widget.WebGLRenderCmd=
function(a){this._pNodeCmdCtor(a);this._needDraw=!1},a=ccui.Widget.WebGLRenderCmd.prototype=Object.create(cc.ProtectedNode.WebGLRenderCmd.prototype),a.constructor=ccui.Widget.WebGLRenderCmd,a.visit=function(a){var b=this._node,d=cc.renderer;if(a=a||this.getParentRenderCmd())this._curLevel=a._curLevel+1;isNaN(b._customZ)&&(b._vertexZ=d.assignedZ,d.assignedZ+=d.assignedZStep);b._adaptRenderers();this._syncStatus(a)},a.transform=function(a,c){this._transform||(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});var b=this._node;if(b._visible&&b._running){b._adaptRenderers();if(!this._usingLayoutComponent){var e=b.getWidgetParent();e&&(e=e.getContentSize(),0!==e.width&&0!==e.height&&(b._position.x=e.width*b._positionPercent.x,b._position.y=e.height*b._positionPercent.y))}this.pNodeTransform(a,c)}};a.widgetTransform=a.transform});(function(){var a={_pool:{},_lengths:[],put:function(a){var b=a.length;this._pool[b]?this._pool[b].push(a):(this._pool[b]=[a],this._lengths.push(b),this._lengths.sort())},get:function(a){for(var b,c=0;c<this._lengths.length;c++)if(this._lengths[c]>=a){b=this._lengths[c];break}if(b)return this._pool[b].pop()}},b=cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL,c,d={_rebuildQuads_base:function(b,d,e,f){var g=b._vertices,h=b._renderCmd._worldTransform,k;if(f){var m=k=0;var n=e.width;e=e.height}else{k=d._originalSize;
var x=d._rect,w=d._offset;n=e.width/k.width;f=e.height/k.height;var y=w.x-(k.width-x.width)/2;m=w.y+(k.height-x.height)/2;var z=w.y-(k.height-x.height)/2;k=(w.x+(k.width-x.width)/2)*n;m*=f;n=e.width+y*n;e=e.height+z*f}8>g.length&&(a.put(g),g=a.get(8)||new Float32Array(8),b._vertices=g);c?(g[0]=k*h.a+m*h.c+h.tx,g[1]=k*h.b+m*h.d+h.ty,g[2]=n*h.a+m*h.c+h.tx,g[3]=n*h.b+m*h.d+h.ty,g[4]=k*h.a+e*h.c+h.tx,g[5]=k*h.b+e*h.d+h.ty,g[6]=n*h.a+e*h.c+h.tx,g[7]=n*h.b+e*h.d+h.ty):(g[0]=k,g[1]=m,g[2]=n,g[3]=m,g[4]=
k,g[5]=e,g[6]=n,g[7]=e);b._uvsDirty&&this._calculateUVs(b,d);b._vertCount=4},_calculateUVs:function(c,d){var e=c._uvs,f=d._texture._pixelsWide,g=d._texture._pixelsHigh,h=d._rect;h=cc.rectPointsToPixels(h);8>e.length&&(a.put(e),e=a.get(8)||new Float32Array(8),c._uvs=e);var k=b?.5:0;if(d._rotated){var u=(h.x+k)/f;var v=(h.y+h.width-k)/g;f=(h.x+h.height-k)/f;g=(h.y+k)/g;e[0]=u;e[1]=g;e[2]=u;e[3]=v;e[4]=f;e[5]=g;e[6]=f;e[7]=v}else u=(h.x+k)/f,v=(h.y+h.height-k)/g,f=(h.x+h.width-k)/f,g=(h.y+k)/g,e[0]=
u,e[1]=v,e[2]=f,e[3]=v,e[4]=u,e[5]=g,e[6]=f,e[7]=g}},e={x:Array(4),y:Array(4),_rebuildQuads_base:function(b,d,e,f,g,r,t){var h=b._vertices,k=b._renderCmd._worldTransform,m=e.width-f-g,n=e.height-r-t,p=e.width/(f+g),z=e.height/(r+t),A=this.x,B=this.y;A[0]=0;A[1]=f*(1<p?1:p);A[2]=A[1]+(0>m?0:m);A[3]=e.width;B[0]=0;B[1]=t*(1<z?1:z);B[2]=B[1]+(0>n?0:n);B[3]=e.height;32>h.length&&(a.put(h),h=a.get(32)||new Float32Array(32),b._vertices=h);e=0;if(c)for(m=0;4>m;m++)for(n=0;4>n;n++)h[e]=A[n]*k.a+B[m]*k.c+
k.tx,h[e+1]=A[n]*k.b+B[m]*k.d+k.ty,e+=2;else for(m=0;4>m;m++)for(n=0;4>n;n++)h[e]=A[n],h[e+1]=B[m],e+=2;b._uvsDirty&&this._calculateUVs(b,d,f,g,r,t)},_calculateUVs:function(c,d,e,f,g,r){var h=c._uvs,k=d._rect,m=d._texture._pixelsWide,n=d._texture._pixelsHigh,p=d._rect;p=cc.rectPointsToPixels(p);k=cc.rectPointsToPixels(k);var y=cc.contentScaleFactor();e*=y;f=k.width-e-f*y;g*=y;r*=y;var z=k.height-g-r;32>h.length&&(a.put(h),h=a.get(32)||new Float32Array(32),c._uvs=h);c=this.x;k=this.y;var A=b?.5:0;
y=0;if(d._rotated)for(c[0]=(p.x+A)/m,c[1]=(r+p.x)/m,c[2]=(r+z+p.x)/m,c[3]=(p.x+p.height-A)/m,k[3]=(p.y+A)/n,k[2]=(e+p.y)/n,k[1]=(e+f+p.y)/n,k[0]=(p.y+p.width-A)/n,d=0;4>d;d++)for(m=0;4>m;m++)h[y]=c[d],h[y+1]=k[3-m],y+=2;else for(c[0]=(p.x+A)/m,c[1]=(e+p.x)/m,c[2]=(e+f+p.x)/m,c[3]=(p.x+p.width-A)/m,k[3]=(p.y+A)/n,k[2]=(g+p.y)/n,k[1]=(g+z+p.y)/n,k[0]=(p.y+p.height-A)/n,d=0;4>d;d++)for(m=0;4>m;m++)h[y]=c[m],h[y+1]=k[d],y+=2}};ccui.Scale9Sprite=cc.Scale9Sprite=cc.Node.extend({_spriteFrame:null,_scale9Image:null,
_insetLeft:0,_insetRight:0,_insetTop:0,_insetBottom:0,_blendFunc:null,_renderingType:1,_brightState:0,_opacityModifyRGB:!1,_rawVerts:null,_rawUvs:null,_vertices:null,_uvs:null,_vertCount:0,_quadsDirty:!0,_uvsDirty:!0,_isTriangle:!1,_isTrimmedContentSize:!1,_textureLoaded:!1,_flippedX:!1,_flippedY:!1,_className:"Scale9Sprite",ctor:function(b,d,e){cc.Node.prototype.ctor.call(this);this._loader=new cc.Sprite.LoadManager;this._renderCmd.setState(this._brightState);this._blendFunc=cc.BlendFunc._alphaPremultiplied();
this.setAnchorPoint(cc.p(.5,.5));this._rawUvs=this._rawVerts=null;this._vertices=a.get(8)||new Float32Array(8);this._uvs=a.get(8)||new Float32Array(8);if(void 0!==b)if(b instanceof cc.SpriteFrame)this.initWithSpriteFrame(b,d);else{var f=cc.spriteFrameCache.getSpriteFrame(b);f?this.initWithSpriteFrame(f,d):this.initWithFile(b,d,e)}void 0===c&&(c=cc._renderType===cc.game.RENDER_TYPE_WEBGL)},textureLoaded:function(){return this._textureLoaded},getCapInsets:function(){return cc.rect(this._capInsetsInternal)},
_asyncSetCapInsets:function(){this.removeEventListener("load",this._asyncSetCapInsets,this);this.setCapInsets(this._cacheCapInsets);this._cacheCapInsets=null},setCapInsets:function(a){if(!this.loaded())return this._cacheCapInsets=a,this.removeEventListener("load",this._asyncSetCapInsets,this),this.addEventListener("load",this._asyncSetCapInsets,this),!1;this._capInsetsInternal=a;this._updateCapInsets(this._spriteFrame._rect,this._capInsetsInternal)},_updateCapInsets:function(a,b){b&&a&&!cc._rectEqualToZero(b)?
this._capInsetsInternal=b:(a=a||{x:0,y:0,width:this._contentSize.width,height:this._contentSize.height},this._capInsetsInternal=cc.rect(a.width/3,a.height/3,a.width/3,a.height/3));cc._rectEqualToZero(a)||(this._insetLeft=this._capInsetsInternal.x,this._insetTop=this._capInsetsInternal.y,this._insetRight=a.width-this._insetLeft-this._capInsetsInternal.width,this._insetBottom=a.height-this._insetTop-this._capInsetsInternal.height)},initWithFile:function(a,b,c){a instanceof cc.Rect?(c=a=b,b=cc.rect(0,
0,0,0)):(b=b||cc.rect(0,0,0,0),c=c||cc.rect(0,0,0,0));if(!a)throw Error("ccui.Scale9Sprite.initWithFile(): file should be non-null");var d=cc.textureCache.getTextureForKey(a);d||(d=cc.textureCache.addImage(a));var e=d.isLoaded();this._textureLoaded=e;this._loader.clear();if(!e)return this._loader.once(d,function(){this.initWithFile(a,b,c);this.dispatchEvent("load")},this),!1;cc._rectEqualToZero(b)&&(e=d.getContentSize(),b=cc.rect(0,0,e.width,e.height));this.setTexture(d,b);this._updateCapInsets(b,
c);return!0},updateWithBatchNode:function(a,b,c,d){if(!a)return!1;var e=a.getTexture();this._loader.clear();if(!e.isLoaded())return this._loader.once(e,function(){this.updateWithBatchNode(a,b,c,d);this.dispatchEvent("load")},this),!1;this.setTexture(e,b);this._updateCapInsets(b,d);return!0},initWithSpriteFrame:function(a,b){this.setSpriteFrame(a);b=b||cc.rect(0,0,0,0);this._updateCapInsets(a._rect,b)},initWithSpriteFrameName:function(a,b){if(!a)throw Error("ccui.Scale9Sprite.initWithSpriteFrameName(): spriteFrameName should be non-null");
b=b||cc.rect(0,0,0,0);var c=cc.spriteFrameCache.getSpriteFrame(a);if(null==c)return cc.log("ccui.Scale9Sprite.initWithSpriteFrameName(): can't find the sprite frame by spriteFrameName"),!1;this.setSpriteFrame(c);b=b||cc.rect(0,0,0,0);this._updateCapInsets(c._rect,b)},loaded:function(){return null===this._spriteFrame?!1:this._spriteFrame.textureLoaded()},setTexture:function(a,b){var c=new cc.SpriteFrame(a,b);this.setSpriteFrame(c)},_updateBlendFunc:function(){var a=this._blendFunc;this._spriteFrame&&
this._spriteFrame._texture.hasPremultipliedAlpha()?(a.src===cc.SRC_ALPHA&&a.dst===cc.BLEND_DST&&(a.src=cc.ONE),this._opacityModifyRGB=!0):(a.src===cc.ONE&&a.dst===cc.BLEND_DST&&(a.src=cc.SRC_ALPHA),this._opacityModifyRGB=!1)},setOpacityModifyRGB:function(a){this._opacityModifyRGB!==a&&(this._opacityModifyRGB=a,this._renderCmd._setColorDirty())},isOpacityModifyRGB:function(){return this._opacityModifyRGB},setSpriteFrame:function(a){if(a){this._spriteFrame=a;this._uvsDirty=this._quadsDirty=!0;var b=
this,c=function(){cc.sizeEqualToSize(b._contentSize,cc.size(0,0))&&b.setContentSize(b._spriteFrame._rect);b._textureLoaded=!0;b._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.contentDirty);cc.renderer.childrenOrderDirty=!0};b._textureLoaded=a.textureLoaded();b._textureLoaded?c():(this._loader.clear(),this._loader.once(a,function(){c();this.dispatchEvent("load")},this))}},setBlendFunc:function(a,b){void 0===b?(this._blendFunc.src=a.src||cc.BLEND_SRC,this._blendFunc.dst=a.dst||cc.BLEND_DST):(this._blendFunc.src=
a||cc.BLEND_SRC,this._blendFunc.dst=b||cc.BLEND_DST);this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.contentDirty)},getBlendFunc:function(){return new cc.BlendFunc(this._blendFunc.src,this._blendFunc.dst)},setPreferredSize:function(a){a&&!cc.sizeEqualToSize(this._contentSize,a)&&this.setContentSize(a)},getPreferredSize:function(){return this.getContentSize()},setContentSize:function(a,b){void 0===b&&(b=a.height,a=a.width);if(a!==this._contentSize.width||b!==this._contentSize.height)cc.Node.prototype.setContentSize.call(this,
a,b),this._quadsDirty=!0},getContentSize:function(){return this._renderingType===ccui.Scale9Sprite.RenderingType.SIMPLE?this._spriteFrame?this._spriteFrame._originalSize:cc.size(this._contentSize):cc.size(this._contentSize)},_setWidth:function(a){cc.Node.prototype._setWidth.call(this,a);this._quadsDirty=!0},_setHeight:function(a){cc.Node.prototype._setHeight.call(this,a);this._quadsDirty=!0},setState:function(a){this._brightState=a;this._renderCmd.setState(a);this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.contentDirty)},
getState:function(){return this._brightState},setRenderingType:function(a){this._renderingType!==a&&(this._renderingType=a,this._uvsDirty=this._quadsDirty=!0,this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.contentDirty))},getRenderingType:function(){return this._renderingType},setInsetLeft:function(a){this._insetLeft=a;this._uvsDirty=this._quadsDirty=!0;this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.contentDirty)},getInsetLeft:function(){return this._insetLeft},setInsetTop:function(a){this._insetTop=
a;this._uvsDirty=this._quadsDirty=!0;this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.contentDirty)},getInsetTop:function(){return this._insetTop},setInsetRight:function(a){this._insetRight=a;this._uvsDirty=this._quadsDirty=!0;this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.contentDirty)},getInsetRight:function(){return this._insetRight},setInsetBottom:function(a){this._insetBottom=a;this._uvsDirty=this._quadsDirty=!0;this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.contentDirty)},getInsetBottom:function(){return this._insetBottom},
_rebuildQuads:function(){if(this._spriteFrame&&this._spriteFrame._textureLoaded){this._updateBlendFunc();this._isTriangle=!1;switch(this._renderingType){case g.SIMPLE:d._rebuildQuads_base(this,this._spriteFrame,this._contentSize,this._isTrimmedContentSize);break;case g.SLICED:e._rebuildQuads_base(this,this._spriteFrame,this._contentSize,this._insetLeft,this._insetRight,this._insetTop,this._insetBottom);break;default:this._uvsDirty=this._quadsDirty=!1;cc.error("Can not generate quad");return}this._uvsDirty=
this._quadsDirty=!1}},_createRenderCmd:function(){return cc._renderType===cc.game.RENDER_TYPE_CANVAS?new ccui.Scale9Sprite.CanvasRenderCmd(this):new ccui.Scale9Sprite.WebGLRenderCmd(this)}});var f=ccui.Scale9Sprite.prototype;cc.EventHelper.prototype.apply(f);cc.defineGetterSetter(f,"preferredSize",f.getPreferredSize,f.setPreferredSize);cc.defineGetterSetter(f,"capInsets",f.getCapInsets,f.setCapInsets);cc.defineGetterSetter(f,"insetLeft",f.getInsetLeft,f.setInsetLeft);cc.defineGetterSetter(f,"insetTop",
f.getInsetTop,f.setInsetTop);cc.defineGetterSetter(f,"insetRight",f.getInsetRight,f.setInsetRight);cc.defineGetterSetter(f,"insetBottom",f.getInsetBottom,f.setInsetBottom);f=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};var g=ccui.Scale9Sprite.RenderingType={SIMPLE:0,SLICED:1}})();(function(){ccui.Scale9Sprite.CanvasRenderCmd=function(a){cc.Node.CanvasRenderCmd.call(this,a);this._needDraw=!0;this._state=ccui.Scale9Sprite.state.NORMAL;this._originalTexture=this._textureToRender=null};var a=ccui.Scale9Sprite.CanvasRenderCmd.prototype=Object.create(cc.Node.CanvasRenderCmd.prototype);a.constructor=ccui.Scale9Sprite.CanvasRenderCmd;a.transform=function(a,c){this.originTransform(a,c);this._node._rebuildQuads()};a.needDraw=function(){return this._needDraw&&this._node.loaded()};a._updateDisplayColor=
function(a){cc.Node.RenderCmd.prototype._updateDisplayColor.call(this,a);this._originalTexture=this._textureToRender=null};a.setState=function(a){this._state!==a&&(this._state=a,this._originalTexture=this._textureToRender=null)};a._setColorDirty=function(){this.setDirtyFlag(cc.Node._dirtyFlags.colorDirty|cc.Node._dirtyFlags.opacityDirty)};a.rendering=function(a,c,d){var b=this._node,f=this._displayedOpacity,g=f/255,h=null;b._spriteFrame&&(h=b._spriteFrame._texture);if(b.loaded()&&0!==f){if(null===
this._textureToRender||this._originalTexture!==h)this._textureToRender=this._originalTexture=h,cc.Scale9Sprite.state.GRAY===this._state&&(this._textureToRender=this._textureToRender._generateGrayTexture()),f=b.getDisplayedColor(),!h||255===f.r&&255===f.g&&255===f.b||(this._textureToRender=this._textureToRender._generateColorTexture(f.r,f.g,f.b));h=a||cc._renderContext;a=h.getContext();h.setTransform(this._worldTransform,c,d);h.setCompositeOperation(cc.Node.CanvasRenderCmd._getCompositeOperationByBlendFunc(b._blendFunc));
h.setGlobalAlpha(g);if(this._textureToRender){b._quadsDirty&&b._rebuildQuads();c=this._textureToRender._pixelsWide;d=this._textureToRender._pixelsHigh;g=this._textureToRender._htmlElementObj;f=b._vertices;var k=b._uvs,m;if(b._renderingType===cc.Scale9Sprite.RenderingType.SLICED){for(h=0;3>h;++h)for(m=0;3>m;++m){var n=8*h+2*m;var p=f[n];var r=f[n+1];var t=f[n+10]-p;var u=f[n+11]-r;r=-r-u;b=k[n]*c;var v=k[n+11]*d;var x=(k[n+10]-k[n])*c;var w=(k[n+1]-k[n+11])*d;0<x&&0<w&&0<t&&0<u&&a.drawImage(g,b,v,
x,w,p,r,t,u)}cc.g_NumberOfDraws+=9}else{var y=Math.floor(b._vertCount/4);for(n=m=0;m<y;m++)p=f[n],r=f[n+1],t=f[n+6]-p,u=f[n+7]-r,r=-r-u,b=k[n]*c,v=k[n+7]*d,x=(k[n+6]-k[n])*c,w=(k[n+1]-k[n+7])*d,""!==this._textureToRender._pattern?(h.setFillStyle(a.createPattern(g,this._textureToRender._pattern)),a.fillRect(p,r,t,u)):0<x&&0<w&&0<t&&0<u&&a.drawImage(g,b,v,x,w,p,r,t,u),n+=8;cc.g_NumberOfDraws+=y}}}}})();(function(){if(cc.Node.WebGLRenderCmd){ccui.Scale9Sprite.WebGLRenderCmd=function(a){cc.Node.WebGLRenderCmd.call(this,a);this._needDraw=!0;this._color=new Uint32Array(1);this._dirty=!1;this._shaderProgram=cc.shaderCache.programForKey(cc.SHADER_SPRITE_POSITION_TEXTURECOLOR)};var a=ccui.Scale9Sprite,b=ccui.Scale9Sprite.WebGLRenderCmd.prototype=Object.create(cc.Node.WebGLRenderCmd.prototype);b.constructor=ccui.Scale9Sprite.WebGLRenderCmd;b.needDraw=function(){return this._needDraw&&this._node.loaded()};
b._uploadSliced=function(a,b,e,f,g,h,k){for(var c,d=0;3>d;++d)for(var p=0;3>p;++p)c=8*d+2*p,g[k]=a[c],g[k+1]=a[c+1],g[k+2]=f,h[k+3]=e[0],g[k+4]=b[c],g[k+5]=b[c+1],k+=6,g[k]=a[c+2],g[k+1]=a[c+3],g[k+2]=f,h[k+3]=e[0],g[k+4]=b[c+2],g[k+5]=b[c+3],k+=6,g[k]=a[c+8],g[k+1]=a[c+9],g[k+2]=f,h[k+3]=e[0],g[k+4]=b[c+8],g[k+5]=b[c+9],k+=6,g[k]=a[c+10],g[k+1]=a[c+11],g[k+2]=f,h[k+3]=e[0],g[k+4]=b[c+10],g[k+5]=b[c+11],k+=6;return 36};b.transform=function(a,b){this.originTransform(a,b);this._node._rebuildQuads()};
b._setColorDirty=function(){};b.uploadData=function(b,d,e){var c=this._node;if(0===this._displayedOpacity)return 0;c._quadsDirty&&c._rebuildQuads();var g=this._displayedOpacity,h=this._displayedColor.r,k=this._displayedColor.g,m=this._displayedColor.b;if(c._opacityModifyRGB){var n=g/255;h*=n;k*=n;m*=n}this._color[0]=g<<24|m<<16|k<<8|h;g=c._vertexZ;h=c._vertices;k=c._uvs;n=a.RenderingType;m=0;switch(c._renderingType){case n.SIMPLE:m=this._node._vertCount;for(n=c=0;c<m;c++,n+=2)b[e]=h[n],b[e+1]=h[n+
1],b[e+2]=g,d[e+3]=this._color[0],b[e+4]=k[n],b[e+5]=k[n+1],e+=6;break;case n.SLICED:m=this._uploadSliced(h,k,this._color,g,b,d,e)}return m};b.setState=function(b){b===a.state.NORMAL?this._shaderProgram=cc.shaderCache.programForKey(cc.SHADER_SPRITE_POSITION_TEXTURECOLOR):b===a.state.GRAY&&(this._shaderProgram=cc.shaderCache.programForKey(cc.SHADER_SPRITE_POSITION_TEXTURECOLOR_GRAY))}}})();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_SCISSOR;this._colorType=ccui.Layout.BG_COLOR_NONE;ccui.Widget.prototype.ctor.call(this);this.ignoreContentAdaptWithSize(!1);this.setContentSize(cc.size(0,0));
this.setAnchorPoint(0,0);this.onPassFocusToChild=this._findNearestChildWidgetIndex.bind(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._performRecursive(cc.Node._stateCallbackType.onEnter);this._clippingRectDirty=this._doLayoutDirty=!0},onExit:function(){ccui.Widget.prototype.onExit.call(this);this._clippingStencil&&this._clippingStencil._performRecursive(cc.Node._stateCallbackType.onExit)},visit:function(a){var b=this._renderCmd,c=a?a._renderCmd:null;if(this._visible){this._adaptRenderers();this._doLayout();b.visit(c);a=this._clippingEnabled&&this._clippingType===ccui.Layout.CLIPPING_STENCIL;var d=this._clippingEnabled&&
this._clippingType===ccui.Layout.CLIPPING_SCISSOR;a?b.stencilClippingVisit(c):d&&b.scissorClippingVisit(c);var e=this._children,f=e.length,g=this._protectedChildren,h=g.length;this._reorderChildDirty&&this.sortAllChildren();this._reorderProtectedChildDirty&&this.sortAllProtectedChildren();for(c=0;c<f;c++){var k=e[c];if(0>k._localZOrder)k.visit(this);else break}for(k=0;k<h;k++){var m=g[k];if(0>m._localZOrder)b._changeProtectedChild(m),m.visit(this);else break}for(;c<f;c++)e[c].visit(this);for(;k<h;k++)m=
g[k],b._changeProtectedChild(m),m.visit(this);a?b.postStencilVisit():d&&b.postScissorVisit();b._dirtyFlag=0}else b._propagateFlagsDown(c)},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();this._isFocusPassing=!1;if(this.__passFocusToChild){var d=
this._passFocusToChild(a,b);return d instanceof ccui.Layout&&c?(c._isFocusPassing=!0,c.findNextFocusedWidget(a,this)):d}if(null==c||!(c instanceof ccui.Layout))return this;c._isFocusPassing=!0;return c.findNextFocusedWidget(a,this)}if(b.isFocused()||b instanceof ccui.Layout)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)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}else return cc.assert(0,"Un Supported Layout type, please use VBox and HBox instead!!!"),b;else return b},onPassFocusToChild:null,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},setClippingEnabled:function(a){if(a!==this._clippingEnabled)switch(this._clippingEnabled=a,this._clippingType){case ccui.Layout.CLIPPING_SCISSOR:case ccui.Layout.CLIPPING_STENCIL:a?
(this._clippingStencil=new cc.DrawNode,this._renderCmd.rebindStencilRendering(this._clippingStencil),this._running&&this._clippingStencil._performRecursive(cc.Node._stateCallbackType.onEnter),this._setStencilClippingSize(this._contentSize)):(this._running&&this._clippingStencil&&this._clippingStencil._performRecursive(cc.Node._stateCallbackType.onExit),this._clippingStencil=null)}},setClippingType:function(a){if(a!==this._clippingType){var b=this.isClippingEnabled();this.setClippingEnabled(!1);this._clippingType=
a;this.setClippingEnabled(b)}},getClippingType:function(){return this._clippingType},_setStencilClippingSize:function(a){if(this._clippingEnabled){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);var c=cc.color.GREEN;this._clippingStencil.clear();this._clippingStencil.setLocalBB&&this._clippingStencil.setLocalBB(0,0,a.width,a.height);this._clippingStencil.drawPoly(b,4,c,0,c)}},_getClippingRect:function(){if(this._clippingRectDirty){var a=this.convertToWorldSpace(cc.p(0,
0)),b=this.getNodeToWorldTransform(),c=this._contentSize.width*b.a;b=this._contentSize.height*b.d;var d;for(d=this;d;)if((d=d.getParent())&&d instanceof ccui.Layout&&d.isClippingEnabled()){this._clippingParent=d;break}this._clippingParent?(d=this._clippingParent._getClippingRect(),this._clippingRect.x=Math.max(a.x,d.x),this._clippingRect.y=Math.max(a.y,d.y),b=Math.min(a.y+b,d.y+d.height),this._clippingRect.width=Math.max(0,Math.min(a.x+c,d.x+d.width)-this._clippingRect.x),this._clippingRect.height=
Math.max(0,b-this._clippingRect.y)):(this._clippingRect.x=a.x,this._clippingRect.y=a.y,this._clippingRect.width=c,this._clippingRect.height=b);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(.5*a.width,.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(.5*this._contentSize.width,.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(.5*a.width,.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)}this._colorType=a;switch(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){this._opacity=a;switch(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,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=this.getChildren(),b=cc.size(0,0),c=0,d,e=0,f=a.length;e<f;e++)if(d=a[e],null!==d&&d instanceof ccui.Layout)d=d._getLayoutAccumulatedSize(),b.width+=d.width,b.height+=d.height;else if(d instanceof ccui.Widget){c++;
var g=d.getLayoutParameter().getMargin();d=d.getContentSize();b.width+=d.width+.5*(g.right+g.left);b.height+=d.height+.5*(g.top+g.bottom)}a=this.getLayoutType();a===ccui.Layout.LINEAR_HORIZONTAL&&(b.height-=b.height/c*(c-1));a===ccui.Layout.LINEAR_VERTICAL&&(b.width-=b.width/c*(c-1));return b},_findNearestChildWidgetIndex:function(a,b){if(null==b||b===this)return this._findFirstFocusEnabledWidgetIndex();var c=0,d=this.getChildren(),e=d.length,f,g=cc.FLT_MAX,h=0;if(a===ccui.Widget.LEFT||a===ccui.Widget.RIGHT||
a===ccui.Widget.DOWN||a===ccui.Widget.UP){for(f=this._getWorldCenterPoint(b);c<e;){var k=d[c];k&&k instanceof ccui.Widget&&k.isFocusEnabled()&&(k=k instanceof ccui.Layout?k._calculateNearestDistance(b):cc.pLength(cc.pSub(this._getWorldCenterPoint(k),f)),k<g&&(h=c,g=k));c++}return h}cc.log("invalid focus direction!");return 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);c<e;){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}cc.log("invalid focus direction!!!");return 0},_calculateNearestDistance:function(a){for(var b=cc.FLT_MAX,c=this._getWorldCenterPoint(a),d=this._children,e=0,f=d.length;e<f;e++){var g=
d[e];if(g instanceof ccui.Layout)g=g._calculateNearestDistance(a);else if(g instanceof ccui.Widget&&g.isFocusEnabled())g=cc.pLength(cc.pSub(this._getWorldCenterPoint(g),c));else continue;g<b&&(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;e<f;e++){var g=d[e];if(g instanceof ccui.Layout)g=g._calculateFarthestDistance(a);else if(g instanceof ccui.Widget&&g.isFocusEnabled())g=this._getWorldCenterPoint(g),g=cc.pLength(cc.pSub(g,
c));else continue;g>b&&(b=g)}return b},_findProperSearchingFunctor:function(a,b){if(void 0!==b){var c=this._getWorldCenterPoint(b),d=this._getWorldCenterPoint(this._findFirstNonLayoutWidget());a===ccui.Widget.LEFT?this.onPassFocusToChild=c.x>d.x?this._findNearestChildWidgetIndex:this._findFarthestChildWidgetIndex:a===ccui.Widget.RIGHT?this.onPassFocusToChild=c.x>d.x?this._findFarthestChildWidgetIndex:this._findNearestChildWidgetIndex:a===ccui.Widget.DOWN?this.onPassFocusToChild=c.y>d.y?this._findNearestChildWidgetIndex:
this._findFarthestChildWidgetIndex:a===ccui.Widget.UP?this.onPassFocusToChild=c.y<d.y?this._findNearestChildWidgetIndex:this._findFarthestChildWidgetIndex:cc.log("invalid direction!")}},_findFirstNonLayoutWidget:function(){for(var a=this._children,b=0,c=a.length;b<c;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;a<
c;){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:this._findFocusEnabledChildWidgetByIndex(a+1):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=this._children;var d=c.indexOf(b);
d+=1;if(d<c.length){if(c=this._getChildWidgetByIndex(d)){if(c.isFocusEnabled()){if(c instanceof ccui.Layout)return c._isFocusPassing=!0,c.findNextFocusedWidget(a,c);this.dispatchFocusEvent(b,c);return c}return this._getNextFocusedWidget(a,c)}return b}if(this._loopFocus){if(this._checkFocusEnabledChild()){c=this._getChildWidgetByIndex(0);if(c.isFocusEnabled()){if(c instanceof ccui.Layout)return c._isFocusPassing=!0,c.findNextFocusedWidget(a,c);this.dispatchFocusEvent(b,c);return c}return this._getNextFocusedWidget(a,
c)}return b instanceof ccui.Layout?b:ccui.Widget._focusedWidget}return 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=this._children;var d=c.indexOf(b);--d;if(0<=d){c=this._getChildWidgetByIndex(d);if(c.isFocusEnabled()){if(c instanceof ccui.Layout)return c._isFocusPassing=
!0,c.findNextFocusedWidget(a,c);this.dispatchFocusEvent(b,c);return c}return this._getPreviousFocusedWidget(a,c)}if(this._loopFocus){if(this._checkFocusEnabledChild()){d=c.length-1;c=this._getChildWidgetByIndex(d);if(c.isFocusEnabled()){if(c instanceof ccui.Layout)return c._isFocusPassing=!0,c.findNextFocusedWidget(a,c);this.dispatchFocusEvent(b,c);return c}return this._getPreviousFocusedWidget(a,c)}return b instanceof ccui.Layout?b:ccui.Widget._focusedWidget}return 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;a<c;){var f=b[a];if(f&&f instanceof ccui.Widget)return f;d++;a++}for(a=0;a<e;){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){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)}else return cc.log("invalid layout Type"),!1},_isWidgetAncestorSupportLoopFocus:function(a,b){var c=a.getParent();if(null==c||!(c instanceof ccui.Layout))return!1;if(c.isLoopFocus()){var d=c.getLayoutType();if(d===ccui.Layout.LINEAR_HORIZONTAL)return b===ccui.Widget.LEFT||b===ccui.Widget.RIGHT?!0:this._isWidgetAncestorSupportLoopFocus(c,
b);if(d===ccui.Layout.LINEAR_VERTICAL)return b===ccui.Widget.DOWN||b===ccui.Widget.UP?!0:this._isWidgetAncestorSupportLoopFocus(c,b);cc.assert(0,"invalid layout type");return!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);if(c instanceof ccui.Layout)return c._isFocusPassing=!0,c.findNextFocusedWidget(a,
c);this.dispatchFocusEvent(b,c);return c}return this},_checkFocusEnabledChild:function(){for(var a=this._children,b=0,c=a.length;b<c;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.game.RENDER_TYPE_WEBGL?new ccui.Layout.WebGLRenderCmd(this):new ccui.Layout.CanvasRenderCmd(this)}});_p=ccui.Layout.prototype;cc.defineGetterSetter(_p,"clippingEnabled",_p.isClippingEnabled,_p.setClippingEnabled);cc.defineGetterSetter(_p,"clippingType",null,_p.setClippingType);
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=-1;ccui.Layout.BACKGROUND_RENDERER_ZORDER=-2;(function(){ccui.Layout.CanvasRenderCmd=function(a){this._pNodeCmdCtor(a);this._needDraw=!1;this._rendererRestoreCmd=this._rendererClipCmd=this._rendererSaveCmd=null};var a=ccui.Layout.CanvasRenderCmd.prototype=Object.create(ccui.ProtectedNode.CanvasRenderCmd.prototype);a.constructor=ccui.Layout.CanvasRenderCmd;a._layoutCmdCtor=ccui.Layout.CanvasRenderCmd;a._onRenderSaveCmd=function(a,c,d){var b=a||cc._renderContext;a=b.getContext();b.save();b.save();b.setTransform(this._worldTransform,c,d);c=this._node._clippingStencil._renderCmd._buffer;
d=0;for(b=c.length;d<b;d++){var f=c[d].verts,g=f[0];a.beginPath();a.moveTo(g.x,-g.y);g=1;for(var h=f.length;g<h;g++)a.lineTo(f[g].x,-f[g].y);a.closePath()}};a._onRenderClipCmd=function(a){a=a||cc._renderContext;var b=a.getContext();a.restore();b.clip()};a._onRenderRestoreCmd=function(a){a=a||cc._renderContext;a.getContext();a.restore()};a.rebindStencilRendering=function(a){a._renderCmd.rendering=this.__stencilDraw;a._renderCmd._canUseDirtyRegion=!0};a.__stencilDraw=function(a,c,d){};a.stencilClippingVisit=
a.scissorClippingVisit=function(a){a=this._node;a._clippingStencil&&a._clippingStencil.isVisible()&&(this._rendererSaveCmd||(this._rendererSaveCmd=new cc.CustomRenderCmd(this,this._onRenderSaveCmd),this._rendererClipCmd=new cc.CustomRenderCmd(this,this._onRenderClipCmd),this._rendererRestoreCmd=new cc.CustomRenderCmd(this,this._onRenderRestoreCmd)),cc.renderer.pushRenderCommand(this._rendererSaveCmd),a._clippingStencil.visit(this),cc.renderer.pushRenderCommand(this._rendererClipCmd))};a.postStencilVisit=
a.postScissorVisit=function(){cc.renderer.pushRenderCommand(this._rendererRestoreCmd)};ccui.Layout.CanvasRenderCmd._getSharedCache=function(){return cc.ClippingNode._sharedCache||(cc.ClippingNode._sharedCache=document.createElement("canvas"))}})();(function(){if(ccui.ProtectedNode.WebGLRenderCmd){ccui.Layout.WebGLRenderCmd=function(a){this._pNodeCmdCtor(a);this._needDraw=!1;this._currentStencilEnabled=0;this._scissorOldState=!1;this._clippingOldRect=null;this._mask_layer_le=0;this._afterVisitCmdScissor=this._beforeVisitCmdScissor=this._afterVisitCmdStencil=this._afterDrawStencilCmd=this._beforeVisitCmdStencil=null};var a=ccui.Layout.WebGLRenderCmd.prototype=Object.create(ccui.ProtectedNode.WebGLRenderCmd.prototype);a.constructor=ccui.Layout.WebGLRenderCmd;
a._layoutCmdCtor=ccui.Layout.CanvasRenderCmd;a._syncStatus=function(a){this._originSyncStatus(a);a&&a._dirtyFlag&cc.Node._dirtyFlags.transformDirty&&(this._node._clippingRectDirty=!0)};a._onBeforeVisitStencil=function(a){a=a||cc._renderContext;ccui.Layout.WebGLRenderCmd._layer++;var b=1<<ccui.Layout.WebGLRenderCmd._layer;this._mask_layer_le=b|b-1;this._currentStencilEnabled=a.isEnabled(a.STENCIL_TEST);a.clear(a.DEPTH_BUFFER_BIT);a.enable(a.STENCIL_TEST);a.depthMask(!1);a.stencilFunc(a.NEVER,b,b);
a.stencilOp(a.REPLACE,a.KEEP,a.KEEP);a.stencilMask(b);a.clear(a.STENCIL_BUFFER_BIT)};a._onAfterDrawStencil=function(a){a=a||cc._renderContext;a.depthMask(!0);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;ccui.Layout.WebGLRenderCmd._layer--;if(this._currentStencilEnabled){var b=1<<ccui.Layout.WebGLRenderCmd._layer,d=b|b-1;a.stencilMask(b);a.stencilFunc(a.EQUAL,d,d)}else a.disable(a.STENCIL_TEST)};
a._onBeforeVisitScissor=function(a){this._node._clippingRectDirty=!0;var b=this._node._getClippingRect();a=a||cc._renderContext;(this._scissorOldState=a.isEnabled(a.SCISSOR_TEST))?(this._clippingOldRect=cc.view.getScissorRect(),cc.rectEqualToRect(this._clippingOldRect,b)||cc.view.setScissorInPoints(b.x,b.y,b.width,b.height)):(a.enable(a.SCISSOR_TEST),cc.view.setScissorInPoints(b.x,b.y,b.width,b.height))};a._onAfterVisitScissor=function(a){a=a||cc._renderContext;this._scissorOldState?cc.rectEqualToRect(this._clippingOldRect,
this._node._clippingRect)||cc.view.setScissorInPoints(this._clippingOldRect.x,this._clippingOldRect.y,this._clippingOldRect.width,this._clippingOldRect.height):a.disable(a.SCISSOR_TEST)};a.rebindStencilRendering=function(a){};a.transform=function(a,c){var b=this._node;this.pNodeTransform(a,c);b._clippingStencil&&b._clippingStencil._renderCmd.transform(this,c)};a.stencilClippingVisit=function(a){a=this._node;if(a._clippingStencil&&a._clippingStencil.isVisible())if(ccui.Layout.WebGLRenderCmd._layer+
1===cc.stencilBits)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);else{this._beforeVisitCmdStencil||(this._beforeVisitCmdStencil=new cc.CustomRenderCmd(this,this._onBeforeVisitStencil),this._afterDrawStencilCmd=new cc.CustomRenderCmd(this,this._onAfterDrawStencil),this._afterVisitCmdStencil=
new cc.CustomRenderCmd(this,this._onAfterVisitStencil));cc.renderer.pushRenderCommand(this._beforeVisitCmdStencil);var b=cc.current_stack;b.stack.push(b.top);b.top=this._stackMatrix;a._clippingStencil.visit(this);cc.renderer.pushRenderCommand(this._afterDrawStencilCmd)}};a.postStencilVisit=function(){renderer.pushRenderCommand(cmd._afterVisitCmdStencil);cc.current_stack.top=cc.current_stack.stack.pop()};a.scissorClippingVisit=function(a){this._beforeVisitCmdScissor||(this._beforeVisitCmdScissor=new cc.CustomRenderCmd(this,
this._onBeforeVisitScissor),this._afterVisitCmdScissor=new cc.CustomRenderCmd(this,this._onAfterVisitScissor));cc.renderer.pushRenderCommand(this._beforeVisitCmdScissor)};a.postScissorVisit=function(){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();a._copyProperties(this);return 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;d<e;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-=(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*(.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;d<e;d++){var f=a[d];if(f){var g=f.getLayoutParameter();if(g){var h=g.getGravity(),k=f.getAnchorPoint(),m=f.getContentSize();c+=k.x*m.width;var 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*(.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;c<d;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;c<d;c++){var e=a[c];e&&e instanceof ccui.Widget&&(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;d<e;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=.5*a.width-d.width*(.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=.5*a.height-d.height*(.5-c.y);break;case ccui.RelativeLayoutParameter.CENTER_IN_PARENT:this._finalPositionX=
.5*a.width-d.width*(.5-c.x);this._finalPositionY=.5*a.height-d.height*(.5-c.y);break;case ccui.RelativeLayoutParameter.PARENT_RIGHT_CENTER_VERTICAL:this._finalPositionX=a.width-(1-c.x)*d.width;this._finalPositionY=.5*a.height-d.height*(.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=.5*a.width-d.width*(.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()+.5*a.width+c.x*d.width-.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()+.5*a.height+c.y*d.height-.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()+.5*a.height+c.y*d.height-.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()+.5*a.width+c.x*d.width-.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);this.setLayoutType(ccui.Layout.LINEAR_HORIZONTAL);a&&this.setContentSize(a)}});ccui.HBox.create=function(a){return new ccui.HBox(a)};ccui.RelativeBox=ccui.Layout.extend({ctor:function(a){ccui.Layout.prototype.ctor.call(this);this.setLayoutType(ccui.Layout.RELATIVE);a&&this.setContentSize(a)}});ccui.RelativeBox.create=function(a){return new ccui.RelativeBox(a)};ccui.VBox=ccui.Layout.extend({ctor:function(a){ccui.Layout.prototype.ctor.call(this);this.setLayoutType(ccui.Layout.LINEAR_VERTICAL);a&&this.setContentSize(a)},initWithSize:function(a){return this.init()?!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;e<d;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;e<d;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;e<d;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){a=a.getChildren();for(var b,c=0,d=a.length;c<d;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;b.width<e&&(e=c=0);b.height<f&&(f=d=0);return cc.rect(c,d,e,f)},_createSpriteFromBase64:function(a,b){var c=cc.textureCache.getTextureForKey(b);c||(c=new Image,c.src=a,cc.textureCache.cacheImage(b,c),c=cc.textureCache.getTextureForKey(b));return new cc.Sprite(c)}};ccui.Button=ccui.Widget.extend({_buttonScale9Renderer:null,_buttonNormalSpriteFrame:null,_buttonClickedSpriteFrame:null,_buttonDisableSpriteFrame:null,_titleRenderer:null,_normalFileName:"",_clickedFileName:"",_disabledFileName:"",_prevIgnoreSize:!0,_scale9Enabled:!1,_capInsetsNormal:null,_normalTexType:ccui.Widget.LOCAL_TEXTURE,_pressedTexType:ccui.Widget.LOCAL_TEXTURE,_disabledTexType:ccui.Widget.LOCAL_TEXTURE,_normalTextureSize:null,pressedActionEnabled:!1,_titleColor:null,_zoomScale:.1,_normalTextureLoaded:!1,
_pressedTextureLoaded:!1,_disabledTextureLoaded:!1,_className:"Button",_normalTextureAdaptDirty:!0,_fontName:"Thonburi",_fontSize:12,_type:0,ctor:function(a,b,c,d){this._capInsetsNormal=cc.rect(0,0,0,0);this._normalTextureSize=cc.size(0,0);ccui.Widget.prototype.ctor.call(this);this.setTouchEnabled(!0);this._normalLoader=new cc.Sprite.LoadManager;this._clickedLoader=new cc.Sprite.LoadManager;this._disabledLoader=new cc.Sprite.LoadManager;a&&this.loadTextures(a,b,c,d)},_createTitleRendererIfNeeded:function(){this._titleRenderer||
(this._titleRenderer=new cc.LabelTTF(""),this._titleRenderer.setAnchorPoint(.5,.5),this._titleColor=cc.color.WHITE,this._titleRenderer.setVerticalAlignment(cc.VERTICAL_TEXT_ALIGNMENT_CENTER),this.addProtectedChild(this._titleRenderer,ccui.Button.TITLE_RENDERER_ZORDER,-1))},_initRenderer:function(){this._buttonScale9Renderer=new ccui.Scale9Sprite;this._buttonScale9Renderer.setRenderingType(ccui.Scale9Sprite.RenderingType.SIMPLE);this.addProtectedChild(this._buttonScale9Renderer,ccui.Button.DISABLED_RENDERER_ZORDER,
-1)},setScale9Enabled:function(a){this._scale9Enabled!==a&&(this._brightStyle=ccui.Widget.BRIGHT_STYLE_NONE,(this._scale9Enabled=a)?this._buttonScale9Renderer.setRenderingType(ccui.Scale9Sprite.RenderingType.SLICED):this._buttonScale9Renderer.setRenderingType(ccui.Scale9Sprite.RenderingType.SIMPLE),this._scale9Enabled?(a=this._ignoreSize,this.ignoreContentAdaptWithSize(!1),this._prevIgnoreSize=a):this.ignoreContentAdaptWithSize(this._prevIgnoreSize),this.setCapInsets(this._capInsetsNormal),this.setBright(this._bright),
this._normalTextureAdaptDirty=!0)},isScale9Enabled:function(){return this._scale9Enabled},ignoreContentAdaptWithSize:function(a){if(this._unifySize)this._updateContentSize();else if(!this._scale9Enabled||this._scale9Enabled&&!a)ccui.Widget.prototype.ignoreContentAdaptWithSize.call(this,a),this._prevIgnoreSize=a},getVirtualRendererSize:function(){return this._unifySize?this._getNormalSize():!this._normalTextureLoaded&&this._titleRenderer&&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)},_createSpriteFrameWithFile:function(a){var b=cc.textureCache.getTextureForKey(a);b||(b=cc.textureCache.addImage(a));if(!b._textureLoaded)return b;a=b.getContentSize();a=cc.rect(0,0,a.width,a.height);return new cc.SpriteFrame(b,a)},_createSpriteFrameWithName:function(a){a=cc.spriteFrameCache.getSpriteFrame(a);return null==a?(cc.log("ccui.Scale9Sprite.initWithSpriteFrameName(): can't find the sprite frame by spriteFrameName"),
null):a},loadTextureNormal:function(a,b){if(a){b=b||ccui.Widget.LOCAL_TEXTURE;this._normalFileName=a;this._normalTexType=b;switch(this._normalTexType){case ccui.Widget.LOCAL_TEXTURE:var c=this._createSpriteFrameWithFile(a);break;case ccui.Widget.PLIST_TEXTURE:"#"===a[0]&&(a=a.substr(1,a.length-1)),c=this._createSpriteFrameWithName(a)}c&&(c._textureLoaded?(this._normalTextureLoaded=c._textureLoaded,this._buttonNormalSpriteFrame=c,this._buttonScale9Renderer.setSpriteFrame(c),this._scale9Enabled&&this._buttonScale9Renderer.setCapInsets(this._capInsetsNormal),
!this._ignoreSize&&cc.sizeEqualToSize(this._customSize,cc.size(0,0))&&(this._customSize=this._buttonScale9Renderer.getContentSize()),this._normalTextureSize=this._buttonScale9Renderer.getContentSize(),this._updateChildrenDisplayedRGBA(),this._unifySize?this._scale9Enabled&&(this._buttonScale9Renderer.setCapInsets(this._capInsetsNormal),this._updateContentSizeWithTextureSize(this._getNormalSize())):this._updateContentSizeWithTextureSize(this._normalTextureSize),this._normalTextureAdaptDirty=!0,this._findLayout()):
(this._normalLoader.clear(),this._normalLoader.once(c,function(){this.loadTextureNormal(this._normalFileName,this._normalTexType)},this)))}},loadTexturePressed:function(a,b){if(a){b=b||ccui.Widget.LOCAL_TEXTURE;this._clickedFileName=a;this._pressedTexType=b;switch(this._pressedTexType){case ccui.Widget.LOCAL_TEXTURE:var c=this._createSpriteFrameWithFile(a);break;case ccui.Widget.PLIST_TEXTURE:"#"===a[0]&&(a=a.substr(1,a.length-1)),c=this._createSpriteFrameWithName(a)}c&&(c._textureLoaded?(this._buttonClickedSpriteFrame=
c,this._updateChildrenDisplayedRGBA(),this._pressedTextureLoaded=!0):(this._clickedLoader.clear(),this._clickedLoader.once(c,function(){this.loadTexturePressed(this._clickedFileName,this._pressedTexType)},this)))}},loadTextureDisabled:function(a,b){if(a){b=b||ccui.Widget.LOCAL_TEXTURE;this._disabledFileName=a;this._disabledTexType=b;switch(this._disabledTexType){case ccui.Widget.LOCAL_TEXTURE:var c=this._createSpriteFrameWithFile(a);break;case ccui.Widget.PLIST_TEXTURE:"#"===a[0]&&(a=a.substr(1,a.length-
1)),c=this._createSpriteFrameWithName(a)}c&&(c._textureLoaded?(this._buttonDisableSpriteFrame=c,this._updateChildrenDisplayedRGBA(),this._disabledTextureLoaded=!0,this._findLayout()):(this._disabledLoader.clear(),this._disabledLoader.once(c,function(){this.loadTextureDisabled(this._disabledFileName,this._disabledTexType)},this)))}},setCapInsets:function(a){this.setCapInsetsNormalRenderer(a)},setCapInsetsNormalRenderer:function(a){if(a&&this._scale9Enabled){var b=a.x,c=a.y,d=a.width;a=a.height;this._normalTextureSize.width<
d&&(d=b=0);this._normalTextureSize.height<a&&(a=c=0);var e=this._capInsetsNormal;e.x=b;e.y=c;e.width=d;e.height=a;this._capInsetsNormal=e;this._buttonScale9Renderer.setCapInsets(e)}},getCapInsetsNormalRenderer:function(){return cc.rect(this._capInsetsNormal)},setCapInsetsPressedRenderer:function(a){this.setCapInsetsNormalRenderer(a)},getCapInsetsPressedRenderer:function(){return cc.rect(this._capInsetsNormal)},setCapInsetsDisabledRenderer:function(a){this.setCapInsetsNormalRenderer(a)},getCapInsetsDisabledRenderer:function(){return cc.rect(this._capInsetsNormal)},
_onPressStateChangedToNormal:function(){this._buttonScale9Renderer.setSpriteFrame(this._buttonNormalSpriteFrame);this._buttonScale9Renderer.setState(ccui.Scale9Sprite.state.NORMAL);if(this._pressedTextureLoaded){if(this.pressedActionEnabled&&(this._buttonScale9Renderer.stopAllActions(),this._buttonScale9Renderer.setScale(1),this._titleRenderer))if(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._buttonScale9Renderer.stopAllActions(),this._buttonScale9Renderer.setScale(1),this._scale9Enabled&&this._buttonScale9Renderer.setColor(cc.color.WHITE),this._titleRenderer&&(this._titleRenderer.stopAllActions(),this._titleRenderer.setScaleX(1),this._titleRenderer.setScaleY(1))},_onPressStateChangedToPressed:function(){this._buttonScale9Renderer.setState(ccui.Scale9Sprite.state.NORMAL);if(this._pressedTextureLoaded){if(this._buttonScale9Renderer.setSpriteFrame(this._buttonClickedSpriteFrame),
this.pressedActionEnabled){this._buttonScale9Renderer.stopAllActions();var a=cc.scaleTo(ccui.Button.ZOOM_ACTION_TIME_STEP,1+this._zoomScale,1+this._zoomScale);this._buttonScale9Renderer.runAction(a);this._titleRenderer&&(this._titleRenderer.stopAllActions(),this._titleRenderer.runAction(cc.scaleTo(ccui.Button.ZOOM_ACTION_TIME_STEP,1+this._zoomScale,1+this._zoomScale)))}}else this._buttonScale9Renderer.setSpriteFrame(this._buttonClickedSpriteFrame),this._buttonScale9Renderer.stopAllActions(),this._buttonScale9Renderer.setScale(1+
this._zoomScale,1+this._zoomScale),this._titleRenderer&&(this._titleRenderer.stopAllActions(),this._titleRenderer.setScaleX(1+this._zoomScale),this._titleRenderer.setScaleY(1+this._zoomScale))},_onPressStateChangedToDisabled:function(){this._disabledTextureLoaded?this._buttonScale9Renderer.setSpriteFrame(this._buttonDisableSpriteFrame):this._normalTextureLoaded&&this._buttonScale9Renderer.setState(ccui.Scale9Sprite.state.GRAY);this._buttonScale9Renderer.setScale(1)},_updateContentSize:function(){if(this._unifySize){if(this._scale9Enabled)ccui.ProtectedNode.setContentSize(this._customSize);
else{var a=this._getNormalSize();ccui.ProtectedNode.setContentSize(a)}this._onSizeChanged()}else this._ignoreSize&&this.setContentSize(this.getVirtualRendererSize())},_onSizeChanged:function(){ccui.Widget.prototype._onSizeChanged.call(this);this._titleRenderer&&this._updateTitleLocation();this._normalTextureAdaptDirty=!0},getVirtualRenderer:function(){return this._buttonScale9Renderer},_normalTextureScaleChangedWithSize:function(){this._buttonScale9Renderer.setContentSize(this._contentSize);this._buttonScale9Renderer.setPosition(this._contentSize.width/
2,this._contentSize.height/2)},_adaptRenderers:function(){this._normalTextureAdaptDirty&&(this._normalTextureScaleChangedWithSize(),this._normalTextureAdaptDirty=!1)},_updateTitleLocation:function(){this._titleRenderer.setPosition(.5*this._contentSize.width,.5*this._contentSize.height)},setPressedActionEnabled:function(a){this.pressedActionEnabled=a},setTitleText:function(a){a!==this.getTitleText()&&(this._createTitleRendererIfNeeded(),this._titleRenderer.setString(a),this._ignoreSize?(a=this.getVirtualRendererSize(),
this.setContentSize(a)):this._titleRenderer._renderCmd._updateTTF())},getTitleText:function(){return this._titleRenderer?this._titleRenderer.getString():""},setTitleColor:function(a){this._createTitleRendererIfNeeded();this._titleRenderer.setFontFillColor(a)},getTitleColor:function(){return this._titleRenderer?this._titleRenderer._getFillStyle():cc.color.WHITE},setTitleFontSize:function(a){this._createTitleRendererIfNeeded();this._titleRenderer.setFontSize(a);this._fontSize=a},getTitleFontSize:function(){return this._titleRenderer?
this._titleRenderer.getFontSize():this._fontSize},setZoomScale:function(a){this._zoomScale=a},getZoomScale:function(){return this._zoomScale},getNormalTextureSize:function(){return this._normalTextureSize},setTitleFontName:function(a){this._createTitleRendererIfNeeded();this._titleRenderer.setFontName(a);this._fontName=a},getTitleRenderer:function(){return this._titleRenderer},getTitleFontName:function(){return this._titleRenderer?this._titleRenderer.getFontName():this._fontName},_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._capInsetsNormal=a._capInsetsNormal;this.setScale9Enabled(a._scale9Enabled);this.loadTextureNormal(a._normalFileName,a._normalTexType);this.loadTexturePressed(a._clickedFileName,a._pressedTexType);this.loadTextureDisabled(a._disabledFileName,a._disabledTexType);a._titleRenderer&&
a._titleRenderer._string&&(this.setTitleText(a.getTitleText()),this.setTitleFontName(a.getTitleFontName()),this.setTitleFontSize(a.getTitleFontSize()),this.setTitleColor(a.getTitleColor()));this.setPressedActionEnabled(a.pressedActionEnabled);this.setZoomScale(a._zoomScale)},_getNormalSize:function(){var a;null!==this._titleRenderer&&(a=this._titleRenderer.getContentSize());var b=this._buttonScale9Renderer.getContentSize();return cc.size(a.width>b.width?a.width:b.width,a.height>b.height?a.height:
b.height)}});_p=ccui.Button.prototype;cc.defineGetterSetter(_p,"titleText",_p.getTitleText,_p.setTitleText);cc.defineGetterSetter(_p,"titleFont",_p._getTitleFont,_p._setTitleFont);cc.defineGetterSetter(_p,"titleFontSize",_p.getTitleFontSize,_p.setTitleFontSize);cc.defineGetterSetter(_p,"titleFontName",_p.getTitleFontName,_p.setTitleFontName);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=.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:.1,_backgroundTextureScaleX:.1,_backgroundTextureScaleY:.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}f=void 0===f?0:f;this._isSelected=!0;this.setSelected(!1);this.loadTextures(a,b,c,d,e,f)},_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;c._textureLoaded?this._backGroundBoxRenderer.setContentSize(this._customSize):c.addEventListener("load",
function(){this._updateContentSizeWithTextureSize(this._backGroundBoxRenderer.getContentSize());this.loadTextureBackGround(this._backGroundFileName,this._backGroundTexType)},this);switch(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;c._textureLoaded||c.addEventListener("load",function(){this.loadTextureBackGroundSelected(this._backGroundSelectedFileName,this._backGroundSelectedTexType)},this);switch(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;c._textureLoaded||c.addEventListener("load",function(){this.loadTextureFrontCross(this._frontCrossFileName,this._frontCrossTexType)},this);switch(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;c._textureLoaded||c.addEventListener("load",function(){this.loadTextureBackGroundDisabled(this._backGroundDisabledFileName,this._backGroundDisabledTexType)},this);switch(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;c._textureLoaded||c.addEventListener("load",function(){this.loadTextureFrontCrossDisabled(this._frontCrossDisabledFileName,this._frontCrossDisabledTexType)},
this);switch(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),this._frontCrossRendererAdaptDirty=!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),this._frontCrossDisabledRendererAdaptDirty=!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){a.setScale(1);this._backgroundTextureScaleX=this._backgroundTextureScaleY=1;return}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(.5*b.width,.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){a.setScale(1);
return}var d=b.height/c.height;a.setScaleX(b.width/c.width);a.setScaleY(d)}a.setPosition(.5*b.width,.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){a.setScale(1);return}var d=b.height/c.height;a.setScaleX(b.width/c.width);a.setScaleY(d)}a.setPosition(.5*b.width,.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){a.setScale(1);return}var d=b.height/c.height;a.setScaleX(b.width/c.width);a.setScaleY(d)}a.setPosition(.5*b.width,.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){a.setScale(1);return}var d=b.height/c.height;a.setScaleX(b.width/
c.width);a.setScaleY(d)}a.setPosition(.5*b.width,.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;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);a?this.loadTexture(a,void 0===b?0:b):this._imageTexType=ccui.Widget.LOCAL_TEXTURE},_initRenderer:function(){this._imageRenderer=
new ccui.Scale9Sprite;this._imageRenderer.setRenderingType(ccui.Scale9Sprite.RenderingType.SIMPLE);this.addProtectedChild(this._imageRenderer,ccui.ImageView.RENDERER_ZORDER,-1)},loadTexture:function(a,b){if(a&&(this._textureFile!=a||this._imageTexType!=b)){var c=this;b=b||ccui.Widget.LOCAL_TEXTURE;this._textureFile=a;this._imageTexType=b;var d=c._imageRenderer;switch(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)}if(!d._textureLoaded){var e=function(){d.removeEventListener("load",e);!c._ignoreSize&&cc.sizeEqualToSize(c._customSize,cc.size(0,0))&&(c._customSize=c._imageRenderer.getContentSize());c._imageTextureSize=d.getContentSize();c._updateChildrenDisplayedRGBA();c._updateContentSizeWithTextureSize(c._imageTextureSize)};d.addEventListener("load",e)}!this._ignoreSize&&
cc.sizeEqualToSize(this._customSize,cc.size(0,0))&&(this._customSize=this._imageRenderer.getContentSize());c._imageTextureSize=d.getContentSize();this._updateChildrenDisplayedRGBA();c._updateContentSizeWithTextureSize(c._imageTextureSize);c._imageRendererAdaptDirty=!0;c._findLayout()}},setTextureRect:function(){cc.warn("ImageView.setTextureRect  is deprecated!")},setScale9Enabled:function(a){this._scale9Enabled!==a&&((this._scale9Enabled=a)?this._imageRenderer.setRenderingType(ccui.Scale9Sprite.RenderingType.SLICED):
this._imageRenderer.setRenderingType(ccui.Scale9Sprite.RenderingType.SIMPLE),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){if(!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(){this._imageRenderer.setContentSize(this._contentSize);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._capInsets=a._capInsets,this.loadTexture(a._textureFile,
a._imageTexType),this.setScale9Enabled(a._scale9Enabled))},setContentSize:function(a,b){b&&(a=cc.size(a,b));ccui.Widget.prototype.setContentSize.call(this,a);this._imageRenderer.setContentSize(a)}});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,.5)},setDirection:function(a){if(this._direction!==a)switch(this._direction=a,this._direction){case ccui.LoadingBar.TYPE_LEFT:this._barRenderer.setAnchorPoint(0,.5);this._barRenderer.setPosition(0,.5*this._contentSize.height);this._scale9Enabled||this._barRenderer.setFlippedX(!1);break;case ccui.LoadingBar.TYPE_RIGHT:this._barRenderer.setAnchorPoint(1,
.5),this._barRenderer.setPosition(this._totalLength,.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;c._textureLoaded||c.addEventListener("load",function(){d.loadTexture(d._textureFile,d._renderBarTexType);d._setPercent(d._percent)});switch(this._renderBarTexType){case ccui.Widget.LOCAL_TEXTURE:c.initWithFile(a);
break;case ccui.Widget.PLIST_TEXTURE:c.initWithSpriteFrameName(a)}var e=c.getContentSize();this._barRendererTextureSize.width=e.width;this._barRendererTextureSize.height=e.height;switch(this._direction){case ccui.LoadingBar.TYPE_LEFT:c.setAnchorPoint(0,.5);this._scale9Enabled||c.setFlippedX(!1);break;case ccui.LoadingBar.TYPE_RIGHT:c.setAnchorPoint(1,.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(){if(!(0>=this._totalLength)){var a=this._percent/100;if(this._scale9Enabled)this._setScale9Scale();else{var b=this._barRenderer;var c=this._barRendererTextureSize;var d=b.getTextureRect();d.width=c.width*a;b.setTextureRect(cc.rect(d.x,d.y,c.width*a,c.height),b._rectRotated)}}},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){if(!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){a.setScale(1);return}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,.5*b.height);break;case ccui.LoadingBar.TYPE_RIGHT:a.setPosition(this._totalLength,.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;cc.defineGetterSetter(_p,"direction",_p.getDirection,_p.setDirection);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:.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=c||0;this.setTouchEnabled(!0);a&&this.loadBarTexture(a,c);b&&this.loadSlidBallTextures(b,c)},_initRenderer:function(){this._barRenderer=new cc.Sprite;this._progressBarRenderer=new cc.Sprite;this._progressBarRenderer.setAnchorPoint(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;c._textureLoaded||c.addEventListener("load",function(){d.loadBarTexture(d._textureFile,d._barTexType)});switch(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;c._textureLoaded||c.addEventListener("load",function(){d.loadProgressBarTexture(d._progressBarTextureFile,d._progressBarTexType)});
switch(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,.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._progressBarRenderer=this._barRenderer=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){if(!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;this._slidBallNormalRenderer._textureLoaded||this._slidBallNormalRenderer.addEventListener("load",function(){c.loadSlidBallTextureNormal(c._slidBallNormalTextureFile,c._ballNTexType)});switch(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;this._slidBallPressedRenderer._textureLoaded||this._slidBallPressedRenderer.addEventListener("load",function(){c.loadSlidBallTexturePressed(c._slidBallPressedTextureFile,c._ballPTexType)});switch(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;this._slidBallDisabledRenderer._textureLoaded||this._slidBallDisabledRenderer.addEventListener("load",function(){c.loadSlidBallTextureDisabled(c._slidBallDisabledTextureFile,c._ballDTexType)});switch(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=a/100*this._barLength;this._slidBallRenderer.setPosition(a,this._contentSize.height/2);if(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 a/this._barLength*100},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)this._barRenderer.setScale(1);else{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;var 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){this._progressBarRenderer.setScale(1);return}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);
cc._renderType===cc.game.RENDER_TYPE_WEBGL&&(this._slidBallNormalRenderer._renderCmd._shaderProgram=this._getNormalGLProgram())},_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);cc._renderType===cc.game.RENDER_TYPE_WEBGL&&
(this._slidBallNormalRenderer._renderCmd._shaderProgram=this._getNormalGLProgram())},_onPressStateChangedToDisabled:function(){this._slidBallDisabledTextureFile?(this._slidBallNormalRenderer.setVisible(!1),this._slidBallDisabledRenderer.setVisible(!0)):(this._slidBallNormalRenderer.setVisible(!0),cc._renderType===cc.game.RENDER_TYPE_WEBGL&&(this._slidBallNormalRenderer._renderCmd._shaderProgram=this._getGrayGLProgram()));this._slidBallNormalRenderer.setScale(this._sliderBallNormalTextureScaleX,this._sliderBallNormalTextureScaleY);
this._slidBallPressedRenderer.setVisible(!1)},setZoomScale:function(a){this._zoomScale=a},getZoomScale:function(){return this._zoomScale},getSlidBallNormalRenderer:function(){return this._slidBallNormalRenderer},getSlidBallPressedRenderer:function(){return this._slidBallPressedRenderer},getSlidBallDisabledRenderer:function(){return this._slidBallDisabledRenderer},getSlidBallRenderer:function(){return this._slidBallRenderer},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;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:"Arial",_fontSize:16,_onSelectedScaleOffset:.5,_labelRenderer:null,_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.setFontName(b),this.setFontSize(c),this.setString(a)):this.setFontName(this._fontName)},
_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._setString(a),this._updateContentSizeWithTextureSize(this._labelRenderer.getContentSize()))},_setString:function(a){this._labelRenderer.setString(a);this._labelRendererAdaptDirty=!0},getStringValue:function(){cc.log("Please use the getString");
return this._labelRenderer.getString()},getString:function(){return this._labelRenderer.getString()},getStringLength:function(){return this._labelRenderer.getStringLength()},setFontSize:function(a){this._setFontSize(a);this._updateContentSizeWithTextureSize(this._labelRenderer.getContentSize())},_setFontSize:function(a){this._labelRenderer.setFontSize(a);this._fontSize=a;this._labelRendererAdaptDirty=!0},getFontSize:function(){return this._fontSize},setFontName:function(a){this._setFontName(a);this._updateContentSizeWithTextureSize(this._labelRenderer.getContentSize())},
_setFontName:function(a){this._fontName=a;this._labelRenderer.setFontName(a);this._labelRendererAdaptDirty=!0},_updateUITextContentSize:function(){this._updateContentSizeWithTextureSize(this._labelRenderer.getContentSize())},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._setTextAreaSize(a);this._updateContentSizeWithTextureSize(this._labelRenderer.getContentSize())},_setTextAreaSize:function(a){this._labelRenderer.setDimensions(a);this._ignoreSize||(this._customSize=a);this._labelRendererAdaptDirty=!0},getTextAreaSize:function(){return this._labelRenderer.getDimensions()},setTextHorizontalAlignment:function(a){this._setTextHorizontalAlignment(a);this._updateContentSizeWithTextureSize(this._labelRenderer.getContentSize())},
_setTextHorizontalAlignment:function(a){this._labelRenderer.setHorizontalAlignment(a);this._labelRendererAdaptDirty=!0},getTextHorizontalAlignment:function(){return this._labelRenderer.getHorizontalAlignment()},setTextVerticalAlignment:function(a){this._setTextVerticalAlignment(a);this._updateContentSizeWithTextureSize(this._labelRenderer.getContentSize())},_setTextVerticalAlignment:function(a){this._labelRenderer.setVerticalAlignment(a);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();
this._ignoreSize||(this._labelRenderer.setDimensions(0,0),a=this._labelRenderer.getContentSize(),this._labelRenderer.setDimensions(this._contentSize.width,this._contentSize.height));return a},_labelScaleChangedWithSize:function(){var a=this._contentSize;if(this._ignoreSize)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){this._labelRenderer.setScale(1);
return}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()),
this.setTextColor(a.getTextColor()))},_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;cc.defineGetterSetter(_p,"boundingWidth",_p._getBoundingWidth,_p._setBoundingWidth);cc.defineGetterSetter(_p,"boundingHeight",_p._getBoundingHeight,_p._setBoundingHeight);cc.defineGetterSetter(_p,"string",_p.getString,_p.setString);cc.defineGetterSetter(_p,"stringLength",_p.getStringLength);
cc.defineGetterSetter(_p,"font",_p._getFont,_p._setFont);cc.defineGetterSetter(_p,"fontSize",_p.getFontSize,_p.setFontSize);cc.defineGetterSetter(_p,"fontName",_p.getFontName,_p.setFontName);cc.defineGetterSetter(_p,"textAlign",_p.getTextHorizontalAlignment,_p.setTextHorizontalAlignment);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(.5,.5));this.addProtectedChild(this._labelAtlasRenderer,ccui.TextAtlas.RENDERER_ZORDER,
-1);this._labelAtlasRenderer.addEventListener("load",function(){this._updateContentSizeWithTextureSize(this._labelAtlasRenderer.getContentSize());this._findLayout()},this)},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(){cc.log("Please use the getString");return 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){a.setScale(1);return}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;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);this._loader=new cc.Sprite.LoadManager;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){this._loader.clear();this._labelBMFontRenderer._textureLoaded?a!==this._labelBMFontRenderer.getString()&&
(this._stringValue=a,this._labelBMFontRenderer.setString(a),this._fntFileHasInit&&(this._updateContentSizeWithTextureSize(this._labelBMFontRenderer.getContentSize()),this._labelBMFontRendererAdaptDirty=!0)):this._loader.add(this._labelBMFontRenderer,function(){this.setString(a)},this)},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){a.setScale(1);return}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;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){this.setAttachWithIME(!0);return!1},onTextFieldInsertText:function(a,b,c){if(1===c&&"\n"===b)return!1;this.setInsertText(!0);return this._maxLengthEnabled&&cc.TextFieldTTF.prototype.getCharCount.call(this)>=this._maxLength},onTextFieldDeleteBackward:function(a,b,c){this.setDeleteBackward(!0);return!1},onTextFieldDetachWithIME:function(a){this.setDetachWithIME(!0);return!1},insertText:function(a,b){"\n"!==a&&
this._maxLengthEnabled&&this.getString().length>=this._maxLength?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;c<a;++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);this.setTouchEnabled(!0);b&&this.setFontName(b);c&&this.setFontSize(c);a&&this.setPlaceHolder(a)},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(){cc.log("Please use the getString");return 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);c._hit?setTimeout(function(){c._textFieldRenderer.attachWithIME()},0):setTimeout(function(){c._textFieldRenderer.detachWithIME()},0);return 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();this._ignoreSize||(this._textFieldRenderer.setDimensions(0,0),a=this._textFieldRenderer.getContentSize(),this._textFieldRenderer.setDimensions(this._contentSize.width,
this._contentSize.height));return 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;cc.defineGetterSetter(_p,"string",_p.getString,_p.setString);cc.defineGetterSetter(_p,"placeHolder",_p.getPlaceHolder,_p.setPlaceHolder);cc.defineGetterSetter(_p,"font",_p._getFont,_p._setFont);cc.defineGetterSetter(_p,"fontSize",_p.getFontSize,_p.setFontSize);cc.defineGetterSetter(_p,"fontName",_p.getFontName,_p.setFontName);cc.defineGetterSetter(_p,"maxLengthEnabled",_p.isMaxLengthEnabled,_p.setMaxLengthEnabled);
cc.defineGetterSetter(_p,"maxLength",_p.getMaxLength,_p.setMaxLength);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.VideoPlayer=ccui.Widget.extend({_played:!1,_playing:!1,_stopped:!0,ctor:function(a){ccui.Widget.prototype.ctor.call(this);this._EventList={};a&&this.setURL(a)},_createRenderCmd:function(){return new ccui.VideoPlayer.RenderCmd(this)},visit:function(){var a=this._renderCmd,b=cc.container,c=cc.eventManager;if(this._visible)b.appendChild(a._video),null===this._listener&&(this._listener=cc.eventManager.addCustomListener(cc.game.EVENT_RESIZE,function(){a.resize()}));else{var d=!1;(d="contains"in b?
b.contains(a._video):b.compareDocumentPosition(a._video)%16)&&b.removeChild(a._video);c.removeListener(a._listener);a._listener=null}a.updateStatus();a.resize()},setURL:function(a){this._renderCmd.updateURL(a)},getURL:function(){return this._renderCmd._url},play:function(){var a=this,b=this._renderCmd._video;if(b){this._played=!0;b.pause();if(!1!==this._stopped||!1!==this._playing||!0!==this._played)b.currentTime=0;ccui.VideoPlayer._polyfill.autoplayAfterOperation?setTimeout(function(){b.play();a._playing=
!0;a._stopped=!1},20):(b.play(),this._playing=!0,this._stopped=!1)}},pause:function(){var a=this._renderCmd._video;a&&!0===this._playing&&!1===this._stopped&&(a.pause(),this._playing=!1)},resume:function(){!1===this._stopped&&!1===this._playing&&!0===this._played&&this.play()},stop:function(){var a=this,b=this._renderCmd._video;b&&(b.pause(),b.currentTime=0,this._playing=!1,this._stopped=!0);setTimeout(function(){a._dispatchEvent(ccui.VideoPlayer.EventType.STOPPED)},0)},seekTo:function(a){var b=this._renderCmd._video;
b&&(b.currentTime=a,ccui.VideoPlayer._polyfill.autoplayAfterOperation&&this.isPlaying()&&setTimeout(function(){b.play()},20))},isPlaying:function(){ccui.VideoPlayer._polyfill.autoplayAfterOperation&&this._playing&&setTimeout(function(){video.play()},20);return this._playing},setKeepAspectRatioEnabled:function(a){cc.log("On the web is always keep the aspect ratio")},isKeepAspectRatioEnabled:function(){return!1},setFullScreenEnabled:function(a){var b=this._renderCmd._video;b&&(a?cc.screen.requestFullScreen(b):
cc.screen.exitFullScreen(b))},isFullScreenEnabled:function(){cc.log("Can't know status")},setEventListener:function(a,b){this._EventList[a]=b},removeEventListener:function(a){this._EventList[a]=null},_dispatchEvent:function(a){(a=this._EventList[a])&&a.call(this,this,this._renderCmd._video.src)},onPlayEvent:function(){var a=this._EventList[ccui.VideoPlayer.EventType.PLAYING];if(a)for(var b=0;b<a.length;b++)a[b].call(this,this,this._renderCmd._video.src)},setContentSize:function(a,b){ccui.Widget.prototype.setContentSize.call(this,
a,b);void 0===b&&(b=a.height,a=a.width);this._renderCmd.changeSize(a,b)},cleanup:function(){this._renderCmd.removeDom();this.stopAllActions();this.unscheduleAllCallbacks()},onEnter:function(){ccui.Widget.prototype.onEnter.call(this);var a=ccui.VideoPlayer.elements;-1===a.indexOf(this)&&a.push(this)},onExit:function(){ccui.Widget.prototype.onExit.call(this);var a=ccui.VideoPlayer.elements,b=a.indexOf(this);-1!==b&&a.splice(b,1)}});ccui.VideoPlayer.elements=[];ccui.VideoPlayer.pauseElements=[];
cc.eventManager.addCustomListener(cc.game.EVENT_HIDE,function(){for(var a=ccui.VideoPlayer.elements,b,c=0;c<a.length;c++)b=a[c],a[c]._playing&&(b.pause(),ccui.VideoPlayer.pauseElements.push(b))});cc.eventManager.addCustomListener(cc.game.EVENT_SHOW,function(){for(var a=ccui.VideoPlayer.pauseElements,b=a.pop();b;)b.play(),b=a.pop()});ccui.VideoPlayer.EventType={PLAYING:"play",PAUSED:"pause",STOPPED:"stop",COMPLETED:"complete"};
(function(a){a._polyfill={devicePixelRatio:!1,event:"canplay",canPlayType:[]};var b=document.createElement("video");b.canPlayType("video/ogg")&&(a._polyfill.canPlayType.push(".ogg"),a._polyfill.canPlayType.push(".ogv"));b.canPlayType("video/mp4")&&a._polyfill.canPlayType.push(".mp4");b.canPlayType("video/webm")&&a._polyfill.canPlayType.push(".webm");cc.sys.OS_IOS===cc.sys.os&&(a._polyfill.devicePixelRatio=!0,a._polyfill.event="progress");cc.sys.browserType===cc.sys.BROWSER_TYPE_FIREFOX&&(a._polyfill.autoplayAfterOperation=
!0);a=document.createElement("style");a.innerHTML=".cocosVideo:-moz-full-screen{transform:matrix(1,0,0,1,0,0) !important;}.cocosVideo:full-screen{transform:matrix(1,0,0,1,0,0) !important;}.cocosVideo:-webkit-full-screen{transform:matrix(1,0,0,1,0,0) !important;}";document.head.appendChild(a)})(ccui.VideoPlayer);
(function(a){var b=null;b=cc._renderType===cc.game.RENDER_TYPE_WEBGL?cc.Node.WebGLRenderCmd:cc.Node.CanvasRenderCmd;ccui.VideoPlayer.RenderCmd=function(a){this._rootCtor(a);this._listener=null;this._url="";this.initStyle()};b=ccui.VideoPlayer.RenderCmd.prototype=Object.create(b.prototype);b.constructor=ccui.VideoPlayer.RenderCmd;b.transform=function(a,b){this.originTransform(a,b);this.updateMatrix(this._worldTransform,cc.view._scaleX,cc.view._scaleY)};b.updateStatus=function(){a.devicePixelRatio=
cc.view.isRetinaEnabled();var b=cc.Node._dirtyFlags,d=this._dirtyFlag;d&b.transformDirty&&(this.transform(this.getParentRenderCmd(),!0),this.updateMatrix(this._worldTransform,cc.view._scaleX,cc.view._scaleY),this._dirtyFlag^=this._dirtyFlag&cc.Node._dirtyFlags.transformDirty);d&b.orderDirty&&(this._dirtyFlag^=this._dirtyFlag&b.orderDirty)};b.resize=function(a){a=a||cc.view;var b=this._node,c=cc.eventManager;b._parent&&b._visible?this.updateMatrix(this._worldTransform,a._scaleX,a._scaleY):(c.removeListener(this._listener),
this._listener=null)};b.updateMatrix=function(b,d,e){var c=this._node;if(a.devicePixelRatio){var g=cc.view.getDevicePixelRatio();d/=g;e/=g}if(!1!==this._loaded){var h=cc.game.container.style;g=parseInt(h.paddingLeft);h=parseInt(h.paddingBottom);var k=c._contentSize.width,m=c._contentSize.height;b="matrix("+b.a*d+","+b.b+","+b.c+","+b.d*e+","+(g+b.tx*d-k/2+k*c._scaleX/2*d)+","+-(h+b.ty*e-m/2+m*c._scaleY/2*e)+")";this._video.style.transform=b;this._video.style["-webkit-transform"]=b}};b.updateURL=function(b){var c=
this._node;if(this._url!=b){this._url=b;cc.loader.resPath&&!/^http/.test(b)&&(b=cc.path.join(cc.loader.resPath,b));var e=!1;var f=cc.container;(e="contains"in f?f.contains(this._video):f.compareDocumentPosition(this._video)%16)&&f.removeChild(this._video);var g=this._video=document.createElement("video");this.bindEvent();var h=this,k=function(){1!=h._loaded&&(h._loaded=!0,h.changeSize(),h.setDirtyFlag(cc.Node._dirtyFlags.transformDirty),g.removeEventListener(a.event,k),g.currentTime=0,g.style.visibility=
"visible",g.play(),c._played||(g.pause(),g.currentTime=0))};g.addEventListener(a.event,k);g.preload="metadata";g.style.visibility="hidden";this._loaded=!1;c._played=!1;c._playing=!1;c._stopped=!0;this.initStyle();this._node.visit();e=document.createElement("source");e.src=b;g.appendChild(e);f=cc.path.extname(b);for(var m=0;m<a.canPlayType.length;m++)f!==a.canPlayType[m]&&(e=document.createElement("source"),e.src=b.replace(f,a.canPlayType[m]),g.appendChild(e))}};b.bindEvent=function(){var a=this,b=
this._node,e=this._video;e.addEventListener("ended",function(){b._renderCmd.updateMatrix(a._worldTransform,cc.view._scaleX,cc.view._scaleY);b._playing=!1;b._dispatchEvent(ccui.VideoPlayer.EventType.COMPLETED)});e.addEventListener("play",function(){b._dispatchEvent(ccui.VideoPlayer.EventType.PLAYING)});e.addEventListener("pause",function(){b._dispatchEvent(ccui.VideoPlayer.EventType.PAUSED)})};b.initStyle=function(){if(this._video){var a=this._video;a.style.position="absolute";a.style.bottom="0px";
a.style.left="0px";a.className="cocosVideo"}};b.changeSize=function(a,b){var c=this._node._contentSize;a=a||c.width;b=b||c.height;if(c=this._video)0!==a&&(c.width=a),0!==b&&(c.height=b)};b.removeDom=function(){var a=this._video;a&&("contains"in cc.container?cc.container.contains(a):cc.container.compareDocumentPosition(a)%16)&&cc.container.removeChild(a)}})(ccui.VideoPlayer._polyfill);ccui.RichElement=ccui.Class.extend({_type:0,_tag:0,_color:null,_opacity:0,ctor:function(a,b,c){this._type=0;this._tag=a||0;this._color=cc.color(255,255,255,255);b&&(this._color.r=b.r,this._color.g=b.g,this._color.b=b.b);this._opacity=c||0;this._color.a=void 0===c?b.a:c}});
ccui.RichElementText=ccui.RichElement.extend({_text:"",_fontName:"",_fontSize:0,_fontDefinition:null,ctor:function(a,b,c,d,e,f){var g=b;b&&b instanceof cc.FontDefinition&&(g=b.fillStyle,e=b.fontName,f=b.fontSize,this._fontDefinition=b);ccui.RichElement.prototype.ctor.call(this,a,g,c);this._type=ccui.RichElement.TEXT;this._text=d;this._fontName=e;this._fontSize=f}});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,a,b,c);this._type=ccui.RichElement.IMAGE;this._filePath=d||"";this._textureRect=cc.rect(0,0,0,0);this._textureType=0}});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,a,b,c);this._type=ccui.RichElement.CUSTOM;this._customNode=d||null}});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(.5,.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=this._richElements;if(this._ignoreSize)for(this._addNewLine(),a=0;a<b.length;a++){var c=b[a];var d=null;switch(c._type){case ccui.RichElement.TEXT:d=c._fontDefinition?new cc.LabelTTF(c._text,c._fontDefinition):new cc.LabelTTF(c._text,c._fontName,c._fontSize);break;case ccui.RichElement.IMAGE:d=new cc.Sprite(c._filePath);break;case ccui.RichElement.CUSTOM:d=c._customNode}d.setColor(c._color);d.setOpacity(c._color.a);this._pushToContainer(d)}else for(this._addNewLine(),
a=0;a<b.length;a++)switch(c=b[a],c._type){case ccui.RichElement.TEXT:c._fontDefinition?this._handleTextRenderer(c._text,c._fontDefinition,c._fontDefinition.fontSize,c._fontDefinition.fillStyle):this._handleTextRenderer(c._text,c._fontName,c._fontSize,c._color);break;case ccui.RichElement.IMAGE:this._handleImageRenderer(c._filePath,c._color,c._color.a);break;case ccui.RichElement.CUSTOM:this._handleCustomRenderer(c._customNode)}this.formatRenderers();this._formatTextDirty=!1}},_handleTextRenderer:function(a,
b,c,d){if(""!==a)if("\n"===a)this._addNewLine();else{var e=b instanceof cc.FontDefinition?new cc.LabelTTF(a,b):new cc.LabelTTF(a,b,c),f=e.getContentSize().width;this._leftSpaceWidth-=f;if(0>this._leftSpaceWidth){e=a.length*(1- -this._leftSpaceWidth/f);f=a.substr(0,e);var 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&&(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=0,b=this._elementRenderersContainer,c=this._elementRenders,d,e;if(this._ignoreSize){var f=0;var g=c[0];for(d=e=0;d<g.length;d++){var h=g[d];h.setAnchorPoint(cc.p(0,0));h.setPosition(e,0);b.addChild(h,1,d);var k=h.getLineHeight?h.getLineHeight():a;h=h.getContentSize();f+=h.width;a=Math.max(Math.min(a,k),h.height);
e+=h.width}if(this._textHorizontalAlignment!==cc.TEXT_ALIGNMENT_LEFT)for(k=0,this._textHorizontalAlignment===cc.TEXT_ALIGNMENT_RIGHT?k=this._contentSize.width-e:this._textHorizontalAlignment===cc.TEXT_ALIGNMENT_CENTER&&(k=(this._contentSize.width-e)/2),d=0;d<g.length;d++)g[d].x+=k;b.setContentSize(f,a)}else{var m=[];for(f=0;f<c.length;f++){g=c[f];for(d=e=0;d<g.length;d++)h=g[d],k=h.getLineHeight?h.getLineHeight():h.getContentSize().height,e=Math.max(Math.min(h.getContentSize().height,k),e);m[f]=e;
a+=m[f]}var n=this._customSize.height;for(f=0;f<c.length;f++){g=c[f];e=0;n-=m[f]+this._verticalSpace;for(d=0;d<g.length;d++)h=g[d],h.setAnchorPoint(cc.p(0,0)),h.setPosition(cc.p(e,n)),b.addChild(h,1),e+=h.getContentSize().width;if(this._textHorizontalAlignment!==cc.TEXT_ALIGNMENT_LEFT||this._textVerticalAlignment!==cc.VERTICAL_TEXT_ALIGNMENT_TOP)for(k=0,this._textHorizontalAlignment===cc.TEXT_ALIGNMENT_RIGHT?k=this._contentSize.width-e:this._textHorizontalAlignment===cc.TEXT_ALIGNMENT_CENTER&&(k=
(this._contentSize.width-e)/2),e=0,this._textVerticalAlignment===cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM?e=this._customSize.height-a:this._textVerticalAlignment===cc.VERTICAL_TEXT_ALIGNMENT_CENTER&&(e=(this._customSize.height-a)/2),d=0;d<g.length;d++)h=g[d],h.x+=k,h.y-=e}b.setContentSize(this._contentSize)}a=c.length;for(f=0;f<a;f++)c[f].length=0;this._elementRenders.length=0;this.setContentSize(this._ignoreSize?this.getVirtualRendererSize():this._customSize);this._updateContentSizeWithTextureSize(this._contentSize);
b.setPosition(.5*this._contentSize.width,.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(){this.formatText();return cc.Node.prototype.getContentSize.call(this)},_getWidth:function(){this.formatText();return cc.Node.prototype._getWidth.call(this)},
_getHeight:function(){this.formatText();return 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){ccui.Widget.prototype.setCascadeOpacityEnabled.call(this,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.WebView=ccui.Widget.extend({ctor:function(a){ccui.Widget.prototype.ctor.call(this);this._EventList={};a&&this.loadURL(a)},visit:function(){var a=this._renderCmd,b=a._div,c=cc.container,d=cc.eventManager;if(this._visible)c.appendChild(b),null===this._listener&&(this._listener=d.addCustomListener(cc.game.EVENT_RESIZE,function(){a.resize()}));else{var e=!1;(e="contains"in c?c.contains(b):c.compareDocumentPosition(b)%16)&&c.removeChild(b);b=d._listenersMap[cc.game.EVENT_RESIZE].getFixedPriorityListeners();
d._removeListenerInVector(b,a._listener);a._listener=null}a.updateStatus();a.resize(cc.view)},setJavascriptInterfaceScheme:function(a){},loadData:function(a,b,c,d){},loadHTMLString:function(a,b){},loadURL:function(a){this._renderCmd.updateURL(a);this._dispatchEvent(ccui.WebView.EventType.LOADING)},stopLoading:function(){cc.log("Web does not support loading")},reload:function(){var a=this._renderCmd._iframe;a&&(a=a.contentWindow)&&a.location&&a.location.reload()},canGoBack:function(){cc.log("Web does not support query history");
return!0},canGoForward:function(){cc.log("Web does not support query history");return!0},goBack:function(){try{if(ccui.WebView._polyfill.closeHistory)return cc.log("The current browser does not support the GoBack");var a=this._renderCmd._iframe;if(a){var b=a.contentWindow;if(b&&b.location)try{b.history.back.call(b)}catch(c){b.history.back()}}}catch(c){cc.log(c)}},goForward:function(){try{if(ccui.WebView._polyfill.closeHistory)return cc.log("The current browser does not support the GoForward");var a=
this._renderCmd._iframe;if(a){var b=a.contentWindow;if(b&&b.location)try{b.history.forward.call(b)}catch(c){b.history.forward()}}}catch(c){cc.log(c)}},evaluateJS:function(a){var b=this._renderCmd._iframe;if(b){b=b.contentWindow;try{b.eval(a),this._dispatchEvent(ccui.WebView.EventType.JS_EVALUATED)}catch(c){console.error(c)}}},setScalesPageToFit:function(){cc.log("Web does not support zoom")},setEventListener:function(a,b){this._EventList[a]=b},removeEventListener:function(a){this._EventList[a]=null},
_dispatchEvent:function(a){(a=this._EventList[a])&&a.call(this,this,this._renderCmd._iframe.src)},_createRenderCmd:function(){return new ccui.WebView.RenderCmd(this)},setContentSize:function(a,b){ccui.Widget.prototype.setContentSize.call(this,a,b);void 0===b&&(b=a.height,a=a.width);this._renderCmd.changeSize(a,b)},cleanup:function(){this._renderCmd.removeDom();this.stopAllActions();this.unscheduleAllCallbacks()}});ccui.WebView.EventType={LOADING:"loading",LOADED:"load",ERROR:"error",JS_EVALUATED:"js"};
(function(){var a=ccui.WebView._polyfill={devicePixelRatio:!1,enableDiv:!1};cc.sys.os===cc.sys.OS_IOS&&(a.enableDiv=!0);cc.sys.isMobile?cc.sys.browserType===cc.sys.BROWSER_TYPE_FIREFOX&&(a.enableBG=!0):cc.sys.browserType===cc.sys.BROWSER_TYPE_IE&&(a.closeHistory=!0)})();
(function(a){var b=null;b=cc._renderType===cc.game.RENDER_TYPE_WEBGL?cc.Node.WebGLRenderCmd:cc.Node.CanvasRenderCmd;ccui.WebView.RenderCmd=function(b){this._rootCtor(b);this._iframe=this._div=null;a.enableDiv?(this._div=document.createElement("div"),this._div.style["-webkit-overflow"]="auto",this._div.style["-webkit-overflow-scrolling"]="touch",this._iframe=document.createElement("iframe"),this._iframe.style.width="100%",this._iframe.style.height="100%",this._div.appendChild(this._iframe)):this._div=
this._iframe=document.createElement("iframe");a.enableBG&&(this._div.style.background="#FFF");this._iframe.addEventListener("load",function(){b._dispatchEvent(ccui.WebView.EventType.LOADED)});this._iframe.addEventListener("error",function(){b._dispatchEvent(ccui.WebView.EventType.ERROR)});this._div.style.background="#FFF";this._div.style.height="200px";this._div.style.width="300px";this._div.style.overflow="scroll";this._div.style.border="none";this._listener=null;this.initStyle()};b=ccui.WebView.RenderCmd.prototype=
Object.create(b.prototype);b.constructor=ccui.WebView.RenderCmd;b.transform=function(a,b){this.originTransform(a,b);this.updateMatrix(this._worldTransform,cc.view._scaleX,cc.view._scaleY)};b.updateStatus=function(){a.devicePixelRatio=cc.view.isRetinaEnabled();var b=cc.Node._dirtyFlags,d=this._dirtyFlag;d&b.transformDirty&&(this.transform(this.getParentRenderCmd(),!0),this.updateMatrix(this._worldTransform,cc.view._scaleX,cc.view._scaleY),this._dirtyFlag^=this._dirtyFlag&cc.Node._dirtyFlags.transformDirty);
d&b.orderDirty&&(this._dirtyFlag^=this._dirtyFlag&b.orderDirty)};b.resize=function(a){a=a||cc.view;var b=this._node,c=cc.eventManager;b._parent&&b._visible?this.updateMatrix(this._worldTransform,a._scaleX,a._scaleY):(a=c._listenersMap[cc.game.EVENT_RESIZE].getFixedPriorityListeners(),c._removeListenerInVector(a,this._listener),this._listener=null)};b.updateMatrix=function(b,d,e){var c=this._node;if(a.devicePixelRatio){var g=cc.view.getDevicePixelRatio();d/=g;e/=g}if(!1!==this._loaded){var h=cc.game.container.style;
g=parseInt(h.paddingLeft);h=parseInt(h.paddingBottom);var k=c._contentSize.width,m=c._contentSize.height;b="matrix("+b.a*d+","+b.b+","+b.c+","+b.d*e+","+(g+b.tx*d-k/2+k*c._scaleX/2*d)+","+-(h+b.ty*e-m/2+m*c._scaleY/2*e)+")";this._div.style.transform=b;this._div.style["-webkit-transform"]=b}};b.initStyle=function(){if(this._div){var a=this._div;a.style.position="absolute";a.style.bottom="0px";a.style.left="0px"}};b.updateURL=function(a){var b=this._iframe;b.src=a;var c=this,f=function(){c._loaded=
!0;b.removeEventListener("load",f)};b.addEventListener("load",f)};b.changeSize=function(a,b){var c=this._div;c&&(c.style.width=a+"px",c.style.height=b+"px")};b.removeDom=function(){var a=this._div;a&&("contains"in cc.container?cc.container.contains(a):cc.container.compareDocumentPosition(a)%16)&&cc.container.removeChild(a)}})(ccui.WebView._polyfill);ccui.ScrollViewBar=ccui.ProtectedNode.extend({_parentScroll:null,_direction:null,_upperHalfCircle:null,_lowerHalfCircle:null,_body:null,_opacity:255,_marginFromBoundary:0,_marginForLength:0,_touching:!1,_autoHideEnabled:!0,autoHideTime:0,_autoHideRemainingTime:0,_className:"ScrollViewBar",ctor:function(a,b){cc.ProtectedNode.prototype.ctor.call(this);this._direction=b;this._parentScroll=a;this._marginForLength=this._marginFromBoundary=ccui.ScrollViewBar.DEFAULT_MARGIN;this.opacity=255*ccui.ScrollViewBar.DEFAULT_SCROLLBAR_OPACITY;
this.autoHideTime=ccui.ScrollViewBar.DEFAULT_AUTO_HIDE_TIME;this._autoHideEnabled=!0;ccui.ScrollViewBar.prototype.init.call(this);this.setCascadeColorEnabled(!0);this.setCascadeOpacityEnabled(!0)},init:function(){this._upperHalfCircle=ccui.helper._createSpriteFromBase64(ccui.ScrollViewBar.HALF_CIRCLE_IMAGE,ccui.ScrollViewBar.HALF_CIRCLE_IMAGE_KEY);this._upperHalfCircle.setAnchorPoint(cc.p(.5,0));this._lowerHalfCircle=ccui.helper._createSpriteFromBase64(ccui.ScrollViewBar.HALF_CIRCLE_IMAGE,ccui.ScrollViewBar.HALF_CIRCLE_IMAGE_KEY);
this._lowerHalfCircle.setAnchorPoint(cc.p(.5,0));this._lowerHalfCircle.setScaleY(-1);this.addProtectedChild(this._upperHalfCircle);this.addProtectedChild(this._lowerHalfCircle);this._body=ccui.helper._createSpriteFromBase64(ccui.ScrollViewBar.BODY_IMAGE_1_PIXEL_HEIGHT,ccui.ScrollViewBar.BODY_IMAGE_1_PIXEL_HEIGHT_KEY);this._body.setAnchorPoint(cc.p(.5,0));this.addProtectedChild(this._body);this.setColor(ccui.ScrollViewBar.DEFAULT_COLOR);this.onScrolled(cc.p(0,0));cc.ProtectedNode.prototype.setOpacity.call(this,
0);this._autoHideRemainingTime=0;this._direction===ccui.ScrollView.DIR_HORIZONTAL&&this.setRotation(90)},setPositionFromCorner:function(a){this._direction===ccui.ScrollView.DIR_VERTICAL?(this._marginForLength=a.y,this._marginFromBoundary=a.x):(this._marginForLength=a.x,this._marginFromBoundary=a.y)},onEnter:function(){cc.ProtectedNode.prototype.onEnter.call(this);this.scheduleUpdate()},getPositionFromCorner:function(){return this._direction===ccui.ScrollView.DIR_VERTICAL?cc.p(this._marginFromBoundary,
this._marginForLength):cc.p(this._marginForLength,this._marginFromBoundary)},setWidth:function(a){a/=this._body.width;this._body.setScaleX(a);this._upperHalfCircle.setScale(a);this._lowerHalfCircle.setScale(-a)},getWidth:function(){return this._body.getBoundingBox().width},setAutoHideEnabled:function(a){this._autoHideEnabled=a;!this._autoHideEnabled&&!this._touching&&0>=this._autoHideRemainingTime?cc.ProtectedNode.prototype.setOpacity.call(this,this.opacity):cc.ProtectedNode.prototype.setOpacity.call(this,
0)},isAutoHideEnabled:function(){return this._autoHideEnabled},setOpacity:function(a){this._opacity=a},getOpacity:function(){return this._opacity},_updateLength:function(a){var b=a/this._body.getTextureRect().height;this._body.setScaleY(b);this._upperHalfCircle.setPositionY(this._body.getPositionY()+a)},_processAutoHide:function(a){!this._autoHideEnabled||0>=this._autoHideRemainingTime||this._touching||(this._autoHideRemainingTime-=a,this._autoHideRemainingTime<=this.autoHideTime&&(this._autoHideRemainingTime=
Math.max(0,this._autoHideRemainingTime),cc.ProtectedNode.prototype.setOpacity.call(this,this._autoHideRemainingTime/this.autoHideTime*this._opacity)))},update:function(a){this._processAutoHide(a)},onTouchBegan:function(){this._autoHideEnabled&&(this._touching=!0)},onTouchEnded:function(){this._autoHideEnabled&&(this._touching=!1,0>=this._autoHideRemainingTime||(this._autoHideRemainingTime=this.autoHideTime))},onScrolled:function(a){this._autoHideEnabled&&(this._autoHideRemainingTime=this.autoHideTime,
cc.ProtectedNode.prototype.setOpacity.call(this,this.opacity));var b=this._parentScroll.getInnerContainer(),c=0,d=0,e=0,f=0;this._direction===ccui.ScrollView.DIR_VERTICAL?(c=b.height,d=this._parentScroll.height,e=a.y,f=-b.getPositionY()):this._direction===ccui.ScrollView.DIR_HORIZONTAL&&(c=b.width,d=this._parentScroll.width,e=a.x,f=-b.getPositionX());a=this._calculateLength(c,d,e);c=this._calculatePosition(c,d,f,e,a);this._updateLength(a);this.setPosition(c)},_calculateLength:function(a,b,c){0!==
c&&(a+=20*(0<c?c:-c));return b/a*Math.abs(b-2*this._marginForLength)},_calculatePosition:function(a,b,c,d,e){a-=b;0!==d&&(a+=Math.abs(d));d=0;0!==a&&(d=Math.max(c/a,0),d=Math.min(d,1));b=(b-e-2*this._marginForLength)*d+this._marginForLength;return this._direction===ccui.ScrollView.DIR_VERTICAL?cc.p(this._parentScroll.width-this._marginFromBoundary,b):cc.p(b,this._marginFromBoundary)}});_p=ccui.ScrollViewBar.prototype;cc.defineGetterSetter(_p,"opacity",_p.getOpacity,_p.setOpacity);
cc.defineGetterSetter(_p,"autoHideEnabled",_p.isAutoHideEnabled,_p.setAutoHideEnabled);ccui.ScrollViewBar.DEFAULT_COLOR=cc.color(52,65,87);ccui.ScrollViewBar.DEFAULT_MARGIN=20;ccui.ScrollViewBar.DEFAULT_AUTO_HIDE_TIME=.2;ccui.ScrollViewBar.DEFAULT_SCROLLBAR_OPACITY=.4;ccui.ScrollViewBar.HALF_CIRCLE_IMAGE_KEY="/__half_circle_image";ccui.ScrollViewBar.HALF_CIRCLE_IMAGE="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAGCAMAAADAMI+zAAAAJ1BMVEX///////////////////////////////////////////////////9Ruv0SAAAADHRSTlMABgcbbW7Hz9Dz+PmlcJP5AAAAMElEQVR4AUXHwQ2AQAhFwYcLH1H6r1djzDK3ASxUpTBeK/uTCyz7dx54b44m4p5cD1MwAooEJyk3AAAAAElFTkSuQmCC";
ccui.ScrollViewBar.BODY_IMAGE_1_PIXEL_HEIGHT_KEY="/__body_image_height";ccui.ScrollViewBar.BODY_IMAGE_1_PIXEL_HEIGHT="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAABCAMAAADdNb8LAAAAA1BMVEX///+nxBvIAAAACklEQVR4AWNABgAADQABYc2cpAAAAABJRU5ErkJggg==";ccui.ScrollView=ccui.Layout.extend({_innerContainer:null,_direction:null,_topBoundary:0,_bottomBoundary:0,_leftBoundary:0,_rightBoundary:0,_touchMoveDisplacements:null,_touchMoveTimeDeltas:null,_touchMovePreviousTimestamp:0,_touchTotalTimeThreshold:.5,_autoScrolling:!1,_autoScrollTargetDelta:null,_autoScrollAttenuate:!0,_autoScrollStartPosition:null,_autoScrollTotalTime:0,_autoScrollAccumulatedTime:0,_autoScrollCurrentlyOutOfBoundary:!1,_autoScrollBraking:!1,_autoScrollBrakingStartPosition:null,_bePressed:!1,
_childFocusCancelOffset:0,bounceEnabled:!1,_outOfBoundaryAmount:null,_outOfBoundaryAmountDirty:!0,inertiaScrollEnabled:!1,_scrollBarEnabled:!0,_verticalScrollBar:null,_horizontalScrollBar:null,_scrollViewEventListener:null,_scrollViewEventSelector:null,_className:"ScrollView",ctor:function(){ccui.Layout.prototype.ctor.call(this);this.setClippingEnabled(!0);this._innerContainer.setTouchEnabled(!1);this._direction=ccui.ScrollView.DIR_NONE;this._childFocusCancelOffset=5;this.inertiaScrollEnabled=!0;
this._outOfBoundaryAmount=cc.p(0,0);this._autoScrollTargetDelta=cc.p(0,0);this._autoScrollStartPosition=cc.p(0,0);this._autoScrollBrakingStartPosition=cc.p(0,0);this._touchMoveDisplacements=[];this._touchMoveTimeDeltas=[];this._touchMovePreviousTimestamp=0;this._scrollBarEnabled=!0;this._initScrollBar();this.setTouchEnabled(!0)},onEnter:function(){ccui.Layout.prototype.onEnter.call(this);this.scheduleUpdate()},onExit:function(){cc.renderer._removeCache(this.__instanceId);ccui.Layout.prototype.onExit.call(this)},
visit:function(a){var b=this._renderCmd,c=a?a._renderCmd:null;if(this._visible){this._adaptRenderers();this._doLayout();a=cc.renderer;b.visit(c);a.pushRenderCommand(b);b instanceof ccui.ScrollView.WebGLRenderCmd&&a._turnToCacheMode(this.__instanceId);var d=this._clippingEnabled&&this._clippingType===ccui.Layout.CLIPPING_STENCIL,e=this._clippingEnabled&&this._clippingType===ccui.Layout.CLIPPING_SCISSOR;d?b.stencilClippingVisit(c):e&&b.scissorClippingVisit(c);var f,g=this._children,h=g.length,k;c=this._protectedChildren;
var m=c.length;this._reorderChildDirty&&this.sortAllChildren();this._reorderProtectedChildDirty&&this.sortAllProtectedChildren();for(f=0;f<h;f++)(k=g[f])&&k._visible&&k.visit(this);for(f=0;f<m;f++)(g=c[f])&&g._visible&&(b._changeProtectedChild(g),g.visit(this));d?b.postStencilVisit():e&&b.postScissorVisit();b instanceof ccui.ScrollView.WebGLRenderCmd&&a._turnToNormalMode();this.updateChildren();b._dirtyFlag=0}else b._propagateFlagsDown(c)},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)},_createRenderCmd:function(){return cc._renderType===cc.game.RENDER_TYPE_WEBGL?new ccui.ScrollView.WebGLRenderCmd(this):new ccui.ScrollView.CanvasRenderCmd(this)},_onSizeChanged:function(){ccui.Layout.prototype._onSizeChanged.call(this);var a=this._contentSize;this._topBoundary=a.height;this._rightBoundary=a.width;var 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);if(this._verticalScrollBar)this._verticalScrollBar.onScrolled(this._getHowMuchOutOfBoundary());if(this._horizontalScrollBar)this._horizontalScrollBar.onScrolled(this._getHowMuchOutOfBoundary())},setInnerContainerSize:function(a){var b=this._innerContainer,c=this._contentSize,d=c.width,e=c.height;a.width<c.width?cc.log("Inner width <= ScrollView width, it will be force sized!"):d=a.width;a.height<c.height?cc.log("Inner height <= ScrollView height, it will be force sized!"):
e=a.height;b.setContentSize(cc.size(d,e));a=this._innerContainer.getPosition();b=this._innerContainer.getAnchorPoint();0!=this._innerContainer.getLeftBoundary()&&(a.x=b.x*d);this._innerContainer.getTopBoundary()!=this._contentSize.height&&(a.y=this._contentSize.height-(1-b.y)*e);this.setInnerContainerPosition(a);this._updateScrollBar(cc.p(0,0))},_setInnerWidth:function(a){var b=this._contentSize.width,c=b,d=this._innerContainer,e=d.width;a<b?cc.log("Inner width <= scrollview width, it will be force sized!"):
c=a;d.width=c;switch(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;a<b?cc.log("Inner height <= scrollview height, it will be force sized!"):c=a;d.height=c;switch(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)},setInnerContainerPosition:function(a){if(a.x!==this._innerContainer.getPositionX()||a.y!==this._innerContainer.getPositionY()){this._innerContainer.setPosition(a);this._outOfBoundaryAmountDirty=!0;if(this.bounceEnabled)for(a=ccui.ScrollView.MOVEDIR_TOP;a<ccui.ScrollView.MOVEDIR_RIGHT;++a)this._isOutOfBoundary(a)&&this._processScrollEvent(a,!0);this._dispatchEvent(ccui.ScrollView.EVENT_CONTAINER_MOVED)}},getInnerContainerPosition:function(){return this._innerContainer.getPosition()},
getInnerContainerSize:function(){return this._innerContainer.getContentSize()},_getInnerWidth:function(){return this._innerContainer.width},_getInnerHeight:function(){return this._innerContainer.height},_isInContainer:function(a){if(!this._clippingEnabled)return!0;var b=a._position,c=a._contentSize;a=a._anchorPoint;var d=this._customSize,e=this._innerContainer._position,f=0,g=0;return(f=b.y-a.y*c.height)>=d.height-e.y||f+c.height<=-e.y||(g=b.x-a.x*c.width)>=d.width-e.x||g+c.width<=-e.x?!1:!0},updateChildren:function(){var a,
b=this._innerContainer._children;var c=0;for(a=b.length;c<a;c++){var d=b[c];!0===d._inViewRect&&!1===this._isInContainer(d)?d._inViewRect=!1:!1===d._inViewRect&&!0===this._isInContainer(d)&&(d._inViewRect=!0)}},addChild:function(a,b,c){if(!a)return!1;!1===this._isInContainer(a)&&(a._inViewRect=!1);b=b||a.getLocalZOrder();c=c||a.getTag();return this._innerContainer.addChild(a,b,c)},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)},_flattenVectorByDirection:function(a){var b=cc.p(0,0);b.x=this._direction===ccui.ScrollView.DIR_VERTICAL?0:a.x;b.y=this._direction===ccui.ScrollView.DIR_HORIZONTAL?
0:a.y;return b},_getHowMuchOutOfBoundary:function(a){void 0===a&&(a=cc.p(0,0));if(0===a.x&&0===a.y&&!this._outOfBoundaryAmountDirty)return this._outOfBoundaryAmount;var b=cc.p(0,0);this._innerContainer.getLeftBoundary()+a.x>this._leftBoundary?b.x=this._leftBoundary-(this._innerContainer.getLeftBoundary()+a.x):this._innerContainer.getRightBoundary()+a.x<this._rightBoundary&&(b.x=this._rightBoundary-(this._innerContainer.getRightBoundary()+a.x));this._innerContainer.getTopBoundary()+a.y<this._topBoundary?
b.y=this._topBoundary-(this._innerContainer.getTopBoundary()+a.y):this._innerContainer.getBottomBoundary()+a.y>this._bottomBoundary&&(b.y=this._bottomBoundary-(this._innerContainer.getBottomBoundary()+a.y));0===a.x&&0===a.y&&(this._outOfBoundaryAmount=b,this._outOfBoundaryAmountDirty=!1);return b},_isOutOfBoundary:function(a){var b=this._getHowMuchOutOfBoundary();if(void 0!==a)switch(a){case ccui.ScrollView.MOVEDIR_TOP:return 0<b.y;case ccui.ScrollView.MOVEDIR_BOTTOM:return 0>b.y;case ccui.ScrollView.MOVEDIR_LEFT:return 0>
b.x;case ccui.ScrollView.MOVEDIR_RIGHT:return 0<b.x}else return!this._fltEqualZero(b);return!1},_moveInnerContainer:function(a,b){var c=this._flattenVectorByDirection(a);this.setInnerContainerPosition(cc.pAdd(this.getInnerContainerPosition(),c));c=this._getHowMuchOutOfBoundary();this._updateScrollBar(c);this.bounceEnabled&&b&&this._startBounceBackIfNeeded()},_updateScrollBar:function(a){if(this._verticalScrollBar)this._verticalScrollBar.onScrolled(a);if(this._horizontalScrollBar)this._horizontalScrollBar.onScrolled(a)},
_calculateTouchMoveVelocity:function(){for(var a=0,b=0;b<this._touchMoveTimeDeltas.length;++b)a+=this._touchMoveTimeDeltas[b];if(0==a||a>=this._touchTotalTimeThreshold)return cc.p(0,0);var c=cc.p(0,0);for(b=0;b<this._touchMoveDisplacements.length;++b)c.x+=this._touchMoveDisplacements[b].x,c.y+=this._touchMoveDisplacements[b].y;return cc.pMult(c,1/a)},setTouchTotalTimeThreshold:function(a){this._touchTotalTimeThreshold=a},getTouchTotalTimeThreshold:function(){return this._touchTotalTimeThreshold},
_startInertiaScroll:function(a){var b=cc.pMult(a,.7);this._startAttenuatingAutoScroll(b,a)},_startBounceBackIfNeeded:function(){if(!this.bounceEnabled)return!1;var a=this._getHowMuchOutOfBoundary();if(this._fltEqualZero(a))return!1;this._startAutoScroll(a,1,!0);return!0},_startAutoScrollToDestination:function(a,b,c){this._startAutoScroll(cc.pSub(a,this._innerContainer.getPosition()),b,c)},_calculateAutoScrollTimeByInitialSpeed:function(a){return Math.sqrt(Math.sqrt(a/5))},_startAttenuatingAutoScroll:function(a,
b){var c=this._calculateAutoScrollTimeByInitialSpeed(cc.pLength(b));this._startAutoScroll(a,c,!0)},_startAutoScroll:function(a,b,c){a=this._flattenVectorByDirection(a);this._autoScrolling=!0;this._autoScrollTargetDelta=a;this._autoScrollAttenuate=c;this._autoScrollStartPosition=this._innerContainer.getPosition();this._autoScrollTotalTime=b;this._autoScrollAccumulatedTime=0;this._autoScrollBraking=!1;this._autoScrollBrakingStartPosition=cc.p(0,0);b=this._getHowMuchOutOfBoundary();!this._fltEqualZero(b)&&
(this._autoScrollCurrentlyOutOfBoundary=!0,c=this._getHowMuchOutOfBoundary(a),0<b.x*c.x||0<b.y*c.y)&&(this._autoScrollBraking=!0)},stopAutoScroll:function(){this._autoScrolling=!1;this._autoScrollAttenuate=!0;this._autoScrollAccumulatedTime=this._autoScrollTotalTime=0},_isNecessaryAutoScrollBrake:function(){if(this._autoScrollBraking)return!0;if(this._isOutOfBoundary()){if(!this._autoScrollCurrentlyOutOfBoundary)return this._autoScrollBraking=this._autoScrollCurrentlyOutOfBoundary=!0,this._autoScrollBrakingStartPosition=
this.getInnerContainerPosition(),!0}else this._autoScrollCurrentlyOutOfBoundary=!1;return!1},_getAutoScrollStopEpsilon:function(){return 1E-4},_fltEqualZero:function(a){return 1E-4>=Math.abs(a.x)&&1E-4>=Math.abs(a.y)},_processAutoScrolling:function(a){var b=this._isNecessaryAutoScrollBrake()?.05:1;this._autoScrollAccumulatedTime+=1/b*a;var c=Math.min(1,this._autoScrollAccumulatedTime/this._autoScrollTotalTime);this._autoScrollAttenuate&&(--c,c=c*c*c*c*c+1);a=cc.pAdd(this._autoScrollStartPosition,
cc.pMult(this._autoScrollTargetDelta,c));c=Math.abs(c-1)<=this._getAutoScrollStopEpsilon();this.bounceEnabled?a=cc.pAdd(this._autoScrollBrakingStartPosition,cc.pMult(cc.pSub(a,this._autoScrollBrakingStartPosition),b)):(b=cc.pSub(a,this.getInnerContainerPosition()),b=this._getHowMuchOutOfBoundary(b),this._fltEqualZero(b)||(a.x+=b.x,a.y+=b.y,c=!0));c&&(this._autoScrolling=!1,this._dispatchEvent(ccui.ScrollView.EVENT_AUTOSCROLL_ENDED));this._moveInnerContainer(cc.pSub(a,this.getInnerContainerPosition()),
c)},_jumpToDestination:function(a,b){void 0===a.x&&(a=cc.p(a,b));this._autoScrolling=!1;this._moveInnerContainer(cc.pSub(a,this.getInnerContainerPosition()),!0)},_scrollChildren:function(a){if(this.bounceEnabled){var b=this._getHowMuchOutOfBoundary();a.x*=0==b.x?1:.5;a.y*=0==b.y?1:.5}this.bounceEnabled||(b=this._getHowMuchOutOfBoundary(a),a.x+=b.x,a.y+=b.y);var c=b=!1,d=!1,e=!1;0<a.y?this._innerContainer.getBottomBoundary()+a.y>=this._bottomBoundary&&(e=!0):0>a.y&&this._innerContainer.getTopBoundary()+
a.y<=this._topBoundary&&(d=!0);0>a.x?this._innerContainer.getRightBoundary()+a.x<=this._rightBoundary&&(c=!0):0<a.x&&this._innerContainer.getLeftBoundary()+a.x>=this._leftBoundary&&(b=!0);this._moveInnerContainer(a,!1);0==a.x&&0==a.y||this._processScrollingEvent();e&&this._processScrollEvent(ccui.ScrollView.MOVEDIR_BOTTOM,!1);d&&this._processScrollEvent(ccui.ScrollView.MOVEDIR_TOP,!1);b&&this._processScrollEvent(ccui.ScrollView.MOVEDIR_LEFT,!1);c&&this._processScrollEvent(ccui.ScrollView.MOVEDIR_RIGHT,
!1)},scrollToBottom:function(a,b){this._startAutoScrollToDestination(cc.p(this._innerContainer.getPositionX(),0),a,b)},scrollToTop:function(a,b){this._startAutoScrollToDestination(cc.p(this._innerContainer.getPositionX(),this._contentSize.height-this._innerContainer.getContentSize().height),a,b)},scrollToLeft:function(a,b){this._startAutoScrollToDestination(cc.p(0,this._innerContainer.getPositionY()),a,b)},scrollToRight:function(a,b){this._startAutoScrollToDestination(cc.p(this._contentSize.width-
this._innerContainer.getContentSize().width,this._innerContainer.getPositionY()),a,b)},scrollToTopLeft:function(a,b){this._direction!==ccui.ScrollView.DIR_BOTH?cc.log("Scroll direction is not both!"):this._startAutoScrollToDestination(cc.p(0,this._contentSize.height-this._innerContainer.getContentSize().height),a,b)},scrollToTopRight:function(a,b){if(this._direction!==ccui.ScrollView.DIR_BOTH)cc.log("Scroll direction is not both!");else{var c=this._innerContainer.getContentSize();this._startAutoScrollToDestination(cc.p(this._contentSize.width-
c.width,this._contentSize.height-c.height),a,b)}},scrollToBottomLeft:function(a,b){this._direction!==ccui.ScrollView.DIR_BOTH?cc.log("Scroll direction is not both!"):this._startAutoScrollToDestination(cc.p(0,0),a,b)},scrollToBottomRight:function(a,b){this._direction!==ccui.ScrollView.DIR_BOTH?cc.log("Scroll direction is not both!"):this._startAutoScrollToDestination(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._startAutoScrollToDestination(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._startAutoScrollToDestination(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._startAutoScrollToDestination(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(){this._direction!==ccui.ScrollView.DIR_BOTH?cc.log("Scroll _direction is not both!"):this._jumpToDestination(0,this._contentSize.height-this._innerContainer.getContentSize().height)},jumpToTopRight:function(){if(this._direction!==ccui.ScrollView.DIR_BOTH)cc.log("Scroll _direction is not both!");else{var a=this._innerContainer.getContentSize();this._jumpToDestination(this._contentSize.width-a.width,
this._contentSize.height-a.height)}},jumpToBottomLeft:function(){this._direction!==ccui.ScrollView.DIR_BOTH?cc.log("Scroll _direction is not both!"):this._jumpToDestination(0,0)},jumpToBottomRight:function(){this._direction!==ccui.ScrollView.DIR_BOTH?cc.log("Scroll _direction is not both!"):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)}},
_gatherTouchMove:function(a){for(;5<=this._touchMoveDisplacements.length;)this._touchMoveDisplacements.splice(0,1),this._touchMoveTimeDeltas.splice(0,1);this._touchMoveDisplacements.push(a);a=(new Date).getTime();this._touchMoveTimeDeltas.push((a-this._touchMovePreviousTimestamp)/1E3);this._touchMovePreviousTimestamp=a},_handlePressLogic:function(a){this._bePressed=!0;this._autoScrolling=!1;this._touchMovePreviousTimestamp=(new Date).getTime();this._touchMoveDisplacements.length=0;this._touchMoveTimeDeltas.length=
0;if(this._verticalScrollBar)this._verticalScrollBar.onTouchBegan();if(this._horizontalScrollBar)this._horizontalScrollBar.onTouchBegan()},_handleMoveLogic:function(a){var b=this.convertToNodeSpace(a.getLocation());a=this.convertToNodeSpace(a.getPreviousLocation());b=cc.pSub(b,a);this._scrollChildren(b);this._gatherTouchMove(b)},_handleReleaseLogic:function(a){var b=this.convertToNodeSpace(a.getLocation());a=this.convertToNodeSpace(a.getPreviousLocation());b=cc.pSub(b,a);this._gatherTouchMove(b);
this._bePressed=!1;!this._startBounceBackIfNeeded()&&this.inertiaScrollEnabled&&(b=this._calculateTouchMoveVelocity(),0===b.x&&0===b.y||this._startInertiaScroll(b));if(this._verticalScrollBar)this._verticalScrollBar.onTouchEnded();if(this._horizontalScrollBar)this._horizontalScrollBar.onTouchEnded()},onTouchBegan:function(a,b){var c=ccui.Layout.prototype.onTouchBegan.call(this,a,b);this._isInterceptTouch||this._hit&&this._handlePressLogic(a);return 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._autoScrolling&&this._processAutoScrolling(a)},interceptTouchEvent:function(a,b,c){if(!this._touchEnabled)ccui.Layout.prototype.interceptTouchEvent.call(this,
a,b,c);else if(this._direction!==ccui.ScrollView.DIR_NONE){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)}}},_processScrollEvent:function(a,b){var c=0;switch(a){case ccui.ScrollView.MOVEDIR_TOP:c=b?ccui.ScrollView.EVENT_BOUNCE_TOP:ccui.ScrollView.EVENT_SCROLL_TO_TOP;break;case ccui.ScrollView.MOVEDIR_BOTTOM:c=b?ccui.ScrollView.EVENT_BOUNCE_BOTTOM:ccui.ScrollView.EVENT_SCROLL_TO_BOTTOM;break;case ccui.ScrollView.MOVEDIR_LEFT:c=b?ccui.ScrollView.EVENT_BOUNCE_LEFT:ccui.ScrollView.EVENT_SCROLL_TO_LEFT;
break;case ccui.ScrollView.MOVEDIR_RIGHT:c=b?ccui.ScrollView.EVENT_BOUNCE_RIGHT:ccui.ScrollView.EVENT_SCROLL_TO_RIGHT}this._dispatchEvent(c)},_processScrollingEvent:function(){this._dispatchEvent(ccui.ScrollView.EVENT_SCROLLING)},_dispatchEvent:function(a){this._scrollViewEventSelector&&(this._scrollViewEventListener?this._scrollViewEventSelector.call(this._scrollViewEventListener,this,a):this._scrollViewEventSelector(this,a));this._ccEventCallback&&this._ccEventCallback(this,a)},addEventListenerScrollView:function(a,
b){this._scrollViewEventSelector=a;this._scrollViewEventListener=b},addEventListener:function(a){this._ccEventCallback=a},setDirection:function(a){this._direction=a;this._scrollBarEnabled&&(this._removeScrollBar(),this._initScrollBar())},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},
setScrollBarEnabled:function(a){this._scrollBarEnabled!==a&&(this._scrollBarEnabled&&this._removeScrollBar(),(this._scrollBarEnabled=a)&&this._initScrollBar())},isScrollBarEnabled:function(){return this._scrollBarEnabled},setScrollBarPositionFromCorner:function(a){this._direction!==ccui.ScrollView.DIR_HORIZONTAL&&this.setScrollBarPositionFromCornerForVertical(a);this._direction!==ccui.ScrollView.DIR_VERTICAL&&this.setScrollBarPositionFromCornerForHorizontal(a)},setScrollBarPositionFromCornerForVertical:function(a){cc.assert(this._scrollBarEnabled,
"Scroll bar should be enabled!");cc.assert(this._direction!==ccui.ScrollView.DIR_HORIZONTAL,"Scroll view doesn't have a vertical scroll bar!");this._verticalScrollBar.setPositionFromCorner(a)},getScrollBarPositionFromCornerForVertical:function(){cc.assert(this._scrollBarEnabled,"Scroll bar should be enabled!");cc.assert(this._direction!==ccui.ScrollView.DIR_HORIZONTAL,"Scroll view doesn't have a vertical scroll bar!");return this._verticalScrollBar.getPositionFromCorner()},setScrollBarPositionFromCornerForHorizontal:function(a){cc.assert(this._scrollBarEnabled,
"Scroll bar should be enabled!");cc.assert(this._direction!==ccui.ScrollView.DIR_VERTICAL,"Scroll view doesn't have a horizontal scroll bar!");this._horizontalScrollBar.setPositionFromCorner(a)},getScrollBarPositionFromCornerForHorizontal:function(){cc.assert(this._scrollBarEnabled,"Scroll bar should be enabled!");cc.assert(this._direction!==ccui.ScrollView.DIR_VERTICAL,"Scroll view doesn't have a horizontal scroll bar!");return this._horizontalScrollBar.getPositionFromCorner()},setScrollBarWidth:function(a){cc.assert(this._scrollBarEnabled,
"Scroll bar should be enabled!");this._verticalScrollBar&&this._verticalScrollBar.setWidth(a);this._horizontalScrollBar&&this._horizontalScrollBar.setWidth(a)},getScrollBarWidth:function(){cc.assert(this._scrollBarEnabled,"Scroll bar should be enabled!");return this._verticalScrollBar?this._verticalScrollBar.getWidth():this._horizontalScrollBar?this._horizontalScrollBar.getWidth():0},setScrollBarColor:function(a){cc.assert(this._scrollBarEnabled,"Scroll bar should be enabled!");this._verticalScrollBar&&
this._verticalScrollBar.setColor(a);this._horizontalScrollBar&&this._horizontalScrollBar.setColor(a)},getScrollBarColor:function(){cc.assert(this._scrollBarEnabled,"Scroll bar should be enabled!");this._verticalScrollBar&&this._verticalScrollBar.getColor();this._horizontalScrollBar&&this._horizontalScrollBar.getColor();return cc.color.WHITE},setScrollBarOpacity:function(a){cc.assert(this._scrollBarEnabled,"Scroll bar should be enabled!");this._verticalScrollBar&&(this._verticalScrollBar.opacity=a);
this._horizontalScrollBar&&(this._horizontalScrollBar.opacity=a)},getScrollBarOpacity:function(){cc.assert(this._scrollBarEnabled,"Scroll bar should be enabled!");return this._verticalScrollBar?this._verticalScrollBar.opacity:this._horizontalScrollBar?this._horizontalScrollBar.opacity:-1},setScrollBarAutoHideEnabled:function(a){cc.assert(this._scrollBarEnabled,"Scroll bar should be enabled!");this._verticalScrollBar&&(this._verticalScrollBar.autoHideEnabled=a);this._horizontalScrollBar&&(this._horizontalScrollBar.autoHideEnabled=
a)},isScrollBarAutoHideEnabled:function(){cc.assert(this._scrollBarEnabled,"Scroll bar should be enabled!");return this._verticalScrollBar?this._verticalScrollBar.autoHideEnabled:this._horizontalScrollBar?this._horizontalScrollBar.autoHideEnabled:!1},setScrollBarAutoHideTime:function(a){cc.assert(this._scrollBarEnabled,"Scroll bar should be enabled!");this._verticalScrollBar&&(this._verticalScrollBar.autoHideTime=a);this._horizontalScrollBar&&(this._horizontalScrollBar.autoHideTime=a)},getScrollBarAutoHideTime:function(){cc.assert(this._scrollBarEnabled,
"Scroll bar should be enabled!");return this._verticalScrollBar?this._verticalScrollBar.autoHideTime:this._horizontalScrollBar?this._horizontalScrollBar.autoHideTime:0},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.setInnerContainerPosition(a.getInnerContainerPosition()),this.setDirection(a._direction),this._topBoundary=a._topBoundary,this._bottomBoundary=a._bottomBoundary,this._leftBoundary=a._leftBoundary,this._rightBoundary=a._rightBoundary,
this._bePressed=a._bePressed,this._childFocusCancelOffset=a._childFocusCancelOffset,this._touchMoveDisplacements=a._touchMoveDisplacements,this._touchMoveTimeDeltas=a._touchMoveTimeDeltas,this._touchMovePreviousTimestamp=a._touchMovePreviousTimestamp,this._autoScrolling=a._autoScrolling,this._autoScrollAttenuate=a._autoScrollAttenuate,this._autoScrollStartPosition=a._autoScrollStartPosition,this._autoScrollTargetDelta=a._autoScrollTargetDelta,this._autoScrollTotalTime=a._autoScrollTotalTime,this._autoScrollAccumulatedTime=
a._autoScrollAccumulatedTime,this._autoScrollCurrentlyOutOfBoundary=a._autoScrollCurrentlyOutOfBoundary,this._autoScrollBraking=a._autoScrollBraking,this._autoScrollBrakingStartPosition=a._autoScrollBrakingStartPosition,this.setBounceEnabled(a.bounceEnabled),this.setInertiaScrollEnabled(a.inertiaScrollEnabled),this._scrollViewEventListener=a._scrollViewEventListener,this._scrollViewEventSelector=a._scrollViewEventSelector,this._ccEventCallback=a._ccEventCallback,this.setScrollBarEnabled(a.isScrollBarEnabled()),
this.isScrollBarEnabled()&&(this._direction!==ccui.ScrollView.DIR_HORIZONTAL&&this.setScrollBarPositionFromCornerForVertical(a.getScrollBarPositionFromCornerForVertical()),this._direction!==ccui.ScrollView.DIR_VERTICAL&&this.setScrollBarPositionFromCornerForHorizontal(a.getScrollBarPositionFromCornerForHorizontal()),this.setScrollBarWidth(a.getScrollBarWidth()),this.setScrollBarColor(a.getScrollBarColor()),this.setScrollBarAutoHideEnabled(a.isScrollBarAutoHideEnabled()),this.setScrollBarAutoHideTime(a.getScrollBarAutoHideTime())))},
_initScrollBar:function(){this._direction===ccui.ScrollView.DIR_HORIZONTAL||this._verticalScrollBar||(this._verticalScrollBar=new ccui.ScrollViewBar(this,ccui.ScrollView.DIR_VERTICAL),this.addProtectedChild(this._verticalScrollBar,2));this._direction===ccui.ScrollView.DIR_VERTICAL||this._horizontalScrollBar||(this._horizontalScrollBar=new ccui.ScrollViewBar(this,ccui.ScrollView.DIR_HORIZONTAL),this.addProtectedChild(this._horizontalScrollBar,2))},_removeScrollBar:function(){this._verticalScrollBar&&
(this.removeProtectedChild(this._verticalScrollBar),this._verticalScrollBar=null);this._horizontalScrollBar&&(this.removeProtectedChild(this._horizontalScrollBar),this._horizontalScrollBar=null)},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;cc.defineGetterSetter(_p,"innerWidth",_p._getInnerWidth,_p._setInnerWidth);cc.defineGetterSetter(_p,"innerHeight",_p._getInnerHeight,_p._setInnerHeight);cc.defineGetterSetter(_p,"direction",_p.getDirection,_p.setDirection);cc.defineGetterSetter(_p,"touchTotalTimeThreshold",_p.getTouchTotalTimeThreshold,_p.setTouchTotalTimeThreshold);_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.EVENT_CONTAINER_MOVED=9;
ccui.ScrollView.EVENT_AUTOSCROLL_ENDED=10;ccui.ScrollView.MOVEDIR_TOP=0;ccui.ScrollView.MOVEDIR_BOTTOM=1;ccui.ScrollView.MOVEDIR_LEFT=2;ccui.ScrollView.MOVEDIR_RIGHT=3;ccui.ListView=ccui.ScrollView.extend({_model:null,_items:null,_gravity:null,_itemsMargin:0,_curSelectedIndex:0,_refreshViewDirty:!0,_listViewEventListener:null,_listViewEventSelector:null,_ccListViewEventCallback:null,_magneticAllowedOutOfBoundary:!0,_magneticType:0,_className:"ListView",ctor:function(){this._items=[];ccui.ScrollView.prototype.ctor.call(this);this._gravity=ccui.ListView.GRAVITY_CENTER_VERTICAL;this.setTouchEnabled(!0);this.setDirection(ccui.ScrollView.DIR_VERTICAL)},setItemModel:function(a){a?
this._model=a:cc.log("Can't set a null to item model!")},_handleReleaseLogic:function(a){ccui.ScrollView.prototype._handleReleaseLogic.call(this,a);this._autoScrolling||this._startMagneticScroll()},_onItemListChanged:function(){this._outOfBoundaryAmountDirty=!0},_updateInnerContainerSize:function(){var a,b=this._items;switch(this.direction){case ccui.ScrollView.DIR_VERTICAL:var c=b.length;var d=(c-1)*this._itemsMargin;for(a=0;a<c;a++)d+=b[a].getContentSize().height;this.setInnerContainerSize(cc.size(this._contentSize.width,
d));break;case ccui.ScrollView.DIR_HORIZONTAL:c=b.length;d=(c-1)*this._itemsMargin;for(a=0;a<c;a++)d+=b[a].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(ccui.LayoutParameter.LINEAR),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){cc.assert(null!=a,"Layout parameter can't be nil!");switch(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)}0===
b?a.setMargin(ccui.MarginZero()):a.setMargin(new ccui.Margin(0,this._itemsMargin,0,0))},_remedyHorizontalLayoutParameter:function(a,b){cc.assert(null!=a,"Layout parameter can't be nil!");switch(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)}0===b?a.setMargin(ccui.MarginZero()):
a.setMargin(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),this._onItemListChanged()))},removeChild:function(a,b){if(a){var c=this._items.indexOf(a);-1<c&&this._items.splice(c,1);this._onItemListChanged();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=[];this._onItemListChanged()},insertCustomItem:function(a,b){this._items.splice(b,0,a);this._onItemListChanged();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)},setMagneticType:function(a){this._magneticType=a;this._onItemListChanged();this._startMagneticScroll()},getMagneticType:function(){return this._magneticType},setMagneticAllowedOutOfBoundary:function(a){this._magneticAllowedOutOfBoundary=a},getMagneticAllowedOutOfBoundary:function(){return this._magneticAllowedOutOfBoundary},
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)},_getHowMuchOutOfBoundary:function(a){void 0===
a&&(a=cc.p(0,0));if(this._magneticAllowedOutOfBoundary&&0!==this._items.length){if(this._magneticType===ccui.ListView.MAGNETIC_NONE||this._magneticType===ccui.ListView.MAGNETIC_BOTH_END)return ccui.ScrollView.prototype._getHowMuchOutOfBoundary.call(this,a);if(0===a.x&&0===a.y&&!this._outOfBoundaryAmountDirty)return this._outOfBoundaryAmount}else return ccui.ScrollView.prototype._getHowMuchOutOfBoundary.call(this,a);var b=this._leftBoundary,c=this._rightBoundary,d=this._topBoundary,e=this._bottomBoundary,
f=this._items.length-1,g=this.getContentSize(),h=cc.p(0,0),k=cc.p(0,0);switch(this._magneticType){case ccui.ListView.MAGNETIC_CENTER:h.x=(g.width-this._items[0].width)/2;h.y=(g.height-this._items[0].height)/2;k.x=(g.width-this._items[f].width)/2;k.y=(g.height-this._items[f].height)/2;break;case ccui.ListView.MAGNETIC_LEFT:case ccui.ListView.MAGNETIC_TOP:k.x=g.width-this._items[f].width;k.y=g.height-this._items[f].height;break;case ccui.ListView.MAGNETIC_RIGHT:case ccui.ListView.MAGNETIC_BOTTOM:h.x=
g.width-this._items[0].width,h.y=g.height-this._items[0].height}b+=h.x;c-=k.x;d-=h.y;e+=k.y;f=cc.p(0,0);this._innerContainer.getLeftBoundary()+a.x>b?f.x=b-(this._innerContainer.getLeftBoundary()+a.x):this._innerContainer.getRightBoundary()+a.x<c&&(f.x=c-(this._innerContainer.getRightBoundary()+a.x));this._innerContainer.getTopBoundary()+a.y<d?f.y=d-(this._innerContainer.getTopBoundary()+a.y):this._innerContainer.getBottomBoundary()+a.y>e&&(f.y=e-(this._innerContainer.getBottomBoundary()+a.y));0===
a.x&&0===a.y&&(this._outOfBoundaryAmount=f,this._outOfBoundaryAmountDirty=!1);return f},_calculateItemPositionWithAnchor:function(a,b){var c=cc.p(a.getLeftBoundary(),a.getBottomBoundary()),d=a.getContentSize();return cc.p(c.x+d.width*b.x,c.y+d.height*b.y)},_findClosestItem:function(a,b,c,d,e,f,g){cc.assert(0<=d&&f<b.length&&d<=f,"");if(d===f)return b[d];if(1===f-d)return e<=g?b[d]:b[f];var h=Math.floor((d+f)/2),k=this._calculateItemPositionWithAnchor(b[h],c);k=cc.pLength(cc.pSub(a,k));return e<=g?
this._findClosestItem(a,b,c,d,e,h,k):this._findClosestItem(a,b,c,h,k,f,g)},getClosestItemToPosition:function(a,b){if(0===this._items.length)return null;var c=this._calculateItemPositionWithAnchor(this._items[0],b);c=cc.pLength(cc.pSub(a,c));var d=this._items.length-1,e=this._calculateItemPositionWithAnchor(this._items[d],b);e=cc.pLength(cc.pSub(a,e));return this._findClosestItem(a,this._items,b,0,c,d,e)},getClosestItemToPositionInCurrentView:function(a,b){var c=this.getContentSize(),d=cc.pMult(this._innerContainer.getPosition(),
-1);d.x+=c.width*a.x;d.y+=c.height*a.y;return this.getClosestItemToPosition(d,b)},getCenterItemInCurrentView:function(){return this.getClosestItemToPositionInCurrentView(cc.p(.5,.5),cc.p(.5,.5))},getLeftmostItemInCurrentView:function(){return this._direction===ccui.ScrollView.DIR_HORIZONTAL?this.getClosestItemToPositionInCurrentView(cc.p(0,.5),cc.p(.5,.5)):null},getRightmostItemInCurrentView:function(){return this._direction===ccui.ScrollView.DIR_HORIZONTAL?this.getClosestItemToPositionInCurrentView(cc.p(1,
.5),cc.p(.5,.5)):null},getTopmostItemInCurrentView:function(){return this._direction===ccui.ScrollView.DIR_VERTICAL?this.getClosestItemToPositionInCurrentView(cc.p(.5,1),cc.p(.5,.5)):null},getBottommostItemInCurrentView:function(){return this._direction===ccui.ScrollView.DIR_VERTICAL?this.getClosestItemToPositionInCurrentView(cc.p(.5,0),cc.p(.5,.5)):null},_calculateItemDestination:function(a,b,c){var d=this.getContentSize(),e=cc.p(0,0);e.x+=d.width*a.x;e.y+=d.height*a.y;a=this._calculateItemPositionWithAnchor(b,
c);return cc.pMult(cc.pSub(a,e),-1)},jumpToBottom:function(){this.doLayout();ccui.ScrollView.prototype.jumpToBottom.call(this)},jumpToTop:function(){this.doLayout();ccui.ScrollView.prototype.jumpToTop.call(this)},jumpToLeft:function(){this.doLayout();ccui.ScrollView.prototype.jumpToLeft.call(this)},jumpToRight:function(){this.doLayout();ccui.ScrollView.prototype.jumpToRight.call(this)},jumpToTopLeft:function(){this.doLayout();ccui.ScrollView.prototype.jumpToTopLeft.call(this)},jumpToTopRight:function(){this.doLayout();
ccui.ScrollView.prototype.jumpToTopRight.call(this)},jumpToBottomLeft:function(){this.doLayout();ccui.ScrollView.prototype.jumpToBottomLeft.call(this)},jumpToBottomRight:function(){this.doLayout();ccui.ScrollView.prototype.jumpToBottomRight.call(this)},jumpToPercentVertical:function(a){this.doLayout();ccui.ScrollView.prototype.jumpToPercentVertical.call(this,a)},jumpToPercentHorizontal:function(a){this.doLayout();ccui.ScrollView.prototype.jumpToPercentHorizontal.call(this,a)},jumpToPercentBothDirection:function(a){this.doLayout();
ccui.ScrollView.prototype.jumpToPercentBothDirection.call(this,a)},jumpToItem:function(a,b,c){if(a=this.getItem(a))this.doLayout(),b=this._calculateItemDestination(b,a,c),this.bounceEnabled||(c=cc.pSub(b,this._innerContainer.getPosition()),c=this._getHowMuchOutOfBoundary(c),b.x+=c.x,b.y+=c.y),this._jumpToDestination(b)},scrollToItem:function(a,b,c,d){void 0===d&&(d=1);if(a=this.getItem(a))b=this._calculateItemDestination(b,a,c),this._startAutoScrollToDestination(b,d,!0)},requestRefreshView:function(){this._refreshViewDirty=
!0},refreshView:function(){this.forceDoLayout()},doLayout:function(){this._doLayout()},requestDoLayout:function(){this._refreshViewDirty=!0},_doLayout:function(){if(this._refreshViewDirty){for(var a=this._items,b=0;b<a.length;b++){var c=a[b];c.setLocalZOrder(b);this._remedyLayoutParameter(c)}this._updateInnerContainerSize();this._innerContainer.forceDoLayout();this._refreshViewDirty=!1}},addEventListenerListView:function(a,b){this._listViewEventListener=b;this._listViewEventSelector=a},addEventListener:function(a){this._ccListViewEventCallback=
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._ccListViewEventCallback&&this._ccListViewEventCallback(this,a)},interceptTouchEvent:function(a,b,c){ccui.ScrollView.prototype.interceptTouchEvent.call(this,a,b,c);if(this._touchEnabled&&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)},_startAttenuatingAutoScroll:function(a,b){var c=a;if(0!==this._items.length&&this._magneticType!==ccui.ListView.MAGNETIC_NONE){c=this._flattenVectorByDirection(c);var d=this._getHowMuchOutOfBoundary(c);
if(0===d.x&&0===d.y){d=this._magneticType;d===ccui.ListView.MAGNETIC_BOTH_END&&(this._direction===ccui.ScrollView.DIR_HORIZONTAL?d=0<c.x?ccui.ListView.MAGNETIC_LEFT:ccui.ListView.MAGNETIC_RIGHT:this._direction===ccui.ScrollView.DIR_VERTICAL&&(d=0<c.y?ccui.ListView.MAGNETIC_BOTTOM:ccui.ListView.MAGNETIC_TOP));var e=this._getAnchorPointByMagneticType(d);d=cc.pMult(this._innerContainer.getPosition(),-1);d.x+=this.width*e.x;d.y+=this.height*e.y;c=this.getClosestItemToPosition(cc.pSub(d,c),e);c=this._calculateItemPositionWithAnchor(c,
e);c=cc.pSub(d,c)}}ccui.ScrollView.prototype._startAttenuatingAutoScroll.call(this,c,b)},_getAnchorPointByMagneticType:function(a){switch(a){case ccui.ListView.MAGNETIC_BOTH_END:return cc.p(0,1);case ccui.ListView.MAGNETIC_CENTER:return cc.p(.5,.5);case ccui.ListView.MAGNETIC_LEFT:return cc.p(0,.5);case ccui.ListView.MAGNETIC_RIGHT:return cc.p(1,.5);case ccui.ListView.MAGNETIC_TOP:return cc.p(.5,1);case ccui.ListView.MAGNETIC_BOTTOM:return cc.p(.5,0)}return cc.p(0,0)},_startMagneticScroll:function(){if(0!==
this._items.length&&this._magneticType!==ccui.ListView.MAGNETIC_NONE){var a=this._getAnchorPointByMagneticType(this._magneticType),b=cc.pMult(this._innerContainer.getPosition(),-1);b.x+=this.width*a.x;b.y+=this.height*a.y;b=this.getClosestItemToPosition(b,a);this.scrollToItem(this.getIndex(b),a,a)}}});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.ListView.MAGNETIC_NONE=0;ccui.ListView.MAGNETIC_CENTER=1;ccui.ListView.MAGNETIC_BOTH_END=2;ccui.ListView.MAGNETIC_LEFT=3;ccui.ListView.MAGNETIC_RIGHT=4;ccui.ListView.MAGNETIC_TOP=5;ccui.ListView.MAGNETIC_BOTTOM=6;ccui.PageView=ccui.ListView.extend({_curPageIdx:0,_childFocusCancelOffset:0,_pageViewEventListener:null,_pageViewEventSelector:null,_className:"PageView",_indicator:null,_indicatorPositionAsAnchorPoint:null,ctor:function(){ccui.ListView.prototype.ctor.call(this);this._childFocusCancelOffset=5;this._indicatorPositionAsAnchorPoint=cc.p(.5,.1);this._pageViewEventSelector=this._pageViewEventListener=null;this.setDirection(ccui.ScrollView.DIR_HORIZONTAL);this.setMagneticType(ccui.ListView.MAGNETIC_CENTER);
this.setScrollBarEnabled(!1)},addWidgetToPage:function(a,b,c){this.insertCustomItem(a,b)},addPage:function(a){this.pushBackCustomItem(a)},insertPage:function(a,b){this.insertCustomItem(a,b)},removePage:function(a){this.removeItem(this.getIndex(a))},removePageAtIndex:function(a){this.removeItem(a)},removeAllPages:function(){this.removeAllItems()},scrollToItem:function(a){ccui.ListView.prototype.scrollToItem.call(this,a,cc.p(.5,.5),cc.p(.5,.5))},scrollToPage:function(a){this.scrollToItem(a)},_doLayout:function(){if(this._refreshViewDirty){ccui.ListView.prototype._doLayout.call(this);
if(this._indicator){var a=this.getIndex(this.getCenterItemInCurrentView());this._indicator.indicate(a)}this._refreshViewDirty=!1}},setDirection:function(a){ccui.ListView.prototype.setDirection.call(this,a);a===ccui.ScrollView.DIR_HORIZONTAL?this._indicatorPositionAsAnchorPoint=cc.p(.5,.1):a===ccui.ScrollView.DIR_VERTICAL&&(this._indicatorPositionAsAnchorPoint=cc.p(.1,.5));this._indicator&&(this._indicator.setDirection(a),this._refreshIndicatorPosition())},setCustomScrollThreshold:function(a){},getCustomScrollThreshold:function(){return 0},
setUsingCustomScrollThreshold:function(a){},isUsingCustomScrollThreshold:function(){return!1},_moveInnerContainer:function(a,b){ccui.ListView.prototype._moveInnerContainer.call(this,a,b);this._curPageIdx=this.getIndex(this.getCenterItemInCurrentView());this._indicator&&this._indicator.indicate(this._curPageIdx)},_onItemListChanged:function(){ccui.ListView.prototype._onItemListChanged.call(this);this._indicator&&this._indicator.reset(this._items.length)},_onSizeChanged:function(){ccui.ListView.prototype._onSizeChanged.call(this);
this._refreshIndicatorPosition()},_remedyLayoutParameter:function(a){a.setContentSize(this.getContentSize());ccui.ListView.prototype._remedyLayoutParameter.call(this,a)},_refreshIndicatorPosition:function(){if(this._indicator){var a=this.getContentSize();this._indicator.setPosition(cc.p(a.width*this._indicatorPositionAsAnchorPoint.x,a.height*this._indicatorPositionAsAnchorPoint.y))}},_handleReleaseLogic:function(a){ccui.ScrollView.prototype._handleReleaseLogic.call(this,a);if(!(0>=this._items.length))if(a=
this._flattenVectorByDirection(this._calculateTouchMoveVelocity()),500>cc.pLength(a))this._startMagneticScroll();else{var b=this.getItem(this._curPageIdx);b=this._calculateItemDestination(cc.p(.5,.5),b,cc.p(.5,.5));b=cc.pSub(b,this.getInnerContainerPosition());b=this._flattenVectorByDirection(b);0<a.x*b.x||0<a.y*b.y?this._startMagneticScroll():(0>a.x||0<a.y?++this._curPageIdx:--this._curPageIdx,this._curPageIdx=Math.min(this._curPageIdx,this._items.length),this._curPageIdx=Math.max(this._curPageIdx,
0),this.scrollToItem(this._curPageIdx))}},_getAutoScrollStopEpsilon:function(){return.001},_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._pageViewEventSelector=a;this._pageViewEventListener=
b},addEventListener:function(a){this._ccEventCallback=function(b,c){c==ccui.ScrollView.EVENT_AUTOSCROLL_ENDED&&a(this,c)}},setCurrentPageIndex:function(a){this.jumpToItem(a,cc.p(.5,.5),cc.p(.5,.5))},setCurPageIndex:function(a){this.setCurrentPageIndex(a)},getCurrentPageIndex:function(){return this._curPageIdx},getCurPageIndex:function(){var a=this.getCenterItemInCurrentView();return this.getIndex(a)},getPages:function(){return this.getItems()},getPage:function(a){return this.getItem(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.ListView.prototype._copySpecialProperties.call(this,a);this._ccEventCallback=a._ccEventCallback;this._pageViewEventListener=a._pageViewEventListener;this._pageViewEventSelector=a._pageViewEventSelector;this._customScrollThreshold=a._customScrollThreshold},setIndicatorEnabled:function(a){a!=(null!==
this._indicator)&&(a?(this._indicator=new ccui.PageViewIndicator,this._indicator.setDirection(this.getDirection()),this.addProtectedChild(this._indicator,1E4),this.setIndicatorSelectedIndexColor(cc.color(100,100,255)),this._refreshIndicatorPosition()):(this.removeProtectedChild(this._indicator),this._indicator=null))},getIndicatorEnabled:function(){return null!==this._indicator},setIndicatorPositionAsAnchorPoint:function(a){this._indicatorPositionAsAnchorPoint=a;this._refreshIndicatorPosition()},
getIndicatorPositionAsAnchorPoint:function(){return this._indicatorPositionAsAnchorPoint},setIndicatorPosition:function(a){if(this._indicator){var b=this.getContentSize();this._indicatorPositionAsAnchorPoint.x=a.x/b.width;this._indicatorPositionAsAnchorPoint.y=a.y/b.height;this._indicator.setPosition(a)}},getIndicatorPosition:function(){cc.assert(null!==this._indicator,"");return this._indicator.getPosition()},setIndicatorSpaceBetweenIndexNodes:function(a){this._indicator&&this._indicator.setSpaceBetweenIndexNodes(a)},
getIndicatorSpaceBetweenIndexNodes:function(){cc.assert(null!==this._indicator,"");return this._indicator.getSpaceBetweenIndexNodes()},setIndicatorSelectedIndexColor:function(a){this._indicator&&this._indicator.setSelectedIndexColor(a)},getIndicatorSelectedIndexColor:function(){cc.assert(null!==this._indicator,"");return this._indicator.getSelectedIndexColor()},setIndicatorIndexNodesColor:function(a){this._indicator&&this._indicator.setIndexNodesColor(a)},getIndicatorIndexNodesColor:function(){cc.assert(null!==
this._indicator,"");return this._indicator.getIndexNodesColor()},setIndicatorIndexNodesScale:function(a){this._indicator&&(this._indicator.setIndexNodesScale(a),this._indicator.indicate(this._curPageIdx))},getIndicatorIndexNodesScale:function(){cc.assert(null!==this._indicator,"");return this._indicator.getIndexNodesScale()},setIndicatorIndexNodesTexture:function(a,b){this._indicator&&(this._indicator.setIndexNodesTexture(a,b),this._indicator.indicate(this._curPageIdx))}});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;ccui.PageViewIndicator=ccui.ProtectedNode.extend({_direction:null,_indexNodes:null,_currentIndexNode:null,_spaceBetweenIndexNodes:0,_indexNodesScale:1,_indexNodesColor:null,_useDefaultTexture:!0,_indexNodesTextureFile:"",_indexNodesTexType:ccui.Widget.LOCAL_TEXTURE,_className:"PageViewIndicator",ctor:function(){cc.ProtectedNode.prototype.ctor.call(this);this._direction=ccui.ScrollView.DIR_HORIZONTAL;this._indexNodes=[];this._spaceBetweenIndexNodes=ccui.PageViewIndicator.SPACE_BETWEEN_INDEX_NODES_DEFAULT;
this._indexNodesColor=cc.color.WHITE;this._currentIndexNode=ccui.helper._createSpriteFromBase64(ccui.PageViewIndicator.CIRCLE_IMAGE,ccui.PageViewIndicator.CIRCLE_IMAGE_KEY);this._currentIndexNode.setVisible(!1);this.addProtectedChild(this._currentIndexNode,1)},setDirection:function(a){this._direction=a;this._rearrange()},reset:function(a){for(;this._indexNodes.length<a;)this._increaseNumberOfPages();for(;this._indexNodes.length>a;)this._decreaseNumberOfPages();this._rearrange();this._currentIndexNode.setVisible(0<
this._indexNodes.length)},indicate:function(a){0>a||a>=this._indexNodes.length||this._currentIndexNode.setPosition(this._indexNodes[a].getPosition())},_rearrange:function(){if(0!==this._indexNodes.length){var a=this._direction===ccui.ScrollView.DIR_HORIZONTAL,b=this._indexNodes[0].getContentSize(),c=a?b.width:b.height,d=this._indexNodes.length;d=-((c*d+this._spaceBetweenIndexNodes*(d-1))/2)+c/2;for(var e=0;e<this._indexNodes.length;++e){var f=a?cc.p(d,b.height/2):cc.p(b.width/2,-d);this._indexNodes[e].setPosition(f);
d+=c+this._spaceBetweenIndexNodes}}},setSpaceBetweenIndexNodes:function(a){this._spaceBetweenIndexNodes!==a&&(this._spaceBetweenIndexNodes=a,this._rearrange())},getSpaceBetweenIndexNodes:function(){return this._spaceBetweenIndexNodes},setSelectedIndexColor:function(a){this._currentIndexNode.setColor(a)},getSelectedIndexColor:function(){return this._currentIndexNode.getColor()},setIndexNodesColor:function(a){this._indexNodesColor=a;for(var b=0;b<this._indexNodes.length;++b)this._indexNodes[b].setColor(a)},
getIndexNodesColor:function(){var a=this._indexNodesColor;return cc.color(a.r,a.g,a.b,a.a)},setIndexNodesScale:function(a){if(this._indexNodesScale!==a){this._indexNodesScale=a;this._currentIndexNode.setScale(a);for(a=0;a<this._indexNodes.length;++a)this._indexNodes[a].setScale(this,_indexNodesScale);this._rearrange()}},getIndexNodesScale:function(){return this._indexNodesScale},setIndexNodesTexture:function(a,b){void 0===b&&(b=ccui.Widget.LOCAL_TEXTURE);this._useDefaultTexture=!1;this._indexNodesTextureFile=
a;this._indexNodesTexType=b;switch(b){case ccui.Widget.LOCAL_TEXTURE:this._currentIndexNode.setTexture(a);for(var c=0;c<this._indexNodes.length;++c)this._indexNodes[c].setTexture(a);break;case ccui.Widget.PLIST_TEXTURE:for(this._currentIndexNode.setSpriteFrame(a),c=0;c<this._indexNodes.length;++c)this._indexNodes[c].setSpriteFrame(a)}this._rearrange()},_increaseNumberOfPages:function(){if(this._useDefaultTexture)var a=ccui.helper._createSpriteFromBase64(ccui.PageViewIndicator.CIRCLE_IMAGE,ccui.PageViewIndicator.CIRCLE_IMAGE_KEY);
else switch(a=new cc.Sprite,this._indexNodesTexType){case ccui.Widget.LOCAL_TEXTURE:a.initWithFile(this._indexNodesTextureFile);break;case ccui.Widget.PLIST_TEXTURE:a.initWithSpriteFrameName(this._indexNodesTextureFile)}a.setColor(this._indexNodesColor);a.setScale(this._indexNodesScale);this.addProtectedChild(a);this._indexNodes.push(a)},_decreaseNumberOfPages:function(){0!==this._indexNodes.length&&(this.removeProtectedChild(this._indexNodes[0]),this._indexNodes.splice(0,1))},clear:function(){for(var a=
0;a<this._indexNodes.length;++a)this.removeProtectedChild(this._indexNodes[a]);this._indexNodes.length=0;this._currentIndexNode.setVisible(!1)}});_p=ccui.PageViewIndicator.prototype;cc.defineGetterSetter(_p,"spaceBetweenIndexNodes",_p.getSpaceBetweenIndexNodes,_p.setSpaceBetweenIndexNodes);ccui.PageViewIndicator.SPACE_BETWEEN_INDEX_NODES_DEFAULT=23;ccui.PageViewIndicator.CIRCLE_IMAGE_KEY="/__circle_image";ccui.PageViewIndicator.CIRCLE_IMAGE="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAQAAADZc7J/AAAA8ElEQVRIx62VyRGCQBBF+6gWRCEmYDIQkhiBCgHhSclC8YqWzOV5oVzKAYZp3r1/9fpbxAIBMTsKrjx5cqVgR0wgLhCRUWOjJiPqD56xoaGPhpRZV/iSEy6crHmw5oIrF9b/lVeMofrJgjlnxlIy/wik+JB+mme8BExbBhm+5CJC2LE2LtSEQoyGWDioBA5CoRIohJtK4CYDxzNEM4GAugR1E9VjVC+SZpXvhCJCrjomESLvc17pDGX7bWmlh6UtpjPVCWy9zaJ0TD7qfm3pwERMz2trRVZk3K3BD/L34AY+dEDCniMVBkPFkT2J/b2/AIV+dRpFLOYoAAAAAElFTkSuQmCC";(function(){if(ccui.ProtectedNode.CanvasRenderCmd){ccui.ScrollView.CanvasRenderCmd=function(a){this._layoutCmdCtor(a);this._dirty=!1};var a=ccui.ScrollView.CanvasRenderCmd.prototype=Object.create(ccui.Layout.CanvasRenderCmd.prototype);a.constructor=ccui.ScrollView.CanvasRenderCmd;a.rendering=function(a){var b=cc.renderer._cacheToCanvasCmds[this._node.__instanceId],d,e=cc.view.getScaleX(),f=cc.view.getScaleY(),g=a||cc._renderContext;g.computeRealOffsetY();this._node.updateChildren();a=0;for(d=b.length;a<
d;a++){var h=b[a]._node;h instanceof ccui.ScrollView||h&&h._parent&&!1===h._parent._inViewRect||b[a].rendering(g,e,f)}}}})();(function(){if(ccui.ProtectedNode.WebGLRenderCmd){ccui.ScrollView.WebGLRenderCmd=function(a){this._layoutCmdCtor(a);this._needDraw=!0;this._dirty=!1};var a=ccui.ScrollView.WebGLRenderCmd.prototype=Object.create(ccui.Layout.WebGLRenderCmd.prototype);a.constructor=ccui.ScrollView.WebGLRenderCmd;a.rendering=function(a){var b=cc.renderer._cacheToBufferCmds[this._node.__instanceId],d,e=a||cc._renderContext;if(b)for(this._node.updateChildren(),e.bindBuffer(gl.ARRAY_BUFFER,null),a=0,d=b.length;a<d;a++){var f=
b[a];var g=f._node;g&&g._parent&&!1===g._parent._inViewRect||(f.uploadData?cc.renderer._uploadBufferData(f):(0<f._batchingSize&&cc.renderer._batchRendering(),f.rendering(e)),cc.renderer._batchRendering())}}}})();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};cc.ComponentContainer=cc.Class.extend({_components:null,_owner:null,ctor:function(a){this._components=null;this._owner=a},getComponent:function(a){if(!a)throw Error("cc.ComponentContainer.getComponent(): name should be non-null");a=a.trim();this._components||(this._components={});return this._components[a]},add:function(a){if(!a)throw Error("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());if(this._components[a.getName()])return 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();return!0},remove:function(a){if(!a)throw Error("cc.ComponentContainer.remove(): name should be non-null");if(!this._components)return!1;if(a instanceof cc.Component)return this._removeByComponent(a);a=a.trim();return this._removeByComponent(this._components[a])},
_removeByComponent:function(a){if(!a)return!1;a.onExit();a.setOwner(null);delete this._components[a.getName()];return!0},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}});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=this._getOwnerParent();if(null!=c){if(void 0===b){var d=a.x;b=a.y}else d=a;c=c.getContentSize();0!==c.width?this._positionPercentX=d/c.width:(this._positionPercentX=0,this._usingPositionPercentX&&(d=0));0!==c.height?this._positionPercentY=
b/c.height:(this._positionPercentY=0,this._usingPositionPercentY&&(b=0));this._owner.setPosition(d,b);this._refreshHorizontalMargin();this._refreshVerticalMargin()}else this._owner.setPosition(a,b)},isPositionPercentXEnabled:function(){return this._usingPositionPercentX},setPositionPercentXEnabled:function(a){if(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){if(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){if(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){if(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){if(this._usingStretchWidth=
a)this._usingPercentWidth=!1},isStretchHeightEnabled:function(){return this._usingStretchHeight},setStretchHeightEnabled:function(a){if(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){a=a.getContentSize();var 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;if(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;
if(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:this._isPercentOnly||(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;if(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;
if(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:this._isPercentOnly||(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);if(b instanceof
ccui.PageView)for(b.forceDoLayout(),a=b.getPages(),b=0;b<a.length;b++)ccui.helper.doLayout(a[b]);else 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);if(void 0!==b)return b;b=new ccui.LayoutComponent;b.init();a.addComponent(b);a instanceof ccui.Widget||a.addEventListener&&a.addEventListener("load",function(){b.refreshLayout()},this);return b};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=.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=.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))e&&d&&(0===this._asyncRefTotalCount&&0===this._asyncRefCount?this._asyncCallBack(d,e,1):this._asyncCallBack(d,e,(this._asyncRefTotalCount-this._asyncRefCount)/this._asyncRefTotalCount));
else{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,.1,!1,0,!1,"armatrueDataHelper")}},removeConfigFile:function(a){for(var b=this._configFileList,c=b.length,d=b[c],e=0;e<c;e++)b[e]===a&&(d=e);d!==b[c]&&cc.arrayRemoveObject(b,a)},addDataFromCache:function(a,b){if(a){b.flashToolVersion=parseFloat(a.getAttribute(ccs.CONST_VERSION));
var c=a.querySelectorAll(ccs.CONST_SKELETON+" > "+ccs.CONST_ARMATURES+" >  "+ccs.CONST_ARMATURE+""),d=ccs.armatureDataManager,e;for(e=0;e<c.length;e++){var f=this.decodeArmature(c[e],b);d.addArmatureData(f.name,f,b.filename)}c=a.querySelectorAll(ccs.CONST_SKELETON+" > "+ccs.CONST_ANIMATIONS+" >  "+ccs.CONST_ANIMATION+"");for(e=0;e<c.length;e++)f=this.decodeAnimation(c[e],b),d.addAnimationData(f.name,f,b.filename);c=a.querySelectorAll(ccs.CONST_SKELETON+" > "+ccs.CONST_TEXTURE_ATLAS+" >  "+ccs.CONST_SUB_TEXTURE+
"");for(e=0;e<c.length;e++)f=this.decodeTexture(c[e],b),d.addTextureData(f.name,f,b.filename)}else cc.log("XML error  or  XML is empty.")},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+" > "+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]||.1;d=a[ccs.CONST_BONE_DATA];for(var 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+
" > "+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){if(1===(parseFloat(a.getAttribute(ccs.CONST_A_IS_ARMATURE))||
0)){var c=new ccs.ArmatureDisplayData;c.displayType=ccs.DISPLAY_TYPE_ARMATURE}else c=new ccs.SpriteDisplayData,c.displayType=ccs.DISPLAY_TYPE_SPRITE;var d=a.getAttribute(ccs.CONST_A_NAME)||"";d&&(c.displayName=d);return c},decodeBoneDisplayFromJson:function(a,b){var c=a[ccs.CONST_A_DISPLAY_TYPE]||ccs.DISPLAY_TYPE_SPRITE;switch(c){case ccs.DISPLAY_TYPE_SPRITE:var d=new ccs.SpriteDisplayData;var 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&&(d.displayName=b.asyncStruct?b.asyncStruct.basefilePath+e:b.basefilePath+e);break;default:d=new ccs.SpriteDisplayData}d.displayType=c;return 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;d=a.querySelectorAll(ccs.CONST_ANIMATION+" > "+ccs.CONST_MOVEMENT);for(var f,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=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?!!parseFloat(e):!0;if(e=a.getAttribute(ccs.CONST_A_TWEEN_EASING))e!=ccs.CONST_FL_NAN?(e=null==e?0:parseFloat(e),d.tweenEasing=2===e?ccs.TweenType.SINE_EASEINOUT:e):d.tweenEasing=ccs.TweenType.LINEAR;a=a.querySelectorAll(ccs.CONST_MOVEMENT+" > "+ccs.CONST_BONE);for(e=0;e<a.length;e++){var f=a[e];var g=f.getAttribute(ccs.CONST_A_NAME);if(!d.getMovementBoneData(g)){g=
b.getBoneData(g);var 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++);f=this.decodeMovementBone(f,k,g,c);d.addMovementBoneData(f)}}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;c.scale=null==a[ccs.CONST_A_DURATION]?1: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);d=a[ccs.CONST_MOVEMENT_BONE_DATA]||[];for(var 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();if(a){var f=parseFloat(a.getAttribute(ccs.CONST_A_MOVEMENT_SCALE))||0;e.scale=f;f=parseFloat(a.getAttribute(ccs.CONST_A_MOVEMENT_DELAY))||
0;0<f&&--f;e.delay=f}var g=0,h=f=0,k=null,m=[];if(null!=b){var n=b.querySelectorAll(ccs.CONST_BONE+" > "+ccs.CONST_FRAME);for(g=0;g<n.length;g++)m.push(n[g]);g=m.length}e.name=a.getAttribute(ccs.CONST_A_NAME);a=a.querySelectorAll(ccs.CONST_BONE+" > "+ccs.CONST_FRAME);for(var p=n=0,r=0;r<a.length;r++){var t=a[r];if(b)for(;n<g&&(k?p<f||p>=f+h:1);)k=m[n],f+=h,h=parseFloat(k.getAttribute(ccs.CONST_A_DURATION)),n++;t=this.decodeFrame(t,k,c,d);e.addFrameData(t);t.frameID=p;p+=t.duration;e.duration=p}b=
e.frameList;c=Math.PI;for(g=b.length-1;0<=g;g--)if(0<g){d=b[g].skewX-b[g-1].skewX;f=b[g].skewY-b[g-1].skewY;if(d<-c||d>c)b[g-1].skewX=0>d?b[g-1].skewX-2*c:b[g-1].skewX+2*c;if(f<-c||f>c)b[g-1].skewY=0>f?b[g-1].skewY-2*c:b[g-1].skewY+2*c}b=new ccs.FrameData;b.copy(e.frameList[e.frameList.length-1]);b.frameID=e.duration;e.addFrameData(b);return 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);var e=(a[ccs.CONST_FRAME_DATA]||[]).length;for(d=0;d<e;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)for(f=c.frameList,e=Math.PI,d=f.length-1;0<=d;d--)if(0<d){var g=f[d].skewX-f[d-1].skewX,h=f[d].skewY-f[d-1].skewY;if(g<-e||g>e)f[d-1].skewX=0>g?f[d-1].skewX-2*e:f[d-1].skewX+2*e;if(h<-e||h>e)f[d-1].skewY=0>h?
f[d-1].skewY-2*e:f[d-1].skewY+2*e}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){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 e=a.getAttribute(ccs.CONST_A_TWEEN_FRAME);c.isTween=!(void 0!==e&&("false"===e||"0"===e));if(d.flashToolVersion>=ccs.CONST_VERSION_2_0){if(e=a.getAttribute(ccs.CONST_A_COCOS2DX_X))c.x=parseFloat(e),c.x*=this._positionReadScale;e=a.getAttribute(ccs.CONST_A_COCOS2DX_Y)}else{if(e=a.getAttribute(ccs.CONST_A_X))c.x=parseFloat(e),c.x*=this._positionReadScale;e=a.getAttribute(ccs.CONST_A_Y)}e&&(c.y=-parseFloat(e),c.y*=this._positionReadScale);e=a.getAttribute(ccs.CONST_A_SCALE_X);
null!=e&&(c.scaleX=parseFloat(e));e=a.getAttribute(ccs.CONST_A_SCALE_Y);null!=e&&(c.scaleY=parseFloat(e));e=a.getAttribute(ccs.CONST_A_SKEW_X);null!=e&&(c.skewX=cc.degreesToRadians(parseFloat(e)));e=a.getAttribute(ccs.CONST_A_SKEW_Y);null!=e&&(c.skewY=cc.degreesToRadians(-parseFloat(e)));e=a.getAttribute(ccs.CONST_A_DURATION);null!=e&&(c.duration=parseFloat(e));e=a.getAttribute(ccs.CONST_A_DISPLAY_INDEX);null!=e&&(c.displayIndex=parseFloat(e));e=a.getAttribute(ccs.CONST_A_Z);null!=e&&(c.zOrder=parseInt(e));
e=a.getAttribute(ccs.CONST_A_TWEEN_ROTATE);null!=e&&(c.tweenRotate=parseFloat(e));e=a.getAttribute(ccs.CONST_A_BLEND_TYPE);if(null!=e){var f=c.blendFunc;switch(e){case ccs.BLEND_TYPE_NORMAL:f.src=cc.BLEND_SRC;f.dst=cc.BLEND_DST;break;case ccs.BLEND_TYPE_ADD:f.src=cc.SRC_ALPHA;f.dst=cc.ONE;break;case ccs.BLEND_TYPE_MULTIPLY:f.src=cc.DST_COLOR;f.dst=cc.ONE_MINUS_SRC_ALPHA;break;case ccs.BLEND_TYPE_SCREEN:f.src=cc.ONE;f.dst=cc.ONE_MINUS_DST_COLOR;break;default:c.blendFunc.src=cc.BLEND_SRC,c.blendFunc.dst=
cc.BLEND_DST}}var g=a.querySelectorAll(ccs.CONST_FRAME+" > "+ccs.CONST_A_COLOR_TRANSFORM);if(g&&0<g.length){g=g[0];e=parseFloat(g.getAttribute(ccs.CONST_A_ALPHA))||0;f=parseFloat(g.getAttribute(ccs.CONST_A_RED))||0;var h=parseFloat(g.getAttribute(ccs.CONST_A_GREEN))||0;var k=parseFloat(g.getAttribute(ccs.CONST_A_BLUE))||0;var m=parseFloat(g.getAttribute(ccs.CONST_A_ALPHA_OFFSET))||0;var n=parseFloat(g.getAttribute(ccs.CONST_A_RED_OFFSET))||0;var p=parseFloat(g.getAttribute(ccs.CONST_A_GREEN_OFFSET))||
0;g=parseFloat(g.getAttribute(ccs.CONST_A_BLUE_OFFSET))||0;c.a=2.55*m+e;c.r=2.55*n+f;c.g=2.55*p+h;c.b=2.55*g+k;c.isUseColorInfo=!0}e=a.getAttribute(ccs.CONST_A_TWEEN_EASING);null!=e&&(e!=ccs.CONST_FL_NAN?(a=a.getAttribute(ccs.CONST_A_TWEEN_EASING))&&(c.tweenEasing=2===a?ccs.TweenType.SINE_EASEINOUT:a):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];d=a[ccs.CONST_A_EASING_PARAM]||
[];for(var 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));if(b.flashToolVersion>=ccs.CONST_VERSION_2_0){var d=parseFloat(a.getAttribute(ccs.CONST_A_COCOS2D_PIVOT_X))||0;var e=parseFloat(a.getAttribute(ccs.CONST_A_COCOS2D_PIVOT_Y))||0}else 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+" > "+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=a.querySelectorAll(ccs.CONST_CONTOUR+" > "+ccs.CONST_CONTOUR_VERTEX),e,f=0;f<d.length;f++){e=d[f];var g=cc.p(0,0);g.x=parseFloat(e.getAttribute(ccs.CONST_A_X))||0;g.y=parseFloat(e.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;d<c;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=a[ccs.CONST_ARMATURE_DATA]||[],d;for(d=0;d<c.length;d++){var e=this.decodeArmatureFromJSON(c[d],b);ccs.armatureDataManager.addArmatureData(e.name,e,b.filename)}c=a[ccs.CONST_ANIMATION_DATA]||[];for(d=0;d<c.length;d++)e=this.decodeAnimationFromJson(c[d],
b),ccs.armatureDataManager.addAnimationData(e.name,e,b.filename);c=a[ccs.CONST_TEXTURE_DATA]||[];for(d=0;d<c.length;d++)e=this.decodeTextureFromJson(c[d],b),ccs.armatureDataManager.addTextureData(e.name,e,b.filename);if(null==b.asyncStruct?ccs.armatureDataManager.isAutoLoadSpriteFile():b.asyncStruct.autoLoadSpriteFile)for(c=a[ccs.CONST_CONFIG_FILE_PATH]||[],d=0;d<c.length;d++){e=c[d];var 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];if(b=c.cocoStudioVersion<ccs.VERSION_COLOR_READING?b[0]:b[ccs.CONST_COLOR_INFO]||null)a.a=null==b[ccs.CONST_A_ALPHA]?
255:b[ccs.CONST_A_ALPHA],a.r=null==b[ccs.CONST_A_RED]?255:b[ccs.CONST_A_RED],a.g=null==b[ccs.CONST_A_GREEN]?255:b[ccs.CONST_A_GREEN],a.b=null==b[ccs.CONST_A_BLUE]?255:b[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);if(b&&a&&"string"===typeof a)b[a](c)},_initBaseFilePath:function(a){var b=a.lastIndexOf("/");return a=-1<b?a.substr(0,b+1):""},addDataFromXML:function(a,
b){var c=cc.loader.getRes(a);if(!c)throw Error("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){switch(b){case ccs.TweenType.CUSTOM_EASING:a=this.customEase(a,c);break;case ccs.TweenType.LINEAR:a=this.linear(a);break;case ccs.TweenType.SINE_EASEIN:a=this.sineEaseIn(a);break;case ccs.TweenType.SINE_EASEOUT:a=this.sineEaseOut(a);break;case ccs.TweenType.SINE_EASEINOUT:a=this.sineEaseInOut(a);break;case ccs.TweenType.QUAD_EASEIN:a=this.quadEaseIn(a);break;case ccs.TweenType.QUAD_EASEOUT:a=this.quadEaseOut(a);break;case ccs.TweenType.QUAD_EASEINOUT:a=this.quadEaseInOut(a);
break;case ccs.TweenType.CUBIC_EASEIN:a=this.cubicEaseIn(a);break;case ccs.TweenType.CUBIC_EASEOUT:a=this.cubicEaseOut(a);break;case ccs.TweenType.CUBIC_EASEINOUT:a=this.cubicEaseInOut(a);break;case ccs.TweenType.QUART_EASEIN:a=this.quartEaseIn(a);break;case ccs.TweenType.QUART_EASEOUT:a=this.quartEaseOut(a);break;case ccs.TweenType.QUART_EASEINOUT:a=this.quartEaseInOut(a);break;case ccs.TweenType.QUINT_EASEIN:a=this.quintEaseIn(a);break;case ccs.TweenType.QUINT_EASEOUT:a=this.quintEaseOut(a);break;
case ccs.TweenType.QUINT_EASEINOUT:a=this.quintEaseInOut(a);break;case ccs.TweenType.EXPO_EASEIN:a=this.expoEaseIn(a);break;case ccs.TweenType.EXPO_EASEOUT:a=this.expoEaseOut(a);break;case ccs.TweenType.EXPO_EASEINOUT:a=this.expoEaseInOut(a);break;case ccs.TweenType.CIRC_EASEIN:a=this.circEaseIn(a);break;case ccs.TweenType.CIRC_EASEOUT:a=this.circEaseOut(a);break;case ccs.TweenType.CIRC_EASEINOUT:a=this.circEaseInOut(a);break;case ccs.TweenType.ELASTIC_EASEIN:b=.3;null!=c&&0<c.length&&(b=c[0]);a=
this.elasticEaseIn(a,b);break;case ccs.TweenType.ELASTIC_EASEOUT:b=.3;null!=c&&0<c.length&&(b=c[0]);a=this.elasticEaseOut(a,b);break;case ccs.TweenType.ELASTIC_EASEINOUT:b=.3;null!=c&&0<c.length&&(b=c[0]);a=this.elasticEaseInOut(a,b);break;case ccs.TweenType.BACK_EASEIN:a=this.backEaseIn(a);break;case ccs.TweenType.BACK_EASEOUT:a=this.backEaseOut(a);break;case ccs.TweenType.BACK_EASEINOUT:a=this.backEaseInOut(a);break;case ccs.TweenType.BOUNCE_EASEIN:a=this.bounceEaseIn(a);break;case ccs.TweenType.BOUNCE_EASEOUT:a=
this.bounceEaseOut(a);break;case ccs.TweenType.BOUNCE_EASEINOUT:a=this.bounceEaseInOut(a);break;default:a=this.sineEaseInOut(a)}return a};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-.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){a*=2;if(1>a)return.5*a*a;--a;return-.5*(a*(a-2)-1)};ccs.TweenFunction.cubicEaseIn=function(a){return a*a*a};ccs.TweenFunction.cubicEaseOut=function(a){--a;return a*a*a+1};ccs.TweenFunction.cubicEaseInOut=function(a){a*=2;if(1>a)return.5*a*a*a;a-=2;return.5*(a*a*a+2)};ccs.TweenFunction.quartEaseIn=function(a){return a*a*a*a};ccs.TweenFunction.quartEaseOut=function(a){--a;return-(a*a*a*a-1)};
ccs.TweenFunction.quartEaseInOut=function(a){a*=2;if(1>a)return.5*a*a*a*a;a-=2;return-.5*(a*a*a*a-2)};ccs.TweenFunction.quintEaseIn=function(a){return a*a*a*a*a};ccs.TweenFunction.quintEaseOut=function(a){--a;return a*a*a*a*a+1};ccs.TweenFunction.quintEaseInOut=function(a){a*=2;if(1>a)return.5*a*a*a*a*a;a-=2;return.5*(a*a*a*a*a+2)};ccs.TweenFunction.expoEaseIn=function(a){return 0===a?0:Math.pow(2,10*(a-1))-.001};ccs.TweenFunction.expoEaseOut=function(a){return 1===a?1:-Math.pow(2,-10*a)+1};
ccs.TweenFunction.expoEaseInOut=function(a){a/=.5;return a=1>a?.5*Math.pow(2,10*(a-1)):.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){--a;return Math.sqrt(1-a*a)};ccs.TweenFunction.circEaseInOut=function(a){a*=2;if(1>a)return-.5*(Math.sqrt(1-a*a)-1);a-=2;return.5*(Math.sqrt(1-a*a)+1)};
ccs.TweenFunction.elasticEaseIn=function(a,b){var c=.3;0<b.length&&(c=b[0]);0===a||1===a?c=a:(--a,c=-Math.pow(2,10*a)*Math.sin((a-c/4)*ccs.DOUBLE_PI/c));return c};ccs.TweenFunction.elasticEaseOut=function(a,b){var c=.3;0<b.length&&(c=b[0]);return 0===a||1===a?a:Math.pow(2,-10*a)*Math.sin((a-c/4)*ccs.DOUBLE_PI/c)+1};
ccs.TweenFunction.elasticEaseInOut=function(a,b){var c=.3;0<b.length&&(c=b[0]);if(0===a||1===a)c=a;else{c||(c=.3*1.5);var d=c/4;a=2*a-1;c=0>a?-.5*Math.pow(2,10*a)*Math.sin((a-d)*ccs.DOUBLE_PI/c):Math.pow(2,-10*a)*Math.sin((a-d)*ccs.DOUBLE_PI/c)*.5+1}return c};ccs.TweenFunction.backEaseIn=function(a){return a*a*(2.70158*a-1.70158)};ccs.TweenFunction.backEaseOut=function(a){--a;return a*a*(2.70158*a+1.70158)+1};
ccs.TweenFunction.backEaseInOut=function(a){a*=2;if(1>a)return a*a*(3.5949095*a-2.5949095)/2;a-=2;return a*a*(3.5949095*a+2.5949095)/2+1};ccs.bounceTime=function(a){if(a<1/2.75)return 7.5625*a*a;if(a<2/2.75)return a-=1.5/2.75,7.5625*a*a+.75;if(a<2.5/2.75)return a-=2.25/2.75,7.5625*a*a+.9375;a-=2.625/2.75;return 7.5625*a*a+.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.5>a?.5*(1-ccs.bounceTime(1-2*a)):.5*ccs.bounceTime(2*a-1)+.5};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){a*=2;return 1>a?.5*Math.pow(a,b):1-.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);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));return f};ccs.extCircleTo=function(a,b,c,d,e){var f=cc.p(0,0);f.x=b.x+c*Math.cos(d+e*a);f.y=b.y+c*Math.sin(d+e*a);return 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;for(c=0;c<b.armatures.length;c++){var 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){var b=null;this._armatureDatas&&(b=this._armatureDatas[a]);return b},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){var b=null;this._animationDatas[a]&&(b=this._animationDatas[a]);return b},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){var b=null;this._textureDatas&&(b=this._textureDatas[a]);return b},removeTextureData:function(a){this._textureDatas[a]&&delete this._textureDatas[a]},addArmatureFileInfo:function(){switch(arguments.length){case 1:var a=
arguments[0];this.addRelativeData(a);this._autoLoadSpriteFile=!0;ccs.dataReaderHelper.addDataFromFile(a);break;case 3:var b=arguments[0];var c=arguments[1];a=arguments[2];this.addRelativeData(a);this._autoLoadSpriteFile=!1;ccs.dataReaderHelper.addDataFromFile(a);this.addSpriteFrameFromFile(c,b)}},addArmatureFileInfoAsync:function(){switch(arguments.length){case 3:var a=arguments[0];var b=arguments[2];var c=arguments[1];this.addRelativeData(a);this._autoLoadSpriteFile=!0;ccs.dataReaderHelper.addDataFromFileAsync("",
"",a,c,b);break;case 5:var d=arguments[0];var e=arguments[1];a=arguments[2];b=arguments[4];c=arguments[3];this.addRelativeData(a);this._autoLoadSpriteFile=!1;ccs.dataReaderHelper.addDataFromFileAsync(d,e,a,c,b);this.addSpriteFrameFromFile(e,d)}},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(){for(var a in this._relativeDatas)this.removeArmatureFileInfo(a);this._animationDatas={};this._armatureDatas={};this._textureDatas={};this._relativeDatas={};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+=b.tweenRotate*ccs.PI*2,this.skewY-=b.tweenRotate*ccs.PI*2)}});
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(".");-1!==b&&(a=a.substring(0,b));return 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(){this.displayDataList.length=0;return!0},addDisplayData:function(a){this.displayDataList.push(a)},getDisplayData:function(a){return this.displayDataList[a]}});
ccs.ArmatureData=ccs.Class.extend({boneDataDic:null,name:"",dataVersion:.1,ctor:function(){this.boneDataDic={};this.name="";this.dataVersion=.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){ccs.BaseData.prototype.copy.call(this,a);this.duration=a.duration;this.displayIndex=a.displayIndex;this.tweenEasing=a.tweenEasing;this.easingParamNumber=a.easingParamNumber;if(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(){this.vertexList.length=0;return!0};ccs.ContourData.prototype.addVertex=function(a){this.vertexList.push(a)};ccs.TextureData=function(){this.width=this.height=0;this.pivotY=this.pivotX=.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._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty),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&&(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=b.getDisplayData();var d=c.displayName;var e=d.lastIndexOf(".");-1!==e&&(d=d.substring(0,e));d=""===d?new ccs.Skin:new ccs.Skin("#"+d+".png");b.setDisplay(d);d.setBone(a);this.initSpriteDisplay(a,b,c.displayName,d);(e=a.getArmature())&&(e.getArmatureData().dataVersion>=ccs.CONST_VERSION_COMBINED?d.setSkinData(c.skinData):d.setSkinData(a.boneData))},initSpriteDisplay:function(a,b,c,d){var e=c.lastIndexOf(".");
-1!==e&&(c=c.substring(0,e));(c=ccs.armatureDataManager.getTextureData(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){this._bone=a;this.initDisplayList(a.getBoneData());
return!0},addDisplay:function(a,b){var c=this._decoDisplayList;if(0<=b&&b<c.length)var d=c[b];else d=new ccs.DecorativeDisplay,c.push(d);if(a instanceof ccs.DisplayData)ccs.displayFactory.addDisplay(this._bone,d,a);else{if(a instanceof ccs.Skin){a.setBone(this._bone);var e=new ccs.SpriteDisplayData;ccs.displayFactory.initSpriteDisplay(this._bone,d,a.getDisplayName(),a);var f=d.getDisplayData();if(f instanceof ccs.SpriteDisplayData)a.setSkinData(f.skinData),e.skinData=f.skinData;else{f=!1;for(var g=
c.length-2;0<=g;g--){var h=c[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._performRecursive(cc.Node._stateCallbackType.cleanup),(c=this._bone.getArmature())&&a.setParent(c)):a instanceof ccs.Armature?(e=new ccs.ArmatureDisplayData,e.displayName=a.getName(),a.setParentBone(this._bone)):e=new ccs.DisplayData;
d.setDisplay(a);d.setDisplayData(e)}b===this._displayIndex&&(this._displayIndex=-1,this.changeDisplayWithIndex(b,!1))},_addDisplayOther:function(a,b){if(b instanceof ccs.Skin){b.setBone(this._bone);var 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{d=!1;for(var 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){a>=this._decoDisplayList.length?cc.log("the index value is out of range"):(this._forceChangeDisplay=b,this._displayIndex!==a&&(this._displayIndex=a,0>a?this._displayRenderNode&&(this._displayRenderNode.removeFromParent(!0),this.setCurrentDecorativeDisplay(null)):this.setCurrentDecorativeDisplay(this._decoDisplayList[a])))},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;b=this._displayRenderNode;var 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){this._decoDisplayList.length=
0;if(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;void 0!==b&&(a=cc.p(a,b));if(this._currentDecoDisplay.getDisplayData().displayType===ccs.DISPLAY_TYPE_SPRITE){var c=this._currentDecoDisplay.getDisplay();c=c.getChildByTag(0);return 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),c=!0;b?this.initWithSpriteFrame(b):(cc.log("Can't find CCSpriteFrame with %s. Please check your .plist file",a),c=!1);this._displayName=a;return c},initWithFile:function(a,b){var c=b?cc.Sprite.prototype.initWithFile.call(this,a,b):cc.Sprite.prototype.initWithFile.call(this,a);this._displayName=a;return 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);this._renderCmd.transform()},getSkinData:function(){return this._skinData},updateArmatureTransform:function(){this._renderCmd.transform()},getNodeToWorldTransform:function(){return this._renderCmd.getNodeToWorldTransform()},getNodeToWorldTransformAR:function(){return this._renderCmd.getNodeToWorldTransformAR()},setBone:function(a){this.bone=a;if(a=this.bone.getArmature())this._armature=a},getBone:function(){return this.bone},
getDisplayName:function(){return this._displayName},_createRenderCmd:function(){return cc._renderType===cc.game.RENDER_TYPE_CANVAS?new ccs.Skin.CanvasRenderCmd(this):new ccs.Skin.WebGLRenderCmd(this)}});_p=ccs.Skin.prototype;cc.defineGetterSetter(_p,"skinData",_p.getSkinData,_p.setSkinData);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={_realWorldTM:null,transform:function(a,c){this._transform||(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});var b=this._node,e=a?a._worldTransform:null,f=this._transform,g=this._worldTransform;if(this._dirtyFlag&cc.Node._dirtyFlags.transformDirty||e)this.originTransform(),cc.affineTransformConcatIn(this._transform,b.bone.getNodeToArmatureTransform()),this._dirtyFlag&=~cc.Node._dirtyFlags.transformDirty;if(e){if(g.a=f.a*
e.a+f.b*e.c,g.b=f.a*e.b+f.b*e.d,g.c=f.c*e.a+f.d*e.c,g.d=f.c*e.b+f.d*e.d,g.tx=f.tx*e.a+f.ty*e.c+e.tx,g.ty=f.tx*e.b+f.ty*e.d+e.ty,e=this._vertices){var h=b._offsetPosition.x,k=h+b._rect.width,m=b._offsetPosition.y;b=m+b._rect.height;e[0].x=h*g.a+b*g.c+g.tx;e[0].y=h*g.b+b*g.d+g.ty;e[1].x=h*g.a+m*g.c+g.tx;e[1].y=h*g.b+m*g.d+g.ty;e[2].x=k*g.a+b*g.c+g.tx;e[2].y=k*g.b+b*g.d+g.ty;e[3].x=k*g.a+m*g.c+g.tx;e[3].y=k*g.b+m*g.d+g.ty}}else g.a=f.a,g.b=f.b,g.c=f.c,g.d=f.d,g.tx=f.tx,g.ty=f.ty;if(g=this._realWorldTM)g.a=
f.a,g.b=f.b,g.c=f.c,g.d=f.d,g.tx=f.tx,g.ty=f.ty,cc.affineTransformConcatIn(g,this._node.bone.getArmature()._renderCmd._worldTransform)},getNodeToWorldTransform:function(){return cc.affineTransformConcat(this._transform,this._node.bone.getArmature().getNodeToWorldTransform())},getNodeToWorldTransformAR:function(){var a=this._transform,c=this._node;this._anchorPointInPoints=cc.pointApplyAffineTransform(this._anchorPointInPoints,a);a.tx=this._anchorPointInPoints.x;a.ty=this._anchorPointInPoints.y;return cc.affineTransformConcat(a,
c.bone.getArmature().getNodeToWorldTransform())}};ccs.Skin.CanvasRenderCmd=function(a){this._spriteCmdCtor(a);this._realWorldTM={a:1,b:0,c:0,d:1,tx:0,ty:0}};var a=ccs.Skin.CanvasRenderCmd.prototype=Object.create(cc.Sprite.CanvasRenderCmd.prototype);cc.inject(ccs.Skin.RenderCmd,a);a.constructor=ccs.Skin.CanvasRenderCmd;a._updateCurrentRegions=function(){var a=this._currentRegion;this._currentRegion=this._oldRegion;this._oldRegion=a;cc.Node.CanvasRenderCmd.RegionStatus.DirtyDouble!==this._regionFlag||
this._currentRegion.isEmpty()||this._oldRegion.union(this._currentRegion);this._currentRegion.updateRegion(this.getLocalBB(),this._realWorldTM)};ccs.Skin.WebGLRenderCmd=function(a){this._spriteCmdCtor(a)};a=ccs.Skin.WebGLRenderCmd.prototype=Object.create(cc.Sprite.WebGLRenderCmd.prototype);cc.inject(ccs.Skin.RenderCmd,a);a.constructor=ccs.Skin.WebGLRenderCmd})();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+=a/this.animationInternal*this._processScale,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},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;cc.defineGetterSetter(_p,"currentFrameIndex",_p.getCurrentFrameIndex);cc.defineGetterSetter(_p,"paused",_p.isPause);cc.defineGetterSetter(_p,"completed",_p.isComplete);cc.defineGetterSetter(_p,"currentPercent",_p.getCurrentPercent);cc.defineGetterSetter(_p,"rawDuration",_p.getRawDuration);cc.defineGetterSetter(_p,"loop",_p.getLoop);cc.defineGetterSetter(_p,"tweenEasing",_p.getTweenEasing);
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){this._armature=a;this._tweenList.length=0;return!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=this._armature.getBoneDic(),f;for(f in e){var g=
e[f];var h=this._movementData.movBoneDataDic[g.getName()];var k=g.getTween();h&&0<h.frameList.length?(this._tweenList.push(k),h.duration=this._movementData.duration,k.play(h,b,a,c,d),k.setProcessScale(this._processScale),g.getChildArmature()&&(g.getChildArmature().getAnimation().setSpeedScale(this._processScale),g.getChildArmature().getAnimation().isPlaying()||g.getChildArmature().getAnimation().playWithIndex(0))):g.isIgnoreMovementBoneData()||(g.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)cc.log("Please ensure you have played a movement, and the frameIndex is in the range.");
else{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: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;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=this._movementList;if(this._movementListLoop){var b=a[this._movementIndex];this.play(b,b.durationTo,0);this._movementIndex++;this._movementIndex>=a.length&&(this._movementIndex=
0)}else this._movementIndex<a.length?(b=a[this._movementIndex],this.play(b,b.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;
cc.defineGetterSetter(_p,"speedScale",_p.getSpeedScale,_p.setSpeedScale);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){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;return!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: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):(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):this._currentFrame=a=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;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);return 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));a*=this._rawDuration-1;var b,c=this._totalDuration,d=this._betweenDuration,e=this._toIndex;if(a<c||a>=c+d){d=this._movementBoneData.frameList;var f=d.length;if(a<d[0].frameID){var g=b=d[0];this.setBetween(g,b);return this._currentPercent}if(a>=d[f-1].frameID){if(this._passLastFrame)return g=b=d[f-1],this.setBetween(g,b),this._currentPercent;this._passLastFrame=!0}else this._passLastFrame=
!1;do if(this._fromIndex=e,g=d[this._fromIndex],c=g.frameID,e=this._fromIndex+1,e>=f&&(e=0),b=d[e],g.strEvent&&!this._animation.isIgnoreFrameEvent()&&this._animation.frameEvent(this._bone,g.strEvent,g.frameID,a),a===g.frameID||this._passLastFrame&&this._fromIndex===f-1)break;while(a<g.frameID||a>=b.frameID);d=b.frameID-g.frameID;this._frameTweenEasing=g.tweenEasing;this.setBetween(g,b,!1);this._totalDuration=c;this._betweenDuration=d;this._toIndex=e}a=0===d?0:(a-this._totalDuration)/this._betweenDuration;
g=this._frameTweenEasing!==ccs.TweenType.LINEAR?this._frameTweenEasing:this._tweenEasing;g===ccs.TweenType.TWEEN_EASING_MAX||g===ccs.TweenType.LINEAR||this._passLastFrame||(a=ccs.TweenFunction.tweenTo(a,g,this._from.easingParams));return a},setAnimation:function(a){this._animation=a},getAnimation:function(){return this._animation},setMovementBoneData:function(a){this._movementBoneData=a}});_p=ccs.Tween.prototype;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){this._colliderBodyList.length=0;a&&(this._bone=a);this._filter=new ccs.ColliderFilter;return!0},addContourData:function(a){var b=new ccs.ColliderBody(a);this._colliderBodyList.push(b);if(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(c=0;c<d.length;c++){var e=d[c];e&&e.getContourData()===a&&b.push(e)}for(c=0;c<b.length;c++)cc.arrayRemoveObject(d,b[c])},removeAll:function(){this._colliderBodyList.length=0},setActive:function(a){if(this._active!==a&&(this._active=
a,a=this._body,a))if(this._active)for(var b=0;b<this._colliderBodyList.length;b++){var c=this._colliderBodyList[b];c=c.getShape();a.space.addShape(c)}else for(b=0;b<this._colliderBodyList.length;b++)c=this._colliderBodyList[b],c=c.getShape(),a.space.removeShape(c)},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,c=this._body,d=this.helpPoint,e=0;e<this._colliderBodyList.length;e++){b=this._colliderBodyList[e];var f=b.getContourData(),g=null;c&&(g=b.getShape());f=f.vertexList;var h=b.getCalculatedVertexList();for(b=0;b<f.length;b++){d.x=f[b].x;d.y=f[b].y;d=cc.pointApplyAffineTransform(d,a);if(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;cc.defineGetterSetter(_p,"colliderFilter",_p.getColliderFilter,_p.setColliderFilter);cc.defineGetterSetter(_p,"active",_p.getActive,_p.setActive);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,_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);this._texture={}},init:function(a,b){b&&(this._parentBone=b);this.removeAllChildren();this.animation=new ccs.ArmatureAnimation;this.animation.init(this);this._boneDic={};this._topBoneList.length=0;var c=ccs.armatureDataManager;if(""!==a){var d=c.getAnimationData(a);cc.assert(d,"AnimationData not exist!");this.animation.setAnimationData(d);c=c.getArmatureData(a);cc.assert(c,"ArmatureData not exist!");this.armatureData=c;c=c.getBoneDataDic();for(var e in c){c=this.createBone(String(e));var f=d.getMovement(d.movementNames[0]);
f&&(f=f.getMovementBoneData(c.getName()))&&!(0>=f.frameList.length)&&(f=f.getFrameData(0))&&(c.getTweenData().copy(f),c.changeDisplayWithIndex(f.displayIndex,!1))}this.update(0);this.updateOffsetPoint()}else a="new_armature",this.armatureData=new ccs.ArmatureData,this.armatureData.name=a,d=new ccs.AnimationData,d.name=a,c.addArmatureData(a,this.armatureData),c.addAnimationData(a,d),this.animation.setAnimationData(d);this._renderCmd.initShaderCache();this.setCascadeOpacityEnabled(!0);this.setCascadeColorEnabled(!0);
return!0},visit:function(a){var b=this._renderCmd;a=a?a._renderCmd:null;this._visible?(b.visit(a),b._dirtyFlag=0):b._propagateFlagsDown(a)},addChild:function(a,b,c){a instanceof ccui.Widget?cc.log("Armature doesn't support to add Widget as its child, it will be fix soon."):cc.Node.prototype.addChild.call(this,a,b,c)},createBone:function(a){var b=this.getBone(a);if(b)return b;b=this.armatureData.getBoneData(a);var c=b.parentName;c?(this.createBone(c),a=new ccs.Bone(a),this.addBone(a,c)):(a=new ccs.Bone(a),
this.addBone(a,""));a.setBoneData(b);a.getDisplayManager().changeDisplayWithIndex(-1,!1);return a},addBone:function(a,b){cc.assert(a,"Argument must be non-nil");var c=this._boneDic;a.getName()&&cc.assert(!c[a.getName()],"bone already added. It can't be added again");if(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();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,e=!0,f=cc.rect(0,0,0,0),g=this._children,h=g.length,k=0;k<h;k++)if(a=g[k])if(d=a.getDisplayManager().getBoundingBox(),0!==d.x||0!==d.y||0!==d.width||0!==d.height)e?(a=d.x,b=d.y,c=d.x+d.width,d=d.y+d.height,e=!1):(a=d.x<f.x?d.x:f.x,b=d.y<
f.y?d.y:f.y,c=d.x+d.width>f.x+f.width?d.x+d.width:f.x+f.width,d=d.y+d.height>f.y+f.height?d.y+d.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){c=c.getColliderBodyList();for(var 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;a=this._children;for(var b=0;b<a.length;b++){var c=a[b];if(c instanceof
ccs.Bone){c=c.getDisplayManager().getDecorativeDisplayList();for(var d=0;d<c.length;d++){var e=c[d];(e=e.getColliderDetector())&&e.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.game.RENDER_TYPE_CANVAS?new ccs.Armature.CanvasRenderCmd(this):new ccs.Armature.WebGLRenderCmd(this)}});_p=ccs.Armature.prototype;
cc.defineGetterSetter(_p,"parentBone",_p.getParentBone,_p.setParentBone);cc.defineGetterSetter(_p,"body",_p.getBody,_p.setBody);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){this._rootCtor(a);this._needDraw=!0;this._realAnchorPointInPoints=new cc.Point(0,0);this._canUseDirtyRegion=!0;this._startRenderCmd=new cc.CustomRenderCmd(this,this._startCmdCallback);this._RestoreRenderCmd=new cc.CustomRenderCmd(this,this._RestoreCmdCallback);this._startRenderCmd._canUseDirtyRegion=!0;this._RestoreRenderCmd._canUseDirtyRegion=!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}};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 b=this._node._parent;this.transform(b?b._renderCmd:null);a=a||cc._renderContext;a.save();a._switchToArmatureMode(!0,this._worldTransform,c,d)};a.transform=function(a,c){this.originTransform(a,c);for(var b=this._node._children,e=0,f=b.length;e<f;e++){var g=b[e],h=g._renderCmd;if(g&&g.getDisplayRenderNode){var k=
g.getDisplayRenderNodeType(),m=g.getDisplayRenderNode();if(m&&m._renderCmd){m=m._renderCmd;m.transform(null);k!==ccs.DISPLAY_TYPE_ARMATURE&&k!==ccs.DISPLAY_TYPE_SPRITE&&cc.affineTransformConcatIn(m._worldTransform,g._worldTransform);k=cc.Node._dirtyFlags;var n=m._dirtyFlag,p=h._dirtyFlag,r=p&k.colorDirty;p&=k.opacityDirty;r&&h._updateDisplayColor(this._displayedColor);p&&h._updateDisplayOpacity(this._displayedOpacity);(r||p)&&h._updateColor();h=g._renderCmd._displayedColor;g=g._renderCmd._displayedOpacity;
r=n&k.colorDirty;p=n&k.opacityDirty;r&&m._updateDisplayColor(h);p&&m._updateDisplayOpacity(g);(r||p)&&m._updateColor()}}}};a._RestoreCmdCallback=function(a){this._cacheDirty=!1;a._switchToArmatureMode(!1);a.restore()};a.initShaderCache=function(){};a.setShaderProgram=function(){};a.updateChildPosition=function(a,c){a.visit()};a.rendering=function(a,c,d){for(var b=this._node._children,f=0,g=b.length;f<g;f++){var h=b[f];if(h&&h.getDisplayRenderNode){var k=h.getDisplayRenderNode();if(null!==k)switch(h._renderCmd._syncStatus(this),
h.getDisplayRenderNodeType()){case ccs.DISPLAY_TYPE_SPRITE:k.visit(h);break;case ccs.DISPLAY_TYPE_ARMATURE:k._renderCmd.rendering(a,c,d);break;default:k.visit(h)}}else h instanceof cc.Node&&this._visitNormalChild(h)}};a._visitNormalChild=function(a){if(a){var b=a._renderCmd;if(a._visible){b._curLevel=this._curLevel+1;var d,e=a._children;b._syncStatus(this);b.transform(null);var f=e.length;if(0<f){a.sortAllChildren();for(d=0;d<f;d++){var g=e[d];if(0>g._localZOrder)g.visit(a);else break}for(cc.renderer.pushRenderCommand(b);d<
f;d++)e[d].visit(a)}else cc.renderer.pushRenderCommand(b);this._dirtyFlag=0}}};a.visit=function(a){var b=this._node;b._visible&&(this._syncStatus(a),b.sortAllChildren(),cc.renderer.pushRenderCommand(this._startRenderCmd),this.rendering(),cc.renderer.pushRenderCommand(this._RestoreRenderCmd),this._cacheDirty=!1)}})();(function(){ccs.Armature.WebGLRenderCmd=function(a){this._rootCtor(a);this._needDraw=!0;this._parentCmd=null;this._realAnchorPointInPoints=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}};var a=ccs.Armature.WebGLRenderCmd.prototype=Object.create(cc.Node.WebGLRenderCmd.prototype);cc.inject(ccs.Armature.RenderCmd,a);a.constructor=ccs.Armature.WebGLRenderCmd;a.uploadData=function(a,c,d){a=this._node;d=this._parentCmd||this;for(var b=a._children,
f=cc.BlendFunc.ALPHA_PREMULTIPLIED,g=cc.BlendFunc.ALPHA_NON_PREMULTIPLIED,h=0,k=b.length;h<k;h++){var m=b[h],n=m._renderCmd;if(m&&m.getDisplayRenderNode){var p=m.getDisplayRenderNode();if(null!==p)switch(c=p._renderCmd,m.getDisplayRenderNodeType()){case ccs.DISPLAY_TYPE_SPRITE:p instanceof ccs.Skin&&(p.setShaderProgram(this._shaderProgram),this._updateColorAndOpacity(c,m),c.transform(d),n=m.getBlendFunc(),n.src!==f.src||n.dst!==f.dst?p.setBlendFunc(m.getBlendFunc()):(m=p.getTexture(),a._blendFunc.src===
f.src&&a._blendFunc.dst===f.dst&&m&&!m.hasPremultipliedAlpha()?p.setBlendFunc(g):p.setBlendFunc(a._blendFunc)),cc.renderer._uploadBufferData(c));break;case ccs.DISPLAY_TYPE_ARMATURE:p.setShaderProgram(this._shaderProgram),this._updateColorAndOpacity(c,m),c._parentCmd=this;default:n._syncStatus(d),c._syncStatus(n),c.uploadData?cc.renderer._uploadBufferData(c):c.rendering&&(cc.renderer._batchRendering(),c.rendering(cc._renderContext))}}else m instanceof cc.Node&&(m.setShaderProgram(this._shaderProgram),
n._syncStatus(d),n.uploadData?cc.renderer._uploadBufferData(n):n.rendering&&(cc.renderer._batchRendering(),n.rendering(cc._renderContext)))}this._parentCmd=null;return 0};a.initShaderCache=function(){this._shaderProgram=cc.shaderCache.programForKey(cc.SHADER_SPRITE_POSITION_TEXTURECOLOR)};a.setShaderProgram=function(a){this._glProgramState=cc.GLProgramState.getOrCreateWithGLProgram(a)};a._updateColorAndOpacity=function(a,c){var b=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(b);f&&a._updateDisplayOpacity(e);(h||f)&&a._updateColor()};a.visit=function(a){var b=this._node;if(b._visible){if(a=a||this.getParentRenderCmd())this._curLevel=a._curLevel+1;this._syncStatus(a);b.sortAllChildren();a=cc.renderer;var d=b._children,e,f=d.length;isNaN(b._customZ)&&(b._vertexZ=a.assignedZ,a.assignedZ+=a.assignedZStep);for(e=0;e<f;e++)if(b=d[e],0>b._localZOrder)isNaN(b._customZ)&&(b._vertexZ=a.assignedZ,a.assignedZ+=
a.assignedZStep);else break;for(a.pushRenderCommand(this);e<f;e++)b=d[e],isNaN(b._customZ)&&(b._vertexZ=a.assignedZ,a.assignedZ+=a.assignedZStep);this._dirtyFlag=0}}})();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){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;return!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){this._parentBone&&(this._boneTransformDirty=this._boneTransformDirty||this._parentBone.isTransformDirty());this._armatureParentBone&&!this._boneTransformDirty&&(this._boneTransformDirty=this._armatureParentBone.isTransformDirty());if(this._boneTransformDirty){var b=this._tweenData;this._dataVersion>=ccs.CONST_VERSION_COMBINED&&(ccs.TransformHelp.nodeConcat(b,this._boneData),--b.scaleX,--b.scaleY);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&&cc.affineTransformConcatIn(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=this._blendFunc;if(void 0===b){var d=a.src;var e=a.dst}else d=a,e=b;if(c.src!==d||c.dst!==
e)c.src=d,c.dst=e,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._armature.getArmatureData().dataVersion>=ccs.CONST_VERSION_COMBINED?this.setLocalZOrder(this._tweenData.zOrder+this._boneData.zOrder):
this.setLocalZOrder(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 this._displayManager.addDisplay(a,b||0)},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.game.RENDER_TYPE_CANVAS?new ccs.Bone.CanvasRenderCmd(this):new ccs.Bone.WebGLRenderCmd(this)}});_p=ccs.Bone.prototype;
cc.defineGetterSetter(_p,"boneData",_p.getBoneData,_p.setBoneData);cc.defineGetterSetter(_p,"armature",_p.getArmature,_p.setArmature);cc.defineGetterSetter(_p,"childArmature",_p.getChildArmature,_p.setChildArmature);cc.defineGetterSetter(_p,"childrenBone",_p.getChildrenBone);cc.defineGetterSetter(_p,"tween",_p.getTween);cc.defineGetterSetter(_p,"tweenData",_p.getTweenData);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(this._displayedColor);b.setOpacity(this._displayedOpacity);c._syncDisplayColor(a._tweenData);c._syncDisplayOpacity(a._tweenData.a);c._updateColor()}},transform:function(a,b){this._transform||(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});var c=this._node,d=this._transform,e=this._worldTransform,f=a?a._worldTransform:
null;f&&(this.originTransform(),cc.affineTransformConcatIn(d,c._worldTransform));f?(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=d.tx*f.a+d.ty*f.c+f.tx,e.ty=d.tx*f.b+d.ty*f.d+f.ty):(e.a=d.a,e.b=d.b,e.c=d.c,e.d=d.d,e.tx=d.tx,e.ty=d.ty)}};(function(){ccs.Bone.CanvasRenderCmd=function(a){this._rootCtor(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){this._rootCtor(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){cc.log("Need a definition of <getAction> for ActionFrame");return null},_getEasingAction:function(a){if(null===a)return console.error("Action cannot be null!"),null;switch(this.easingType){case ccs.FrameEaseType.LINEAR:var 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;d=[];for(var 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=.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=ccui.helper.seekActionWidgetByActionTag(b,a.ActionTag),e=d instanceof ccui.Widget&&!(d instanceof ccui.Layout),f=0;f<c.length;f++){var g=c[f],h=g.frameid,k=g.tweenType;null==k&&(k=0);for(var m=g.tweenParameter,n=[],p=0;p<m;p++)n.push(g.tweenParameter[p]);if(void 0!==g.positionx){p=g.positionx;var r=g.positiony;e&&d.parent&&(m=d.parent.getAnchorPointInPoints(),p+=m.x,r+=m.y);m=new ccs.ActionMoveFrame;m.frameIndex=h;m.setEasingType(k);m.setEasingParameter(n);m.setPosition(p,
r);p=this._frameArray[ccs.FRAME_TYPE_MOVE];p.push(m)}void 0!==g.scalex&&(p=g.scalex,r=g.scaley,m=new ccs.ActionScaleFrame,m.frameIndex=h,m.setEasingType(k),m.setEasingParameter(n),m.setScaleX(p),m.setScaleY(r),p=this._frameArray[ccs.FRAME_TYPE_SCALE],p.push(m));void 0!==g.rotation&&(p=g.rotation,m=new ccs.ActionRotationFrame,m.frameIndex=h,m.setEasingType(k),m.setEasingParameter(n),m.setRotation(p),p=this._frameArray[ccs.FRAME_TYPE_ROTATE],p.push(m));void 0!==g.opacity&&(p=g.opacity,m=new ccs.ActionFadeFrame,
m.frameIndex=h,m.setEasingType(k),m.setEasingParameter(n),m.setOpacity(p),p=this._frameArray[ccs.FRAME_TYPE_FADE],p.push(m));void 0!==g.colorr&&(p=g.colorr,r=g.colorg,g=g.colorb,m=new ccs.ActionTintFrame,m.frameIndex=h,m.setEasingType(k),m.setEasingParameter(n),m.setColor(cc.color(p,r,g)),p=this._frameArray[ccs.FRAME_TYPE_TINT],p.push(m))}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){void 0!==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(!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)}else f=f.getAction(0);f&&d.push(f)}d&&
(c=cc.sequence(d),null!==c&&a.push(c))}}this._action=null;return this._actionSpawn=cc.spawn(a)},playAction:function(a){this._object&&this._actionSpawn&&(this._action=a?cc.sequence(this._actionSpawn,a):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;d<e;d++){var f=c[d];0>=f.length||(b=!0,f=f[0].frameIndex,a=a>f?f:a)}b||(a=0);return a},getLastFrameIndex:function(){for(var a=-1,b=!1,c=this._frameArray,d=0,e=this._frameArrayNum;d<e;d++){var f=c[d];0>=f.length||(b=!0,f=f[f.length-1].frameIndex,a=a<f?f:a)}b||(a=0);return a},updateActionToTimeLine:function(a){for(var b=!1,c=this.getUnitTime(),d=0;d<this._frameArrayNum;d++){var e=this._frameArray[d];if(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}else 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 this._action?this._action.isDone():!0}});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=.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;b<a;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;d<c;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;c<d;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(){this._jsonDict={};return!0},setInt:function(a,b){a?this._jsonDict[a]=b:cc.log("Argument must be non-nil")},setDouble:function(a,b){a?this._jsonDict[a]=b:cc.log("Argument must be non-nil")},setFloat:function(a,b){a?this._jsonDict[a]=b:cc.log("Argument must be non-nil")},
setBool:function(a,b){a?this._jsonDict[a]=b:cc.log("Argument must be non-nil")},setString:function(a,b){a?this._jsonDict[a]=b:cc.log("Argument must be non-nil")},setObject:function(a,b){a?this._jsonDict[a]=b: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!!this._jsonDict[a]},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){var b=null;(a=this._typeMap[a])&&(b=cc.isFunction(a._fun)?new a._fun:a._fun);return b},registerType:function(a){this._typeMap[a._className]=a},createGUI:function(a){var b=null;"Panel"===a?a="Layout":"TextArea"===a?a="Label":"TextButton"===a&&(a="Button");(a=this._typeMap[a])&&a._fun&&(b=a._fun);return b},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);c=d.getEvents();for(var 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[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(){this._cons=[];this._acts=[];this._vInt=[];return!0},detect:function(){if(!this._enable||0===this._cons.length)return!0;for(var a=!0,b,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,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];var e=d.classname;var 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){this._actionTag=a;return!0},setActionTag:function(a){this._actionTag=a},getActionTag:function(){return this._actionTag}});ccs.AnimationInfo=function(a,b,c){this.name=a;this.startIndex=b;this.endIndex=c};
ccs.ComExtensionData=ccs.Component.extend({_customProperty:null,_timelineData:null,_name:"ComExtensionData",ctor:function(){this._customProperty="";this._timelineData=new ccs.ActionTimelineData(0);return!0},setActionTag:function(a){this._timelineData.setActionTag(a)},getActionTag:function(){return this._timelineData.getActionTag()},setCustomProperty:function(a){this._customProperty=a},getCustomProperty:function(){return this._customProperty}});ccs.ComExtensionData.create=function(){return new ccs.ComExtensionData};
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,_lastFrameListener: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;c<b;c++)this._timelineList[c]._gotoFrame(a)},
_stepToFrame:function(a){for(var b=this._timelineList.length,c=0;c<b;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=0,f=arguments.length,g=[],h;for(e;e<f;e++)"boolean"===typeof arguments[e]?h=arguments[e]:g.push(arguments[e]);a=g[0];b=void 0!==g[1]?g[1]:this._duration;c=g[2]||a;this._startFrame=a;this._endFrame=b;this._currentFrame=c;this._loop=null!=h?
h:!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]=[]);-1===
this._timelineMap[b].indexOf(a)&&(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){if(b===a)return!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,a=this._time-this._endFrame*this._frameInternal,a<this._frameInternal?(this._currentFrame=Math.floor(this._time/this._frameInternal),
this._stepToFrame(this._currentFrame),0<=a&&this._lastFrameListener&&this._lastFrameListener()):(this._playing=this._loop)?this.gotoFrameAndPlay(this._startFrame,this._endFrame,this._loop):(this._time=this._endFrame*this._frameInternal,this._currentFrame!=this._endFrame&&(this._currentFrame=this._endFrame,this._stepToFrame(this._currentFrame),this._lastFrameListener&&this._lastFrameListener())))},_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 c=a.getComponent("ComExtensionData");if(c&&(c=c.getActionTag(),b._timelineMap[c])){c=b._timelineMap[c];for(var e=0;e<c.length;e++)c[e].setNode(a)}})},isDone:function(){return!1},play:function(a,b){var c=this._animationInfos[a];if(!c)return cc.log("Can't find animation info for %s",a);this.gotoFrameAndPlay(c.startIndex,c.endIndex,b)},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]},setLastFrameCallFunc:function(a){this._lastFrameListener=a},clearLastFrameCallFunc:function(){this._lastFrameListener=null}});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,_enterWhenPassed:null,ctor:function(){this._frameIndex=0;this._tween=!0;this._node=this._timeline=null;this._enterWhenPassed=!1;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":function(a,b){if(b){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},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){var c=.3;null!=b&&(c=b[0]);return cc.easeElasticIn(c).easing(a)},23:function(a,b){var c=.3;null!=b&&(c=b[0]);return cc.easeElasticOut(c).easing(a)},24:function(a,b){var c=
.3;null!=b&&(c=b[0]);return cc.easeElasticInOut(c).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;a.setVisible(this._visible);a._cloneProperty(this);return 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;a.setTextureName(this._textureName);a._cloneProperty(this);return 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;a.setRotation(this._rotation);a._cloneProperty(this);return 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;a.setSkewX(this._skewX);a.setSkewY(this._skewY);a._cloneProperty(this);return 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;
a.setSkewX(this._skewX);a.setSkewY(this._skewY);a._cloneProperty(this);return 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;a.setPosition(this._position);a._cloneProperty(this);return 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;a.setScaleX(this._scaleX);a.setScaleY(this._scaleY);a._cloneProperty(this);return 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;a.setAnchorPoint(this._anchorPoint);a._cloneProperty(this);return 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)a.gotoFrameAndPause(this._singleFrameIndex);else{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;a.setInnerActionType(this._innerActionType);a.setStartFrameIndex(this._startFrameIndex);a.setEnterWithName(this._enterWithName);
a.setAnimationName(this._animationName);a.setSingleFrameIndex(this._singleFrameIndex);a._cloneProperty(this);return 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){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;a.setColor(this._color);a._cloneProperty(this);return 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;a.setAlpha(this._alpha);a._cloneProperty(this);
return a}});ccs.EventFrame=ccs.Frame.extend({_event:null,ctor:function(){ccs.Frame.prototype.ctor.call(this);this._event="";this._enterWhenPassed=!0},onEnter:function(a){this._emitEvent()},clone:function(){var a=new ccs.EventFrame;a.setEvent(this._event);a._cloneProperty(this);return 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:0,onEnter:function(a){this._node&&this._node.setLocalZOrder(this._zorder)},clone:function(){var a=new ccs.ZOrderFrame;a.setZOrder(this._zorder);a._cloneProperty(this);return 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({ctor:function(){this._super();this._blendFunc=null},onEnter:function(a,b){this._node&&this._blendFunc&&this._node.setBlendFunc(this._blendFunc)},clone:function(){var a=new ccs.BlendFuncFrame;a.setBlendFunc(this._blendFunc);a._cloneProperty(this);return a},setBlendFunc:function(a){a&&a.src&&a.dst&&(this._blendFunc=a)},getBlendFunc:function(){return this._blendFunc}});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,
c=this._frames.length,d=!1;do if(a<this._frames[0].getFrameIndex()){this._currentKeyFrameIndex>=this._frames[0].getFrameIndex()&&(d=!0);this._toIndex=this._fromIndex=0;var e=b=this._frames[0];this._currentKeyFrameIndex=0;this._betweenDuration=this._frames[0].getFrameIndex()}else if(a>=this._frames[c-1].getFrameIndex())this._fromIndex=c-1,this._toIndex=0,e=b=this._frames[c-1],this._currentKeyFrameIndex=this._frames[c-1].getFrameIndex(),this._betweenDuration=0;else{var f=-1;e=0;b=c-1;for(var g;e<=b;){g=
Math.ceil((e+b)/2);if(a>=this._frames[g].getFrameIndex()&&a<this._frames[g+1].getFrameIndex()){f=g;break}this._frames[g].getFrameIndex()>a?b=g-1:e=g+1}this._fromIndex=f;this._toIndex=1<c?f+1|0:f|0;e=this._frames[f];b=this._frames[f+1];0===f&&this._currentKeyFrameIndex<e.getFrameIndex()&&(d=!0);this._currentKeyFrameIndex=e.getFrameIndex();this._betweenDuration=b.getFrameIndex()-e.getFrameIndex()}while(0);if(d||this._currentKeyFrame!=e)this._currentKeyFrame=e,this._currentKeyFrame.onEnter(b)},_updateCurrentKeyFrame:function(a){if(a<
this._currentKeyFrameIndex||a>=this._currentKeyFrameIndex+this._betweenDuration){var b;do{var c=this._frames.length;if(a<this._frames[0].getFrameIndex()){var d=b=this._frames[0];this._currentKeyFrameIndex=0;this._betweenDuration=this._frames[0].getFrameIndex()}else{if(a>=this._frames[c-1].getFrameIndex()&&(a=this._frames[c-1].getFrameIndex(),this._currentKeyFrameIndex>=a))return;do{this._fromIndex=this._toIndex;d=this._frames[this._fromIndex];this._currentKeyFrameIndex=d.getFrameIndex();this._toIndex=
this._fromIndex+1;this._toIndex>=c&&(this._toIndex=0);b=this._frames[this._toIndex];if(a===d.getFrameIndex())break;if(a>d.getFrameIndex()&&a<b.getFrameIndex())break;if(d.isEnterWhenPassed())d.onEnter(b)}while(1);this._betweenDuration=b.getFrameIndex()-d.getFrameIndex()}}while(0);this._currentKeyFrame=d;this._currentKeyFrame.onEnter(b)}}});ccs.Timeline.create=function(){return new ccs.Timeline};ccs.SkinNode=function(){var a=cc.Node.extend({});a.create=function(){};return a}();ccs.BoneNode=function(){var a=cc.Node,b=ccs.SkinNode,c=cc.BlendFunc,d={p:cc.p,size:cc.size,rect:cc.rect},e={log:cc.log,assert:cc.assert},f=a.extend({_customCommand:null,_blendFunc:null,_rackColor:null,_rackLength:null,_rackWidth:null,_childBones:null,_boneSkins:null,_rootSkeleton:null,_squareVertices:null,_squareColors:null,_noMVPVertices:null,ctor:function(b){a.prototype.ctor.call(this);null===this._squareVertices&&(this._squareVertices=[{x:0,y:0},{x:0,y:0},{x:0,y:0},{x:0,y:0}]);this._rackColor=
cc.color.WHITE;this._blendFunc=c.ALPHA_NON_PREMULTIPLIED;this._childBones=[];this._boneSkins=[];this._rackLength=void 0===b?50:b;this._rackWidth=20;this._updateVertices()},visit:function(a){this._visit&&this._visit(a&&a._renderCmd)},addSkin:function(b,c,d){var f=this._boneSkins;e.assert(null!=b,"Argument must be non-nil");if(d)for(d=0;d<f.length;d++)f[d].setVisible(!1);a.prototype.addChild.call(this,b);this._boneSkins.push(b);b.setVisible(c)},getChildBones:function(){return this._childBones},getSkins:function(){return this._boneSkins},
displaySkin:function(a,b){var c=this._boneSkins,d;if("string"===typeof a)for(d=0;d<c.length;d++){var e=c[d];a==e.getName()?e.setVisible(!0):b&&e.setVisible(!1)}else for(d=0;d<c.length;d++)e=c[d],e==a?e.setVisible(!0):b&&e.setVisible(!1)},getVisibleSkins:function(){for(var a=[],b=this._boneSkins,c,d=0;d<b.length;d++)c=b[d],c.isVisible()&&a.push(c);return a},getRootSkeletonNode:function(){return this._rootSkeleton},getAllSubBones:function(){for(var a=[],b=[],c=this._childBones,d=0;d<c.length;d++)b.push(c[d]);
for(;0<b.length;)for(c=b.pop(),a.push(c),c=c.getChildBones(),d=0;d<c;d++)b.push(c[d]);return a},getAllSubSkins:function(){for(var a=this.getAllSubBones(),b=[],c=0;c<a.length;c++)for(var d=a[c].getSkins(),e=0;e<d.length;e++)b.push(d[c]);return b},addChild:function(b,c,d){a.prototype.addChild.call(this,b,c,d);this._addToChildrenListHelper(b)},removeChild:function(b,c){-1!==this._children.indexOf(b)&&(a.prototype.removeChild.call(this,b,c),this._removeFromChildrenListHelper(b))},setBlendFunc:function(a){var b=
this._blendFunc;if(a&&b.src!==a.src&&b.dst!==a.dst){this._blendFunc=a;b=this._boneSkins;for(var c,d=0;d<b.length;d++)c=b[d],c.setBlendFunc(a)}},getBlendFunc:function(){return this._blendFunc},setDebugDrawLength:function(a){this._rackLength=a;this._updateVertices()},getDebugDrawLength:function(){return this._rackLength},setDebugDrawWidth:function(a){this._rackWidth=a;this._updateVertices()},getDebugDrawWidth:function(){return this._rackWidth},setDebugDrawEnabled:function(a){var b=this._renderCmd;b._debug!==
a&&(b._debug=a,cc.renderer.childrenOrderDirty=!0,this._visible&&null!=this._rootSkeleton&&(this._rootSkeleton._subBonesDirty=!0,this._rootSkeleton._subBonesOrderDirty=!0))},isDebugDrawEnabled:function(){return this._renderCmd._debug},setDebugDrawColor:function(a){this._rackColor=a},getDebugDrawColor:function(){return this._rackColor},getVisibleSkinsRect:function(){var a,b,c=0;var e=a=b=c;var f=!0,g=d.rect(0,0,0,0);this._renderCmd._debug&&null!=this._rootSkeleton&&this._rootSkeleton._renderCmd._debug&&
(b=this._rackWidth,c=this._rackLength,f=!1);for(var h=this._boneSkins,v,x=0;x<h.length;x++){v=h[x];var w=v.getBoundingBox();!v.isVisible()||0===w.x&&0===w.y&&0===w.width&&0===w.height||(f?(e=cc.rectGetMinX(w),a=cc.rectGetMinY(w),b=cc.rectGetMaxX(w),c=cc.rectGetMaxY(w),f=!1):(e=Math.min(cc.rectGetMinX(w),e),a=Math.min(cc.rectGetMinY(w),a),b=Math.max(cc.rectGetMaxX(w),b),c=Math.max(cc.rectGetMaxY(w),c)),g.setRect(e,a,b-e,c-a))}return g},getBoundingBox:function(){var a=this.getVisibleSkinsRect();return cc.rectApplyAffineTransform(a,
this.getNodeToParentAffineTransform())},batchBoneDrawToSkeleton:function(a){},setLocalZOrder:function(b){a.prototype.setLocalZOrder.call(this,b);null!=this._rootSkeleton&&(this._rootSkeleton._subBonesOrderDirty=!0)},setName:function(b){var c=this._rootSkeleton,d=this.getName();a.prototype.setName.call(this,b);if(null!=c){d=c._subBonesMap[d];var e=c._subBonesMap[b];d&&!e&&(delete c._subBonesMap[d],c._subBonesMap[b]=d)}},setContentSize:function(b){a.prototype.setContentSize.call(this,b);this._updateVertices()},
setAnchorPoint:function(b){a.prototype.setAnchorPoint.call(this,b);this._updateVertices()},setVisible:function(b){this._visible!=b&&(a.prototype.setVisible.call(this,b),null!=this._rootSkeleton&&(this._rootSkeleton._subBonesDirty=!0,this._rootSkeleton._subBonesOrderDirty=!0))},_addToChildrenListHelper:function(a){a instanceof f?this._addToBoneList(a):this._addToSkinList(a)},_removeFromChildrenListHelper:function(a){a instanceof f?this._removeFromBoneList(a):a instanceof b&&this._removeFromSkinList(skin)},
_removeFromBoneList:function(a){if(null!=this._rootSkeleton&&a instanceof ccs.SkeletonNode&&a._rootSkeleton===this._rootSkeleton){a._rootSkeleton=null;var b=a.getAllSubBones();b.push(a);for(var c,d=0;d<b.length;d++)c=b[d],c._rootSkeleton=null,delete this._rootSkeleton._subBonesMap[c.getName()],this._rootSkeleton._subBonesDirty=!0,this._rootSkeleton._subBonesOrderDirty=!0}else this._rootSkeleton._subBonesDirty=!0,this._rootSkeleton._subBonesOrderDirty=!0;cc.arrayRemoveObject(this._childBones,a)},_setRootSkeleton:function(a){this._rootSkeleton=
a;a=this.getAllSubBones();for(var b=0;b<a.length;b++)this._addToBoneList(a[b])},_addToBoneList:function(a){-1===this._childBones.indexOf(a)&&this._childBones.push(a);if(null!=this._rootSkeleton&&!(a instanceof b||a._rootSkeleton)){var c=a.getAllSubBones();c.push(a);for(var d=0;d<c.length;d++){a=c[d];a._setRootSkeleton(this._rootSkeleton);var e=a.getName();this._rootSkeleton._subBonesMap[e]?cc.log("already has a bone named %s in skeleton %s",e,this._rootSkeleton.getName()):this._rootSkeleton._subBonesMap[a.getName()]=
a;this._rootSkeleton._subBonesDirty=!0;this._rootSkeleton._subBonesOrderDirty=!0}}},_visitSkins:function(){var a=this._renderCmd;if(this._visible){var b=a.getParentRenderCmd();b&&(a._curLevel=b._curLevel+1);var c=this._boneSkins;a._syncStatus(b);var d=c.length;if(0<d){this.sortAllChildren();for(b=0;b<d;b++){var e=c[b];if(0>e._localZOrder)e.visit(this);else break}for(;b<d;b++)c[b].visit(this)}a._dirtyFlag=0}},_addToSkinList:function(a){this._boneSkins.push(a);if(a.getBlendFunc){var b=a.getBlendFunc();
this._blendFunc.src!==b.src&&this._blendFunc.dst!==b.dst&&a.setBlendFunc(this._blendFunc)}},_removeFromSkinList:function(a){cc.arrayRemoveObject(this._boneSkins,a)},sortAllChildren:function(){this._sortArray(this._childBones);this._sortArray(this._boneSkins);a.prototype.sortAllChildren.call(this)},_sortArray:function(a){if(a){var b=a.length,c,d;for(c=1;c<b;c++){var e=a[c];for(d=c-1;0<=d;){if(e._localZOrder<a[d]._localZOrder)a[d+1]=a[d];else if(e._localZOrder===a[d]._localZOrder&&e.arrivalOrder<a[d].arrivalOrder)a[d+
1]=a[d];else break;d--}a[d+1]=e}}},_updateVertices:function(){var a=this._squareVertices,b=this._renderCmd._anchorPointInPoints;if(this._rackLength!=a[2].x-b.x||a[3].y!=this._rackWidth/2-b.y){a[1].x=a[1].y=a[3].y=0;a[0].x=a[2].x=.1*this._rackLength;a[2].y=.5*this._rackWidth;a[0].y=-a[2].y;a[3].x=this._rackLength;for(var c=0;c<a.length;c++)a[c].x+=b.x,a[c].y+=b.y;this._renderCmd.updateDebugPoint(a)}},_createRenderCmd:function(){return cc._renderType===cc.game.RENDER_TYPE_CANVAS?new g(this):new h(this)}});
f.create=function(a,b){return new ccui.BoneNode(a,b)};var g=function(){var b=function(a){this._rootCtor(a);this._debug=!1;this._color=cc.color.WHITE;this._drawNode=new cc.DrawNode},c=b.prototype=Object.create(a.CanvasRenderCmd.prototype);c.constructor=b;c.updateDebugPoint=function(a){this._drawNode.clear();this._drawNode.drawPoly(a,this._color,0,this._color)};c.transform=function(a,b){var c=this._node._rootSkeleton;this.originTransform(a,b);c&&c._renderCmd._debug&&this._drawNode._renderCmd.transform(this)};
return b}(),h=function(){var b=function(a){this._rootCtor(a);this._debug=!1;this._color=cc.color.WHITE;this._drawNode=new cc.DrawNode},c=b.prototype=Object.create(a.WebGLRenderCmd.prototype);c.constructor=b;c.updateDebugPoint=function(a){this._drawNode.clear();this._drawNode.drawPoly(a,this._color,0,this._color)};c.transform=function(a,b){var c=this._node._rootSkeleton;this.originTransform(a,b);c&&c._renderCmd._debug&&this._drawNode._renderCmd.transform(this)};return b}();return f}();ccs.SkeletonNode=function(){var a=ccs.BoneNode,b=a.extend({_subBonesMap:null,_squareVertices:null,_squareColors:null,_noMVPVertices:null,_skinGroupMap:null,_sortedAllBonesDirty:!1,_sortedAllBones:null,_batchedBoneVetices:null,_batchedBoneColors:null,_batchedVeticesCount:null,_batchBoneCommand:null,_subOrderedAllBones:null,ctor:function(){this._squareVertices=[{x:0,y:0},{x:0,y:0},{x:0,y:0},{x:0,y:0},{x:0,y:0},{x:0,y:0},{x:0,y:0},{x:0,y:0}];this._rootSkeleton=this;a.prototype.ctor.call(this);this._subBonesMap=
{};this._subOrderedAllBones=[];this._skinGroupMap={};this._rackLength=this._rackWidth=20;this._updateVertices()},getBoneNode:function(a){return(a=this._subBonesMap[a])?a:null},getAllSubBonesMap:function(){return this._subBonesMap},changeSkins:function(a){if("object"===typeof a){var b;for(b in a){var c=a[b];var f=this.getBoneNode(b);null!==f&&f.displaySkin(c,!0)}}else(a=this._suitMap[a])&&this.changeSkins(a,!0)},addSkinGroup:function(a,b){this._skinGroupMap[a]=b},getBoundingBox:function(){var a,b,
e=0;var f=a=b=e;var g=this.getVisibleSkinsRect(),h=!0;if(0!==g.x||0!==g.y||0!==g.width||0!==g.height)f=cc.rectGetMinX(g),a=cc.rectGetMinY(g),b=cc.rectGetMaxX(g),e=cc.rectGetMaxY(g),h=!1;for(var k=this.getAllSubBones(),m,n=0;n<k.length;n++)if(m=k[n],m=cc.rectApplyAffineTransform(m.getVisibleSkinsRect(),m.getNodeToParentTransform(m.getRootSkeletonNode())),0!==m.x||0!==m.y||0!==m.width||0!==m.height)h?(f=cc.rectGetMinX(m),a=cc.rectGetMinY(m),b=cc.rectGetMaxX(m),e=cc.rectGetMaxY(m),h=!1):(f=Math.min(cc.rectGetMinX(m),
f),a=Math.min(cc.rectGetMinY(m),a),b=Math.max(cc.rectGetMaxX(m),b),e=Math.max(cc.rectGetMaxY(m),e));g.x=f;g.y=a;g.width=b-f;g.height=e-a;return cc.rectApplyAffineTransform(g,this.getNodeToParentTransform())},_visit:function(a){var b=this._renderCmd;a=a||b.getParentRenderCmd();if(this._visible){b._syncStatus(a);if(0!==this._children.length)for(a=0;a<this._children.length;a++){var c=this._children[a];c.visit(this)}this._checkSubBonesDirty();c=this._subOrderedAllBones;for(a=0;a<c.length;a++){var f=c[a];
f._visitSkins()}if(b._debug)for(a=0;a<c.length;a++)f=c[a]._renderCmd,cc.renderer.pushRenderCommand(f._drawNode._renderCmd);b._dirtyFlag=0}else b._propagateFlagsDown(a)},_checkSubBonesDirty:function(){this._subBonesDirty&&(this._updateOrderedAllbones(),this._subBonesDirty=!1);this._subBonesOrderDirty&&(this._sortOrderedAllBones(),this._subBonesOrderDirty=!1)},_updateOrderedAllbones:function(){this._subOrderedAllBones.length=0;for(var a=[],b=this._childBones,e,f=0;f<b.length;f++)e=b[f],e.isVisible()&&
a.push(e);for(;0<a.length;)for(f=a.pop(),b=f._renderCmd,b._syncStatus(b.getParentRenderCmd()),this._subOrderedAllBones.push(f),b=f.getChildBones(),f=0;f<b.length;f++)e=b[f],e.isVisible()&&a.push(e)},_sortOrderedAllBones:function(){this._sortArray(this._subOrderedAllBones)},_updateVertices:function(){var a=this._squareVertices,b=this._renderCmd._anchorPointInPoints;if(this._rackLength!=a[6].x-b.x||this._rackWidth!=a[3].y-b.y){var e=.5*this._rackLength,f=.5*this._rackWidth,g=.25*e,h=.25*f;a[5].y=a[2].y=
a[1].y=a[6].y=a[0].x=a[4].x=a[7].x=a[3].x=0;a[5].x=-e;a[0].y=-f;a[6].x=e;a[3].y=f;a[1].x=g;a[7].y=h;a[2].x=-g;a[4].y=-h;for(e=0;e<a.length;e++)a[e].x+=b.x,a[e].y+=b.y}},_updateAllDrawBones:function(){this._subDrawBones={};for(var a in this._subBonesMap){var b=this._subBonesMap[a];b.isVisible()&&b.isDebugDrawEnabled()&&this._subDrawBones.push(b)}this._sortArray(this._sortedAllBones);this._subDrawBones=!1}});b.create=function(){return new b};return b}();ccs._load=function(){var a=function(a,d,h){var f=cc.loader.getRes(a);if(!f)return cc.log("%s does not exist",a);var g=a.match(c);g=(g&&g[1]?g[1]:null).toLocaleLowerCase();if("json"!==g&&"exportjson"!==g)return cc.log("%s load error, must be json file",a);var n;d?n=b[d]:f.widgetTree?n=b.ccui:f.nodeTree?n=b.timeline:f.Content&&f.Content.Content?n=b.timeline:f.gameobjects&&(n=b.scene);if(!n)return cc.log("Can't find the parser : %s",a),new cc.Node;d=f.version||f.Version;if(!d&&f.armature_data)return cc.warn("%s is armature. please use:",
a),cc.warn("    ccs.armatureDataManager.addArmatureFileInfoAsync(%s);",a),cc.warn("    var armature = new ccs.Armature('name');"),new cc.Node;n=e(n,d);return n?n.parse(a,f,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){if(!a||!c||!d)return cc.log("register parser error");b[a]||(b[a]={});b[a][c]=d};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,c){c=c||this._dirname(a);this.pretreatment(b,c);var d=this.parseNode(this.getNodeJson(b),c,a);d&&this.deferred(b,c,d,a);return d},pretreatment:function(a,b,c){},deferred:function(a,b,c,d){},parseNode:function(a,b){var c=this.parsers[this.getClass(a)],
d=null;c?d=c.call(this,a,b):cc.log("Can't find the parser : %s",this.getClass(a));return d},registerParser:function(a,b){this.parsers[a]=b}});ccs.load=function(a,b){var c={node:null,action:null};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);return c};ccs.load.validate={};ccs.load.preload=!0;
ccs.loadWithVisibleSize=function(a,b){var c=ccs.load(a,b),d=cc.director.getVisibleSize();c.node&&d&&(c.node.setContentSize(d.width,d.height),ccui.helper.doLayout(c.node));return c};ccs.actionTimelineCache={createAction:function(a){return ccs._load(a,"action")}};ccs.csLoader={createNode:function(a){return ccs._load(a)}};
cc.loader.register(["json"],{load:function(a,b,c,d){cc.loader.loadJson(a,function(a,c){var e=cc.path;if(c&&c.Content&&c.Content.Content.UsedResources){for(var f=c.Content.Content.UsedResources,k=e.dirname(b),m=[],n,p=0;p<f.length;p++)if(ccs.load.preload||!/\.(png|jpg$)/.test(f[p]))n=e.join(k,f[p]),n=e._normalize(n),ccs.load.validate[n]||(ccs.load.validate[n]=!0,m.push(n));cc.loader.load(m,function(){d(a,c)})}else d(a,c)})}});(function(a,b){var c=new (b.extend({getNodeJson:function(a){return a},parseNode:function(a,b){var c=this.parsers[this.getClass(a)],d=null;c?d=c.call(this,a,b):cc.log("Can't find the parser : %s",this.getClass(a));return d},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=!(!cc.isUndefined(b.visible)&&!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");a.addComponent(b);return 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");a.addComponent(b);return 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");a.addComponent(b);return b},CCArmature:function(a,b,c){var d=null;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)}});if(d)return c=new ccs.ComRender(d,"CCArmature"),a.addComponent(c),(a=b.selectedactionname)&&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;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!")});return 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=!!b.loop;d.setLoop(f);
var g=b.name;g&&d.setName(g);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");a.addComponent(b);return 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;d&&c.setContentSize(cc.size(d._width,d._height));return c});a.registerParser("scene","*",c)})(ccs._load,ccs._parser);(function(a,b){var c=Array(50),d=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)},parseRecursive:function(a,b){var d=1,e=null,f;for(c[0]=a;0<d;){d--;var g=c[d];c[d]=null;if(g){var h=g.classname;if(f=this.parsers[h]){h=new f.object;e||(e=h);var t=g.options;this.generalAttributes(h,t);f.handle(h,t,b);this.colorAttributes(h,t);f=g.parent;g.parent=null;if(f instanceof ccui.PageView)f.addPage(h);
else if(f instanceof ccui.ListView)f.pushBackCustomItem(h);else if(f){if(!(f instanceof ccui.Layout)){if(h.getPositionType()===ccui.Widget.POSITION_PERCENT){t=h._positionPercent;var u=f._anchorPoint;h._positionPercent.x=t.x+u.x;h._positionPercent.y=t.y+u.y}t=f._renderCmd._anchorPointInPoints;h._position.x+=t.x;h._position.y+=t.y;h.setNodeDirty()}f.addChild(h)}if((g=g.children)&&0<g.length)for(f=g.length-1;0<=f;f--)c[d]=g[f],c[d].parent=h,d++}else cc.log("Can't find the parser : %s",h)}}return e},
parse:function(a,b,c){c=c||this._dirname(a);this.pretreatment(b,c);var d=this.parseRecursive(b.widgetTree,c);d&&this.deferred(b,c,d,a);return d},deferred:function(a,b,c,d){c&&(ccs.actionManager.initWithDictionary(d,a.animation,c),c.setContentSize(a.designWidth,a.designHeight))}}));d.generalAttributes=function(a,b){a._ignoreSize=b.ignoreSize||!0;a._sizeType=b.sizeType||0;a._positionType=b.positionType||0;a._sizePercent.x=b.sizePercentX||0;a._sizePercent.y=b.sizePercentY||0;a._positionPercent.x=b.positionPercentX||
0;a._positionPercent.y=b.positionPercentY||0;if(b.adaptScreen){var c=cc.director.getWinSize();var d=c.width;c=c.height}else d=b.width||0,c=b.height||0;var e=b.anchorPointX,f=b.anchorPointY;a._anchorPoint.x=isNaN(e)?.5:e;a._anchorPoint.y=isNaN(f)?.5:f;a.setContentSize(d,c);a.setTag(b.tag);a.setActionTag(b.actiontag);a.setTouchEnabled(b.touchAble);a._name=b.name||"default";a._position.x=b.x||0;a._position.y=b.y||0;a._scaleX=b.scaleX||1;a._scaleY=b.scaleY||1;a._rotationX=a._rotationY=b.rotation||0;a._visible=
b.visible||!1;a._localZOrder=b.ZOrder||0;if(null!=b.layoutParameter){d=b.layoutParameter;c=null;switch(isNaN(d.type)?2:d.type){case 1:c=new ccui.LinearLayoutParameter;c._linearGravity=d.gravity||0;break;case 2:c=new ccui.RelativeLayoutParameter,c._relativeLayoutName=d.relativeName,c._relativeWidgetName=d.relativeToName,c._relativeAlign=d.align||0}null!=c&&(e=c._margin,e.left=d.marginLeft||0,e.top=d.marginTop||0,e.right=d.marginRight||0,e.bottom=d.marginDown||0,a.setLayoutParameter(c))}};d.colorAttributes=
function(a,b){var c=null!==b.opacity?b.opacity:255;null!=c&&a.setOpacity(c);c=b.colorR;var 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)};var e=function(a,b,c,d){c&&(0===b?d(a+c,b):d(c,b))};d.LayoutAttributes=function(a,b,c){var d=0,f=0;b.adaptScreen?(f=cc.director.getWinSize(),d=f.width,f=f.height):(d=b.width||0,f=b.height||0);a.setSize(cc.size(d,f));a.setClippingEnabled(b.clipAble);d=b.backGroundScale9Enable;a.setBackGroundImageScale9Enabled(d);
f=b.bgColorR||0;var g=b.bgColorG||0,h=b.bgColorB||0,k=isNaN(b.bgStartColorR)?255:b.bgStartColorR,u=isNaN(b.bgStartColorG)?255:b.bgStartColorG,v=isNaN(b.bgStartColorB)?255:b.bgStartColorB,x=isNaN(b.bgEndColorR)?255:b.bgEndColorR,w=isNaN(b.bgEndColorG)?255:b.bgEndColorG,y=isNaN(b.bgEndColorB)?255:b.bgEndColorB;a.setBackGroundColorVector(cc.p(b.vectorX||0,b.vectorY||0));var z=b.bgColorOpacity||0;a.setBackGroundColorType(b.colorType||0);a.setBackGroundColor(cc.color(k,u,v),cc.color(x,w,y));a.setBackGroundColor(cc.color(f,
g,h));a.setBackGroundColorOpacity(z);(f=b.backGroundImageData)&&e(c,f.resourceType||0,f.path,function(b,c){a.setBackGroundImage(b,c)});d&&(c=b.capInsetsX||0,d=b.capInsetsY||0,f=isNaN(b.capInsetsWidth)?1:b.capInsetsWidth,g=isNaN(b.capInsetsHeight)?1:b.capInsetsHeight,a.setBackGroundImageCapInsets(cc.rect(c,d,f,g)));b.layoutType&&a.setLayoutType(b.layoutType)};d.ButtonAttributes=function(a,b,c){var d=b.scale9Enable;a.setScale9Enabled(d);var f=b.normalData;e(c,f.resourceType||0,f.path,function(b,c){a.loadTextureNormal(b,
c)});f=b.pressedData;e(c,f.resourceType||0,f.path,function(b,c){a.loadTexturePressed(b,c)});f=b.disabledData;e(c,f.resourceType||0,f.path,function(b,c){a.loadTextureDisabled(b,c)});if(d){c=b.capInsetsX||0;d=b.capInsetsY||0;f=isNaN(b.capInsetsWidth)?1:b.capInsetsWidth;var g=isNaN(b.capInsetsHeight)?1:b.capInsetsHeight;a.setCapInsets(cc.rect(c,d,f,g));c=b.scale9Width||0;d=b.scale9Height||0;null!=c&&null!=d&&a.setSize(cc.size(c,d))}if(c=b.text||"")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)};d.CheckBoxAttributes=function(a,b,c){var d=b.backGroundBoxData;e(c,d.resourceType||0,d.path,function(b,c){a.loadTextureBackGround(b,c)});var f=b.backGroundBoxSelectedData;e(c,f.resourceType||d.resourceType,f.path||d.path,function(b,c){a.loadTextureBackGroundSelected(b,c)});d=b.frontCrossData;e(c,d.resourceType||0,
d.path,function(b,c){a.loadTextureFrontCross(b,c)});f=b.backGroundBoxDisabledData;e(c,f.resourceType||d.resourceType,f.path||d.path,function(b,c){a.loadTextureBackGroundDisabled(b,c)});d=b.frontCrossDisabledData;e(c,d.resourceType||0,d.path,function(b,c){a.loadTextureFrontCrossDisabled(b,c)});b.selectedState&&a.setSelected(b.selectedState)};d.ImageViewAttributes=function(a,b,c){var d=b.fileNameData;e(c,d.resourceType||0,d.path,function(b,c){a.loadTexture(b,c)});c=!1;b.scale9Enable&&(c=b.scale9Enable);
a.setScale9Enabled(c);if(c){c=b.scale9Height||0;b.scale9Width&&c&&a.setSize(cc.size(b.scale9Width||0,b.scale9Height||0));c=b.capInsetsX||0;d=b.capInsetsY||0;var f=isNaN(b.capInsetsWidth)?1:b.capInsetsWidth;b=isNaN(b.capInsetsHeight)?1:b.capInsetsHeight;a.setCapInsets(cc.rect(c,d,f,b))}};d.TextAtlasAttributes=function(a,b,c){var d=b.stringValue,e=b.charMapFileData,f=b.itemWidth,g=b.itemHeight,h=b.startCharMap;if(null!=d&&e&&null!=f&&null!=g&&null!=h)switch(b=b.charMapFileData,b.resourceType||0){case 0:a.setProperty(d,
c+b.path,f,g,h);break;case 1:cc.log("Wrong res type of LabelAtlas!")}};d.TextBMFontAttributes=function(a,b,c){var d=b.fileNameData;switch(d.resourceType||0){case 0:a.setFntFile(c+d.path);break;case 1:cc.log("Wrong res type of LabelAtlas!")}a.setString(b.text||"")};var f=/\.ttf$/;d.TextAttributes=function(a,b,c){a.setTouchScaleChangeEnabled(b.touchScaleEnable);var d=b.text||"";d&&a._setString(d);null!=b.fontSize&&a._setFontSize(b.fontSize);d=b.fontName;null!=d&&(cc.sys.isNative?f.test(d)?a.setFontName(cc.path.join(cc.loader.resPath,
c,d)):a.setFontName(d):a._setFontName(d.replace(f,"")));c=b.areaHeight||0;b.areaWidth&&c&&(c=cc.size(b.areaWidth,b.areaHeight),a._setTextAreaSize(c));c=b.hAlignment||0;null!=c&&a._setTextHorizontalAlignment(c);b=b.vAlignment||0;null!=b&&a._setTextVerticalAlignment(b);a._updateUITextContentSize()};d.ListViewAttributes=function(a,b,c){d.ScrollViewAttributes(a,b,c);a.setDirection(b.direction||1);a.setGravity(b.gravity||0);a.setItemsMargin(b.itemMargin||0)};d.LoadingBarAttributes=function(a,b,c){var d=
b.textureData;e(c,d.resourceType||0,d.path,function(b,c){a.loadTexture(b,c)});c=b.scale9Enable;a.setScale9Enabled(c);if(c){c=b.capInsetsX||0;d=b.capInsetsY||0;var f=isNaN(b.capInsetsWidth)?1:b.capInsetsWidth,g=isNaN(b.capInsetsHeight)?1:b.capInsetsHeight;a.setCapInsets(cc.rect(c,d,f,g));a.setSize(cc.size(b.width||0,b.height||0))}a.setDirection(b.direction||0);a.setPercent(b.percent||0)};d.PageViewAttributes=d.LayoutAttributes;d.ScrollViewAttributes=function(a,b,c){d.LayoutAttributes(a,b,c);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)};d.SliderAttributes=function(a,b,c){var d=b.scale9Enable;a.setScale9Enabled(d);var f=b.length,g=b.barFileNameData,h=g.resourceType||0;g=g.path;null!=b.barFileName?d&&(e(c,h,g,function(b,c){a.loadBarTexture(b,c)}),a.setSize(cc.size(f,a.getContentSize().height))):e(c,h,g,function(b,c){a.loadBarTexture(b,c)});d=b.ballNormalData;e(c,d.resourceType||0,
d.path,function(b,c){a.loadSlidBallTextureNormal(b,c)});f=b.ballPressedData;e(c,f.resourceType||d.resourceType,f.path||d.path,function(b,c){a.loadSlidBallTexturePressed(b,c)});d=b.ballDisabledData;e(c,d.resourceType||0,d.path,function(b,c){a.loadSlidBallTextureDisabled(b,c)});b=b.progressBarData;e(c,b.resourceType||0,b.path,function(b,c){a.loadProgressBarTexture(b,c)})};d.TextFieldAttributes=function(a,b,c){var d=b.placeHolder||"";d&&a.setPlaceHolder(d);a.setString(b.text||"");(d=b.fontSize)&&a.setFontSize(d);
d=b.fontName;null!=d&&(cc.sys.isNative?f.test(d)?a.setFontName(cc.path.join(cc.loader.resPath,c,d)):a.setFontName(d):a.setFontName(d.replace(f,"")));c=b.touchSizeWidth||0;d=b.touchSizeHeight||0;null!=c&&null!=d&&a.setTouchSize(c,d);c=b.maxLengthEnable;a.setMaxLengthEnabled(c);c&&a.setMaxLength(b.maxLength);c=b.passwordEnable;a.setPasswordEnabled(c);c&&a.setPasswordStyleText(b.passwordStyleText);c=b.areaWidth||0;d=b.areaHeight||0;c&&d&&(c=cc.size(c,d),a.setTextAreaSize(c));(c=b.hAlignment||0)&&a.setTextHorizontalAlignment(c);
(c=b.vAlignment||0)&&a.setTextVerticalAlignment(c);c=isNaN(b.colorR)?255:b.colorR;d=isNaN(b.colorG)?255:b.colorG;b=isNaN(b.colorB)?255:b.colorB;a.setTextColor(cc.color(c,d,b))};d.parsers={Panel:{object:ccui.Layout,handle:d.LayoutAttributes},Button:{object:ccui.Button,handle:d.ButtonAttributes},CheckBox:{object:ccui.CheckBox,handle:d.CheckBoxAttributes},ImageView:{object:ccui.ImageView,handle:d.ImageViewAttributes},LabelAtlas:{object:ccui.TextAtlas,handle:d.TextAtlasAttributes},LabelBMFont:{object:ccui.TextBMFont,
handle:d.TextBMFontAttributes},Label:{object:ccui.Text,handle:d.TextAttributes},ListView:{object:ccui.ListView,handle:d.ListViewAttributes},LoadingBar:{object:ccui.LoadingBar,handle:d.LoadingBarAttributes},PageView:{object:ccui.PageView,handle:d.PageViewAttributes},ScrollView:{object:ccui.ScrollView,handle:d.ScrollViewAttributes},Slider:{object:ccui.Slider,handle:d.SliderAttributes},TextField:{object:ccui.TextField,handle:d.TextFieldAttributes}};a.registerParser("ccui","*",d)})(ccs._load,ccs._parser);(function(a,b){var c=new (b.extend({getNodeJson:function(a){return a.action},parseNode:function(a,b,c){if(!a)return null;var d=this,e=new ccs.ActionTimeline;e.setDuration(a.duration);e.setTimeSpeed(a.speed||1);a.timelines.forEach(function(a){var c=d.parsers[a.frameType],f;c?f=c.call(d,a,b):cc.log("parser does not exist : %s",a.frameType);f&&e.addTimeline(f);"ColorFrame"===a.frameType&&e.addTimeline(d.parsers.AlphaFrame.call(d,a,b))});return e}}));[{name:"PositionFrame",handle:function(a){var b=new ccs.PositionFrame;
b.setPosition(cc.p(a.x,a.y));return b}},{name:"VisibleFrame",handle:function(a){var b=new ccs.VisibleFrame;b.setVisible(a.value);return b}},{name:"ScaleFrame",handle:function(a){var b=new ccs.ScaleFrame,c=a.y;b.setScaleX(a.x);b.setScaleY(c);return b}},{name:"RotationFrame",handle:function(a){var b=new ccs.RotationFrame;b.setRotation(a.rotation);return b}},{name:"SkewFrame",handle:function(a){var b=new ccs.SkewFrame,c=a.y;b.setSkewX(a.x);b.setSkewY(c);return b}},{name:"RotationSkewFrame",handle:function(a){var b=
new ccs.RotationSkewFrame,c=a.y;b.setSkewX(a.x);b.setSkewY(c);return b}},{name:"AnchorFrame",handle:function(a){var b=new ccs.AnchorPointFrame;b.setAnchorPoint(cc.p(a.x,a.y));return b}},{name:"InnerActionFrame",handle:function(a){var b=new ccs.InnerActionFrame,c=a.startFrame;b.setInnerActionType(a.innerActionType);b.setStartFrameIndex(c);return b}},{name:"ColorFrame",handle:function(a){var b=new ccs.ColorFrame;b.setColor(cc.color(a.red,a.green,a.blue));(new ccs.AlphaFrame).setAlpha(a.alpha);return b}},
{name:"AlphaFrame",handle:function(a){var b=new ccs.AlphaFrame;b.setAlpha(a.alpha);return 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;null!=a&&b.setEvent(a);return b}},{name:"ZOrderFrame",handle:function(a){var b=new ccs.ZOrderFrame;b.setZOrder(a.value);return b}}].forEach(function(a){c.registerParser(a.name,
function(b,c){var d=new ccs.Timeline;d.setActionTag(b.actionTag);var e=b.frames;e&&e.length&&e.forEach(function(b){var c=a.handle(b);c.setFrameIndex(b.frameIndex);c.setTween(b.tween);d.addFrame(c)});return d})});a.registerParser("action","0.*",c);a.registerParser("action","1.*",c)})(ccs._load,ccs._parser);(function(a,b){var c=new (b.extend({getNodeJson:function(a){return a.Content.Content.Animation},parseNode:function(a,b,c){if(!a)return null;var d=this,e=new ccs.ActionTimeline;e.setDuration(a.Duration);e.setTimeSpeed(a.Speed||1);a.Timelines.forEach(function(a){var c=d.parsers[a.Property],f;c?f=c.call(d,a,b):cc.log("parser does not exist : %s",a.Property);f&&e.addTimeline(f)});return e},deferred:function(a,b,c,d){b=(a=a.Content.Content.AnimationList)?a.length:0;for(d=0;d<b;d++){var e=a[d],f={name:null,
startIndex:null,endIndex:null};f.name=e.Name;f.startIndex=e.StartIndex;f.endIndex=e.EndIndex;c.addAnimationInfo(f)}}})),d=function(a,b){a.setTweenType(b.Type);var c=b.Points,d=[];c&&(c.forEach(function(a){d.push(a.X);d.push(a.Y)}),a.setEasingParams(d))};[{name:"Position",handle:function(a){var b=new ccs.PositionFrame;b.setPosition(cc.p(a.X,a.Y));return b}},{name:"VisibleForFrame",handle:function(a){var b=new ccs.VisibleFrame;b.setVisible(a.Value);return b}},{name:"Scale",handle:function(a){var b=
new ccs.ScaleFrame,c=a.Y;b.setScaleX(a.X);b.setScaleY(c);return b}},{name:"Rotation",handle:function(a){var b=new ccs.RotationFrame;b.setRotation(a.Rotation||a.Value||0);return b}},{name:"Skew",handle:function(a){var b=new ccs.SkewFrame,c=a.Y;b.setSkewX(a.X);b.setSkewY(c);return b}},{name:"RotationSkew",handle:function(a){var b=new ccs.RotationSkewFrame,c=a.Y;b.setSkewX(a.X);b.setSkewY(c);return b}},{name:"Anchor",handle:function(a){var b=new ccs.AnchorPointFrame;b.setAnchorPoint(cc.p(a.X,a.Y));return b}},
{name:"AnchorPoint",handle:function(a){var b=new ccs.AnchorPointFrame;b.setAnchorPoint(cc.p(a.X,a.Y));return b}},{name:"InnerAction",handle:function(a){var b=new ccs.InnerActionFrame,c=a.StartFrame;b.setInnerActionType(a.InnerActionType);b.setStartFrameIndex(c);return b}},{name:"CColor",handle:function(a){var b=new ccs.ColorFrame;(a=a.Color)||(a={});a.R=void 0===a.R?255:a.R;a.G=void 0===a.G?255:a.G;a.B=void 0===a.B?255:a.B;b.setColor(cc.color(a.R,a.G,a.B));return b}},{name:"Alpha",handle:function(a){var b=
new ccs.AlphaFrame;b.setAlpha(a.Value);return b}},{name:"FileData",handle:function(a,b){var c=new ccs.TextureFrame;var d=a.TextureFile;if(null!=d){var e=d.Plist;d=d.Path;var f=cc.spriteFrameCache.getSpriteFrame(d);!f&&e&&(cc.loader.getRes(b+e)?(cc.spriteFrameCache.addSpriteFrames(b+e),f=cc.spriteFrameCache.getSpriteFrame(d)):cc.log("%s need to be preloaded",b+e));null==f&&(d=b+d);c.setTextureName(d)}return c}},{name:"FrameEvent",handle:function(a){var b=new ccs.EventFrame;a=a.Value;null!=a&&b.setEvent(a);
return b}},{name:"ZOrder",handle:function(a){var b=new ccs.ZOrderFrame;b.setZOrder(a.Value);return b}},{name:"ActionValue",handle:function(a){var b=new ccs.InnerActionFrame,c=a.InnerActionType,d=a.CurrentAniamtionName,e=a.SingleFrameIndex;a=a.FrameIndex;void 0!==a&&b.setFrameIndex(a);b.setInnerActionType(ccs.InnerActionType[c]);b.setSingleFrameIndex(e);b.setEnterWithName(!0);d&&b.setAnimationName(d);return b}},{name:"BlendFunc",handle:function(a){var b=new ccs.BlendFuncFrame;(a=a.BlendFunc)&&void 0!==
a.Src&&void 0!==a.Dst&&b.setBlendFunc(new cc.BlendFunc(a.Src,a.Dst));return b}}].forEach(function(a){c.registerParser(a.name,function(b,c){var e=new ccs.Timeline;e.setActionTag(b.ActionTag);var f=b.Frames;f&&f.length&&f.forEach(function(b){var f=a.handle(b,c);f.setFrameIndex(b.FrameIndex);f.setTween(null!=b.Tween?b.Tween:!0);(b=b.EasingData)&&d(f,b);e.addFrame(f)});return e})});a.registerParser("action","2.*",c);a.registerParser("action","*",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 f=d+a[e];cc.loader.getRes(f)||c[f]?c[f]=!0:cc.log("%s need to be preloaded",f);cc.spriteFrameCache.addSpriteFrames(f,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,f=null!=
b.y?b.y:0,g=null!=b.scaleX?b.scaleX:1,r=null!=b.scaleY?b.scaleY:1,t=null!=b.rotation?b.rotation:0,u=null!=b.rotationSkewX?b.rotationSkewX:0,v=null!=b.rotationSkewY?b.rotationSkewY:0,x=null!=b.skewX?b.skewX:0,w=null!=b.skewY?b.skewY:0,y=null!=b.anchorPointX?b.anchorPointX:.5,z=null!=b.anchorPointY?b.anchorPointY:.5,A=null!=b.opacity?b.opacity:255,B=null!=b.colorR?b.colorR:255,C=null!=b.colorG?b.colorG:255,D=null!=b.colorB?b.colorB:255,E=null!=b.colorR?b.colorR:0,J=null!=b.tag?b.tag:0,I=null!=b.actionTag?
b.actionTag:0,G=null!=b.visible?b.visible:!0;0==e&&0==f||a.setPosition(cc.p(e,f));1!=g&&a.setScaleX(g);1!=r&&a.setScaleY(r);0!=t&&a.setRotation(t);0!=u&&a.setRotationX(u);0!=v&&a.setRotationY(v);0!=x&&a.setSkewX(x);0!=w&&a.setSkewY(w);.5==y&&.5==z||a.setAnchorPoint(cc.p(y,z));0==c&&0==d||a.setContentSize(cc.size(c,d));0!=E&&a.setLocalZOrder(E);1!=G&&a.setVisible(G);255!=A&&a.setOpacity(A);255==B&&255==C&&255==D||a.setColor(cc.color(B,C,D));a.setTag(J);a.setUserObject(new ccs.ActionTimelineData(I))};
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 f=e.getPositionPercent(),
g=b.getAnchorPoint();e.setPositionPercent(cc.p(f.x+g.x,f.y+g.y))}f=b.getAnchorPointInPoints();e.setPosition(cc.p(e.getPositionX()+f.x,e.getPositionY()+f.y))}b.addChild(e)}}};d.initNode=function(a){var b=new cc.Node;this.generalAttributes(b,a);return b};d.initSubGraph=function(a){var b=a.fileName;b=b&&""!==b?this.createNode(b):new ccs.Node;this.generalAttributes(b,a);return b};d.initSprite=function(a,b){var c=a.fileName;if(null!=c){var d=cc.spriteFrameCache.getSpriteFrame(c);c=d?ccs.Sprite.createWithSpriteFrame(d):
new ccs.Sprite(b+c);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;var e=a.flipY;0!=d&&c.setFlippedX(d);0!=e&&c.setFlippedY(e);return c};d.initParticle=function(a,b){var c=a.tmxFile,d=new cc.ParticleSystemQuad(a.plistFile);d.setTotalParticles(c);this.generalAttributes(d,a);return d};d.initTMXTiledMap=function(a,b){var c=a.tmxFile,d=a.tmxString,e=a.resourcePath,f=null;c&&""!==c?f=new cc.TMXTiledMap(c):d&&
""!==d&&e&&""!==e&&(f=new cc.TMXTiledMap(d,e));return f};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)){d=a.rotationSkewX;var f=a.rotationSkewY,g=a.skewX,p=a.skewY;0!=d&&c.setRotationX(d);0!=f&&c.setRotationY(f);0!=g&&c.setSkewX(g);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);this.parseComponent(e,b.components);this.parseChild(c,e,b,d);return e})});a.registerParser("timeline","0.*",d);a.registerParser("timeline","1.*",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);this.deferred(b,c,d,a);return d},getNodeJson:function(a){a=a.Content;return a.ObjectData?a.ObjectData:a.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),.5==c.ScaleX&&.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);(c=b.Size)&&r(a,c);null!=b.Alpha&&a.setOpacity(b.Alpha);
a.setTag(b.Tag||0);c=b.ActionTag||0;var e=new ccs.ComExtensionData,g=b.UserData;void 0!==g&&e.setCustomProperty(g);e.setActionTag(c);a.getComponent("ComExtensionData")&&a.removeComponent("ComExtensionData");a.addComponent(e);a.setCascadeColorEnabled(!0);a.setCascadeOpacityEnabled(!0);f(a,b)};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;this.generalAttributes(b,a);a=a.CColor;null!=a&&b.setColor(p(a));return b};c.initSprite=function(a,b){var c=new cc.Sprite;n(a.FileData,b,function(a,b){if(0===b)c.setTexture(a);else if(1===b){var d=
cc.spriteFrameCache.getSpriteFrame(a);d&&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;null!=d&&c.setColor(p(d));return c};c.initParticle=function(a,b){var c,d=this;n(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)}});return c};c.widgetAttributes=function(a,b,c){a.setCascadeColorEnabled(!0);a.setCascadeOpacityEnabled(!0);a.setUnifySizeEnabled(!1);a.ignoreContentAdaptWithSize(!1);!c&&r(a,b.Size);(c=b.Name)&&a.setName(c);c=b.ActionTag||0;a.setActionTag(c);
var g=new ccs.ComExtensionData,h=b.UserData;void 0!==h&&g.setCustomProperty(h);g.setActionTag(c);a.getComponent("ComExtensionData")&&a.removeComponent("ComExtensionData");a.addComponent(g);(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);g=b.Scale;null!=g&&(c=d(g.ScaleX,1),g=d(g.ScaleY,1),a.setScaleX(c),a.setScaleY(g));c=b.AnchorPoint;null!=c&&a.setAnchorPoint(c.ScaleX||0,c.ScaleY||0);c=b.CColor;null!=c&&a.setColor(p(c));f(a,b);e(a,b)};var e=function(a,b){var c=b.CallBackType,d=b.CallBackName,e=function(b){if("function"===typeof a[d])a[d](b)};"Click"===c?a.addClickEventListener(e):"Touch"===c?a.addTouchEventListener(e):
"Event"===c&&a.addCCSEventListener(e)},f=function(a,b){var c=ccui.LayoutComponent.bindLayoutComponent(a);if(c){var d=b.PositionPercentXEnable||b.PositionPercentXEnabled||!1,e=b.PositionPercentYEnable||b.PositionPercentYEnabled||!1,f=0,g=0,h=b.PrePosition;null!=h&&(f=h.X||0,g=h.Y||0);var k=b.PercentWidthEnable||b.PercentWidthEnabled||!1,m=b.PercentHeightEnable||b.PercentHeightEnabled||!1,n=0,p=0,t=b.PreSize;null!=h&&(n=t.X||0,p=t.Y||0);var r=b.StretchWidthEnable||!1,u=b.StretchHeightEnable||!1,H=b.HorizontalEdge;
h=b.VerticalEdge;t=b.LeftMargin||0;var F=b.RightMargin||0,K=b.TopMargin||0,L=b.BottomMargin||0;c.setPositionPercentXEnabled(d);c.setPositionPercentYEnabled(e);c.setPositionPercentX(f);c.setPositionPercentY(g);c.setPercentWidthEnabled(k);c.setPercentHeightEnabled(m);c.setPercentWidth(n);c.setPercentHeight(p);c.setPercentWidthEnabled(k||m);c.setStretchWidthEnabled(r);c.setStretchHeightEnabled(u);d=ccui.LayoutComponent.horizontalEdge.NONE;"LeftEdge"===H?d=ccui.LayoutComponent.horizontalEdge.LEFT:"RightEdge"===
H?d=ccui.LayoutComponent.horizontalEdge.RIGHT:"BothEdge"===H&&(d=ccui.LayoutComponent.horizontalEdge.CENTER);c.setHorizontalEdge(d);d=ccui.LayoutComponent.verticalEdge.NONE;"TopEdge"===h?d=ccui.LayoutComponent.verticalEdge.TOP:"BottomEdge"===h?d=ccui.LayoutComponent.verticalEdge.BOTTOM:"BothEdge"===h&&(d=ccui.LayoutComponent.verticalEdge.CENTER);c.setVerticalEdge(d);c.setTopMargin(K);c.setBottomMargin(L);c.setLeftMargin(t);c.setRightMargin(F);c.setVerticalEdge(d);c.setTopMargin(K);c.setBottomMargin(L);
c.setLeftMargin(t);c.setRightMargin(F)}},g=function(a,b,c,d){2===a.getBackGroundColorType()?(c=c||{},d=d||{},a.setBackGroundColor(p(c),p(d))):(b=b||{},a.setBackGroundColor(p(b)))},h=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 e=a.ClipAble||!1;null!=e&&c.setClippingEnabled(e);e=d(a.ComboBoxIndex,0);c.setBackGroundColorType(e);e=d(a.BackColorAlpha,255);null!=e&&c.setBackGroundColorOpacity(e);
e=a.Scale9Enable;null!=e&&c.setBackGroundImageScale9Enabled(e);var f=d(a.Alpha,255);c.setOpacity(f);n(a.FileData,b,function(a,b){c.setBackGroundImage(a,b)});e?(c.setBackGroundImageCapInsets(cc.rect(a.Scale9OriginX||0,a.Scale9OriginY||0,a.Scale9Width||0,a.Scale9Height||0)),r(c,a.Size)):c.isIgnoreContentAdaptWithSize()||r(c,a.Size);g(c,a.SingleColor,a.FirstColor,a.EndColor);h(c,a.ColorVector);return 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);e=a.AreaWidth;var f=a.areaHeight;e&&f&&c.setTextAreaSize(cc.size(e,f));e=a.HorizontalAlignmentType||"HT_Left";switch(e){case "HT_Right":e=2;break;case "HT_Center":e=1;break;default:e=0}c.setTextHorizontalAlignment(e);e=a.VerticalAlignmentType||"VT_Top";switch(e){case "VT_Bottom":e=2;break;case "VT_Center":e=1;break;default:e=0}c.setTextVerticalAlignment(e);e=a.FontResource;null!=e&&
(e=e.Path,null!=e&&(e=cc.sys.isNative?cc.path.join(cc.loader.resPath,b,e):(e=e.match(/([^\/]+)\.(\S+)/))?e[1]:"",c.setFontName(e)));a.OutlineEnabled&&a.OutlineColor&&c.enableOutline&&c.enableOutline(p(a.OutlineColor),d(a.OutlineSize,1));a.ShadowEnabled&&a.ShadowColor&&c.enableShadow&&c.enableShadow(p(a.ShadowColor),cc.size(d(a.ShadowOffsetX,2),d(a.ShadowOffsetY,-2)),a.ShadowBlurRadius||0);e=a.IsCustomSize;null!=e&&c.ignoreContentAdaptWithSize(!e);c.setUnifySizeEnabled(!1);e=a.CColor;a.CColor=null;
c.setTextColor(p(e));this.widgetAttributes(c,a,c.isIgnoreContentAdaptWithSize());a.CColor=e;return c};c.initButton=function(a,b){var c=new ccui.Button;n(a.NormalFileData,b,function(a,b){c.loadTextureNormal(a,b)});n(a.PressedFileData,b,function(a,b){c.loadTexturePressed(a,b)});n(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);f=a.TextColor;null!=f&&c.setTitleColor(p(f));f=d(a.DisplayState,!0);c.setBright(f);c.setEnabled(f);f=a.FontResource;null!=f&&(f=f.Path,null!=f&&(f=cc.sys.isNative?cc.path.join(cc.loader.resPath,b,f):(f=f.match(/([^\/]+)\.(\S+)/))?f[1]:"",c.setTitleFontName(f)));(f=c.getTitleRenderer())&&a.ShadowEnabled&&a.ShadowColor&&f.enableShadow&&f.enableShadow(p(a.ShadowColor),cc.size(d(a.ShadowOffsetX,2),d(a.ShadowOffsetY,-2)),a.ShadowBlurRadius||0);f&&a.OutlineEnabled&&a.OutlineColor&&
f.enableStroke&&f.enableStroke(p(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));r(c,a.Size);return 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){n(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);c.setBright(e);c.setEnabled(e);return c};c.initScrollView=function(a,b){var c=new ccui.ScrollView;this.widgetAttributes(c,a);n(a.FileData,b,function(a,b){c.setBackGroundImage(a,b)});c.setClippingEnabled(a.ClipAble||
!1);var e=d(a.ComboBoxIndex,0);c.setBackGroundColorType(e);e=a.BackColorAlpha;null!=e&&c.setBackGroundColorOpacity(e);a.Scale9Enable?(c.setBackGroundImageScale9Enabled(!0),c.setBackGroundImageCapInsets(cc.rect(a.Scale9OriginX||0,a.Scale9OriginY||0,a.Scale9Width||0,a.Scale9Height||0)),r(c,a.Size)):c.isIgnoreContentAdaptWithSize()||r(c,a.Size);g(c,a.SingleColor,a.FirstColor,a.EndColor);h(c,a.ColorVector);e=a.InnerNodeSize;e=cc.size(e.Width||0,e.Height||0);c.setInnerContainerSize(e);e=0;"Vertical"===
a.ScrollDirectionType&&(e=1);"Horizontal"===a.ScrollDirectionType&&(e=2);"Vertical_Horizontal"===a.ScrollDirectionType&&(e=3);c.setDirection(e);e=d(a.IsBounceEnabled,!1);c.setBounceEnabled(e);return c};c.initImageView=function(a,b){var c=new ccui.ImageView;n(a.FileData,b,function(a,b){c.loadTexture(a,b)});n(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))):r(c,a.Size);this.widgetAttributes(c,a);return c};c.initLoadingBar=function(a,b){var c=new ccui.LoadingBar;this.widgetAttributes(c,a);n(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);null!=e&&c.setPercent(e);return 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){n(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);c.setBright(f);c.setEnabled(f);return c};c.initPageView=function(a,b){var c=new ccui.PageView;this.widgetAttributes(c,
a);n(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 e=d(a.ComboBoxIndex,0);c.setBackGroundColorType(e);g(c,a.SingleColor,a.FirstColor,a.EndColor);h(c,a.ColorVector);e=a.BackColorAlpha;null!=e&&c.setBackGroundColorOpacity(e);r(c,a.Size);return c};c.initListView=function(a,b){var c=new ccui.ListView;
this.widgetAttributes(c,a);n(a.FileData,b,function(a,b){c.setBackGroundImage(a,b)});c.setClippingEnabled(a.ClipAble||!1);var e=d(a.ComboBoxIndex,0);c.setBackGroundColorType(e);e=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 f=d(a.DirectionType,ccui.ListView.DIR_HORIZONTAL),k=d(a.VerticalType,"Align_Left"),m=d(a.HorizontalType,"Align_Top");f?"Vertical"===
f&&(c.setDirection(ccui.ScrollView.DIR_VERTICAL),""===m?c.setGravity(ccui.ListView.GRAVITY_LEFT):"Align_Right"===m?c.setGravity(ccui.ListView.GRAVITY_RIGHT):"Align_HorizontalCenter"===m&&c.setGravity(ccui.ListView.GRAVITY_CENTER_HORIZONTAL)):(c.setDirection(ccui.ScrollView.DIR_HORIZONTAL),"Align_Bottom"===k?c.setGravity(ccui.ListView.GRAVITY_BOTTOM):"Align_VerticalCenter"===k?c.setGravity(ccui.ListView.GRAVITY_CENTER_VERTICAL):c.setGravity(ccui.ListView.GRAVITY_TOP));f=d(a.IsBounceEnabled,!1);c.setBounceEnabled(f);
c.setItemsMargin(a.ItemMargin||0);f=a.InnerNodeSize;null!=f&&c.setInnerContainerSize(cc.size(f.Widget||0,f.Height||0));g(c,a.SingleColor,a.FirstColor,a.EndColor);h(c,a.ColorVector);null!=e&&c.setBackGroundColorOpacity(e);r(c,a.Size);return c};c.initTextAtlas=function(a,b){var c=new ccui.TextAtlas,d=a.LabelText,e=a.CharWidth,f=a.CharHeight,g=a.StartChar;n(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.ignoreContentAdaptWithSize(!0);return c};c.initTextBMFont=function(a,b){var c=new ccui.TextBMFont;this.widgetAttributes(c,a);n(a.LabelBMFontFile_CNB,b,function(a,b){cc.loader.getRes(a)||cc.log("%s need to be pre loaded",a);c.setFntFile(a)});c.setString(a.LabelText);c.ignoreContentAdaptWithSize(!0);return 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);d=a.LabelText;null!=d&&c.setString(d);d=a.FontResource;null!=d&&(d=d.Path,null!=d&&(d=cc.sys.isNative?cc.path.join(cc.loader.resPath,b,d):(d=d.match(/([^\/]+)\.(\S+)/))?d[1]:"",c.setFontName(d)));c.setUnifySizeEnabled(!1);c.ignoreContentAdaptWithSize(!1);d=a.CColor;null!=d&&c.setTextColor(p(d));c.isIgnoreContentAdaptWithSize()||
(r(c,a.Size),cc.sys.isNative&&c.getVirtualRenderer().setLineBreakWithoutSpace(!0));return c};c.initSimpleAudio=function(a,b){var c=new ccs.ComAudio;c.setLoop(a.Loop||!1);n(a.FileData,b,function(a,b){c.setFile(a)})};c.initGameMap=function(a,b){var d=null;n(a.FileData,b,function(b,e){0===e&&(d=new cc.TMXTiledMap(b));c.generalAttributes(d,a)});return 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);c.generalAttributes(d.node,a);
if(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 k=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,g=a.CurrentAnimationName;n(a.FileData,b,function(a,b){var c=cc.loader.getRes(a);if(c){var h=c.config_file_path;var m=c.config_png_path;
h.forEach(function(a,b){m[b]&&cc.spriteFrameCache.addSpriteFrames(a,m[b])})}else cc.log("%s need to be preloaded",a);ccs.armatureDataManager.addArmatureFileInfo(a);d.init(k(a));f?d.getAnimation().play(g,-1,e):(d.getAnimation().play(g),d.getAnimation().gotoAndPause(0))});delete a.AnchorPoint;delete a.Size;c.generalAttributes(d,a);d.setColor(p(a.CColor));return d};c.initBoneNode=function(a,b){var d=new ccs.BoneNode,e=a.Length;void 0!==e&&d.setDebugDrawLength(e);(e=a.BlendFunc)&&void 0!==e.Src&&void 0!==
e.Dst&&d.setBlendFunc(new cc.BlendFunc(e.Src,e.Dst));c.generalAttributes(d,a);e=a.CColor;!e||void 0===e.R&&void 0===e.G&&void 0===e.B||d.setColor(p(e));return d};c.initSkeletonNode=function(a){var b=new ccs.SkeletonNode;c.generalAttributes(b,a);a=a.CColor;!a||void 0===a.R&&void 0===a.G&&void 0===a.B||b.setColor(p(a));return b};var m={},n=function(a,b,c){if(null!=a){var d=a.Path;var e="Default"===a.Type||"Normal"===a.Type?0:1;if(a=a.Plist)cc.loader.getRes(b+a)?(m[b+a]=!0,cc.spriteFrameCache.addSpriteFrames(b+
a)):m[b+a]||cc.spriteFrameCache.getSpriteFrame(d)||cc.log("%s need to be preloaded",b+a);0!==e?cc.spriteFrameCache.getSpriteFrame(d)?c(d,e):cc.log("failed to get spriteFrame: %s",d):c(b+d,e)}},p=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)},r=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:"GameNodeObjectData",handle:c.initSingleNode},{name:"GameLayerObjectData",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},{name:"BoneNodeObjectData",handle:c.initBoneNode},{name:"SkeletonNodeObjectData",handle:c.initSkeletonNode}].forEach(function(a){c.registerParser(a.name,function(b,c){var d=a.handle.call(this,b,c);this.parseChild(d,b.Children,c);return d})});a.registerParser("timeline","2.*",c);a.registerParser("timeline","*",c)})(ccs._load,ccs._parser);(function(){ccs.uiReader={_fileDesignSizes:{},widgetFromJsonFile:function(a){var b=cc.loader.getRes(a);b&&(this._fileDesignSizes[a]=cc.size(b.designWidth||0,b.designHeight||0));b=b.Version||b.version;var d=ccs.uiReader.getVersionInteger(b);return!b||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 b=ccs._load.getParser("ccui")["*"],g=e.bind(d);b.registerParser(a,function(b,e){var f=new c,h=b.options;
d.setPropsFromJsonDictionary&&d.setPropsFromJsonDictionary(f,h);this.generalAttributes(f,h);var k=h.customProperty;k=k?JSON.parse(k):{};g(a,f,k);this.colorAttributes(f,h);this.anchorPointAttributes(f,h);this.parseChild.call(this,f,b,e);return f})},getVersionInteger:function(a){if(!a||"string"!==typeof a)return 0;a=a.split(".");if(4!==a.length)return 0;var b=0;a.forEach(function(a,c){b+=a*Math.pow(10,3-c)});return b},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){return this._node=a=ccs._load(a,"scene")},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()}}})();var __extends=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)},spine;
(function(a){var b=function(){function a(a,b,c){if(null==a)throw Error("name cannot be null.");if(null==b)throw Error("timelines cannot be null.");this.name=a;this.timelines=b;this.duration=c}a.prototype.apply=function(a,b,c,d,e,f,g,u){if(null==a)throw Error("skeleton cannot be null.");d&&0!=this.duration&&(c%=this.duration,0<b&&(b%=this.duration));d=this.timelines;for(var h=0,k=d.length;h<k;h++)d[h].apply(a,b,c,e,f,g,u)};a.binarySearch=function(a,b,c){void 0===c&&(c=1);var d=0,e=a.length/c-2;if(0==
e)return c;for(var f=e>>>1;;){a[(f+1)*c]<=b?d=f+1:e=f;if(d==e)return(d+1)*c;f=d+e>>>1}};a.linearSearch=function(a,b,c){for(var d=0,e=a.length-c;d<=e;d+=c)if(a[d]>b)return d;return-1};return a}();a.Animation=b;(function(a){a[a.rotate=0]="rotate";a[a.translate=1]="translate";a[a.scale=2]="scale";a[a.shear=3]="shear";a[a.attachment=4]="attachment";a[a.color=5]="color";a[a.deform=6]="deform";a[a.event=7]="event";a[a.drawOrder=8]="drawOrder";a[a.ikConstraint=9]="ikConstraint";a[a.transformConstraint=10]=
"transformConstraint";a[a.pathConstraintPosition=11]="pathConstraintPosition";a[a.pathConstraintSpacing=12]="pathConstraintSpacing";a[a.pathConstraintMix=13]="pathConstraintMix"})(a.TimelineType||(a.TimelineType={}));var c=a.TimelineType,d=function(){function b(c){if(0>=c)throw Error("frameCount must be > 0: "+c);this.curves=a.Utils.newFloatArray((c-1)*b.BEZIER_SIZE)}b.prototype.getFrameCount=function(){return this.curves.length/b.BEZIER_SIZE+1};b.prototype.setLinear=function(a){this.curves[a*b.BEZIER_SIZE]=
b.LINEAR};b.prototype.setStepped=function(a){this.curves[a*b.BEZIER_SIZE]=b.STEPPED};b.prototype.getCurveType=function(a){a*=b.BEZIER_SIZE;if(a==this.curves.length)return b.LINEAR;a=this.curves[a];return a==b.LINEAR?b.LINEAR:a==b.STEPPED?b.STEPPED:b.BEZIER};b.prototype.setCurve=function(a,c,d,e,f){var g=.03*(2*-c+e),h=.03*(2*-d+f);e=.006*(3*(c-e)+1);f=.006*(3*(d-f)+1);var k=2*g+e,m=2*h+f;c=.3*c+g+.16666667*e;d=.3*d+h+.16666667*f;a*=b.BEZIER_SIZE;h=this.curves;h[a++]=b.BEZIER;g=c;for(var n=d,p=a+b.BEZIER_SIZE-
1;a<p;a+=2)h[a]=g,h[a+1]=n,c+=k,d+=m,k+=e,m+=f,g+=c,n+=d};b.prototype.getCurvePercent=function(c,d){d=a.MathUtils.clamp(d,0,1);var e=this.curves,f=c*b.BEZIER_SIZE,g=e[f];if(g==b.LINEAR)return d;if(g==b.STEPPED)return 0;f++;g=0;for(var h=f,k=f+b.BEZIER_SIZE-1;f<k;f+=2)if(g=e[f],g>=d)return f==h?k=h=0:(h=e[f-2],k=e[f-1]),k+(e[f+1]-k)*(d-h)/(g-h);e=e[f-1];return e+(1-e)*(d-g)/(1-g)};b.LINEAR=0;b.STEPPED=1;b.BEZIER=2;b.BEZIER_SIZE=19;return b}();a.CurveTimeline=d;var e=function(d){function e(b){d.call(this,
b);this.frames=a.Utils.newFloatArray(b<<1)}__extends(e,d);e.prototype.getPropertyId=function(){return(c.rotate<<24)+this.boneIndex};e.prototype.setFrame=function(a,b,c){a<<=1;this.frames[a]=b;this.frames[a+e.ROTATION]=c};e.prototype.apply=function(a,c,d,f,g,h,u){c=this.frames;a=a.bones[this.boneIndex];if(d<c[0])h&&(a.rotation=a.data.rotation);else if(d>=c[c.length-e.ENTRIES])h?a.rotation=a.data.rotation+c[c.length+e.PREV_ROTATION]*g:(h=a.data.rotation+c[c.length+e.PREV_ROTATION]-a.rotation,a.rotation+=
(h-360*(16384-(16384.499999999996-h/360|0)))*g);else{u=b.binarySearch(c,d,e.ENTRIES);f=c[u+e.PREV_ROTATION];var k=c[u];d=this.getCurvePercent((u>>1)-1,1-(d-k)/(c[u+e.PREV_TIME]-k));c=c[u+e.ROTATION]-f;c=f+(c-360*(16384-(16384.499999999996-c/360|0)))*d;h?a.rotation=a.data.rotation+(c-360*(16384-(16384.499999999996-c/360|0)))*g:(c=a.data.rotation+c-a.rotation,a.rotation+=(c-360*(16384-(16384.499999999996-c/360|0)))*g)}};e.ENTRIES=2;e.PREV_TIME=-2;e.PREV_ROTATION=-1;e.ROTATION=1;return e}(d);a.RotateTimeline=
e;e=function(d){function e(b){d.call(this,b);this.frames=a.Utils.newFloatArray(b*e.ENTRIES)}__extends(e,d);e.prototype.getPropertyId=function(){return(c.translate<<24)+this.boneIndex};e.prototype.setFrame=function(a,b,c,d){a*=e.ENTRIES;this.frames[a]=b;this.frames[a+e.X]=c;this.frames[a+e.Y]=d};e.prototype.apply=function(a,c,d,f,g,h,u){c=this.frames;a=a.bones[this.boneIndex];if(d<c[0])h&&(a.x=a.data.x,a.y=a.data.y);else{if(d>=c[c.length-e.ENTRIES])f=c[c.length+e.PREV_X],u=c[c.length+e.PREV_Y];else{var k=
b.binarySearch(c,d,e.ENTRIES);f=c[k+e.PREV_X];u=c[k+e.PREV_Y];var m=c[k];d=this.getCurvePercent(k/e.ENTRIES-1,1-(d-m)/(c[k+e.PREV_TIME]-m));f+=(c[k+e.X]-f)*d;u+=(c[k+e.Y]-u)*d}h?(a.x=a.data.x+f*g,a.y=a.data.y+u*g):(a.x+=(a.data.x+f-a.x)*g,a.y+=(a.data.y+u-a.y)*g)}};e.ENTRIES=3;e.PREV_TIME=-3;e.PREV_X=-2;e.PREV_Y=-1;e.X=1;e.Y=2;return e}(d);a.TranslateTimeline=e;var f=function(d){function e(a){d.call(this,a)}__extends(e,d);e.prototype.getPropertyId=function(){return(c.scale<<24)+this.boneIndex};e.prototype.apply=
function(c,d,f,g,h,t,u){var k=this.frames;c=c.bones[this.boneIndex];if(f<k[0])t&&(c.scaleX=c.data.scaleX,c.scaleY=c.data.scaleY);else{if(f>=k[k.length-e.ENTRIES])d=k[k.length+e.PREV_X]*c.data.scaleX,g=k[k.length+e.PREV_Y]*c.data.scaleY;else{var m=b.binarySearch(k,f,e.ENTRIES);d=k[m+e.PREV_X];g=k[m+e.PREV_Y];var n=k[m];f=this.getCurvePercent(m/e.ENTRIES-1,1-(f-n)/(k[m+e.PREV_TIME]-n));d=(d+(k[m+e.X]-d)*f)*c.data.scaleX;g=(g+(k[m+e.Y]-g)*f)*c.data.scaleY}1==h?(c.scaleX=d,c.scaleY=g):(t?(t=c.data.scaleX,
f=c.data.scaleY):(t=c.scaleX,f=c.scaleY),u?(d=Math.abs(d)*a.MathUtils.signum(t),g=Math.abs(g)*a.MathUtils.signum(f)):(t=Math.abs(t)*a.MathUtils.signum(d),f=Math.abs(f)*a.MathUtils.signum(g)),c.scaleX=t+(d-t)*h,c.scaleY=f+(g-f)*h)}};return e}(e);a.ScaleTimeline=f;e=function(a){function d(b){a.call(this,b)}__extends(d,a);d.prototype.getPropertyId=function(){return(c.shear<<24)+this.boneIndex};d.prototype.apply=function(a,c,e,f,g,h,u){c=this.frames;a=a.bones[this.boneIndex];if(e<c[0])h&&(a.shearX=a.data.shearX,
a.shearY=a.data.shearY);else{if(e>=c[c.length-d.ENTRIES])f=c[c.length+d.PREV_X],u=c[c.length+d.PREV_Y];else{var k=b.binarySearch(c,e,d.ENTRIES);f=c[k+d.PREV_X];u=c[k+d.PREV_Y];var m=c[k];e=this.getCurvePercent(k/d.ENTRIES-1,1-(e-m)/(c[k+d.PREV_TIME]-m));f+=(c[k+d.X]-f)*e;u+=(c[k+d.Y]-u)*e}h?(a.shearX=a.data.shearX+f*g,a.shearY=a.data.shearY+u*g):(a.shearX+=(a.data.shearX+f-a.shearX)*g,a.shearY+=(a.data.shearY+u-a.shearY)*g)}};return d}(e);a.ShearTimeline=e;e=function(d){function e(b){d.call(this,
b);this.frames=a.Utils.newFloatArray(b*e.ENTRIES)}__extends(e,d);e.prototype.getPropertyId=function(){return(c.color<<24)+this.slotIndex};e.prototype.setFrame=function(a,b,c,d,f,g){a*=e.ENTRIES;this.frames[a]=b;this.frames[a+e.R]=c;this.frames[a+e.G]=d;this.frames[a+e.B]=f;this.frames[a+e.A]=g};e.prototype.apply=function(a,c,d,f,g,h,u){a=a.slots[this.slotIndex];var k=this.frames;if(d<k[0])h&&a.color.setFromColor(a.data.color);else{if(d>=k[k.length-e.ENTRIES]){d=k.length;c=k[d+e.PREV_R];f=k[d+e.PREV_G];
u=k[d+e.PREV_B];var m=k[d+e.PREV_A]}else{var n=b.binarySearch(k,d,e.ENTRIES);c=k[n+e.PREV_R];f=k[n+e.PREV_G];u=k[n+e.PREV_B];m=k[n+e.PREV_A];var p=k[n];d=this.getCurvePercent(n/e.ENTRIES-1,1-(d-p)/(k[n+e.PREV_TIME]-p));c+=(k[n+e.R]-c)*d;f+=(k[n+e.G]-f)*d;u+=(k[n+e.B]-u)*d;m+=(k[n+e.A]-m)*d}1==g?a.color.set(c,f,u,m):(d=a.color,h&&d.setFromColor(a.data.color),d.add((c-d.r)*g,(f-d.g)*g,(u-d.b)*g,(m-d.a)*g))}};e.ENTRIES=5;e.PREV_TIME=-5;e.PREV_R=-4;e.PREV_G=-3;e.PREV_B=-2;e.PREV_A=-1;e.R=1;e.G=2;e.B=
3;e.A=4;return e}(d);a.ColorTimeline=e;e=function(){function d(b){this.frames=a.Utils.newFloatArray(b);this.attachmentNames=Array(b)}d.prototype.getPropertyId=function(){return(c.attachment<<24)+this.slotIndex};d.prototype.getFrameCount=function(){return this.frames.length};d.prototype.setFrame=function(a,b,c){this.frames[a]=b;this.attachmentNames[a]=c};d.prototype.apply=function(a,c,d,e,f,g,t){c=a.slots[this.slotIndex];t&&g?(d=c.data.attachmentName,c.setAttachment(null==d?null:a.getAttachment(this.slotIndex,
d))):(t=this.frames,d<t[0]?g&&(d=c.data.attachmentName,c.setAttachment(null==d?null:a.getAttachment(this.slotIndex,d))):(d=d>=t[t.length-1]?t.length-1:b.binarySearch(t,d,1)-1,d=this.attachmentNames[d],a.slots[this.slotIndex].setAttachment(null==d?null:a.getAttachment(this.slotIndex,d))))};return d}();a.AttachmentTimeline=e;e=function(d){function e(b){d.call(this,b);this.frames=a.Utils.newFloatArray(b);this.frameVertices=Array(b)}__extends(e,d);e.prototype.getPropertyId=function(){return(c.deform<<
24)+this.slotIndex};e.prototype.setFrame=function(a,b,c){this.frames[a]=b;this.frameVertices[a]=c};e.prototype.apply=function(c,d,e,f,g,h,u){c=c.slots[this.slotIndex];var k=c.getAttachment();if(k instanceof a.VertexAttachment&&k.applyDeform(this.attachment)){var m=this.frames;d=c.attachmentVertices;if(e<m[0])h&&a.Utils.setArraySize(d,0);else if(u=this.frameVertices,c=u[0].length,d.length!=c&&(g=1),d=a.Utils.setArraySize(d,c),e>=m[m.length-1])if(e=u[m.length-1],1==g)a.Utils.arrayCopy(e,0,d,0,c);else if(h)if(h=
k,null==h.bones)for(k=h.vertices,m=0;m<c;m++)h=k[m],d[m]=h+(e[m]-h)*g;else for(m=0;m<c;m++)d[m]=e[m]*g;else for(m=0;m<c;m++)d[m]+=(e[m]-d[m])*g;else{var n=b.binarySearch(m,e);f=u[n-1];u=u[n];var p=m[n];e=this.getCurvePercent(n-1,1-(e-p)/(m[n-1]-p));if(1==g)for(m=0;m<c;m++)n=f[m],d[m]=n+(u[m]-n)*e;else if(h)if(h=k,null==h.bones)for(k=h.vertices,m=0;m<c;m++)n=f[m],h=k[m],d[m]=h+(n+(u[m]-n)*e-h)*g;else for(m=0;m<c;m++)n=f[m],d[m]=(n+(u[m]-n)*e)*g;else for(m=0;m<c;m++)n=f[m],d[m]+=(n+(u[m]-n)*e-d[m])*
g}}};return e}(d);a.DeformTimeline=e;e=function(){function d(b){this.frames=a.Utils.newFloatArray(b);this.events=Array(b)}d.prototype.getPropertyId=function(){return c.event<<24};d.prototype.getFrameCount=function(){return this.frames.length};d.prototype.setFrame=function(a,b){this.frames[a]=b.time;this.events[a]=b};d.prototype.apply=function(a,c,d,e,f,g,t){if(null!=e){var h=this.frames,k=this.frames.length;if(c>d)this.apply(a,c,Number.MAX_VALUE,e,f,g,t),c=-1;else if(c>=h[k-1])return;if(!(d<h[0])){if(c<
h[0])a=0;else for(a=b.binarySearch(h,c),c=h[a];0<a&&h[a-1]==c;)a--;for(;a<k&&d>=h[a];a++)e.push(this.events[a])}}};return d}();a.EventTimeline=e;e=function(){function d(b){this.frames=a.Utils.newFloatArray(b);this.drawOrders=Array(b)}d.prototype.getPropertyId=function(){return c.drawOrder<<24};d.prototype.getFrameCount=function(){return this.frames.length};d.prototype.setFrame=function(a,b,c){this.frames[a]=b;this.drawOrders[a]=c};d.prototype.apply=function(c,d,e,f,g,r,t){d=c.drawOrder;f=c.slots;
if(t&&r)a.Utils.arrayCopy(c.slots,0,c.drawOrder,0,c.slots.length);else if(t=this.frames,e<t[0])r&&a.Utils.arrayCopy(c.slots,0,c.drawOrder,0,c.slots.length);else if(c=e>=t[t.length-1]?t.length-1:b.binarySearch(t,e)-1,c=this.drawOrders[c],null==c)a.Utils.arrayCopy(f,0,d,0,f.length);else for(e=0,r=c.length;e<r;e++)d[e]=f[c[e]]};return d}();a.DrawOrderTimeline=e;e=function(d){function e(b){d.call(this,b);this.frames=a.Utils.newFloatArray(b*e.ENTRIES)}__extends(e,d);e.prototype.getPropertyId=function(){return(c.ikConstraint<<
24)+this.ikConstraintIndex};e.prototype.setFrame=function(a,b,c,d){a*=e.ENTRIES;this.frames[a]=b;this.frames[a+e.MIX]=c;this.frames[a+e.BEND_DIRECTION]=d};e.prototype.apply=function(a,c,d,f,g,h,u){c=this.frames;a=a.ikConstraints[this.ikConstraintIndex];if(d<c[0])h&&(a.mix=a.data.mix,a.bendDirection=a.data.bendDirection);else if(d>=c[c.length-e.ENTRIES])h?(a.mix=a.data.mix+(c[c.length+e.PREV_MIX]-a.data.mix)*g,a.bendDirection=u?a.data.bendDirection:c[c.length+e.PREV_BEND_DIRECTION]):(a.mix+=(c[c.length+
e.PREV_MIX]-a.mix)*g,u||(a.bendDirection=c[c.length+e.PREV_BEND_DIRECTION]));else{f=b.binarySearch(c,d,e.ENTRIES);var k=c[f+e.PREV_MIX],m=c[f];d=this.getCurvePercent(f/e.ENTRIES-1,1-(d-m)/(c[f+e.PREV_TIME]-m));h?(a.mix=a.data.mix+(k+(c[f+e.MIX]-k)*d-a.data.mix)*g,a.bendDirection=u?a.data.bendDirection:c[f+e.PREV_BEND_DIRECTION]):(a.mix+=(k+(c[f+e.MIX]-k)*d-a.mix)*g,u||(a.bendDirection=c[f+e.PREV_BEND_DIRECTION]))}};e.ENTRIES=3;e.PREV_TIME=-3;e.PREV_MIX=-2;e.PREV_BEND_DIRECTION=-1;e.MIX=1;e.BEND_DIRECTION=
2;return e}(d);a.IkConstraintTimeline=e;e=function(d){function e(b){d.call(this,b);this.frames=a.Utils.newFloatArray(b*e.ENTRIES)}__extends(e,d);e.prototype.getPropertyId=function(){return(c.transformConstraint<<24)+this.transformConstraintIndex};e.prototype.setFrame=function(a,b,c,d,f,g){a*=e.ENTRIES;this.frames[a]=b;this.frames[a+e.ROTATE]=c;this.frames[a+e.TRANSLATE]=d;this.frames[a+e.SCALE]=f;this.frames[a+e.SHEAR]=g};e.prototype.apply=function(a,c,d,f,g,h,u){c=this.frames;a=a.transformConstraints[this.transformConstraintIndex];
if(d<c[0])h&&(h=a.data,a.rotateMix=h.rotateMix,a.translateMix=h.rotateMix,a.scaleMix=h.scaleMix,a.shearMix=h.shearMix);else{if(d>=c[c.length-e.ENTRIES]){d=c.length;f=c[d+e.PREV_ROTATE];u=c[d+e.PREV_TRANSLATE];var k=c[d+e.PREV_SCALE];var m=c[d+e.PREV_SHEAR]}else{var n=b.binarySearch(c,d,e.ENTRIES);f=c[n+e.PREV_ROTATE];u=c[n+e.PREV_TRANSLATE];k=c[n+e.PREV_SCALE];m=c[n+e.PREV_SHEAR];var p=c[n];d=this.getCurvePercent(n/e.ENTRIES-1,1-(d-p)/(c[n+e.PREV_TIME]-p));f+=(c[n+e.ROTATE]-f)*d;u+=(c[n+e.TRANSLATE]-
u)*d;k+=(c[n+e.SCALE]-k)*d;m+=(c[n+e.SHEAR]-m)*d}h?(h=a.data,a.rotateMix=h.rotateMix+(f-h.rotateMix)*g,a.translateMix=h.translateMix+(u-h.translateMix)*g,a.scaleMix=h.scaleMix+(k-h.scaleMix)*g,a.shearMix=h.shearMix+(m-h.shearMix)*g):(a.rotateMix+=(f-a.rotateMix)*g,a.translateMix+=(u-a.translateMix)*g,a.scaleMix+=(k-a.scaleMix)*g,a.shearMix+=(m-a.shearMix)*g)}};e.ENTRIES=5;e.PREV_TIME=-5;e.PREV_ROTATE=-4;e.PREV_TRANSLATE=-3;e.PREV_SCALE=-2;e.PREV_SHEAR=-1;e.ROTATE=1;e.TRANSLATE=2;e.SCALE=3;e.SHEAR=
4;return e}(d);a.TransformConstraintTimeline=e;e=function(d){function e(b){d.call(this,b);this.frames=a.Utils.newFloatArray(b*e.ENTRIES)}__extends(e,d);e.prototype.getPropertyId=function(){return(c.pathConstraintPosition<<24)+this.pathConstraintIndex};e.prototype.setFrame=function(a,b,c){a*=e.ENTRIES;this.frames[a]=b;this.frames[a+e.VALUE]=c};e.prototype.apply=function(a,c,d,f,g,h,u){c=this.frames;a=a.pathConstraints[this.pathConstraintIndex];if(d<c[0])h&&(a.position=a.data.position);else{if(d>=c[c.length-
e.ENTRIES])f=c[c.length+e.PREV_VALUE];else{u=b.binarySearch(c,d,e.ENTRIES);f=c[u+e.PREV_VALUE];var k=c[u];d=this.getCurvePercent(u/e.ENTRIES-1,1-(d-k)/(c[u+e.PREV_TIME]-k));f+=(c[u+e.VALUE]-f)*d}a.position=h?a.data.position+(f-a.data.position)*g:a.position+(f-a.position)*g}};e.ENTRIES=2;e.PREV_TIME=-2;e.PREV_VALUE=-1;e.VALUE=1;return e}(d);a.PathConstraintPositionTimeline=e;e=function(a){function d(b){a.call(this,b)}__extends(d,a);d.prototype.getPropertyId=function(){return(c.pathConstraintSpacing<<
24)+this.pathConstraintIndex};d.prototype.apply=function(a,c,e,f,g,h,u){c=this.frames;a=a.pathConstraints[this.pathConstraintIndex];if(e<c[0])h&&(a.spacing=a.data.spacing);else{if(e>=c[c.length-d.ENTRIES])f=c[c.length+d.PREV_VALUE];else{u=b.binarySearch(c,e,d.ENTRIES);f=c[u+d.PREV_VALUE];var k=c[u];e=this.getCurvePercent(u/d.ENTRIES-1,1-(e-k)/(c[u+d.PREV_TIME]-k));f+=(c[u+d.VALUE]-f)*e}a.spacing=h?a.data.spacing+(f-a.data.spacing)*g:a.spacing+(f-a.spacing)*g}};return d}(e);a.PathConstraintSpacingTimeline=
e;d=function(d){function e(b){d.call(this,b);this.frames=a.Utils.newFloatArray(b*e.ENTRIES)}__extends(e,d);e.prototype.getPropertyId=function(){return(c.pathConstraintMix<<24)+this.pathConstraintIndex};e.prototype.setFrame=function(a,b,c,d){a*=e.ENTRIES;this.frames[a]=b;this.frames[a+e.ROTATE]=c;this.frames[a+e.TRANSLATE]=d};e.prototype.apply=function(a,c,d,f,g,h,u){c=this.frames;a=a.pathConstraints[this.pathConstraintIndex];if(d<c[0])h&&(a.rotateMix=a.data.rotateMix,a.translateMix=a.data.translateMix);
else{if(d>=c[c.length-e.ENTRIES])f=c[c.length+e.PREV_ROTATE],u=c[c.length+e.PREV_TRANSLATE];else{var k=b.binarySearch(c,d,e.ENTRIES);f=c[k+e.PREV_ROTATE];u=c[k+e.PREV_TRANSLATE];var m=c[k];d=this.getCurvePercent(k/e.ENTRIES-1,1-(d-m)/(c[k+e.PREV_TIME]-m));f+=(c[k+e.ROTATE]-f)*d;u+=(c[k+e.TRANSLATE]-u)*d}h?(a.rotateMix=a.data.rotateMix+(f-a.data.rotateMix)*g,a.translateMix=a.data.translateMix+(u-a.data.translateMix)*g):(a.rotateMix+=(f-a.rotateMix)*g,a.translateMix+=(u-a.translateMix)*g)}};e.ENTRIES=
3;e.PREV_TIME=-3;e.PREV_ROTATE=-2;e.PREV_TRANSLATE=-1;e.ROTATE=1;e.TRANSLATE=2;return e}(d);a.PathConstraintMixTimeline=d})(spine||(spine={}));
(function(a){var b=function(){function b(b){this.tracks=[];this.events=[];this.listeners=[];this.queue=new d(this);this.propertyIDs=new a.IntSet;this.animationsChanged=!1;this.timeScale=1;this.trackEntryPool=new a.Pool(function(){return new c});this.data=b}b.prototype.update=function(a){a*=this.timeScale;for(var b=this.tracks,c=0,d=b.length;c<d;c++){var e=b[c];if(null!=e){e.animationLast=e.nextAnimationLast;e.trackLast=e.nextTrackLast;var f=a*e.timeScale;if(0<e.delay){e.delay-=f;if(0<e.delay)continue;
f=-e.delay;e.delay=0}var g=e.next;if(null!=g){var t=e.trackLast-g.delay;if(0<=t){g.delay=0;g.trackTime=t+a*g.timeScale;e.trackTime+=f;for(this.setCurrent(c,g,!0);null!=g.mixingFrom;)g.mixTime+=f,g=g.mixingFrom;continue}}else if(e.trackLast>=e.trackEnd&&null==e.mixingFrom){b[c]=null;this.queue.end(e);this.disposeNext(e);continue}this.updateMixingFrom(e,a);e.trackTime+=f}}this.queue.drain()};b.prototype.updateMixingFrom=function(a,b){var c=a.mixingFrom;null!=c&&(this.updateMixingFrom(c,b),a.mixTime>=
a.mixDuration&&null!=c.mixingFrom&&0<a.mixTime?(a.mixingFrom=null,this.queue.end(c)):(c.animationLast=c.nextAnimationLast,c.trackLast=c.nextTrackLast,c.trackTime+=b*c.timeScale,a.mixTime+=b*c.timeScale))};b.prototype.apply=function(b){if(null==b)throw Error("skeleton cannot be null.");this.animationsChanged&&this._animationsChanged();for(var c=this.events,d=this.tracks,e=0,f=d.length;e<f;e++){var g=d[e];if(!(null==g||0<g.delay)){var r=g.alpha;null!=g.mixingFrom?r*=this.applyMixingFrom(g,b):g.trackTime>=
g.trackEnd&&(r=0);var t=g.animationLast,u=g.getAnimationTime(),v=g.animation.timelines.length,x=g.animation.timelines;if(1==r)for(var w=0;w<v;w++)x[w].apply(b,t,u,c,1,!0,!1);else{var y=0==g.timelinesRotation.length;y&&a.Utils.setArraySize(g.timelinesRotation,v<<1,null);var z=g.timelinesRotation,A=g.timelinesFirst;for(w=0;w<v;w++){var B=x[w];B instanceof a.RotateTimeline?this.applyRotateTimeline(B,b,u,r,A[w],z,w<<1,y):B.apply(b,t,u,c,r,A[w],!1)}}this.queueEvents(g,u);c.length=0;g.nextAnimationLast=
u;g.nextTrackLast=g.trackTime}}this.queue.drain()};b.prototype.applyMixingFrom=function(b,c){var d=b.mixingFrom;null!=d.mixingFrom&&this.applyMixingFrom(d,c);if(0==b.mixDuration)var e=1;else e=b.mixTime/b.mixDuration,1<e&&(e=1);var f=e<d.eventThreshold?this.events:null,g=e<d.attachmentThreshold,h=e<d.drawOrderThreshold,t=d.animationLast,u=d.getAnimationTime(),v=d.animation.timelines.length,x=d.animation.timelines,w=d.timelinesFirst,y=d.alpha*b.mixAlpha*(1-e),z=0==d.timelinesRotation.length;z&&a.Utils.setArraySize(d.timelinesRotation,
v<<1,null);for(var A=d.timelinesRotation,B=0;B<v;B++){var C=x[B],D=w[B];if(C instanceof a.RotateTimeline)this.applyRotateTimeline(C,c,u,y,D,A,B<<1,z);else{if(!D){if(!g&&C instanceof a.AttachmentTimeline)continue;if(!h&&C instanceof a.DrawOrderTimeline)continue}C.apply(c,t,u,f,y,D,!0)}}0<b.mixDuration&&this.queueEvents(d,u);this.events.length=0;d.nextAnimationLast=u;d.nextTrackLast=d.trackTime;return e};b.prototype.applyRotateTimeline=function(b,c,d,e,f,p,r,t){t&&(p[r]=0);if(1==e)b.apply(c,0,d,null,
1,f,!1);else{var g=b.frames;c=c.bones[b.boneIndex];if(d<g[0])f&&(c.rotation=c.data.rotation);else{if(d>=g[g.length-a.RotateTimeline.ENTRIES])g=c.data.rotation+g[g.length+a.RotateTimeline.PREV_ROTATION];else{var h=a.Animation.binarySearch(g,d,a.RotateTimeline.ENTRIES),k=g[h+a.RotateTimeline.PREV_ROTATION],m=g[h];b=b.getCurvePercent((h>>1)-1,1-(d-m)/(g[h+a.RotateTimeline.PREV_TIME]-m));g=g[h+a.RotateTimeline.ROTATION]-k;g=k+(g-360*(16384-(16384.499999999996-g/360|0)))*b+c.data.rotation;g-=360*(16384-
(16384.499999999996-g/360|0))}f=f?c.data.rotation:c.rotation;g-=f;0==g?d=p[r]:(g-=360*(16384-(16384.499999999996-g/360|0)),t?(t=0,d=g):(t=p[r],d=p[r+1]),k=0<g,b=0<=t,a.MathUtils.signum(d)!=a.MathUtils.signum(g)&&90>=Math.abs(d)&&(180<Math.abs(t)&&(t+=360*a.MathUtils.signum(t)),b=k),d=g+t-t%360,b!=k&&(d+=360*a.MathUtils.signum(t)),p[r]=d);p[r+1]=g;f+=d*e;c.rotation=f-360*(16384-(16384.499999999996-f/360|0))}}};b.prototype.queueEvents=function(a,b){for(var c=a.animationStart,d=a.animationEnd,e=d-c,
f=a.trackLast%e,g=this.events,h=0,u=g.length;h<u;h++){var v=g[h];if(v.time<f)break;v.time>d||this.queue.event(a,v)}for((a.loop?f>a.trackTime%e:b>=d&&a.animationLast<d)&&this.queue.complete(a);h<u;h++)g[h].time<c||this.queue.event(a,g[h])};b.prototype.clearTracks=function(){this.queue.drainDisabled=!0;for(var a=0,b=this.tracks.length;a<b;a++)this.clearTrack(a);this.tracks.length=0;this.queue.drainDisabled=!1;this.queue.drain()};b.prototype.clearTrack=function(a){if(!(a>=this.tracks.length)&&(a=this.tracks[a],
null!=a)){this.queue.end(a);this.disposeNext(a);for(var b=a;;){var c=b.mixingFrom;if(null==c)break;this.queue.end(c);b.mixingFrom=null;b=c}this.tracks[a.trackIndex]=null;this.queue.drain()}};b.prototype.setCurrent=function(a,b,c){var d=this.expandToIndex(a);this.tracks[a]=b;null!=d&&(c&&this.queue.interrupt(d),b.mixingFrom=d,b.mixTime=0,d.timelinesRotation.length=0,null!=d.mixingFrom&&0<d.mixDuration&&(b.mixAlpha*=Math.min(d.mixTime/d.mixDuration,1)));this.queue.start(b)};b.prototype.setAnimation=
function(a,b,c){var d=this.data.skeletonData.findAnimation(b);if(null==d)throw Error("Animation not found: "+b);return this.setAnimationWith(a,d,c)};b.prototype.setAnimationWith=function(a,b,c){if(null==b)throw Error("animation cannot be null.");var d=!0,e=this.expandToIndex(a);null!=e&&(-1==e.nextTrackLast?(this.tracks[a]=e.mixingFrom,this.queue.interrupt(e),this.queue.end(e),this.disposeNext(e),e=e.mixingFrom,d=!1):this.disposeNext(e));b=this.trackEntry(a,b,c,e);this.setCurrent(a,b,d);this.queue.drain();
return b};b.prototype.addAnimation=function(a,b,c,d){var e=this.data.skeletonData.findAnimation(b);if(null==e)throw Error("Animation not found: "+b);return this.addAnimationWith(a,e,c,d)};b.prototype.addAnimationWith=function(a,b,c,d){if(null==b)throw Error("animation cannot be null.");var e=this.expandToIndex(a);if(null!=e)for(;null!=e.next;)e=e.next;c=this.trackEntry(a,b,c,e);null==e?(this.setCurrent(a,c,!0),this.queue.drain()):(e.next=c,0>=d&&(a=e.animationEnd-e.animationStart,d=0!=a?d+(a*(1+(e.trackTime/
a|0))-this.data.getMix(e.animation,b)):0));c.delay=d;return c};b.prototype.setEmptyAnimation=function(a,c){var d=this.setAnimationWith(a,b.emptyAnimation,!1);d.mixDuration=c;d.trackEnd=c;return d};b.prototype.addEmptyAnimation=function(a,c,d){0>=d&&(d-=c);a=this.addAnimationWith(a,b.emptyAnimation,!1,d);a.mixDuration=c;a.trackEnd=c;return a};b.prototype.setEmptyAnimations=function(a){this.queue.drainDisabled=!0;for(var b=0,c=this.tracks.length;b<c;b++){var d=this.tracks[b];null!=d&&this.setEmptyAnimation(d.trackIndex,
a)}this.queue.drainDisabled=!1;this.queue.drain()};b.prototype.expandToIndex=function(b){if(b<this.tracks.length)return this.tracks[b];a.Utils.ensureArrayCapacity(this.tracks,b-this.tracks.length+1,null);this.tracks.length=b+1;return null};b.prototype.trackEntry=function(a,b,c,d){var e=this.trackEntryPool.obtain();e.trackIndex=a;e.animation=b;e.loop=c;e.eventThreshold=0;e.attachmentThreshold=0;e.drawOrderThreshold=0;e.animationStart=0;e.animationEnd=b.duration;e.animationLast=-1;e.nextAnimationLast=
-1;e.delay=0;e.trackTime=0;e.trackLast=-1;e.nextTrackLast=-1;e.trackEnd=Number.MAX_VALUE;e.timeScale=1;e.alpha=1;e.mixAlpha=1;e.mixTime=0;e.mixDuration=null==d?0:this.data.getMix(d.animation,b);return e};b.prototype.disposeNext=function(a){for(var b=a.next;null!=b;)this.queue.dispose(b),b=b.next;a.next=null};b.prototype._animationsChanged=function(){this.animationsChanged=!1;var a=0,b=this.tracks.length;for(this.propertyIDs.clear();a<b;a++){var c=this.tracks[a];if(null!=c){this.setTimelinesFirst(c);
a++;break}}for(;a<b;a++)c=this.tracks[a],null!=c&&this.checkTimelinesFirst(c)};b.prototype.setTimelinesFirst=function(b){if(null!=b.mixingFrom)this.setTimelinesFirst(b.mixingFrom),this.checkTimelinesUsage(b,b.timelinesFirst);else{var c=this.propertyIDs,d=b.animation.timelines,e=d.length;b=a.Utils.setArraySize(b.timelinesFirst,e,!1);for(var f=0;f<e;f++)c.add(d[f].getPropertyId()),b[f]=!0}};b.prototype.checkTimelinesFirst=function(a){null!=a.mixingFrom&&this.checkTimelinesFirst(a.mixingFrom);this.checkTimelinesUsage(a,
a.timelinesFirst)};b.prototype.checkTimelinesUsage=function(b,c){for(var d=this.propertyIDs,e=b.animation.timelines,f=e.length,g=a.Utils.setArraySize(c,f),h=0;h<f;h++)g[h]=d.add(e[h].getPropertyId())};b.prototype.getCurrent=function(a){return a>=this.tracks.length?null:this.tracks[a]};b.prototype.addListener=function(a){if(null==a)throw Error("listener cannot be null.");this.listeners.push(a)};b.prototype.removeListener=function(a){a=this.listeners.indexOf(a);0<=a&&this.listeners.splice(a,1)};b.prototype.clearListeners=
function(){this.listeners.length=0};b.prototype.clearListenerNotifications=function(){this.queue.clear()};b.emptyAnimation=new a.Animation("<empty>",[],0);return b}();a.AnimationState=b;var c=function(){function a(){this.timelinesFirst=[];this.timelinesRotation=[]}a.prototype.reset=function(){this.listener=this.animation=this.mixingFrom=this.next=null;this.timelinesFirst.length=0;this.timelinesRotation.length=0};a.prototype.getAnimationTime=function(){if(this.loop){var a=this.animationEnd-this.animationStart;
return 0==a?this.animationStart:this.trackTime%a+this.animationStart}return Math.min(this.trackTime+this.animationStart,this.animationEnd)};a.prototype.setAnimationLast=function(a){this.nextAnimationLast=this.animationLast=a};a.prototype.isComplete=function(){return this.trackTime>=this.animationEnd-this.animationStart};a.prototype.resetRotationDirections=function(){this.timelinesRotation.length=0};return a}();a.TrackEntry=c;var d=function(){function a(a){this.objects=[];this.drainDisabled=!1;this.animState=
a}a.prototype.start=function(a){this.objects.push(e.start);this.objects.push(a);this.animState.animationsChanged=!0};a.prototype.interrupt=function(a){this.objects.push(e.interrupt);this.objects.push(a)};a.prototype.end=function(a){this.objects.push(e.end);this.objects.push(a);this.animState.animationsChanged=!0};a.prototype.dispose=function(a){this.objects.push(e.dispose);this.objects.push(a)};a.prototype.complete=function(a){this.objects.push(e.complete);this.objects.push(a)};a.prototype.event=
function(a,b){this.objects.push(e.event);this.objects.push(a);this.objects.push(b)};a.prototype.drain=function(){if(!this.drainDisabled){this.drainDisabled=!0;for(var a=this.objects,b=this.animState.listeners,c=0;c<a.length;c+=2){var d=a[c+1];switch(a[c]){case e.start:null!=d.listener&&d.listener.start&&d.listener.start(d);for(var f=0;f<b.length;f++)b[f].start&&b[f].start(d);break;case e.interrupt:null!=d.listener&&d.listener.interrupt&&d.listener.interrupt(d);for(f=0;f<b.length;f++)b[f].interrupt&&
b[f].interrupt(d);break;case e.end:for(null!=d.listener&&d.listener.end&&d.listener.end(d),f=0;f<b.length;f++)b[f].end&&b[f].end(d);case e.dispose:null!=d.listener&&d.listener.dispose&&d.listener.dispose(d);for(f=0;f<b.length;f++)b[f].dispose&&b[f].dispose(d);this.animState.trackEntryPool.free(d);break;case e.complete:null!=d.listener&&d.listener.complete&&d.listener.complete(d);for(f=0;f<b.length;f++)b[f].complete&&b[f].complete(d);break;case e.event:var p=a[c++ +2];null!=d.listener&&d.listener.event&&
d.listener.event(d,p);for(f=0;f<b.length;f++)b[f].event&&b[f].event(d,p)}}this.clear();this.drainDisabled=!1}};a.prototype.clear=function(){this.objects.length=0};return a}();a.EventQueue=d;(function(a){a[a.start=0]="start";a[a.interrupt=1]="interrupt";a[a.end=2]="end";a[a.dispose=3]="dispose";a[a.complete=4]="complete";a[a.event=5]="event"})(a.EventType||(a.EventType={}));var e=a.EventType;b=function(){function a(){}a.prototype.start=function(a){};a.prototype.interrupt=function(a){};a.prototype.end=
function(a){};a.prototype.dispose=function(a){};a.prototype.complete=function(a){};a.prototype.event=function(a,b){};return a}();a.AnimationStateAdapter2=b})(spine||(spine={}));
(function(a){var b=function(){function a(a){this.animationToMixTime={};this.defaultMix=0;if(null==a)throw Error("skeletonData cannot be null.");this.skeletonData=a}a.prototype.setMix=function(a,b,c){var d=this.skeletonData.findAnimation(a);if(null==d)throw Error("Animation not found: "+a);a=this.skeletonData.findAnimation(b);if(null==a)throw Error("Animation not found: "+b);this.setMixWith(d,a,c)};a.prototype.setMixWith=function(a,b,c){if(null==a)throw Error("from cannot be null.");if(null==b)throw Error("to cannot be null.");
this.animationToMixTime[a.name+b.name]=c};a.prototype.getMix=function(a,b){var c=this.animationToMixTime[a.name+b.name];return void 0===c?this.defaultMix:c};return a}();a.AnimationStateData=b})(spine||(spine={}));
(function(a){var b=function(){function a(a,b){void 0===b&&(b="");this.assets={};this.errors={};this.loaded=this.toLoad=0;this.textureLoader=a;this.pathPrefix=b}a.prototype.loadText=function(a,b,c){var d=this;void 0===b&&(b=null);void 0===c&&(c=null);a=this.pathPrefix+a;this.toLoad++;var e=new XMLHttpRequest;e.onreadystatechange=function(){e.readyState==XMLHttpRequest.DONE&&(200<=e.status&&300>e.status?(d.assets[a]=e.responseText,b&&b(a,e.responseText)):(d.errors[a]="Couldn't load text "+a+": status "+
e.status+", "+e.responseText,c&&c(a,"Couldn't load text "+a+": status "+e.status+", "+e.responseText)),d.toLoad--,d.loaded++)};e.open("GET",a,!0);e.send()};a.prototype.loadTexture=function(a,b,c){var d=this;void 0===b&&(b=null);void 0===c&&(c=null);a=this.pathPrefix+a;this.toLoad++;var e=new Image;e.crossOrigin="anonymous";e.src=a;e.onload=function(c){c=d.textureLoader(e);d.assets[a]=c;d.toLoad--;d.loaded++;b&&b(a,e)};e.onerror=function(b){d.errors[a]="Couldn't load image "+a;d.toLoad--;d.loaded++;
c&&c(a,"Couldn't load image "+a)}};a.prototype.get=function(a){a=this.pathPrefix+a;return this.assets[a]};a.prototype.remove=function(a){a=this.pathPrefix+a;var b=this.assets[a];b.dispose&&b.dispose();this.assets[a]=null};a.prototype.removeAll=function(){for(var a in this.assets){var b=this.assets[a];b.dispose&&b.dispose()}this.assets={}};a.prototype.isLoadingComplete=function(){return 0==this.toLoad};a.prototype.getToLoad=function(){return this.toLoad};a.prototype.getLoaded=function(){return this.loaded};
a.prototype.dispose=function(){this.removeAll()};a.prototype.hasErrors=function(){return 0<Object.keys(this.errors).length};a.prototype.getErrors=function(){return this.errors};return a}();a.AssetManager=b})(spine||(spine={}));
(function(a){var b=function(){function b(a){this.atlas=a}b.prototype.newRegionAttachment=function(b,c,f){b=this.atlas.findRegion(f);if(null==b)throw Error("Region not found in atlas: "+f+" (region attachment: "+c+")");b.renderObject=b;c=new a.RegionAttachment(c);c.setRegion(b);return c};b.prototype.newMeshAttachment=function(b,c,f){b=this.atlas.findRegion(f);if(null==b)throw Error("Region not found in atlas: "+f+" (mesh attachment: "+c+")");b.renderObject=b;c=new a.MeshAttachment(c);c.region=b;return c};
b.prototype.newBoundingBoxAttachment=function(b,c){return new a.BoundingBoxAttachment(c)};b.prototype.newPathAttachment=function(b,c){return new a.PathAttachment(c)};return b}();a.AtlasAttachmentLoader=b})(spine||(spine={}));
(function(a){var b=function(){return function(a){if(null==a)throw Error("name cannot be null.");this.name=a}}();a.Attachment=b;b=function(a){function b(b){a.call(this,b);this.worldVerticesLength=0}__extends(b,a);b.prototype.computeWorldVertices=function(a,b){this.computeWorldVerticesWith(a,0,this.worldVerticesLength,b,0)};b.prototype.computeWorldVerticesWith=function(a,b,c,d,k){var e;c+=k;var f=a.bone.skeleton;var g=a.attachmentVertices,h=this.vertices,t=this.bones;if(null==t){0<g.length&&(h=g);var u=
a.bone;g=u.worldX;t=u.worldY;var v=u.a;f=u.b;var x=u.c;u=u.d;for(var w=b;k<c;w+=2,k+=2)a=h[w],b=h[w+1],d[k]=a*v+b*f+g,d[k+1]=a*x+b*u+t}else{for(u=a=x=0;u<b;u+=2)v=t[x],x+=v+1,a+=v;w=f.bones;if(0==g.length)for(f=3*a;k<c;k+=2){var y=e=0;v=t[x++];for(v+=x;x<v;x++,f+=3){u=w[t[x]];a=h[f];b=h[f+1];var z=h[f+2];e+=(a*u.a+b*u.b+u.worldX)*z;y+=(a*u.c+b*u.d+u.worldY)*z}d[k]=e;d[k+1]=y}else{f=3*a;for(var A=a<<1;k<c;k+=2){y=e=0;v=t[x++];for(v+=x;x<v;x++,f+=3,A+=2)u=w[t[x]],a=h[f]+g[A],b=h[f+1]+g[A+1],z=h[f+2],
e+=(a*u.a+b*u.b+u.worldX)*z,y+=(a*u.c+b*u.d+u.worldY)*z;d[k]=e;d[k+1]=y}}}};b.prototype.applyDeform=function(a){return this==a};return b}(b);a.VertexAttachment=b})(spine||(spine={}));(function(a){a=a.AttachmentType||(a.AttachmentType={});a[a.Region=0]="Region";a[a.BoundingBox=1]="BoundingBox";a[a.Mesh=2]="Mesh";a[a.LinkedMesh=3]="LinkedMesh";a[a.Path=4]="Path"})(spine||(spine={}));
(function(a){var b=function(b){function c(c){b.call(this,c);this.color=new a.Color(1,1,1,1)}__extends(c,b);return c}(a.VertexAttachment);a.BoundingBoxAttachment=b})(spine||(spine={}));
(function(a){var b=function(b){function c(c){b.call(this,c);this.color=new a.Color(1,1,1,1);this.inheritDeform=!1;this.tempColor=new a.Color(0,0,0,0)}__extends(c,b);c.prototype.updateUVs=function(){var b=this.regionUVs,c=b.length,d=8*(c>>1);if(null==this.worldVertices||this.worldVertices.length!=d)this.worldVertices=a.Utils.newFloatArray(d);var h,k;if(null==this.region){d=h=0;var m=k=1}else d=this.region.u,h=this.region.v,m=this.region.u2-d,k=this.region.v2-h;if(this.region.rotate)for(var n=0,p=6;n<
c;n+=2,p+=8)this.worldVertices[p]=d+b[n+1]*m,this.worldVertices[p+1]=h+k-b[n]*k;else for(n=0,p=6;n<c;n+=2,p+=8)this.worldVertices[p]=d+b[n]*m,this.worldVertices[p+1]=h+b[n+1]*k};c.prototype.updateWorldVertices=function(a,b){var c;var d=a.bone.skeleton;var e=d.color,f=a.color;var n=this.color;var p=e.a*f.a*n.a;var r=b?p:1,t=this.tempColor;t.set(e.r*f.r*n.r*r,e.g*f.g*n.g*r,e.b*f.b*n.b*r,p);var u=a.attachmentVertices;e=this.vertices;f=this.worldVertices;var v=this.bones;if(null==v){v=e.length;0<u.length&&
(e=u);var x=a.bone;u=x.worldX;var w=x.worldY;var y=x.a;p=x.b;var z=x.c;x=x.d;for(var A=r=0;r<v;r+=2,A+=8)n=e[r],d=e[r+1],f[A]=n*y+d*p+u,f[A+1]=n*z+d*x+w,f[A+2]=t.r,f[A+3]=t.g,f[A+4]=t.b,f[A+5]=t.a;return f}var B=d.bones;if(0==u.length){p=r=A=0;for(var C=v.length;r<C;A+=8){z=c=0;for(y=v[r++]+r;r<y;r++,p+=3)x=B[v[r]],n=e[p],d=e[p+1],w=e[p+2],c+=(n*x.a+d*x.b+x.worldX)*w,z+=(n*x.c+d*x.d+x.worldY)*w;f[A]=c;f[A+1]=z;f[A+2]=t.r;f[A+3]=t.g;f[A+4]=t.b;f[A+5]=t.a}}else{var D=p=r=A=0;for(C=v.length;r<C;A+=8){z=
c=0;for(y=v[r++]+r;r<y;r++,p+=3,D+=2)x=B[v[r]],n=e[p]+u[D],d=e[p+1]+u[D+1],w=e[p+2],c+=(n*x.a+d*x.b+x.worldX)*w,z+=(n*x.c+d*x.d+x.worldY)*w;f[A]=c;f[A+1]=z;f[A+2]=t.r;f[A+3]=t.g;f[A+4]=t.b;f[A+5]=t.a}}return f};c.prototype.applyDeform=function(a){return this==a||this.inheritDeform&&this.parentMesh==a};c.prototype.getParentMesh=function(){return this.parentMesh};c.prototype.setParentMesh=function(a){this.parentMesh=a;null!=a&&(this.bones=a.bones,this.vertices=a.vertices,this.regionUVs=a.regionUVs,
this.triangles=a.triangles,this.hullLength=a.hullLength)};return c}(a.VertexAttachment);a.MeshAttachment=b})(spine||(spine={}));(function(a){var b=function(b){function c(c){b.call(this,c);this.constantSpeed=this.closed=!1;this.color=new a.Color(1,1,1,1)}__extends(c,b);return c}(a.VertexAttachment);a.PathAttachment=b})(spine||(spine={}));
(function(a){var b=function(b){function c(c){b.call(this,c);this.y=this.x=0;this.scaleY=this.scaleX=1;this.height=this.width=this.rotation=0;this.color=new a.Color(1,1,1,1);this.offset=a.Utils.newFloatArray(8);this.vertices=a.Utils.newFloatArray(32);this.tempColor=new a.Color(1,1,1,1)}__extends(c,b);c.prototype.setRegion=function(a){var b=this.vertices;a.rotate?(b[c.U2]=a.u,b[c.V2]=a.v2,b[c.U3]=a.u,b[c.V3]=a.v,b[c.U4]=a.u2,b[c.V4]=a.v,b[c.U1]=a.u2,b[c.V1]=a.v2):(b[c.U1]=a.u,b[c.V1]=a.v2,b[c.U2]=a.u,
b[c.V2]=a.v,b[c.U3]=a.u2,b[c.V3]=a.v,b[c.U4]=a.u2,b[c.V4]=a.v2);this.region=a};c.prototype.updateOffset=function(){var a=this.width/this.region.originalWidth*this.scaleX,b=this.height/this.region.originalHeight*this.scaleY,d=-this.width/2*this.scaleX+this.region.offsetX*a,h=-this.height/2*this.scaleY+this.region.offsetY*b,k=d+this.region.width*a;a=h+this.region.height*b;b=this.rotation*Math.PI/180;var m=Math.cos(b),n=Math.sin(b);b=d*m+this.x;d*=n;var p=h*m+this.y;h*=n;var r=k*m+this.x;k*=n;m=a*m+
this.y;a*=n;n=this.offset;n[c.OX1]=b-h;n[c.OY1]=p+d;n[c.OX2]=b-a;n[c.OY2]=m+d;n[c.OX3]=r-a;n[c.OY3]=m+k;n[c.OX4]=r-h;n[c.OY4]=p+k};c.prototype.updateWorldVertices=function(a,b){var d=a.bone.skeleton.color,e=a.color,f=this.color,m=d.a*e.a*f.a,n=b?m:1,p=this.tempColor;p.set(d.r*e.r*f.r*n,d.g*e.g*f.g*n,d.b*e.b*f.b*n,m);d=this.vertices;e=this.offset;var r=a.bone;f=r.worldX;m=r.worldY;n=r.a;var t=r.b,u=r.c;r=r.d;var v=e[c.OX1];var x=e[c.OY1];d[c.X1]=v*n+x*t+f;d[c.Y1]=v*u+x*r+m;d[c.C1R]=p.r;d[c.C1G]=p.g;
d[c.C1B]=p.b;d[c.C1A]=p.a;v=e[c.OX2];x=e[c.OY2];d[c.X2]=v*n+x*t+f;d[c.Y2]=v*u+x*r+m;d[c.C2R]=p.r;d[c.C2G]=p.g;d[c.C2B]=p.b;d[c.C2A]=p.a;v=e[c.OX3];x=e[c.OY3];d[c.X3]=v*n+x*t+f;d[c.Y3]=v*u+x*r+m;d[c.C3R]=p.r;d[c.C3G]=p.g;d[c.C3B]=p.b;d[c.C3A]=p.a;v=e[c.OX4];x=e[c.OY4];d[c.X4]=v*n+x*t+f;d[c.Y4]=v*u+x*r+m;d[c.C4R]=p.r;d[c.C4G]=p.g;d[c.C4B]=p.b;d[c.C4A]=p.a;return d};c.OX1=0;c.OY1=1;c.OX2=2;c.OY2=3;c.OX3=4;c.OY3=5;c.OX4=6;c.OY4=7;c.X1=0;c.Y1=1;c.C1R=2;c.C1G=3;c.C1B=4;c.C1A=5;c.U1=6;c.V1=7;c.X2=8;c.Y2=
9;c.C2R=10;c.C2G=11;c.C2B=12;c.C2A=13;c.U2=14;c.V2=15;c.X3=16;c.Y3=17;c.C3R=18;c.C3G=19;c.C3B=20;c.C3A=21;c.U3=22;c.V3=23;c.X4=24;c.Y4=25;c.C4R=26;c.C4G=27;c.C4B=28;c.C4A=29;c.U4=30;c.V4=31;return c}(a.Attachment);a.RegionAttachment=b})(spine||(spine={}));(function(a){a=a.BlendMode||(a.BlendMode={});a[a.Normal=0]="Normal";a[a.Additive=1]="Additive";a[a.Multiply=2]="Multiply";a[a.Screen=3]="Screen"})(spine||(spine={}));
(function(a){var b=function(){function b(a,b,c){this.children=[];this.ashearY=this.ashearX=this.ascaleY=this.ascaleX=this.arotation=this.ay=this.ax=this.shearY=this.shearX=this.scaleY=this.scaleX=this.rotation=this.y=this.x=0;this.appliedValid=!1;this.worldY=this.d=this.c=this.worldX=this.b=this.a=0;this.sorted=!1;if(null==a)throw Error("data cannot be null.");if(null==b)throw Error("skeleton cannot be null.");this.data=a;this.skeleton=b;this.parent=c;this.setToSetupPose()}b.prototype.update=function(){this.updateWorldTransformWith(this.x,
this.y,this.rotation,this.scaleX,this.scaleY,this.shearX,this.shearY)};b.prototype.updateWorldTransform=function(){this.updateWorldTransformWith(this.x,this.y,this.rotation,this.scaleX,this.scaleY,this.shearX,this.shearY)};b.prototype.updateWorldTransformWith=function(b,c,f,g,h,k,m){this.ax=b;this.ay=c;this.arotation=f;this.ascaleX=g;this.ascaleY=h;this.ashearX=k;this.ashearY=m;this.appliedValid=!0;var d=this.parent;if(null==d){m=f+90+m;var e=a.MathUtils.cosDeg(f+k)*g;d=a.MathUtils.cosDeg(m)*h;g*=
a.MathUtils.sinDeg(f+k);h*=a.MathUtils.sinDeg(m);var r=this.skeleton;r.flipX&&(b=-b,e=-e,d=-d);r.flipY&&(c=-c,g=-g,h=-h);this.a=e;this.b=d;this.c=g;this.d=h;this.worldX=b+r.x;this.worldY=c+r.y}else{r=d.a;var t=d.b,u=d.c,v=d.d;this.worldX=r*b+t*c+d.worldX;this.worldY=u*b+v*c+d.worldY;switch(this.data.transformMode){case a.TransformMode.Normal:m=f+90+m;e=a.MathUtils.cosDeg(f+k)*g;d=a.MathUtils.cosDeg(m)*h;g*=a.MathUtils.sinDeg(f+k);h*=a.MathUtils.sinDeg(m);this.a=r*e+t*g;this.b=r*d+t*h;this.c=u*e+v*
g;this.d=u*d+v*h;return;case a.TransformMode.OnlyTranslation:m=f+90+m;this.a=a.MathUtils.cosDeg(f+k)*g;this.b=a.MathUtils.cosDeg(m)*h;this.c=a.MathUtils.sinDeg(f+k)*g;this.d=a.MathUtils.sinDeg(m)*h;break;case a.TransformMode.NoRotationOrReflection:d=r*r+u*u;1E-4<d?(d=Math.abs(r*v-t*u)/d,t=u*d,v=r*d,d=Math.atan2(u,r)*a.MathUtils.radDeg):(u=r=0,d=90-Math.atan2(v,t)*a.MathUtils.radDeg);k=f+k-d;m=f+m-d+90;e=a.MathUtils.cosDeg(k)*g;d=a.MathUtils.cosDeg(m)*h;g*=a.MathUtils.sinDeg(k);h*=a.MathUtils.sinDeg(m);
this.a=r*e-t*g;this.b=r*d-t*h;this.c=u*e+v*g;this.d=u*d+v*h;break;case a.TransformMode.NoScale:case a.TransformMode.NoScaleOrReflection:d=a.MathUtils.cosDeg(f);e=a.MathUtils.sinDeg(f);f=r*d+t*e;b=u*d+v*e;d=Math.sqrt(f*f+b*b);1E-5<d&&(d=1/d);f*=d;b*=d;d=Math.sqrt(f*f+b*b);e=Math.PI/2+Math.atan2(b,f);c=Math.cos(e)*d;var x=Math.sin(e)*d;e=a.MathUtils.cosDeg(k)*g;d=a.MathUtils.cosDeg(90+m)*h;g*=a.MathUtils.sinDeg(k);h*=a.MathUtils.sinDeg(90+m);this.a=f*e+c*g;this.b=f*d+c*h;this.c=b*e+x*g;this.d=b*d+x*
h;if(this.data.transformMode!=a.TransformMode.NoScaleOrReflection?0>r*v-t*u:this.skeleton.flipX!=this.skeleton.flipY)this.b=-this.b,this.d=-this.d;return}this.skeleton.flipX&&(this.a=-this.a,this.b=-this.b);this.skeleton.flipY&&(this.c=-this.c,this.d=-this.d)}};b.prototype.setToSetupPose=function(){var a=this.data;this.x=a.x;this.y=a.y;this.rotation=a.rotation;this.scaleX=a.scaleX;this.scaleY=a.scaleY;this.shearX=a.shearX;this.shearY=a.shearY};b.prototype.getWorldRotationX=function(){return Math.atan2(this.c,
this.a)*a.MathUtils.radDeg};b.prototype.getWorldRotationY=function(){return Math.atan2(this.d,this.b)*a.MathUtils.radDeg};b.prototype.getWorldScaleX=function(){return Math.sqrt(this.a*this.a+this.c*this.c)};b.prototype.getWorldScaleY=function(){return Math.sqrt(this.b*this.b+this.d*this.d)};b.prototype.worldToLocalRotationX=function(){var b=this.parent;if(null==b)return this.arotation;var c=this.a,f=this.c;return Math.atan2(b.a*f-b.c*c,b.d*c-b.b*f)*a.MathUtils.radDeg};b.prototype.worldToLocalRotationY=
function(){var b=this.parent;if(null==b)return this.arotation;var c=this.b,f=this.d;return Math.atan2(b.a*f-b.c*c,b.d*c-b.b*f)*a.MathUtils.radDeg};b.prototype.rotateWorld=function(b){var c=this.a,d=this.b,g=this.c,h=this.d,k=a.MathUtils.cosDeg(b);b=a.MathUtils.sinDeg(b);this.a=k*c-b*g;this.b=k*d-b*h;this.c=b*c+k*g;this.d=b*d+k*h;this.appliedValid=!1};b.prototype.updateAppliedTransform=function(){this.appliedValid=!0;var b=this.parent;if(null==b)this.ax=this.worldX,this.ay=this.worldY,this.arotation=
Math.atan2(this.c,this.a)*a.MathUtils.radDeg,this.ascaleX=Math.sqrt(this.a*this.a+this.c*this.c),this.ascaleY=Math.sqrt(this.b*this.b+this.d*this.d),this.ashearX=0,this.ashearY=Math.atan2(this.a*this.b+this.c*this.d,this.a*this.d-this.b*this.c)*a.MathUtils.radDeg;else{var c=b.a,f=b.b,g=b.c,h=b.d,k=1/(c*h-f*g),m=this.worldX-b.worldX;b=this.worldY-b.worldY;this.ax=m*h*k-b*f*k;this.ay=b*c*k-m*g*k;h*=k;c*=k;f*=k;k*=g;g=h*this.a-f*this.c;f=h*this.b-f*this.d;h=c*this.c-k*this.a;k=c*this.d-k*this.b;this.ashearX=
0;this.ascaleX=Math.sqrt(g*g+h*h);1E-4<this.ascaleX?(c=g*k-f*h,this.ascaleY=c/this.ascaleX,this.ashearY=Math.atan2(g*f+h*k,c)*a.MathUtils.radDeg,this.arotation=Math.atan2(h,g)*a.MathUtils.radDeg):(this.ascaleX=0,this.ascaleY=Math.sqrt(f*f+k*k),this.ashearY=0,this.arotation=90-Math.atan2(k,f)*a.MathUtils.radDeg)}};b.prototype.worldToLocal=function(a){var b=this.a,c=this.b,d=this.c,h=this.d,k=1/(b*h-c*d),m=a.x-this.worldX,n=a.y-this.worldY;a.x=m*h*k-n*c*k;a.y=n*b*k-m*d*k;return a};b.prototype.localToWorld=
function(a){var b=a.x,c=a.y;a.x=b*this.a+c*this.b+this.worldX;a.y=b*this.c+c*this.d+this.worldY;return a};return b}();a.Bone=b})(spine||(spine={}));
(function(a){var b=function(){return function(a,b,f){this.rotation=this.y=this.x=0;this.scaleY=this.scaleX=1;this.shearY=this.shearX=0;this.transformMode=c.Normal;if(0>a)throw Error("index must be >= 0.");if(null==b)throw Error("name cannot be null.");this.index=a;this.name=b;this.parent=f}}();a.BoneData=b;(function(a){a[a.Normal=0]="Normal";a[a.OnlyTranslation=1]="OnlyTranslation";a[a.NoRotationOrReflection=2]="NoRotationOrReflection";a[a.NoScale=3]="NoScale";a[a.NoScaleOrReflection=4]="NoScaleOrReflection"})(a.TransformMode||
(a.TransformMode={}));var c=a.TransformMode})(spine||(spine={}));(function(a){var b=function(){return function(a,b){if(null==b)throw Error("data cannot be null.");this.time=a;this.data=b}}();a.Event=b})(spine||(spine={}));(function(a){var b=function(){return function(a){this.name=a}}();a.EventData=b})(spine||(spine={}));
(function(a){var b=function(){function b(a,b){this.mix=1;this.bendDirection=0;if(null==a)throw Error("data cannot be null.");if(null==b)throw Error("skeleton cannot be null.");this.data=a;this.mix=a.mix;this.bendDirection=a.bendDirection;this.bones=[];for(var c=0;c<a.bones.length;c++)this.bones.push(b.findBone(a.bones[c].name));this.target=b.findBone(a.target.name)}b.prototype.getOrder=function(){return this.data.order};b.prototype.apply=function(){this.update()};b.prototype.update=function(){var a=
this.target,b=this.bones;switch(b.length){case 1:this.apply1(b[0],a.worldX,a.worldY,this.mix);break;case 2:this.apply2(b[0],b[1],a.worldX,a.worldY,this.bendDirection,this.mix)}};b.prototype.apply1=function(b,c,f,g){b.appliedValid||b.updateAppliedTransform();var d=b.parent,e=1/(d.a*d.d-d.b*d.c);c-=d.worldX;f-=d.worldY;d=Math.atan2((f*d.a-c*d.c)*e-b.ay,(c*d.d-f*d.b)*e-b.ax)*a.MathUtils.radDeg-b.ashearX-b.arotation;0>b.ascaleX&&(d+=180);180<d?d-=360:-180>d&&(d+=360);b.updateWorldTransformWith(b.ax,b.ay,
b.arotation+d*g,b.ascaleX,b.ascaleY,b.ashearX,b.ashearY)};b.prototype.apply2=function(b,c,f,g,h,k){if(0==k)c.updateWorldTransform();else{b.appliedValid||b.updateAppliedTransform();c.appliedValid||c.updateAppliedTransform();var d=b.ax,e=b.ay,p=b.ascaleX,r=b.ascaleY,t=c.ascaleX;if(0>p){p=-p;var u=180;var v=-1}else u=0,v=1;0>r&&(r=-r,v=-v);if(0>t){t=-t;var x=180}else x=0;var w=c.ax,y=b.a,z=b.b,A=b.c,B=b.d,C=1E-4>=Math.abs(p-r);if(C){var D=c.ay;var E=y*w+z*D+b.worldX;var J=A*w+B*D+b.worldY}else D=0,E=
y*w+b.worldX,J=A*w+b.worldY;var I=b.parent;y=I.a;z=I.b;A=I.c;B=I.d;var G=1/(y*B-z*A);f-=I.worldX;g-=I.worldY;var H=(f*B-g*z)*G-d,F=(g*y-f*A)*G-e;f=E-I.worldX;g=J-I.worldY;z=(f*B-g*z)*G-d;y=(g*y-f*A)*G-e;G=Math.sqrt(z*z+y*y);z=c.data.length*t;a:if(C)z*=p,y=(H*H+F*F-G*G-z*z)/(2*G*z),-1>y?y=-1:1<y&&(y=1),h*=Math.acos(y),y=G+z*y,z*=Math.sin(h),y=Math.atan2(F*y-H*z,H*y+F*z);else{y=p*z;z*=r;g=y*y;t=z*z;C=H*H+F*F;H=Math.atan2(F,H);A=t*G*G+g*C-g*t;f=-2*t*G;F=t-g;B=f*f-4*F*A;if(0<=B&&(B=Math.sqrt(B),0>f&&
(B=-B),B=-(f+B)/2,f=B/F,B=A/B,B=Math.abs(f)<Math.abs(B)?f:B,B*B<=C)){g=Math.sqrt(C-B*B)*h;y=H-Math.atan2(g,B);h=Math.atan2(g/r,(B-G)/p);break a}p=0;A=Number.MAX_VALUE;var K=I=J=r=E=F=0;f=G+y;B=f*f;B>J&&(r=0,J=B,I=f);f=G-y;B=f*f;B<A&&(p=a.MathUtils.PI,A=B,F=f);t=Math.acos(-y*G/(g-t));f=y*Math.cos(t)+G;g=z*Math.sin(t);B=f*f+g*g;B<A&&(p=t,A=B,F=f,E=g);B>J&&(r=t,J=B,I=f,K=g);C<=(A+J)/2?(y=H-Math.atan2(E*h,F),h*=p):(y=H-Math.atan2(K*h,I),h*=r)}z=Math.atan2(D,w)*v;G=b.arotation;y=(y-z)*a.MathUtils.radDeg+
u-G;180<y?y-=360:-180>y&&(y+=360);b.updateWorldTransformWith(d,e,G+y*k,b.ascaleX,b.ascaleY,0,0);G=c.arotation;h=((h+z)*a.MathUtils.radDeg-c.ashearX)*v+x-G;180<h?h-=360:-180>h&&(h+=360);c.updateWorldTransformWith(w,D,G+h*k,c.ascaleX,c.ascaleY,c.ashearX,c.ashearY)}};return b}();a.IkConstraint=b})(spine||(spine={}));(function(a){var b=function(){return function(a){this.order=0;this.bones=[];this.mix=this.bendDirection=1;this.name=a}}();a.IkConstraintData=b})(spine||(spine={}));
(function(a){var b=function(){function b(a,b){this.translateMix=this.rotateMix=this.spacing=this.position=0;this.spaces=[];this.positions=[];this.world=[];this.curves=[];this.lengths=[];this.segments=[];if(null==a)throw Error("data cannot be null.");if(null==b)throw Error("skeleton cannot be null.");this.data=a;this.bones=[];for(var c=0,d=a.bones.length;c<d;c++)this.bones.push(b.findBone(a.bones[c].name));this.target=b.findSlot(a.target.name);this.position=a.position;this.spacing=a.spacing;this.rotateMix=
a.rotateMix;this.translateMix=a.translateMix}b.prototype.apply=function(){this.update()};b.prototype.update=function(){var b=this.target.getAttachment();if(b instanceof a.PathAttachment){var c=this.rotateMix,f=this.translateMix,g=0<c;if(0<f||g){var h=this.data,k=h.spacingMode,m=k==a.SpacingMode.Length;var n=h.rotateMode;var p=n==a.RotateMode.Tangent,r=n==a.RotateMode.ChainScale,t=this.bones.length,u=p?t:t+1,v=this.bones,x=a.Utils.setArraySize(this.spaces,u),w=null,y=this.spacing;if(r||m){r&&(w=a.Utils.setArraySize(this.lengths,
t));for(var z=0,A=u-1;z<A;){var B=v[z];var C=B.data.length;var D=C*B.a;C*=B.c;C=Math.sqrt(D*D+C*C);r&&(w[z]=C);x[++z]=m?Math.max(0,C+y):y}}else for(z=1;z<u;z++)x[z]=y;b=this.computeWorldPositions(b,u,p,h.positionMode==a.PositionMode.Percent,k==a.SpacingMode.Percent);k=b[0];m=b[1];h=h.offsetRotation;0==h?u=n==a.RotateMode.Chain:(u=!1,n=this.target.bone,h*=0<n.a*n.d-n.b*n.c?a.MathUtils.degRad:-a.MathUtils.degRad);z=0;for(n=3;z<t;z++,n+=3){B=v[z];B.worldX+=(k-B.worldX)*f;B.worldY+=(m-B.worldY)*f;D=b[n];
C=b[n+1];y=D-k;A=C-m;r&&(k=w[z],0!=k&&(k=(Math.sqrt(y*y+A*A)/k-1)*c+1,B.a*=k,B.c*=k));k=D;m=C;if(g){D=B.a;C=B.b;var E=B.c,J=B.d;var I=p?b[n-1]:0==x[z+1]?b[n+2]:Math.atan2(A,y);I-=Math.atan2(E,D);if(u){var G=Math.cos(I);var H=Math.sin(I);var F=B.data.length;k+=(F*(G*D-H*E)-y)*c;m+=(F*(H*D+G*E)-A)*c}else I+=h;I>a.MathUtils.PI?I-=a.MathUtils.PI2:I<-a.MathUtils.PI&&(I+=a.MathUtils.PI2);I*=c;G=Math.cos(I);H=Math.sin(I);B.a=G*D-H*E;B.b=G*C-H*J;B.c=H*D+G*E;B.d=H*C+G*J}B.appliedValid=!1}}}};b.prototype.computeWorldPositions=
function(c,e,f,g,h){var d=this.target,m=this.position,n=this.spaces,p=a.Utils.setArraySize(this.positions,3*e+2),r=c.closed,t=c.worldVerticesLength,u=t/6,v=b.NONE;if(!c.constantSpeed){var x=c.lengths;u-=r?1:2;var w=x[u];g&&(m*=w);if(h)for(var y=0;y<e;y++)n[y]*=w;var z=a.Utils.setArraySize(this.world,8);for(var A=y=0,B=0;y<e;y++,A+=3){h=n[y];g=m+=h;if(r)g%=w,0>g&&(g+=w),B=0;else if(0>g){v!=b.BEFORE&&(v=b.BEFORE,c.computeWorldVerticesWith(d,2,4,z,0));this.addBeforePosition(g,z,0,p,A);continue}else if(g>
w){v!=b.AFTER&&(v=b.AFTER,c.computeWorldVerticesWith(d,t-6,4,z,0));this.addAfterPosition(g-w,z,0,p,A);continue}for(;;B++){var C=x[B];if(!(g>C)){if(0==B)g/=C;else{var D=x[B-1];g=(g-D)/(C-D)}break}}B!=v&&(v=B,r&&B==u?(c.computeWorldVerticesWith(d,t-4,4,z,0),c.computeWorldVerticesWith(d,0,4,z,4)):c.computeWorldVerticesWith(d,6*B+2,8,z,0));this.addCurvePosition(g,z[0],z[1],z[2],z[3],z[4],z[5],z[6],z[7],p,A,f||0<y&&0==h)}return p}r?(t+=2,z=a.Utils.setArraySize(this.world,t),c.computeWorldVerticesWith(d,
2,t-4,z,0),c.computeWorldVerticesWith(d,0,2,z,t-4),z[t-2]=z[0],z[t-1]=z[1]):(u--,t-=4,z=a.Utils.setArraySize(this.world,t),c.computeWorldVerticesWith(d,2,t,z,0));c=a.Utils.setArraySize(this.curves,u);d=0;x=z[0];w=z[1];var E=C=0,J=0,I=0,G=0,H=0;y=0;for(A=2;y<u;y++,A+=6){C=z[A];E=z[A+1];J=z[A+2];I=z[A+3];G=z[A+4];H=z[A+5];var F=.1875*(x-2*C+J);var K=.1875*(w-2*E+I);D=.09375*(3*(C-J)-x+G);var L=.09375*(3*(E-I)-w+H);var M=2*F+D;var O=2*K+L;F=.75*(C-x)+F+.16666667*D;K=.75*(E-w)+K+.16666667*L;d+=Math.sqrt(F*
F+K*K);F+=M;K+=O;M+=D;O+=L;d+=Math.sqrt(F*F+K*K);F+=M;K+=O;d+=Math.sqrt(F*F+K*K);F+=M+D;K+=O+L;d+=Math.sqrt(F*F+K*K);c[y]=d;x=G;w=H}g&&(m*=d);if(h)for(y=0;y<e;y++)n[y]*=d;u=this.segments;var P=0;for(L=B=A=y=0;y<e;y++,A+=3){h=n[y];g=m+=h;if(r)g%=d,0>g&&(g+=d),B=0;else if(0>g){this.addBeforePosition(g,z,0,p,A);continue}else if(g>d){this.addAfterPosition(g-d,z,t-4,p,A);continue}for(;;B++)if(M=c[B],!(g>M)){0==B?g/=M:(D=c[B-1],g=(g-D)/(M-D));break}if(B!=v){v=B;var N=6*B;x=z[N];w=z[N+1];C=z[N+2];E=z[N+
3];J=z[N+4];I=z[N+5];G=z[N+6];H=z[N+7];F=.03*(x-2*C+J);K=.03*(w-2*E+I);D=.006*(3*(C-J)-x+G);L=.006*(3*(E-I)-w+H);M=2*F+D;O=2*K+L;F=.3*(C-x)+F+.16666667*D;K=.3*(E-w)+K+.16666667*L;P=Math.sqrt(F*F+K*K);u[0]=P;for(N=1;8>N;N++)F+=M,K+=O,M+=D,O+=L,P+=Math.sqrt(F*F+K*K),u[N]=P;F+=M;K+=O;P+=Math.sqrt(F*F+K*K);u[8]=P;F+=M+D;K+=O+L;P+=Math.sqrt(F*F+K*K);u[9]=P;L=0}for(g*=P;;L++)if(M=u[L],!(g>M)){0==L?g/=M:(D=u[L-1],g=L+(g-D)/(M-D));break}this.addCurvePosition(.1*g,x,w,C,E,J,I,G,H,p,A,f||0<y&&0==h)}return p};
b.prototype.addBeforePosition=function(a,b,c,g,h){var d=b[c],e=b[c+1];b=Math.atan2(b[c+3]-e,b[c+2]-d);g[h]=d+a*Math.cos(b);g[h+1]=e+a*Math.sin(b);g[h+2]=b};b.prototype.addAfterPosition=function(a,b,c,g,h){var d=b[c+2],e=b[c+3];b=Math.atan2(e-b[c+1],d-b[c]);g[h]=d+a*Math.cos(b);g[h+1]=e+a*Math.sin(b);g[h+2]=b};b.prototype.addCurvePosition=function(a,b,c,g,h,k,m,n,p,r,t,u){if(0==a||isNaN(a))a=1E-4;var d=a*a,e=d*a,f=1-a,y=f*f,z=y*f,A=f*a,B=3*A;f*=B;a*=B;n=b*z+g*f+k*a+n*e;p=c*z+h*f+m*a+p*e;r[t]=n;r[t+
1]=p;u&&(r[t+2]=Math.atan2(p-(c*y+h*A*2+m*d),n-(b*y+g*A*2+k*d)))};b.prototype.getOrder=function(){return this.data.order};b.NONE=-1;b.BEFORE=-2;b.AFTER=-3;return b}();a.PathConstraint=b})(spine||(spine={}));
(function(a){var b=function(){return function(a){this.order=0;this.bones=[];this.name=a}}();a.PathConstraintData=b;(function(a){a[a.Fixed=0]="Fixed";a[a.Percent=1]="Percent"})(a.PositionMode||(a.PositionMode={}));(function(a){a[a.Length=0]="Length";a[a.Fixed=1]="Fixed";a[a.Percent=2]="Percent"})(a.SpacingMode||(a.SpacingMode={}));(function(a){a[a.Tangent=0]="Tangent";a[a.Chain=1]="Chain";a[a.ChainScale=2]="ChainScale"})(a.RotateMode||(a.RotateMode={}))})(spine||(spine={}));
(function(a){var b=function(){function a(a){this.toLoad=[];this.assets={};this.clientId=a}a.prototype.loaded=function(){var a=0,b;for(b in this.assets)a++;return a};return a}(),c=function(){function a(a){void 0===a&&(a="");this.clientAssets={};this.queuedAssets={};this.rawAssets={};this.errors={};this.pathPrefix=a}a.prototype.queueAsset=function(a,c,d){var e=this.clientAssets[a];if(null===e||void 0===e)e=new b(a),this.clientAssets[a]=e;null!==c&&(e.textureLoader=c);e.toLoad.push(d);if(this.queuedAssets[d]===
d)return!1;this.queuedAssets[d]=d;return!0};a.prototype.loadText=function(a,b){var c=this;b=this.pathPrefix+b;if(this.queueAsset(a,null,b)){var d=new XMLHttpRequest;d.onreadystatechange=function(){d.readyState==XMLHttpRequest.DONE&&(200<=d.status&&300>d.status?c.rawAssets[b]=d.responseText:c.errors[b]="Couldn't load text "+b+": status "+d.status+", "+d.responseText)};d.open("GET",b,!0);d.send()}};a.prototype.loadJson=function(a,b){var c=this;b=this.pathPrefix+b;if(this.queueAsset(a,null,b)){var d=
new XMLHttpRequest;d.onreadystatechange=function(){d.readyState==XMLHttpRequest.DONE&&(200<=d.status&&300>d.status?c.rawAssets[b]=JSON.parse(d.responseText):c.errors[b]="Couldn't load text "+b+": status "+d.status+", "+d.responseText)};d.open("GET",b,!0);d.send()}};a.prototype.loadTexture=function(a,b,c){var d=this;c=this.pathPrefix+c;if(this.queueAsset(a,b,c)){var e=new Image;e.src=c;e.crossOrigin="anonymous";e.onload=function(a){d.rawAssets[c]=e};e.onerror=function(a){d.errors[c]="Couldn't load image "+
c}}};a.prototype.get=function(a,b){b=this.pathPrefix+b;var c=this.clientAssets[a];return null===c||void 0===c?!0:c.assets[b]};a.prototype.updateClientAssets=function(a){for(var b=0;b<a.toLoad.length;b++){var c=a.toLoad[b],d=a.assets[c];if(null===d||void 0===d)d=this.rawAssets[c],null!==d&&void 0!==d&&(a.assets[c]=d instanceof HTMLImageElement?a.textureLoader(d):d)}};a.prototype.isLoadingComplete=function(a){a=this.clientAssets[a];if(null===a||void 0===a)return!0;this.updateClientAssets(a);return a.toLoad.length==
a.loaded()};a.prototype.dispose=function(){};a.prototype.hasErrors=function(){return 0<Object.keys(this.errors).length};a.prototype.getErrors=function(){return this.errors};return a}();a.SharedAssetManager=c})(spine||(spine={}));
(function(a){var b=function(){function b(b){this._updateCache=[];this.updateCacheReset=[];this.time=0;this.flipY=this.flipX=!1;this.y=this.x=0;if(null==b)throw Error("data cannot be null.");this.data=b;this.bones=[];for(var c=0;c<b.bones.length;c++){var d=b.bones[c];if(null==d.parent)d=new a.Bone(d,this,null);else{var g=this.bones[d.parent.index];d=new a.Bone(d,this,g);g.children.push(d)}this.bones.push(d)}this.slots=[];this.drawOrder=[];for(c=0;c<b.slots.length;c++)g=b.slots[c],d=this.bones[g.boneData.index],
d=new a.Slot(g,d),this.slots.push(d),this.drawOrder.push(d);this.ikConstraints=[];for(c=0;c<b.ikConstraints.length;c++)this.ikConstraints.push(new a.IkConstraint(b.ikConstraints[c],this));this.transformConstraints=[];for(c=0;c<b.transformConstraints.length;c++)this.transformConstraints.push(new a.TransformConstraint(b.transformConstraints[c],this));this.pathConstraints=[];for(c=0;c<b.pathConstraints.length;c++)this.pathConstraints.push(new a.PathConstraint(b.pathConstraints[c],this));this.color=new a.Color(1,
1,1,1);this.updateCache()}b.prototype.updateCache=function(){var a;this._updateCache.length=0;var b=this.bones,c=0;for(a=b.length;c<a;c++)b[c].sorted=!1;var g=this.ikConstraints,h=this.transformConstraints,k=this.pathConstraints,m=g.length,n=h.length,p=k.length,r=m+n+p;c=0;a:for(;c<r;c++){for(var t=0;t<m;t++)if(a=g[t],a.data.order==c){this.sortIkConstraint(a);continue a}for(t=0;t<n;t++)if(a=h[t],a.data.order==c){this.sortTransformConstraint(a);continue a}for(t=0;t<p;t++)if(a=k[t],a.data.order==c){this.sortPathConstraint(a);
continue a}}c=0;for(a=b.length;c<a;c++)this.sortBone(b[c])};b.prototype.sortIkConstraint=function(a){this.sortBone(a.target);var b=a.bones,c=b[0];this.sortBone(c);if(1<b.length){var d=b[b.length-1];-1<this._updateCache.indexOf(d)||this.updateCacheReset.push(d)}this._updateCache.push(a);this.sortReset(c.children);b[b.length-1].sorted=!0};b.prototype.sortPathConstraint=function(b){var c=b.target,d=c.data.index,g=c.bone;null!=this.skin&&this.sortPathConstraintAttachment(this.skin,d,g);null!=this.data.defaultSkin&&
this.data.defaultSkin!=this.skin&&this.sortPathConstraintAttachment(this.data.defaultSkin,d,g);for(var h=0,k=this.data.skins.length;h<k;h++)this.sortPathConstraintAttachment(this.data.skins[h],d,g);h=c.getAttachment();h instanceof a.PathAttachment&&this.sortPathConstraintAttachmentWith(h,g);g=b.bones;c=g.length;for(h=0;h<c;h++)this.sortBone(g[h]);this._updateCache.push(b);for(h=0;h<c;h++)this.sortReset(g[h].children);for(h=0;h<c;h++)g[h].sorted=!0};b.prototype.sortTransformConstraint=function(a){this.sortBone(a.target);
for(var b=a.bones,c=b.length,d=0;d<c;d++)this.sortBone(b[d]);this._updateCache.push(a);for(d=0;d<c;d++)this.sortReset(b[d].children);for(d=0;d<c;d++)b[d].sorted=!0};b.prototype.sortPathConstraintAttachment=function(a,b,c){if(a=a.attachments[b])for(var d in a)this.sortPathConstraintAttachmentWith(a[d],c)};b.prototype.sortPathConstraintAttachmentWith=function(b,c){if(b instanceof a.PathAttachment){var d=b.bones;if(null==d)this.sortBone(c);else for(var e=this.bones,h=0;h<d.length;){var k=d[h++];for(k=
h+k;h<k;h++)this.sortBone(e[d[h]])}}};b.prototype.sortBone=function(a){if(!a.sorted){var b=a.parent;null!=b&&this.sortBone(b);a.sorted=!0;this._updateCache.push(a)}};b.prototype.sortReset=function(a){for(var b=0,c=a.length;b<c;b++){var d=a[b];d.sorted&&this.sortReset(d.children);d.sorted=!1}};b.prototype.updateWorldTransform=function(){for(var a=this.updateCacheReset,b=0,c=a.length;b<c;b++){var g=a[b];g.ax=g.x;g.ay=g.y;g.arotation=g.rotation;g.ascaleX=g.scaleX;g.ascaleY=g.scaleY;g.ashearX=g.shearX;
g.ashearY=g.shearY;g.appliedValid=!0}a=this._updateCache;b=0;for(c=a.length;b<c;b++)a[b].update()};b.prototype.setToSetupPose=function(){this.setBonesToSetupPose();this.setSlotsToSetupPose()};b.prototype.setBonesToSetupPose=function(){var a=this.bones;for(var b=0,c=a.length;b<c;b++)a[b].setToSetupPose();var g=this.ikConstraints;b=0;for(c=g.length;b<c;b++)a=g[b],a.bendDirection=a.data.bendDirection,a.mix=a.data.mix;var h=this.transformConstraints;b=0;for(c=h.length;b<c;b++)a=h[b],g=a.data,a.rotateMix=
g.rotateMix,a.translateMix=g.translateMix,a.scaleMix=g.scaleMix,a.shearMix=g.shearMix;h=this.pathConstraints;b=0;for(c=h.length;b<c;b++)a=h[b],g=a.data,a.position=g.position,a.spacing=g.spacing,a.rotateMix=g.rotateMix,a.translateMix=g.translateMix};b.prototype.setSlotsToSetupPose=function(){var b=this.slots;a.Utils.arrayCopy(b,0,this.drawOrder,0,b.length);for(var c=0,f=b.length;c<f;c++)b[c].setToSetupPose()};b.prototype.getRootBone=function(){return 0==this.bones.length?null:this.bones[0]};b.prototype.findBone=
function(a){if(null==a)throw Error("boneName cannot be null.");for(var b=this.bones,c=0,d=b.length;c<d;c++){var h=b[c];if(h.data.name==a)return h}return null};b.prototype.findBoneIndex=function(a){if(null==a)throw Error("boneName cannot be null.");for(var b=this.bones,c=0,d=b.length;c<d;c++)if(b[c].data.name==a)return c;return-1};b.prototype.findSlot=function(a){if(null==a)throw Error("slotName cannot be null.");for(var b=this.slots,c=0,d=b.length;c<d;c++){var h=b[c];if(h.data.name==a)return h}return null};
b.prototype.findSlotIndex=function(a){if(null==a)throw Error("slotName cannot be null.");for(var b=this.slots,c=0,d=b.length;c<d;c++)if(b[c].data.name==a)return c;return-1};b.prototype.setSkinByName=function(a){var b=this.data.findSkin(a);if(null==b)throw Error("Skin not found: "+a);this.setSkin(b)};b.prototype.setSkin=function(a){if(null!=a)if(null!=this.skin)a.attachAll(this,this.skin);else for(var b=this.slots,c=0,d=b.length;c<d;c++){var h=b[c],k=h.data.attachmentName;null!=k&&(k=a.getAttachment(c,
k),null!=k&&h.setAttachment(k))}this.skin=a};b.prototype.getAttachmentByName=function(a,b){return this.getAttachment(this.data.findSlotIndex(a),b)};b.prototype.getAttachment=function(a,b){if(null==b)throw Error("attachmentName cannot be null.");if(null!=this.skin){var c=this.skin.getAttachment(a,b);if(null!=c)return c}return null!=this.data.defaultSkin?this.data.defaultSkin.getAttachment(a,b):null};b.prototype.setAttachment=function(a,b){if(null==a)throw Error("slotName cannot be null.");for(var c=
this.slots,d=0,e=c.length;d<e;d++){var k=c[d];if(k.data.name==a){c=null;if(null!=b&&(c=this.getAttachment(d,b),null==c))throw Error("Attachment not found: "+b+", for slot: "+a);k.setAttachment(c);return}}throw Error("Slot not found: "+a);};b.prototype.findIkConstraint=function(a){if(null==a)throw Error("constraintName cannot be null.");for(var b=this.ikConstraints,c=0,d=b.length;c<d;c++){var h=b[c];if(h.data.name==a)return h}return null};b.prototype.findTransformConstraint=function(a){if(null==a)throw Error("constraintName cannot be null.");
for(var b=this.transformConstraints,c=0,d=b.length;c<d;c++){var h=b[c];if(h.data.name==a)return h}return null};b.prototype.findPathConstraint=function(a){if(null==a)throw Error("constraintName cannot be null.");for(var b=this.pathConstraints,c=0,d=b.length;c<d;c++){var h=b[c];if(h.data.name==a)return h}return null};b.prototype.getBounds=function(b,c){if(null==b)throw Error("offset cannot be null.");if(null==c)throw Error("size cannot be null.");for(var d=this.drawOrder,e=Number.POSITIVE_INFINITY,
h=Number.POSITIVE_INFINITY,k=Number.NEGATIVE_INFINITY,m=Number.NEGATIVE_INFINITY,n=0,p=d.length;n<p;n++){var r=d[n],t=null,u=r.getAttachment();u instanceof a.RegionAttachment?t=u.updateWorldVertices(r,!1):u instanceof a.MeshAttachment&&(t=u.updateWorldVertices(r,!0));if(null!=t)for(r=0,u=t.length;r<u;r+=8){var v=t[r],x=t[r+1];e=Math.min(e,v);h=Math.min(h,x);k=Math.max(k,v);m=Math.max(m,x)}}b.set(e,h);c.set(k-e,m-h)};b.prototype.update=function(a){this.time+=a};return b}();a.Skeleton=b})(spine||(spine=
{}));
(function(a){var b=function(){function b(){this.maxY=this.maxX=this.minY=this.minX=0;this.boundingBoxes=[];this.polygons=[];this.polygonPool=new a.Pool(function(){return a.Utils.newFloatArray(16)})}b.prototype.update=function(b,c){if(null==b)throw Error("skeleton cannot be null.");var d=this.boundingBoxes,e=this.polygons,h=this.polygonPool,k=b.slots,m=k.length;d.length=0;h.freeAll(e);for(var n=e.length=0;n<m;n++){var p=k[n],r=p.getAttachment();if(r instanceof a.BoundingBoxAttachment){d.push(r);var t=
h.obtain();t.length!=r.worldVerticesLength&&(t=a.Utils.newFloatArray(r.worldVerticesLength));e.push(t);r.computeWorldVertices(p,t)}}c?this.aabbCompute():(this.minY=this.minX=Number.POSITIVE_INFINITY,this.maxY=this.maxX=Number.NEGATIVE_INFINITY)};b.prototype.aabbCompute=function(){for(var a=Number.POSITIVE_INFINITY,b=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY,h=this.polygons,k=0,m=h.length;k<m;k++){var n=h[k],p=n,r=0;for(n=n.length;r<n;r+=2){var t=p[r],u=p[r+1];
a=Math.min(a,t);b=Math.min(b,u);c=Math.max(c,t);g=Math.max(g,u)}}this.minX=a;this.minY=b;this.maxX=c;this.maxY=g};b.prototype.aabbContainsPoint=function(a,b){return a>=this.minX&&a<=this.maxX&&b>=this.minY&&b<=this.maxY};b.prototype.aabbIntersectsSegment=function(a,b,c,g){var d=this.minX,e=this.minY,f=this.maxX,n=this.maxY;if(a<=d&&c<=d||b<=e&&g<=e||a>=f&&c>=f||b>=n&&g>=n)return!1;c=(g-b)/(c-a);g=c*(d-a)+b;if(g>e&&g<n)return!0;g=c*(f-a)+b;if(g>e&&g<n)return!0;e=(e-b)/c+a;if(e>d&&e<f)return!0;e=(n-
b)/c+a;return e>d&&e<f?!0:!1};b.prototype.aabbIntersectsSkeleton=function(a){return this.minX<a.maxX&&this.maxX>a.minX&&this.minY<a.maxY&&this.maxY>a.minY};b.prototype.containsPoint=function(a,b){for(var c=this.polygons,d=0,e=c.length;d<e;d++)if(this.containsPointPolygon(c[d],a,b))return this.boundingBoxes[d];return null};b.prototype.containsPointPolygon=function(a,b,c){for(var d=a.length,e=d-2,f=!1,m=0;m<d;m+=2){var n=a[m+1],p=a[e+1];if(n<c&&p>=c||p<c&&n>=c){var r=a[m];r+(c-n)/(p-n)*(a[e]-r)<b&&
(f=!f)}e=m}return f};b.prototype.intersectsSegment=function(a,b,c,g){for(var d=this.polygons,e=0,f=d.length;e<f;e++)if(this.intersectsSegmentPolygon(d[e],a,b,c,g))return this.boundingBoxes[e];return null};b.prototype.intersectsSegmentPolygon=function(a,b,c,g,h){for(var d=a.length,e=b-g,f=c-h,p=b*h-c*g,r=a[d-2],t=a[d-1],u=0;u<d;u+=2){var v=a[u],x=a[u+1],w=r*x-t*v,y=r-v,z=t-x,A=e*z-f*y;y=(p*y-e*w)/A;if((y>=r&&y<=v||y>=v&&y<=r)&&(y>=b&&y<=g||y>=g&&y<=b)&&(r=(p*z-f*w)/A,(r>=t&&r<=x||r>=x&&r<=t)&&(r>=
c&&r<=h||r>=h&&r<=c)))return!0;r=v;t=x}return!1};b.prototype.getPolygon=function(a){if(null==a)throw Error("boundingBox cannot be null.");a=this.boundingBoxes.indexOf(a);return-1==a?null:this.polygons[a]};b.prototype.getWidth=function(){return this.maxX-this.minX};b.prototype.getHeight=function(){return this.maxY-this.minY};return b}();a.SkeletonBounds=b})(spine||(spine={}));
(function(a){var b=function(){function a(){this.bones=[];this.slots=[];this.skins=[];this.events=[];this.animations=[];this.ikConstraints=[];this.transformConstraints=[];this.pathConstraints=[];this.fps=0}a.prototype.findBone=function(a){if(null==a)throw Error("boneName cannot be null.");for(var b=this.bones,c=0,d=b.length;c<d;c++){var h=b[c];if(h.name==a)return h}return null};a.prototype.findBoneIndex=function(a){if(null==a)throw Error("boneName cannot be null.");for(var b=this.bones,c=0,d=b.length;c<
d;c++)if(b[c].name==a)return c;return-1};a.prototype.findSlot=function(a){if(null==a)throw Error("slotName cannot be null.");for(var b=this.slots,c=0,d=b.length;c<d;c++){var h=b[c];if(h.name==a)return h}return null};a.prototype.findSlotIndex=function(a){if(null==a)throw Error("slotName cannot be null.");for(var b=this.slots,c=0,d=b.length;c<d;c++)if(b[c].name==a)return c;return-1};a.prototype.findSkin=function(a){if(null==a)throw Error("skinName cannot be null.");for(var b=this.skins,c=0,d=b.length;c<
d;c++){var h=b[c];if(h.name==a)return h}return null};a.prototype.findEvent=function(a){if(null==a)throw Error("eventDataName cannot be null.");for(var b=this.events,c=0,d=b.length;c<d;c++){var h=b[c];if(h.name==a)return h}return null};a.prototype.findAnimation=function(a){if(null==a)throw Error("animationName cannot be null.");for(var b=this.animations,c=0,d=b.length;c<d;c++){var h=b[c];if(h.name==a)return h}return null};a.prototype.findIkConstraint=function(a){if(null==a)throw Error("constraintName cannot be null.");
for(var b=this.ikConstraints,c=0,d=b.length;c<d;c++){var h=b[c];if(h.name==a)return h}return null};a.prototype.findTransformConstraint=function(a){if(null==a)throw Error("constraintName cannot be null.");for(var b=this.transformConstraints,c=0,d=b.length;c<d;c++){var h=b[c];if(h.name==a)return h}return null};a.prototype.findPathConstraint=function(a){if(null==a)throw Error("constraintName cannot be null.");for(var b=this.pathConstraints,c=0,d=b.length;c<d;c++){var h=b[c];if(h.name==a)return h}return null};
a.prototype.findPathConstraintIndex=function(a){if(null==a)throw Error("pathConstraintName cannot be null.");for(var b=this.pathConstraints,c=0,d=b.length;c<d;c++)if(b[c].name==a)return c;return-1};return a}();a.SkeletonData=b})(spine||(spine={}));
(function(a){var b=function(){function b(a){this.scale=1;this.linkedMeshes=[];this.attachmentLoader=a}b.prototype.readSkeletonData=function(c){var d=this.scale;var e=new a.SkeletonData;c="string"===typeof c?JSON.parse(c):c;var h=c.skeleton;null!=h&&(e.hash=h.hash,e.version=h.spine,e.width=h.width,e.height=h.height,e.fps=h.fps,e.imagesPath=h.images);if(c.bones)for(h=0;h<c.bones.length;h++){var k=c.bones[h];var m=null;var n=this.getValue(k,"parent",null);if(null!=n&&(m=e.findBone(n),null==m))throw Error("Parent bone not found: "+
n);m=new a.BoneData(e.bones.length,k.name,m);m.length=this.getValue(k,"length",0)*d;m.x=this.getValue(k,"x",0)*d;m.y=this.getValue(k,"y",0)*d;m.rotation=this.getValue(k,"rotation",0);m.scaleX=this.getValue(k,"scaleX",1);m.scaleY=this.getValue(k,"scaleY",1);m.shearX=this.getValue(k,"shearX",0);m.shearY=this.getValue(k,"shearY",0);m.transformMode=b.transformModeFromString(this.getValue(k,"transform","normal"));e.bones.push(m)}if(c.slots)for(h=0;h<c.slots.length;h++){k=c.slots[h];var p=k.name;n=k.bone;
m=e.findBone(n);if(null==m)throw Error("Slot bone not found: "+n);m=new a.SlotData(e.slots.length,p,m);n=this.getValue(k,"color",null);null!=n&&m.color.setFromString(n);m.attachmentName=this.getValue(k,"attachment",null);m.blendMode=b.blendModeFromString(this.getValue(k,"blend","normal"));e.slots.push(m)}if(c.ik)for(h=0;h<c.ik.length;h++){k=c.ik[h];m=new a.IkConstraintData(k.name);m.order=this.getValue(k,"order",0);for(var r=0;r<k.bones.length;r++){n=k.bones[r];var t=e.findBone(n);if(null==t)throw Error("IK bone not found: "+
n);m.bones.push(t)}n=k.target;m.target=e.findBone(n);if(null==m.target)throw Error("IK target bone not found: "+n);m.bendDirection=this.getValue(k,"bendPositive",!0)?1:-1;m.mix=this.getValue(k,"mix",1);e.ikConstraints.push(m)}if(c.transform)for(h=0;h<c.transform.length;h++){k=c.transform[h];m=new a.TransformConstraintData(k.name);m.order=this.getValue(k,"order",0);for(r=0;r<k.bones.length;r++){n=k.bones[r];t=e.findBone(n);if(null==t)throw Error("Transform constraint bone not found: "+n);m.bones.push(t)}n=
k.target;m.target=e.findBone(n);if(null==m.target)throw Error("Transform constraint target bone not found: "+n);m.offsetRotation=this.getValue(k,"rotation",0);m.offsetX=this.getValue(k,"x",0)*d;m.offsetY=this.getValue(k,"y",0)*d;m.offsetScaleX=this.getValue(k,"scaleX",0);m.offsetScaleY=this.getValue(k,"scaleY",0);m.offsetShearY=this.getValue(k,"shearY",0);m.rotateMix=this.getValue(k,"rotateMix",1);m.translateMix=this.getValue(k,"translateMix",1);m.scaleMix=this.getValue(k,"scaleMix",1);m.shearMix=
this.getValue(k,"shearMix",1);e.transformConstraints.push(m)}if(c.path)for(h=0;h<c.path.length;h++){k=c.path[h];m=new a.PathConstraintData(k.name);m.order=this.getValue(k,"order",0);for(r=0;r<k.bones.length;r++){n=k.bones[r];t=e.findBone(n);if(null==t)throw Error("Transform constraint bone not found: "+n);m.bones.push(t)}n=k.target;m.target=e.findSlot(n);if(null==m.target)throw Error("Path target slot not found: "+n);m.positionMode=b.positionModeFromString(this.getValue(k,"positionMode","percent"));
m.spacingMode=b.spacingModeFromString(this.getValue(k,"spacingMode","length"));m.rotateMode=b.rotateModeFromString(this.getValue(k,"rotateMode","tangent"));m.offsetRotation=this.getValue(k,"rotation",0);m.position=this.getValue(k,"position",0);m.positionMode==a.PositionMode.Fixed&&(m.position*=d);m.spacing=this.getValue(k,"spacing",0);if(m.spacingMode==a.SpacingMode.Length||m.spacingMode==a.SpacingMode.Fixed)m.spacing*=d;m.rotateMix=this.getValue(k,"rotateMix",1);m.translateMix=this.getValue(k,"translateMix",
1);e.pathConstraints.push(m)}if(c.skins)for(var u in c.skins){h=c.skins[u];d=new a.Skin(u);for(p in h){m=e.findSlotIndex(p);if(-1==m)throw Error("Slot not found: "+p);k=h[p];for(var v in k)n=this.readAttachment(k[v],d,m,v),null!=n&&d.addAttachment(m,v,n)}e.skins.push(d);"default"==d.name&&(e.defaultSkin=d)}h=0;for(p=this.linkedMeshes.length;h<p;h++){u=this.linkedMeshes[h];d=null==u.skin?e.defaultSkin:e.findSkin(u.skin);if(null==d)throw Error("Skin not found: "+u.skin);v=d.getAttachment(u.slotIndex,
u.parent);if(null==v)throw Error("Parent mesh not found: "+u.parent);u.mesh.setParentMesh(v);u.mesh.updateUVs()}this.linkedMeshes.length=0;if(c.events)for(var x in c.events)p=c.events[x],m=new a.EventData(x),m.intValue=this.getValue(p,"int",0),m.floatValue=this.getValue(p,"float",0),m.stringValue=this.getValue(p,"string",""),e.events.push(m);if(c.animations)for(var w in c.animations)this.readAnimation(c.animations[w],w,e);return e};b.prototype.readAttachment=function(b,d,g,h){var e=this.scale;h=this.getValue(b,
"name",h);switch(this.getValue(b,"type","region")){case "region":var f=this.getValue(b,"path",h);g=this.attachmentLoader.newRegionAttachment(d,h,f);if(null==g)break;g.path=f;g.x=this.getValue(b,"x",0)*e;g.y=this.getValue(b,"y",0)*e;g.scaleX=this.getValue(b,"scaleX",1);g.scaleY=this.getValue(b,"scaleY",1);g.rotation=this.getValue(b,"rotation",0);g.width=b.width*e;g.height=b.height*e;e=this.getValue(b,"color",null);null!=e&&g.color.setFromString(e);g.updateOffset();return g;case "boundingbox":f=this.attachmentLoader.newBoundingBoxAttachment(d,
h);if(null==f)break;this.readVertices(b,f,b.vertexCount<<1);e=this.getValue(b,"color",null);null!=e&&f.color.setFromString(e);return f;case "mesh":case "linkedmesh":f=this.getValue(b,"path",h);d=this.attachmentLoader.newMeshAttachment(d,h,f);if(null==d)break;d.path=f;e=this.getValue(b,"color",null);null!=e&&d.color.setFromString(e);f=this.getValue(b,"parent",null);if(null!=f)return d.inheritDeform=this.getValue(b,"deform",!0),this.linkedMeshes.push(new c(d,this.getValue(b,"skin",null),g,f)),d;f=b.uvs;
this.readVertices(b,d,f.length);d.triangles=b.triangles;d.regionUVs=f;d.updateUVs();d.hullLength=2*this.getValue(b,"hull",0);return d;case "path":if(f=this.attachmentLoader.newPathAttachment(d,h),null!=f){f.closed=this.getValue(b,"closed",!1);f.constantSpeed=this.getValue(b,"constantSpeed",!0);g=b.vertexCount;this.readVertices(b,f,g<<1);g=a.Utils.newArray(g/3,0);for(d=0;d<b.lengths.length;d++)g[d++]=b.lengths[d]*e;f.lengths=g;e=this.getValue(b,"color",null);null!=e&&f.color.setFromString(e);return f}}return null};
b.prototype.readVertices=function(b,c,d){var e=this.scale;c.worldVerticesLength=d;b=b.vertices;var f=a.Utils.toFloatArray(b);if(d==f.length){if(1!=e){d=0;for(var g=b.length;d<g;d++)f[d]*=e}c.vertices=f}else{f=[];var n=[];d=0;for(g=b.length;d<g;){var p=b[d++];n.push(p);for(p=d+4*p;d<p;d+=4)n.push(b[d]),f.push(b[d+1]*e),f.push(b[d+2]*e),f.push(b[d+3])}c.bones=n;c.vertices=a.Utils.toFloatArray(f)}};b.prototype.readAnimation=function(b,c,d){var e,f=this.scale,g=[],n=0;if(b.slots)for(var p in b.slots){var r=
b.slots[p];var t=d.findSlotIndex(p);if(-1==t)throw Error("Slot not found: "+p);for(var u in r){var v=r[u];if("color"==u){var x=new a.ColorTimeline(v.length);x.slotIndex=t;for(var w=e=0;w<v.length;w++){var y=v[w];var z=new a.Color;z.setFromString(y.color);x.setFrame(e,y.time,z.r,z.g,z.b,z.a);this.readCurve(y,x,e);e++}g.push(x);n=Math.max(n,x.frames[(x.getFrameCount()-1)*a.ColorTimeline.ENTRIES])}else{u="attachment";x=new a.AttachmentTimeline(v.length);x.slotIndex=t;for(w=e=0;w<v.length;w++)y=v[w],
x.setFrame(e++,y.time,y.name);g.push(x);n=Math.max(n,x.frames[x.getFrameCount()-1])}}}if(b.bones)for(var A in b.bones){r=b.bones[A];z=d.findBoneIndex(A);if(-1==z)throw Error("Bone not found: "+A);for(u in r)if(v=r[u],"rotate"===u){x=new a.RotateTimeline(v.length);x.boneIndex=z;for(w=e=0;w<v.length;w++)y=v[w],x.setFrame(e,y.time,y.angle),this.readCurve(y,x,e),e++;g.push(x);n=Math.max(n,x.frames[(x.getFrameCount()-1)*a.RotateTimeline.ENTRIES])}else if("translate"===u||"scale"===u||"shear"===u){t=1;
"scale"===u?x=new a.ScaleTimeline(v.length):"shear"===u?x=new a.ShearTimeline(v.length):(x=new a.TranslateTimeline(v.length),t=f);x.boneIndex=z;for(w=e=0;w<v.length;w++){y=v[w];var B=this.getValue(y,"x",0),C=this.getValue(y,"y",0);x.setFrame(e,y.time,B*t,C*t);this.readCurve(y,x,e);e++}g.push(x);n=Math.max(n,x.frames[(x.getFrameCount()-1)*a.TranslateTimeline.ENTRIES])}else throw Error("Invalid timeline type for a bone: "+u+" ("+A+")");}if(b.ik)for(var D in b.ik){r=b.ik[D];e=d.findIkConstraint(D);x=
new a.IkConstraintTimeline(r.length);x.ikConstraintIndex=d.ikConstraints.indexOf(e);for(w=e=0;w<r.length;w++)y=r[w],x.setFrame(e,y.time,this.getValue(y,"mix",1),this.getValue(y,"bendPositive",!0)?1:-1),this.readCurve(y,x,e),e++;g.push(x);n=Math.max(n,x.frames[(x.getFrameCount()-1)*a.IkConstraintTimeline.ENTRIES])}if(b.transform)for(D in b.transform){r=b.transform[D];e=d.findTransformConstraint(D);x=new a.TransformConstraintTimeline(r.length);x.transformConstraintIndex=d.transformConstraints.indexOf(e);
for(w=e=0;w<r.length;w++)y=r[w],x.setFrame(e,y.time,this.getValue(y,"rotateMix",1),this.getValue(y,"translateMix",1),this.getValue(y,"scaleMix",1),this.getValue(y,"shearMix",1)),this.readCurve(y,x,e),e++;g.push(x);n=Math.max(n,x.frames[(x.getFrameCount()-1)*a.TransformConstraintTimeline.ENTRIES])}if(b.paths)for(D in b.paths){r=b.paths[D];A=d.findPathConstraintIndex(D);if(-1==A)throw Error("Path constraint not found: "+D);z=d.pathConstraints[A];for(u in r)if(v=r[u],"position"===u||"spacing"===u){t=
1;if("spacing"===u){if(x=new a.PathConstraintSpacingTimeline(v.length),z.spacingMode==a.SpacingMode.Length||z.spacingMode==a.SpacingMode.Fixed)t=f}else x=new a.PathConstraintPositionTimeline(v.length),z.positionMode==a.PositionMode.Fixed&&(t=f);x.pathConstraintIndex=A;for(w=e=0;w<v.length;w++)y=v[w],x.setFrame(e,y.time,this.getValue(y,u,0)*t),this.readCurve(y,x,e),e++;g.push(x);n=Math.max(n,x.frames[(x.getFrameCount()-1)*a.PathConstraintPositionTimeline.ENTRIES])}else if("mix"===u){x=new a.PathConstraintMixTimeline(v.length);
x.pathConstraintIndex=A;for(w=e=0;w<v.length;w++)y=v[w],x.setFrame(e,y.time,this.getValue(y,"rotateMix",1),this.getValue(y,"translateMix",1)),this.readCurve(y,x,e),e++;g.push(x);n=Math.max(n,x.frames[(x.getFrameCount()-1)*a.PathConstraintMixTimeline.ENTRIES])}}if(b.deform)for(var E in b.deform){A=b.deform[E];z=d.findSkin(E);if(null==z)throw Error("Skin not found: "+E);for(p in A){r=A[p];t=d.findSlotIndex(p);if(-1==t)throw Error("Slot not found: "+r.name);for(u in r){v=r[u];e=z.getAttachment(t,u);
if(null==e)throw Error("Deform attachment not found: "+v.name);B=null!=e.bones;C=e.vertices;var J=B?C.length/3*2:C.length;x=new a.DeformTimeline(v.length);x.slotIndex=t;x.attachment=e;for(D=e=0;D<v.length;D++){y=v[D];var I=this.getValue(y,"vertices",null);if(null==I)var G=B?a.Utils.newFloatArray(J):C;else{G=a.Utils.newFloatArray(J);w=this.getValue(y,"offset",0);a.Utils.arrayCopy(I,0,G,w,I.length);if(1!=f)for(I=w+I.length;w<I;w++)G[w]*=f;if(!B)for(w=0;w<J;w++)G[w]+=C[w]}x.setFrame(e,y.time,G);this.readCurve(y,
x,e);e++}g.push(x);n=Math.max(n,x.frames[x.getFrameCount()-1])}}}f=b.drawOrder;null==f&&(f=b.draworder);if(null!=f){x=new a.DrawOrderTimeline(f.length);p=d.slots.length;for(D=e=0;D<f.length;D++){u=f[D];E=null;v=this.getValue(u,"offsets",null);if(null!=v){E=a.Utils.newArray(p,-1);y=a.Utils.newArray(p-v.length,0);for(w=A=r=0;w<v.length;w++){z=v[w];t=d.findSlotIndex(z.slot);if(-1==t)throw Error("Slot not found: "+z.slot);for(;r!=t;)y[A++]=r++;E[r+z.offset]=r++}for(;r<p;)y[A++]=r++;for(w=p-1;0<=w;w--)-1==
E[w]&&(E[w]=y[--A])}x.setFrame(e++,u.time,E)}g.push(x);n=Math.max(n,x.frames[x.getFrameCount()-1])}if(b.events){x=new a.EventTimeline(b.events.length);for(w=e=0;w<b.events.length;w++){t=b.events[w];f=d.findEvent(t.name);if(null==f)throw Error("Event not found: "+t.name);p=new a.Event(t.time,f);p.intValue=this.getValue(t,"int",f.intValue);p.floatValue=this.getValue(t,"float",f.floatValue);p.stringValue=this.getValue(t,"string",f.stringValue);x.setFrame(e++,p)}g.push(x);n=Math.max(n,x.frames[x.getFrameCount()-
1])}if(isNaN(n))throw Error("Error while parsing animation, duration is NaN");d.animations.push(new a.Animation(c,g,n))};b.prototype.readCurve=function(a,b,c){a.curve&&("stepped"===a.curve?b.setStepped(c):"[object Array]"===Object.prototype.toString.call(a.curve)&&(a=a.curve,b.setCurve(c,a[0],a[1],a[2],a[3])))};b.prototype.getValue=function(a,b,c){return void 0!==a[b]?a[b]:c};b.blendModeFromString=function(b){b=b.toLowerCase();if("normal"==b)return a.BlendMode.Normal;if("additive"==b)return a.BlendMode.Additive;
if("multiply"==b)return a.BlendMode.Multiply;if("screen"==b)return a.BlendMode.Screen;throw Error("Unknown blend mode: "+b);};b.positionModeFromString=function(b){b=b.toLowerCase();if("fixed"==b)return a.PositionMode.Fixed;if("percent"==b)return a.PositionMode.Percent;throw Error("Unknown position mode: "+b);};b.spacingModeFromString=function(b){b=b.toLowerCase();if("length"==b)return a.SpacingMode.Length;if("fixed"==b)return a.SpacingMode.Fixed;if("percent"==b)return a.SpacingMode.Percent;throw Error("Unknown position mode: "+
b);};b.rotateModeFromString=function(b){b=b.toLowerCase();if("tangent"==b)return a.RotateMode.Tangent;if("chain"==b)return a.RotateMode.Chain;if("chainscale"==b)return a.RotateMode.ChainScale;throw Error("Unknown rotate mode: "+b);};b.transformModeFromString=function(b){b=b.toLowerCase();if("normal"==b)return a.TransformMode.Normal;if("onlytranslation"==b)return a.TransformMode.OnlyTranslation;if("norotationorreflection"==b)return a.TransformMode.NoRotationOrReflection;if("noscale"==b)return a.TransformMode.NoScale;
if("noscaleorreflection"==b)return a.TransformMode.NoScaleOrReflection;throw Error("Unknown transform mode: "+b);};return b}();a.SkeletonJson=b;var c=function(){return function(a,b,c,g){this.mesh=a;this.skin=b;this.slotIndex=c;this.parent=g}}()})(spine||(spine={}));
(function(a){var b=function(){function a(a){this.attachments=[];if(null==a)throw Error("name cannot be null.");this.name=a}a.prototype.addAttachment=function(a,b,c){if(null==c)throw Error("attachment cannot be null.");var d=this.attachments;a>=d.length&&(d.length=a+1);d[a]||(d[a]={});d[a][b]=c};a.prototype.getAttachment=function(a,b){var c=this.attachments[a];return c?c[b]:null};a.prototype.attachAll=function(a,b){for(var c=0,d=0;d<a.slots.length;d++){var e=a.slots[d],k=e.getAttachment();if(k&&c<
b.attachments.length){var m=b.attachments[c],n;for(n in m)if(k==m[n]){k=this.getAttachment(c,n);null!=k&&e.setAttachment(k);break}}c++}};return a}();a.Skin=b})(spine||(spine={}));
(function(a){var b=function(){function b(b,c){this.attachmentVertices=[];if(null==b)throw Error("data cannot be null.");if(null==c)throw Error("bone cannot be null.");this.data=b;this.bone=c;this.color=new a.Color;this.setToSetupPose()}b.prototype.getAttachment=function(){return this.attachment};b.prototype.setAttachment=function(a){this.attachment!=a&&(this.attachment=a,this.attachmentTime=this.bone.skeleton.time,this.attachmentVertices.length=0)};b.prototype.setAttachmentTime=function(a){this.attachmentTime=
this.bone.skeleton.time-a};b.prototype.getAttachmentTime=function(){return this.bone.skeleton.time-this.attachmentTime};b.prototype.setToSetupPose=function(){this.color.setFromColor(this.data.color);null==this.data.attachmentName?this.attachment=null:(this.attachment=null,this.setAttachment(this.bone.skeleton.getAttachment(this.data.index,this.data.attachmentName)))};return b}();a.Slot=b})(spine||(spine={}));
(function(a){var b=function(){return function(b,d,e){this.color=new a.Color(1,1,1,1);if(0>b)throw Error("index must be >= 0.");if(null==d)throw Error("name cannot be null.");if(null==e)throw Error("boneData cannot be null.");this.index=b;this.name=d;this.boneData=e}}();a.SlotData=b})(spine||(spine={}));
(function(a){var b=function(){function a(a){this._image=a}a.prototype.getImage=function(){return this._image};a.filterFromString=function(a){switch(a.toLowerCase()){case "nearest":return c.Nearest;case "linear":return c.Linear;case "mipmap":return c.MipMap;case "mipmapnearestnearest":return c.MipMapNearestNearest;case "mipmaplinearnearest":return c.MipMapLinearNearest;case "mipmapnearestlinear":return c.MipMapNearestLinear;case "mipmaplinearlinear":return c.MipMapLinearLinear;default:throw Error("Unknown texture filter "+
a);}};a.wrapFromString=function(a){switch(a.toLowerCase()){case "mirroredtepeat":return d.MirroredRepeat;case "clamptoedge":return d.ClampToEdge;case "repeat":return d.Repeat;default:throw Error("Unknown texture wrap "+a);}};return a}();a.Texture=b;(function(a){a[a.Nearest=9728]="Nearest";a[a.Linear=9729]="Linear";a[a.MipMap=9987]="MipMap";a[a.MipMapNearestNearest=9984]="MipMapNearestNearest";a[a.MipMapLinearNearest=9985]="MipMapLinearNearest";a[a.MipMapNearestLinear=9986]="MipMapNearestLinear";a[a.MipMapLinearLinear=
9987]="MipMapLinearLinear"})(a.TextureFilter||(a.TextureFilter={}));var c=a.TextureFilter;(function(a){a[a.MirroredRepeat=33648]="MirroredRepeat";a[a.ClampToEdge=33071]="ClampToEdge";a[a.Repeat=10497]="Repeat"})(a.TextureWrap||(a.TextureWrap={}));var d=a.TextureWrap;b=function(){return function(){this.height=this.width=this.v2=this.u2=this.v=this.u=0;this.rotate=!1;this.originalHeight=this.originalWidth=this.offsetY=this.offsetX=0}}();a.TextureRegion=b})(spine||(spine={}));
(function(a){var b=function(){function b(a,b){this.pages=[];this.regions=[];this.load(a,b)}b.prototype.load=function(b,f){if(null==f)throw Error("textureLoader cannot be null.");for(var g=new c(b),h=Array(4),n=null;;){var p=g.readLine();if(null==p)break;p=p.trim();if(0==p.length)n=null;else if(n){var r=new e;r.name=p;r.page=n;r.rotate="true"==g.readValue();g.readTuple(h);p=parseInt(h[0]);var t=parseInt(h[1]);g.readTuple(h);var u=parseInt(h[0]),v=parseInt(h[1]);r.u=p/n.width;r.v=t/n.height;r.rotate?
(r.u2=(p+v)/n.width,r.v2=(t+u)/n.height):(r.u2=(p+u)/n.width,r.v2=(t+v)/n.height);r.x=p;r.y=t;r.width=Math.abs(u);r.height=Math.abs(v);4==g.readTuple(h)&&4==g.readTuple(h)&&g.readTuple(h);r.originalWidth=parseInt(h[0]);r.originalHeight=parseInt(h[1]);g.readTuple(h);r.offsetX=parseInt(h[0]);r.offsetY=parseInt(h[1]);r.index=parseInt(g.readValue());r.texture=n.texture;this.regions.push(r)}else n=new d,n.name=p,2==g.readTuple(h)&&(n.width=parseInt(h[0]),n.height=parseInt(h[1]),g.readTuple(h)),g.readTuple(h),
n.minFilter=a.Texture.filterFromString(h[0]),n.magFilter=a.Texture.filterFromString(h[1]),r=g.readValue(),n.uWrap=a.TextureWrap.ClampToEdge,n.vWrap=a.TextureWrap.ClampToEdge,"x"==r?n.uWrap=a.TextureWrap.Repeat:"y"==r?n.vWrap=a.TextureWrap.Repeat:"xy"==r&&(n.uWrap=n.vWrap=a.TextureWrap.Repeat),n.texture=f(p),n.texture.setFilters(n.minFilter,n.magFilter),n.texture.setWraps(n.uWrap,n.vWrap),n.width=n.texture.getImage().width,n.height=n.texture.getImage().height,this.pages.push(n)}};b.prototype.findRegion=
function(a){for(var b=0;b<this.regions.length;b++)if(this.regions[b].name==a)return this.regions[b];return null};b.prototype.dispose=function(){for(var a=0;a<this.pages.length;a++)this.pages[a].texture.dispose()};return b}();a.TextureAtlas=b;var c=function(){function a(a){this.index=0;this.lines=a.split(/\r\n|\r|\n/)}a.prototype.readLine=function(){return this.index>=this.lines.length?null:this.lines[this.index++]};a.prototype.readValue=function(){var a=this.readLine(),b=a.indexOf(":");if(-1==b)throw Error("Invalid line: "+
a);return a.substring(b+1).trim()};a.prototype.readTuple=function(a){var b=this.readLine(),c=b.indexOf(":");if(-1==c)throw Error("Invalid line: "+b);var d=0;for(c+=1;3>d;d++){var e=b.indexOf(",",c);if(-1==e)break;a[d]=b.substr(c,e-c).trim();c=e+1}a[d]=b.substring(c).trim();return d+1};return a}(),d=function(){return function(){}}();a.TextureAtlasPage=d;var e=function(a){function b(){a.apply(this,arguments)}__extends(b,a);return b}(a.TextureRegion);a.TextureAtlasRegion=e})(spine||(spine={}));
(function(a){var b=function(){function b(b,c){this.shearMix=this.scaleMix=this.translateMix=this.rotateMix=0;this.temp=new a.Vector2;if(null==b)throw Error("data cannot be null.");if(null==c)throw Error("skeleton cannot be null.");this.data=b;this.rotateMix=b.rotateMix;this.translateMix=b.translateMix;this.scaleMix=b.scaleMix;this.shearMix=b.shearMix;this.bones=[];for(var d=0;d<b.bones.length;d++)this.bones.push(c.findBone(b.bones[d].name));this.target=c.findBone(b.target.name)}b.prototype.apply=
function(){this.update()};b.prototype.update=function(){var b=this.rotateMix,c=this.translateMix,f=this.scaleMix,g=this.shearMix,h=this.target,k=h.a,m=h.b,n=h.c,p=h.d,r=0<k*p-m*n?a.MathUtils.degRad:-a.MathUtils.degRad,t=this.data.offsetRotation*r;r*=this.data.offsetShearY;for(var u=this.bones,v=0,x=u.length;v<x;v++){var w=u[v];var y=!1;if(0!=b){var z=w.a;var A=w.b;var B=w.c;var C=w.d;y=Math.atan2(n,k)-Math.atan2(B,z)+t;y>a.MathUtils.PI?y-=a.MathUtils.PI2:y<-a.MathUtils.PI&&(y+=a.MathUtils.PI2);y*=
b;var D=Math.cos(y);y=Math.sin(y);w.a=D*z-y*B;w.b=D*A-y*C;w.c=y*z+D*B;w.d=y*A+D*C;y=!0}0!=c&&(y=this.temp,h.localToWorld(y.set(this.data.offsetX,this.data.offsetY)),w.worldX+=(y.x-w.worldX)*c,w.worldY+=(y.y-w.worldY)*c,y=!0);0<f&&(C=Math.sqrt(w.a*w.a+w.c*w.c),y=Math.sqrt(k*k+n*n),1E-5<C&&(C=(C+(y-C+this.data.offsetScaleX)*f)/C),w.a*=C,w.c*=C,C=Math.sqrt(w.b*w.b+w.d*w.d),y=Math.sqrt(m*m+p*p),1E-5<C&&(C=(C+(y-C+this.data.offsetScaleY)*f)/C),w.b*=C,w.d*=C,y=!0);0<g&&(A=w.b,C=w.d,z=Math.atan2(C,A),y=
Math.atan2(p,m)-Math.atan2(n,k)-(z-Math.atan2(w.c,w.a)),y>a.MathUtils.PI?y-=a.MathUtils.PI2:y<-a.MathUtils.PI&&(y+=a.MathUtils.PI2),y=z+(y+r)*g,C=Math.sqrt(A*A+C*C),w.b=Math.cos(y)*C,w.d=Math.sin(y)*C,y=!0);y&&(w.appliedValid=!1)}};b.prototype.getOrder=function(){return this.data.order};return b}();a.TransformConstraint=b})(spine||(spine={}));
(function(a){var b=function(){return function(a){this.order=0;this.bones=[];this.offsetShearY=this.offsetScaleY=this.offsetScaleX=this.offsetY=this.offsetX=this.offsetRotation=this.shearMix=this.scaleMix=this.translateMix=this.rotateMix=0;if(null==a)throw Error("name cannot be null.");this.name=a}}();a.TransformConstraintData=b})(spine||(spine={}));
(function(a){var b=function(){function a(){this.array=[]}a.prototype.add=function(a){var b=this.contains(a);this.array[a|0]=a|0;return!b};a.prototype.contains=function(a){return void 0!=this.array[a|0]};a.prototype.remove=function(a){this.array[a|0]=void 0};a.prototype.clear=function(){this.array.length=0};return a}();a.IntSet=b;b=function(){function a(a,b,c,g){void 0===a&&(a=0);void 0===b&&(b=0);void 0===c&&(c=0);void 0===g&&(g=0);this.r=a;this.g=b;this.b=c;this.a=g}a.prototype.set=function(a,b,
c,g){this.r=a;this.g=b;this.b=c;this.a=g;this.clamp();return this};a.prototype.setFromColor=function(a){this.r=a.r;this.g=a.g;this.b=a.b;this.a=a.a;return this};a.prototype.setFromString=function(a){a="#"==a.charAt(0)?a.substr(1):a;this.r=parseInt(a.substr(0,2),16)/255;this.g=parseInt(a.substr(2,2),16)/255;this.b=parseInt(a.substr(4,2),16)/255;this.a=(8!=a.length?255:parseInt(a.substr(6,2),16))/255;return this};a.prototype.add=function(a,b,c,g){this.r+=a;this.g+=b;this.b+=c;this.a+=g;this.clamp();
return this};a.prototype.clamp=function(){0>this.r?this.r=0:1<this.r&&(this.r=1);0>this.g?this.g=0:1<this.g&&(this.g=1);0>this.b?this.b=0:1<this.b&&(this.b=1);0>this.a?this.a=0:1<this.a&&(this.a=1);return this};a.WHITE=new a(1,1,1,1);a.RED=new a(1,0,0,1);a.GREEN=new a(0,1,0,1);a.BLUE=new a(0,0,1,1);a.MAGENTA=new a(1,0,1,1);return a}();a.Color=b;b=function(){function a(){}a.clamp=function(a,b,c){return a<b?b:a>c?c:a};a.cosDeg=function(b){return Math.cos(b*a.degRad)};a.sinDeg=function(b){return Math.sin(b*
a.degRad)};a.signum=function(a){return 0<a?1:0>a?-1:0};a.toInt=function(a){return 0<a?Math.floor(a):Math.ceil(a)};a.cbrt=function(a){var b=Math.pow(Math.abs(a),1/3);return 0>a?-b:b};a.PI=3.1415927;a.PI2=2*a.PI;a.radiansToDegrees=180/a.PI;a.radDeg=a.radiansToDegrees;a.degreesToRadians=a.PI/180;a.degRad=a.degreesToRadians;return a}();a.MathUtils=b;b=function(){function a(){}a.arrayCopy=function(a,b,c,g,h){for(var d=b;d<b+h;d++,g++)c[g]=a[d]};a.setArraySize=function(a,b,c){void 0===c&&(c=0);var d=a.length;
if(d==b)return a;a.length=b;if(d<b)for(;d<b;d++)a[d]=c;return a};a.ensureArrayCapacity=function(b,c,f){void 0===f&&(f=0);return b.length>=c?b:a.setArraySize(b,c,f)};a.newArray=function(a,b){for(var c=Array(a),d=0;d<a;d++)c[d]=b;return c};a.newFloatArray=function(b){if(a.SUPPORTS_TYPED_ARRAYS)return new Float32Array(b);b=Array(b);for(var c=0;c<b.length;c++)b[c]=0;return b};a.toFloatArray=function(b){return a.SUPPORTS_TYPED_ARRAYS?new Float32Array(b):b};a.SUPPORTS_TYPED_ARRAYS="undefined"!==typeof Float32Array;
return a}();a.Utils=b;b=function(){function a(){}a.logBones=function(a){for(var b=0;b<a.bones.length;b++){var c=a.bones[b];console.log(c.data.name+", "+c.a+", "+c.b+", "+c.c+", "+c.d+", "+c.worldX+", "+c.worldY)}};return a}();a.DebugUtils=b;b=function(){function a(a){this.items=[];this.instantiator=a}a.prototype.obtain=function(){return 0<this.items.length?this.items.pop():this.instantiator()};a.prototype.free=function(a){a.reset&&a.reset();this.items.push(a)};a.prototype.freeAll=function(a){for(var b=
0;b<a.length;b++)a[b].reset&&a[b].reset(),this.items[b]=a[b]};a.prototype.clear=function(){this.items.length=0};return a}();a.Pool=b;b=function(){function a(a,b){void 0===a&&(a=0);void 0===b&&(b=0);this.x=a;this.y=b}a.prototype.set=function(a,b){this.x=a;this.y=b;return this};a.prototype.length=function(){var a=this.x,b=this.y;return Math.sqrt(a*a+b*b)};a.prototype.normalize=function(){var a=this.length();0!=a&&(this.x/=a,this.y/=a);return this};return a}();a.Vector2=b;b=function(){function a(){this.maxDelta=
.064;this.totalTime=this.delta=this.framesPerSecond=0;this.lastTime=Date.now()/1E3;this.frameTime=this.frameCount=0}a.prototype.update=function(){var a=Date.now()/1E3;this.delta=a-this.lastTime;this.frameTime+=this.delta;this.totalTime+=this.delta;this.delta>this.maxDelta&&(this.delta=this.maxDelta);this.lastTime=a;this.frameCount++;1<this.frameTime&&(this.framesPerSecond=this.frameCount/this.frameTime,this.frameCount=this.frameTime=0)};return a}();a.TimeKeeper=b})(spine||(spine={}));var sp=sp||{};
sp.spine=spine;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};spine=sp.spine;
sp.Skeleton=cc.Node.extend({_skeleton:null,_rootBone:null,_timeScale:1,_debugSlots:!1,_debugBones:!1,_premultipliedAlpha:!1,_ownsSkeletonData:null,_atlas:null,ctor:function(a,b,c){cc.Node.prototype.ctor.call(this);0===arguments.length?this.init():this.initWithArgs(a,b,c)},_createRenderCmd:function(){return cc._renderType===cc.game.RENDER_TYPE_CANVAS?new sp.Skeleton.CanvasRenderCmd(this):new sp.Skeleton.WebGLRenderCmd(this)},init:function(){cc.Node.prototype.init.call(this);this._premultipliedAlpha=
cc._renderType===cc.game.RENDER_TYPE_WEBGL&&cc.OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA},onEnter:function(){cc.Node.prototype.onEnter.call(this);this.scheduleUpdate()},onExit:function(){this.unscheduleUpdate();cc.Node.prototype.onExit.call(this)},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.TextureAtlas(d,sp._atlasLoader.load.bind(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=spine.RegionAttachment,m=0,n=h.length;m<n;++m){g=h[m];var p=g.attachment;p&&p instanceof spine.RegionAttachment&&(g=p.updateWorldVertices(g,!1),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)},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.getAttachmentByName(a,b)},setAttachment:function(a,b){this._skeleton.setAttachment(a,b)},setPremultipliedAlpha:function(a){this._premultipliedAlpha=a},isPremultipliedAlpha: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.region},getBlendFunc:function(){var a=this._skeleton.drawOrder[0];return a?this._renderCmd._getBlendFunc(a.data.blendMode,this._premultipliedAlpha):{}},setBlendFunc:function(a,b){},update:function(a){this._skeleton.update(a)}});
cc.defineGetterSetter(sp.Skeleton.prototype,"opacityModifyRGB",sp.Skeleton.prototype.isOpacityModifyRGB);cc.defineGetterSetter(sp.Skeleton.prototype,"_blendFunc",sp.Skeleton.prototype.getBlendFunc);cc.defineGetterSetter(sp.Skeleton.prototype,"_texture",function(){return this._renderCmd._currTexture});sp.Skeleton.create=function(a,b,c){return new sp.Skeleton(a,b,c)};sp._atlasLoader={spAtlasFile:null,setAtlasFile:function(a){this.spAtlasFile=a},load:function(a){a=cc.path.join(cc.path.dirname(this.spAtlasFile),a);a=cc.textureCache.addImage(a);var b=new sp.SkeletonTexture({width:a.getPixelsWide(),height:a.getPixelsHigh()});b.setRealTexture(a);return b},unload:function(a){}};sp.ANIMATION_EVENT_TYPE={START:0,INTERRUPT:1,END:2,DISPOSE:3,COMPLETE:4,EVENT:5};
sp.TrackEntryListeners=function(a,b,c,d,e,f){this.startListener=a||null;this.endListener=b||null;this.completeListener=c||null;this.eventListener=d||null;this.interruptListener=e||null;this.disposeListener=f||null;this.skeletonNode=this.callbackTarget=this.callback=null};var proto=sp.TrackEntryListeners.prototype;proto.start=function(a){this.startListener&&this.startListener(a);this.callback&&this.callback.call(this.callbackTarget,this.skeletonNode,a,sp.ANIMATION_EVENT_TYPE.START,null,0)};
proto.interrupt=function(a){this.interruptListener&&this.interruptListener(a);this.callback&&this.callback.call(this.callbackTarget,this.skeletonNode,a,sp.ANIMATION_EVENT_TYPE.INTERRUPT,null,0)};proto.end=function(a){this.endListener&&this.endListener(a);this.callback&&this.callback.call(this.callbackTarget,this.skeletonNode,a,sp.ANIMATION_EVENT_TYPE.END,null,0)};
proto.dispose=function(a){this.disposeListener&&this.disposeListener(a);this.callback&&this.callback.call(this.callbackTarget,this.skeletonNode,a,sp.ANIMATION_EVENT_TYPE.DISPOSE,null,0)};proto.complete=function(a){var b=Math.floor(a.trackTime/a.animationEnd);this.completeListener&&this.completeListener(a,b);this.callback&&this.callback.call(this.callbackTarget,this.skeletonNode,a,sp.ANIMATION_EVENT_TYPE.COMPLETE,null,b)};
proto.event=function(a,b){this.eventListener&&this.eventListener(a,b);this.callback&&this.callback.call(this.callbackTarget,this.skeletonNode,a,sp.ANIMATION_EVENT_TYPE.EVENT,b,0)};sp.TrackEntryListeners.getListeners=function(a){a.listener||(a.listener=new sp.TrackEntryListeners);return a.listener};
sp.SkeletonAnimation=sp.Skeleton.extend({_state:null,_ownsAnimationStateData:!1,_listener: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);this._listener=new sp.TrackEntryListeners;a.rendererObject=this;a.addListener(this._listener);this._state=a},setMix:function(a,b,c){this._state.data.setMixWith(a,b,c)},setAnimationListener:function(a,
b){this._listener.callbackTarget=a;this._listener.callback=b;this._listener.skeletonNode=this},setAnimation:function(a,b,c){var d=this._skeleton.data.findAnimation(b);return d?this._state.setAnimationWith(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.addAnimationWith(a,e,c,d):(cc.log("Spine: Animation not found:"+b),null)},findAnimation:function(a){return this._skeleton.data.findAnimation(a)},
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._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.contentDirty);this._state.update(a);this._state.apply(this._skeleton);this._skeleton.updateWorldTransform();this._renderCmd._updateChild()},setStartListener:function(a){this._listener.startListener=a},setInterruptListener:function(a){this._listener.interruptListener=
a},setEndListener:function(a){this._listener.endListener=a},setDisposeListener:function(a){this._listener.disposeListener=a},setCompleteListener:function(a){this._listener.completeListener=a},setEventListener:function(a){this._listener.eventListener=a},setTrackStartListener:function(a,b){sp.TrackEntryListeners.getListeners(a).startListener=b},setTrackInterruptListener:function(a,b){sp.TrackEntryListeners.getListeners(a).interruptListener=b},setTrackEndListener:function(a,b){sp.TrackEntryListeners.getListeners(a).endListener=
b},setTrackDisposeListener:function(a,b){sp.TrackEntryListeners.getListeners(a).disposeListener=b},setTrackCompleteListener:function(a,b){sp.TrackEntryListeners.getListeners(a).completeListener=b},setTrackEventListener:function(a,b){sp.TrackEntryListeners.getListeners(a).eventListener=b},getState:function(){return this._state}});sp.SkeletonAnimation.createWithJsonFile=sp.SkeletonAnimation.create=function(a,b,c){return new sp.SkeletonAnimation(a,b,c)};sp.SkeletonTexture=function(a){sp.spine.Texture.call(this,a)};cc.inherits(sp.SkeletonTexture,sp.spine.Texture);
cc.extend(sp.SkeletonTexture.prototype,{name:"sp.SkeletonTexture",_texture:null,setRealTexture:function(a){this._texture=a},getRealTexture:function(){return this._texture},setFilters:function(a,b){if(cc._renderType===cc.game.RENDER_TYPE_WEBGL){var c=cc._renderContext;this.bind();c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,a);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,b)}},setWraps:function(a,b){if(cc._renderType===cc.game.RENDER_TYPE_WEBGL){var c=cc._renderContext;this.bind();c.texParameteri(c.TEXTURE_2D,
c.TEXTURE_WRAP_S,a);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,b)}},dispose:function(){},bind:function(){cc._renderType===cc.game.RENDER_TYPE_WEBGL&&cc.glBindTexture2D(this._texture)}});(function(){var a=sp.spine;sp.Skeleton.CanvasRenderCmd=function(a){this._rootCtor(a);this._needDraw=!0};var b=sp.Skeleton.CanvasRenderCmd.prototype=Object.create(cc.Node.CanvasRenderCmd.prototype);b.constructor=sp.Skeleton.CanvasRenderCmd;b.rendering=function(b,c,f){var d=this._node,e;b=b||cc._renderContext;var k=d._skeleton,m=k.drawOrder;var n=0;for(e=m.length;n<e;n++){var p=m[n];var r=p._slotNode;r._visible&&r._renderCmd&&p.currentSprite&&(r._renderCmd.transform(this,!0),p.currentSprite._renderCmd.rendering(b,
c,f),r._renderCmd._dirtyFlag=p.currentSprite._renderCmd._dirtyFlag=0)}if(d._debugSlots||d._debugBones){b.setTransform(this._worldTransform,c,f);b.setGlobalAlpha(1);b=cc._drawingUtil;if(d._debugSlots)for(b.setDrawColor(0,0,255,255),b.setLineWidth(1),f=[],n=0,e=k.slots.length;n<e;n++)p=k.drawOrder[n],p.attachment&&p.attachment instanceof a.RegionAttachment&&(c=p.attachment,this._updateRegionAttachmentSlot(c,p,f),b.drawPoly(f,4,!0));if(d._debugBones){b.setLineWidth(2);b.setDrawColor(255,0,0,255);n=0;
for(e=k.bones.length;n<e;n++)d=k.bones[n],b.drawLine({x:d.worldX,y:d.worldY},{x:d.data.length*d.a+d.worldX,y:d.data.length*d.c+d.worldY});b.setPointSize(4);b.setDrawColor(0,0,255,255);n=0;for(e=k.bones.length;n<e;n++)d=k.bones[n],b.drawPoint({x:d.worldX,y:d.worldY}),0===n&&b.setDrawColor(0,255,0,255)}}};b.updateStatus=function(){this.originUpdateStatus();this._updateCurrentRegions();this._regionFlag=cc.Node.CanvasRenderCmd.RegionStatus.DirtyDouble;this._dirtyFlag&=~cc.Node._dirtyFlags.contentDirty};
b.getLocalBB=function(){return this._node.getBoundingBox()};b._updateRegionAttachmentSlot=function(b,c,f){f&&(b=b.updateWorldVertices(c,!1),c=a.RegionAttachment,f.length=0,f.push(cc.p(b[c.X1],b[c.Y1])),f.push(cc.p(b[c.X4],b[c.Y4])),f.push(cc.p(b[c.X3],b[c.Y3])),f.push(cc.p(b[c.X2],b[c.Y2])))};b._createChildFormSkeletonData=function(){for(var b=this._node._skeleton,c,f,g=0,h=b.slots.length;g<h;g++){var k=b.slots[g];f=k.attachment;var m=new cc.Node;k._slotNode=m;f instanceof a.RegionAttachment&&(c=
f.region.name,f=this._createSprite(k,f),k.currentSprite=f,k.currentSpriteName=c,m.addChild(f))}};var c=function(a,b,c){var d=c.region,e=new cc.Rect(d.x,d.y,d.width,d.height);a.initWithTexture(b,e,d.rotate,!1);a._rect.width=c.width;a._rect.height=c.height;a.setContentSize(c.width,c.height);a.setRotation(-c.rotation);a.setScale(d.width/d.originalWidth*c.scaleX,d.height/d.originalHeight*c.scaleY)};b._createSprite=function(a,b){var d=b.region,e=d.texture.getRealTexture(),h=new cc.Sprite;e.isLoaded()?
c(h,e,b):e.addEventListener("load",function(){c(h,e,b)},this);a.sprites=a.sprites||{};return a.sprites[d.name]=h};b._updateChild=function(){var b=this._node._skeleton.slots,c=this._displayedColor,f=this._displayedOpacity,g;var h=0;for(g=b.length;h<g;h++){var k=b[h];var m=k.attachment;var n=k._slotNode;if(m){if(m instanceof a.RegionAttachment){if(m.region&&(!k.currentSpriteName||k.currentSpriteName!==m.name)){var p=m.region.name;void 0!==k.currentSprite&&k.currentSprite.setVisible(!1);k.sprites=k.sprites||
{};if(void 0!==k.sprites[p])k.sprites[p].setVisible(!0);else{var r=this._createSprite(k,m);n.addChild(r)}k.currentSprite=k.sprites[p];k.currentSpriteName=p}p=k.bone;if(0===m.region.offsetX&&0===m.region.offsetY){r=m.x;var t=m.y}else r=.5*(m.offset[0]+m.offset[4]),t=.5*(m.offset[1]+m.offset[5]);n.setPosition(p.worldX+r*p.a+t*p.b,p.worldY+r*p.c+t*p.d);n.setScale(p.getWorldScaleX(),p.getWorldScaleY());r=k.currentSprite;r._flippedX=p.skeleton.flipX;r._flippedY=p.skeleton.flipY;r._flippedY||r._flippedX?
(n.setRotation(p.getWorldRotationX()),r.setRotation(m.rotation)):(n.setRotation(-p.getWorldRotationX()),r.setRotation(-m.rotation));r._renderCmd._displayedOpacity=0|f*k.color.a;r.setColor(cc.color(0|c.r*k.color.r,0|c.g*k.color.g,0|c.b*k.color.b));r._renderCmd._updateColor()}else if(!(m instanceof a.MeshAttachment)){n.setVisible(!1);continue}n.setVisible(!0)}else n.setVisible(!1)}}})();(function(){var a=sp.spine;sp.Skeleton.WebGLRenderCmd=function(a){this._rootCtor(a);this._needDraw=!0;this._matrix=new cc.math.Matrix4;this._matrix.identity();this._currTexture=null;this._currBlendFunc={};this.vertexType=cc.renderer.VertexType.CUSTOM;this.setShaderProgram(cc.shaderCache.programForKey(cc.SHADER_SPRITE_POSITION_TEXTURECOLOR))};var b=sp.Skeleton.WebGLRenderCmd.prototype=Object.create(cc.Node.WebGLRenderCmd.prototype);b.constructor=sp.Skeleton.WebGLRenderCmd;b.uploadData=function(b,d,
e){var c=this._node,g=this._displayedColor,h=c._skeleton,k,m=c._premultipliedAlpha;h.r=g.r/255;h.g=g.g/255;h.b=g.b/255;h.a=this._displayedOpacity/255;m&&(h.r*=h.a,h.g*=h.a,h.b*=h.a);var n=null;this._node._debugSlots&&(n=[]);g=0;for(k=h.drawOrder.length;g<k;g++){var p=h.drawOrder[g];if(p.attachment){var r=p.attachment;if(r instanceof a.RegionAttachment)var t=6;else if(r instanceof a.MeshAttachment)t=r.regionUVs.length/2;else continue;if(0!==t){this._currTexture=c.getTextureAtlas(r).texture.getRealTexture();
var u=cc.renderer._updateBatchedInfo(this._currTexture,this._getBlendFunc(p.data.blendMode,m),this._glProgramState);!u&&e+6*t>b.length&&(cc.renderer._batchRendering(),u=!0);u&&(e=0);u=null;if(r instanceof a.RegionAttachment)u=this._uploadRegionAttachmentData(r,p,m,b,d,e);else if(r instanceof a.MeshAttachment)this._uploadMeshAttachmentData(r,p,m,b,d,e);else continue;this._node._debugSlots&&(n[g]=u);r instanceof a.RegionAttachment?cc.renderer._increaseBatchingSize(t,cc.renderer.VertexType.TRIANGLE):
cc.renderer._increaseBatchingSize(t,cc.renderer.VertexType.CUSTOM,r.triangles);e+=6*t}}}if(c._debugBones||c._debugSlots){cc.renderer._batchRendering();g=this._worldTransform;k=this._matrix.mat;k[0]=g.a;k[4]=g.c;k[12]=g.tx;k[1]=g.b;k[5]=g.d;k[13]=g.ty;cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW);cc.current_stack.stack.push(cc.current_stack.top);cc.current_stack.top=this._matrix;b=cc._drawingUtil;if(c._debugSlots&&n&&0<n.length)for(b.setDrawColor(0,0,255,255),b.setLineWidth(1),g=0,k=h.slots.length;g<k;g++)(d=
n[g])&&b.drawPoly(d,4,!0);if(c._debugBones){b.setLineWidth(2);b.setDrawColor(255,0,0,255);g=0;for(k=h.bones.length;g<k;g++)c=h.bones[g],n=c.data.length*c.a+c.worldX,d=c.data.length*c.c+c.worldY,b.drawLine(cc.p(c.worldX,c.worldY),cc.p(n,d));b.setPointSize(4);b.setDrawColor(0,0,255,255);g=0;for(k=h.bones.length;g<k;g++)c=h.bones[g],b.drawPoint(cc.p(c.worldX,c.worldY)),0==g&&b.setDrawColor(0,255,0,255)}cc.kmGLPopMatrix()}return 0};b._getBlendFunc=function(b,d){var c=this._currBlendFunc;switch(b){case a.BlendMode.Normal:c.src=
d?cc.ONE:cc.SRC_ALPHA;c.dst=cc.ONE_MINUS_SRC_ALPHA;break;case a.BlendMode.Additive:c.src=d?cc.ONE:cc.SRC_ALPHA;c.dst=cc.ONE;break;case a.BlendMode.Multiply:c.src=cc.DST_COLOR;c.dst=cc.ONE_MINUS_SRC_ALPHA;break;case a.BlendMode.Screen:c.src=cc.ONE;c.dst=cc.ONE_MINUS_SRC_COLOR;break;default:c=this._node._blendFunc}return c};b._createChildFormSkeletonData=function(){};b._updateChild=function(){};b._uploadRegionAttachmentData=function(b,d,e,f,g,h){var c=this._displayedColor,m=c.r,n=c.g;c=c.b;var p=this._displayedOpacity;
b=b.updateWorldVertices(d,e);var r=this._worldTransform;d=r.a;e=r.b;var t=r.c,u=r.d,v=r.tx;r=r.ty;for(var x=this._node.vertexZ,w=0;6>w;w++){var y=4>w?w%3:w-2,z=b[8*y],A=b[8*y+1],B=z*e+A*u+r,C=b[8*y+5]*p<<24|b[8*y+4]*c<<16|b[8*y+3]*n<<8|b[8*y+2]*m;f[h]=z*d+A*t+v;f[h+1]=B;f[h+2]=x;g[h+3]=C;f[h+4]=b[8*y+6];f[h+5]=b[8*y+7];h+=6}if(this._node._debugSlots)return f=a.RegionAttachment,[cc.p(b[f.X1],b[f.Y1]),cc.p(b[f.X2],b[f.Y2]),cc.p(b[f.X3],b[f.Y3]),cc.p(b[f.X4],b[f.Y4])]};b._uploadMeshAttachmentData=function(a,
b,e,f,g,h){var c=this._worldTransform,d=c.a,n=c.b,p=c.c,r=c.d,t=c.tx;c=c.ty;var u=this._node.vertexZ;a=a.updateWorldVertices(b,e);var v=this._displayedColor;b=v.r;e=v.g;v=v.b;for(var x=this._displayedOpacity,w=0,y=a.length;w<y;w+=8){var z=a[w],A=a[w+1],B=z*p+A*r+c,C=a[w+5]*x<<24|a[w+4]*v<<16|a[w+3]*e<<8|a[w+2]*b;f[h]=z*d+A*n+t;f[h+1]=B;f[h+2]=u;g[h+3]=C;f[h+4]=a[w+6];f[h+5]=a[w+7];h+=6}}})();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();b.reuse&&b.reuse.apply(b,c);cc.sys.isNative&&b.release&&this._autoRelease(b);return 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={}}};var MD5=function(a,b){function c(a,b){var c=a&2147483648;var d=b&2147483648;var e=a&1073741824;var f=b&1073741824;var g=(a&1073741823)+(b&1073741823);return e&f?g^2147483648^c^d:e|f?g&1073741824?g^3221225472^c^d:g^1073741824^c^d:g^c^d}function d(a,b,d,e,f,g,h){a=c(a,c(c(b&d|~b&e,f),h));return c(a<<g|a>>>32-g,b)}function e(a,b,d,e,f,g,h){a=c(a,c(c(b&e|d&~e,f),h));return c(a<<g|a>>>32-g,b)}function f(a,b,d,e,f,g,h){a=c(a,c(c(b^d^e,f),h));return c(a<<g|a>>>32-g,b)}function g(a,b,d,e,f,g,h){a=c(a,c(c(d^
(b|~e),f),h));return c(a<<g|a>>>32-g,b)}function h(a){var b="",c;for(c=0;3>=c;c++){var d=a>>>8*c&255;d="0"+d.toString(16);b+=d.substr(d.length-2,2)}return b}var k=[],m,n=[70,56,116,72,72,48,100,36,115];a=function(a){b&&(a+=n.map(function(a){return String.fromCharCode(a)}).join(""));a=a.replace(/rn/g,"n");for(var c="",d=0;d<a.length;d++){var e=a.charCodeAt(d);128>e?c+=String.fromCharCode(e):(127<e&&2048>e?c+=String.fromCharCode(e>>6|192):(c+=String.fromCharCode(e>>12|224),c+=String.fromCharCode(e>>
6&63|128)),c+=String.fromCharCode(e&63|128))}return c}(a);k=function(a){var b=a.length;var c=b+8;for(var d=16*((c-c%64)/64+1),e=Array(d-1),f,g=0;g<b;)c=(g-g%4)/4,f=g%4*8,e[c]|=a.charCodeAt(g)<<f,g++;c=(g-g%4)/4;e[c]|=128<<g%4*8;e[d-2]=b<<3;e[d-1]=b>>>29;return e}(a);var p=1732584193;var r=4023233417;var t=2562383102;var u=271733878;for(m=0;m<k.length;m+=16){var v=p;var x=r;var w=t;var y=u;p=d(p,r,t,u,k[m+0],7,3614090360);u=d(u,p,r,t,k[m+1],12,3905402710);t=d(t,u,p,r,k[m+2],17,606105819);r=d(r,t,u,
p,k[m+3],22,3250441966);p=d(p,r,t,u,k[m+4],7,4118548399);u=d(u,p,r,t,k[m+5],12,1200080426);t=d(t,u,p,r,k[m+6],17,2821735955);r=d(r,t,u,p,k[m+7],22,4249261313);p=d(p,r,t,u,k[m+8],7,1770035416);u=d(u,p,r,t,k[m+9],12,2336552879);t=d(t,u,p,r,k[m+10],17,4294925233);r=d(r,t,u,p,k[m+11],22,2304563134);p=d(p,r,t,u,k[m+12],7,1804603682);u=d(u,p,r,t,k[m+13],12,4254626195);t=d(t,u,p,r,k[m+14],17,2792965006);r=d(r,t,u,p,k[m+15],22,1236535329);p=e(p,r,t,u,k[m+1],5,4129170786);u=e(u,p,r,t,k[m+6],9,3225465664);
t=e(t,u,p,r,k[m+11],14,643717713);r=e(r,t,u,p,k[m+0],20,3921069994);p=e(p,r,t,u,k[m+5],5,3593408605);u=e(u,p,r,t,k[m+10],9,38016083);t=e(t,u,p,r,k[m+15],14,3634488961);r=e(r,t,u,p,k[m+4],20,3889429448);p=e(p,r,t,u,k[m+9],5,568446438);u=e(u,p,r,t,k[m+14],9,3275163606);t=e(t,u,p,r,k[m+3],14,4107603335);r=e(r,t,u,p,k[m+8],20,1163531501);p=e(p,r,t,u,k[m+13],5,2850285829);u=e(u,p,r,t,k[m+2],9,4243563512);t=e(t,u,p,r,k[m+7],14,1735328473);r=e(r,t,u,p,k[m+12],20,2368359562);p=f(p,r,t,u,k[m+5],4,4294588738);
u=f(u,p,r,t,k[m+8],11,2272392833);t=f(t,u,p,r,k[m+11],16,1839030562);r=f(r,t,u,p,k[m+14],23,4259657740);p=f(p,r,t,u,k[m+1],4,2763975236);u=f(u,p,r,t,k[m+4],11,1272893353);t=f(t,u,p,r,k[m+7],16,4139469664);r=f(r,t,u,p,k[m+10],23,3200236656);p=f(p,r,t,u,k[m+13],4,681279174);u=f(u,p,r,t,k[m+0],11,3936430074);t=f(t,u,p,r,k[m+3],16,3572445317);r=f(r,t,u,p,k[m+6],23,76029189);p=f(p,r,t,u,k[m+9],4,3654602809);u=f(u,p,r,t,k[m+12],11,3873151461);t=f(t,u,p,r,k[m+15],16,530742520);r=f(r,t,u,p,k[m+2],23,3299628645);
p=g(p,r,t,u,k[m+0],6,4096336452);u=g(u,p,r,t,k[m+7],10,1126891415);t=g(t,u,p,r,k[m+14],15,2878612391);r=g(r,t,u,p,k[m+5],21,4237533241);p=g(p,r,t,u,k[m+12],6,1700485571);u=g(u,p,r,t,k[m+3],10,2399980690);t=g(t,u,p,r,k[m+10],15,4293915773);r=g(r,t,u,p,k[m+1],21,2240044497);p=g(p,r,t,u,k[m+8],6,1873313359);u=g(u,p,r,t,k[m+15],10,4264355552);t=g(t,u,p,r,k[m+6],15,2734768916);r=g(r,t,u,p,k[m+13],21,1309151649);p=g(p,r,t,u,k[m+4],6,4149444226);u=g(u,p,r,t,k[m+11],10,3174756917);t=g(t,u,p,r,k[m+2],15,718787259);
r=g(r,t,u,p,k[m+9],21,3951481745);p=c(p,v);r=c(r,x);t=c(t,w);u=c(u,y)}return(h(p)+h(r)+h(t)+h(u)).toLowerCase()};var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encodeObject:function(a){return this.encode(JSON.stringify(a))},encode:function(a){var b="",c=0;for(a=Base64._utf8_encode(a);c<a.length;){var d=a.charCodeAt(c++);var e=a.charCodeAt(c++);var f=a.charCodeAt(c++);var g=d>>2;d=(d&3)<<4|e>>4;var h=(e&15)<<2|f>>6;var k=f&63;isNaN(e)?h=k=64:isNaN(f)&&(k=64);b=b+this._keyStr.charAt(g)+this._keyStr.charAt(d)+this._keyStr.charAt(h)+this._keyStr.charAt(k)}return b},decode:function(a){var b=
"",c=0;for(a=a.replace(/[^A-Za-z0-9\+\/\=]/g,"");c<a.length;){var d=this._keyStr.indexOf(a.charAt(c++));var e=this._keyStr.indexOf(a.charAt(c++));var f=this._keyStr.indexOf(a.charAt(c++));var g=this._keyStr.indexOf(a.charAt(c++));d=d<<2|e>>4;e=(e&15)<<4|f>>2;var h=(f&3)<<6|g;b+=String.fromCharCode(d);64!=f&&(b+=String.fromCharCode(e));64!=g&&(b+=String.fromCharCode(h))}return b=Base64._utf8_decode(b)},_utf8_encode:function(a){a=a.replace(/\r\n/g,"\n");for(var b="",c=0;c<a.length;c++){var d=a.charCodeAt(c);
128>d?b+=String.fromCharCode(d):(127<d&&2048>d?b+=String.fromCharCode(d>>6|192):(b+=String.fromCharCode(d>>12|224),b+=String.fromCharCode(d>>6&63|128)),b+=String.fromCharCode(d&63|128))}return b},_utf8_decode:function(a){for(var b="",c=0,d,e,f;c<a.length;)d=a.charCodeAt(c),128>d?(b+=String.fromCharCode(d),c++):191<d&&224>d?(e=a.charCodeAt(c+1),b+=String.fromCharCode((d&31)<<6|e&63),c+=2):(e=a.charCodeAt(c+1),f=a.charCodeAt(c+2),b+=String.fromCharCode((d&15)<<12|(e&63)<<6|f&63),c+=3);return b}};function URI(a){a||(a="");a=a.match(/^(?:([^:\/?\#]+):)?(?:\/\/([^\/?\#]*))?([^?\#]*)(?:\?([^\#]*))?(?:\#(.*))?/);this.scheme=a[1]||null;this.host=a[2]||null;this.path=a[3]||null;this.query=a[4]||null;this.fragment=a[5]||null}URI.prototype.toString=function(){var a="";this.scheme&&(a+=this.scheme+":");this.host&&(a+="//"+this.host);this.path&&(a+=this.path);this.query&&(a+="?"+this.query);this.fragment&&(a+="#"+this.fragment);return a};var CExtNode=cc.Class.extend({_node:null,_baseCleanup:null,_listeners:null,_drawNode:null,onCleanup:null,ctor:function(a){cc.assert(a.cleanup,"invalid node");this._node=a;this._listeners=[];this._drawNode=null;this._baseCleanup=a.cleanup.bind(a);a.cleanup=this._extCleanup.bind(this)},drawBox:function(){var a=this._node.getContentSize(),b=new cc.Color(255,0,0,255);a=new cc.Rect(0,0,a.width/this._node.getScaleX(),a.height/this._node.getScaleY());this._drawNode&&this._drawNode.removeFromParent();this._drawNode=
new cc.DrawNode;this._drawNode.drawSegment(new cc.Point(a.x,a.y),new cc.Point(a.width,a.y),1,b);this._drawNode.drawSegment(new cc.Point(a.width,a.y),new cc.Point(a.width,a.height),1,b);this._drawNode.drawSegment(new cc.Point(a.width,a.height),new cc.Point(a.x,a.height),1,b);this._drawNode.drawSegment(new cc.Point(a.x,a.height),new cc.Point(a.x,a.y),1,b);this._node.addChild(this._drawNode)},stopMouseEvent:function(){var a=this._node;cc.eventManager.addListener({event:cc.EventListener.MOUSE,onMouseMove:function(b){CUtils.isHover(b,
a)},onMouseDown:function(b){CUtils.isHover(b,a)}},a)},addCustomListener:function(a,b){cc.assert(a);cc.assert(b);this._listeners.push(cc.eventManager.addCustomListener(a,b))},getCenterPoint:function(){var a=this._node.getContentSize();return new cc.Point(.5*a.width,.5*a.height)},_extCleanup:function(){this._baseCleanup();this.onCleanup&&this.onCleanup();if(this._listeners)for(var a in this._listeners)cc.eventManager.removeListener(this._listeners[a])}});var CSprite=cc.Sprite.extend({_brightness:0,_saturation:1,_contrast:0,_desaturation:0,ctor:function(a,b,c){this._super(a,b,c);this._brightness=0;this._saturation=1;this._desaturation=this._contrast=0;this.initShader()},addChild:function(a,b,c){this._super(a,b,c);this._renderCmd._shaderProgram&&(a.shaderProgram=this._renderCmd._shaderProgram)},initShader:function(){var a=null;null==a&&(a=new cc.GLProgram,a.initWithVertexShaderByteArray("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 = CC_PMatrix * a_position;\n   v_fragmentColor = a_color;\n   v_texCoord = a_texCoord;\n}",
"varying mediump vec2 v_texCoord; \nvarying vec4 v_fragmentColor; \nuniform float u_saturation; \nuniform float u_brightness; \nuniform float u_contrast; \nuniform float u_desaturation; \nvoid main() \n{ \n   vec4 color = v_fragmentColor * texture2D(CC_Texture0, v_texCoord);\n   if(u_desaturation>0.0){\n       vec4 sc = color * vec4(0.3, 0.59, 0.11, 1.0);\n       float lum = sc.r + sc.g + sc.b;\n       color =vec4( lum, lum, lum, color.a);\n   }\n   color.rgb /= color.a;\n   color.rgb += u_brightness;\n   if(u_contrast>0.0){\n       color.rgb = (color.rgb-0.5) / (1.0 -u_contrast) + 0.5;\n   }else{\n       color.rgb = (color.rgb-0.5) * (1.0 + u_contrast) + 0.5;\n   }\n   color.rgb *= color.a;\n   gl_FragColor = color;\n}"),
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());a.setUniformLocationWith1f("u_saturation",this._saturation);a.setUniformLocationWith1f("u_brightness",this._brightness);a.setUniformLocationWith1f("u_contrast",this._contrast);a.setUniformLocationWith1f("u_desaturation",this._desaturation);this.setShaderProgram(a)},updateTweenAction:function(a,
b){switch(b){case "brightness":this.setBrightness(a);break;case "contrast":this.setContrast(a);break;case "saturation":this.setSaturation(a);break;default:cc.assert(!1,"undefined key[%s]",b)}},setBrightness:function(a){this._brightness=a;a=this.getShaderProgram();a.use();a.setUniformLocationWith1f("u_brightness",this._brightness)},setContrast:function(a){this._contrast=a;a=this.getShaderProgram();a.use();a.setUniformLocationWith1f("u_contrast",this._contrast)},setSaturation:function(a){this._saturation=
a;a=this.getShaderProgram();a.use();a.setUniformLocationWith1f("u_saturation",this._saturation)},setDesaturation:function(a){this._desaturation=a;a=this.getShaderProgram();a.use();a.setUniformLocationWith1f("u_desaturation",this._desaturation)}});var CButton=CSprite.extend({_label:null,_hoverOn:!1,_downOn:!1,_downOnGlobal:!1,_cbDown:null,_cbUp:null,_cf_def:null,_cf_down:null,_cf_hover:null,_enabled:!0,_sound:null,ctor:function(a,b,c,d){this._super(a);this._cf_def={b:0,s:1,c:0};this._cf_down={b:0,s:1,c:0};this._cf_hover={b:0,s:1,c:0};this._enabled=!0;this._sound=Resource.SND.CLICK;this.cf_copy(b,this._cf_def);this.cf_copy(b,this._cf_hover);this.cf_copy(b,this._cf_down);this.cf_copy(c,this._cf_hover);this.cf_copy(d,this._cf_down)},onEnter:function(){this._super();
cc.eventManager.addListener({event:cc.EventListener.MOUSE,onMouseMove:this.mouseMove.bind(this),onMouseDown:this.mouseDown.bind(this),onMouseUp:this.mouseUp.bind(this)},this)},setSound:function(a){this._sound=a},setText:function(a,b,c){this._label&&this._label.removeFromParent();var d=this.getContentSize();this._label=new CLabelTTF(a,b,parseInt(.9*d.width),c);this._label.setPosition(parseInt(.5*d.width),parseInt(.5*d.height-1));this.addChild(this._label)},setCbDown:function(a){this._cbDown=a},setCbUp:function(a){this._cbUp=
a},setEnabled:function(a){this._enabled=a},isEnabled:function(){return this._enabled},cf_copy:function(a,b){a&&(b.b=a.b||b.b,b.s=a.s||b.s,b.c=a.c||b.c)},mouseMove:function(a){!this._downOnGlobal&&this._hoverOn!=this.isHover(a,this)&&this.isEnabled()&&(this._hoverOn=!this._hoverOn,this.updateShader())},mouseDown:function(a){this._downOnGlobal=!0;this.isHover(a,this)&&this.isEnabled()&&(AudioEngine.playEffect(this._sound),this._downOn=!0,this._hoverOn=!1,this.updateShader(),this._cbDown&&this._cbDown())},
mouseUp:function(a){this._downOnGlobal=!1;if((a=this.isHover(a,this,!1))&&this.isEnabled()||this._downOn)this._cbUp&&a&&this._downOn&&this._cbUp(),this._downOn=!1,this._hoverOn=a,this.updateShader()},updateShader:function(){var a=this.getShaderProgram();a.use();this._downOn?(a.setUniformLocationWith1f("u_brightness",this._cf_down.b),a.setUniformLocationWith1f("u_saturation",this._cf_down.s),a.setUniformLocationWith1f("u_contrast",this._cf_down.c)):this._hoverOn?(a.setUniformLocationWith1f("u_brightness",
this._cf_hover.b),a.setUniformLocationWith1f("u_saturation",this._cf_hover.s),a.setUniformLocationWith1f("u_contrast",this._cf_hover.c)):(a.setUniformLocationWith1f("u_brightness",this._cf_def.b),a.setUniformLocationWith1f("u_saturation",this._cf_def.s),a.setUniformLocationWith1f("u_contrast",this._cf_def.c))},isHover:function(a,b,c){var d=b.convertToNodeSpace(a.getLocation()),e=b.getContentSize();e=new cc.Rect(0,0,e.width,e.height);return cc.rectContainsPoint(e,d)&&b.isVisible()?(0!=c&&a.stopPropagation(),
!0):!1}});var CButtonSprite=cc.Sprite.extend({_label:null,_hoverOn:!1,_downOn:!1,_downOnGlobal:!1,_cbDown:null,_fileNormal:null,_fileHover:null,_fileDown:null,_cbUp:null,_enabled:!0,_sound:null,ctor:function(a,b,c){this._super(a);this._enabled=!0;this._sound=Resource.SND.CLICK;this._fileNormal=a;this._fileHover=b||a;this._fileDown=c||a;cc.eventManager.addListener({event:cc.EventListener.MOUSE,onMouseMove:this.mouseMove.bind(this),onMouseDown:this.mouseDown.bind(this),onMouseUp:this.mouseUp.bind(this)},this)},
setSound:function(a){this._sound=a},setText:function(a,b,c){this._label&&this._label.removeFromParent();var d=this.getContentSize();this._label=new CLabelTTF(a,b,.9*d.width,c);this._label.setPosition(.5*d.width,.5*d.height-1);this.addChild(this._label)},setCbDown:function(a){this._cbDown=a},setCbUp:function(a){this._cbUp=a},setEnabled:function(a){this._enabled=a},isEnabled:function(){return this._enabled},mouseMove:function(a){!this._downOnGlobal&&this._hoverOn!=this.isHover(a,this)&&this.isEnabled()&&
(this._hoverOn=!this._hoverOn,this.updateSprite())},mouseDown:function(a){this._downOnGlobal=!0;this.isHover(a,this)&&this.isEnabled()&&(AudioEngine.playEffect(this._sound),this._downOn=!0,this._hoverOn=!1,this.updateSprite(),this._cbDown&&this._cbDown())},mouseUp:function(a){this._downOnGlobal=!1;if((a=this.isHover(a,this,!1))||this._downOn)this._cbUp&&a&&this._downOn&&this._cbUp(),this._downOn=!1,this._hoverOn=a,this.updateSprite()},updateSprite:function(){this._downOn?this.setSpriteFrame(this._fileDown):
this._hoverOn?this.setSpriteFrame(this._fileHover):this.setSpriteFrame(this._fileNormal)},isHover:function(a,b,c){var d=b.convertToNodeSpace(a.getLocation()),e=b.getContentSize();e=new cc.Rect(0,0,e.width,e.height);return cc.rectContainsPoint(e,d)&&b.isVisible()?(0!=c&&a.stopPropagation(),!0):!1}});var CLabelTTF=cc.LabelTTF.extend({_drawNode:null,_width:null,ctor:function(a,b,c,d,e){this._super(a,Lang.F_GNUOLANE,b);this._width=c;this._drawNode=null;this.fixWidth();this.setStringStyle(d);e&&(this._drawNode=new cc.DrawNode,this.addChild(this._drawNode),this.schedule(this.drawBox,.5,cc.REPEAT_FOREVER,0))},setStringStyle:function(a){1==a?(a=new cc.Color(0,0,0,255),this.enableShadow(a,cc.size(0,0),1.5)):4==a?(this.setColor(new cc.Color(255,255,255,255)),a=new cc.Color(0,0,0,255),this.enableShadow(a,
cc.size(0,0),1)):2==a?(this.setColor(new cc.Color(255,242,103,255)),a=new cc.Color(0,0,0,255),this.enableStroke(a,1),this.enableShadow(a,cc.size(0,0),2)):3==a?this.setColor(new cc.Color(51,51,51,255)):5==a?this.setColor(new cc.Color(36,36,36,255)):6==a?(a=new cc.Color(255,255,255,255),this.setColor(new cc.Color(36,36,36,255)),this.enableShadow(a,cc.size(0,0),1.5)):7==a?(this.setColor(new cc.Color(255,229,154)),a=new cc.Color(0,0,0,255),this.enableShadow(a,cc.size(0,0),2)):8==a?(this.setColor(new cc.Color(0,
0,0,255)),this.enableStroke(new cc.Color(0,0,0,255),1)):9==a?this.setColor(new cc.Color(30,30,30,255)):10==a?(this.setColor(new cc.Color(255,242,103,255)),a=new cc.Color(0,0,0,255),this.enableStroke(a,1),this.enableShadow(a,cc.size(1,1),1)):11==a?(this.setColor(new cc.Color(255,242,103,255)),this.disableStroke(),this.disableShadow()):12==a?(this.setColor(new cc.Color(254,45,45,255)),this.disableStroke(),this.disableShadow()):(this.disableShadow(),this.disableStroke())},setString:function(a){a=String(a);
this._originalText!==a&&(this._originalText=a+"",this._updateString(),this._setUpdateTextureDirty(),this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty));this.fixWidth()},setAlignment:function(a,b){this.setHorizontalAlignment(a);this.setVerticalAlignment(b)},fixWidth:function(){this.setScaleX(1);var a=this.getContentSize();a.width>this._width&&0!=this._width&&this.setScaleX(this._width/a.width)},drawBox:function(){var a=this.getContentSize(),b=new cc.Color(255,0,0,255),c=new cc.Rect(0,
0,(0!=this._width?this._width:a.width)/this.getScaleX(),a.height/this.getScaleY());if(this.getHorizontalAlignment()==cc.TEXT_ALIGNMENT_CENTER){var d=.5*(c.width-c.x);c.x=-d+.5*a.width;c.width=d+.5*a.width}else this.getHorizontalAlignment()!=cc.TEXT_ALIGNMENT_LEFT&&(c.x=-this._width+a.width,c.width=a.width);this._drawNode.clear();this._drawNode.drawSegment(new cc.Point(c.x,c.y),new cc.Point(c.width,c.y),1,b);this._drawNode.drawSegment(new cc.Point(c.width,c.y),new cc.Point(c.width,c.height),1,b);this._drawNode.drawSegment(new cc.Point(c.width,
c.height),new cc.Point(c.x,c.height),1,b);this._drawNode.drawSegment(new cc.Point(c.x,c.height),new cc.Point(c.x,c.y),1,b)}});var CValue=cc.Class.extend({_rnd:0,_val:0,_eventName:null,ctor:function(a,b){this._eventName=b||null;this._rnd=this.getRandom();this._val=this._rnd+(isNaN(a)?0:Number(a))},getRandom:function(){return Math.ceil(1E3*Math.random())},getValue:function(){return this._val-this._rnd},setValue:function(a,b){this._rnd=this.getRandom();this._val=this._rnd+Number(a);b&&this._eventName&&cc.eventManager.dispatchCustomEvent(this._eventName,Number(a))},addValue:function(a,b){this.setValue(this.getValue()+Number(a),
b)},remValue:function(a,b){this.setValue(this.getValue()-Number(a),b)}});var CUtils={_time_diff:0,random:function(a,b){return Math.round(Math.random()*(b-a))+a},distance:function(a,b){var c=a.x-b.x,d=a.y-b.y;return Math.sqrt(c*c+d*d)},getAngle:function(a,b,c){a=!0===c?Math.atan2(b.x-a.x,b.y-a.y)/Math.PI*180:Math.atan2(b.y-a.y,b.x-a.x)/Math.PI*180;0>a?a=360+a:360<=a&&(a-=360);return a},numToArray:function(a){if(void 0===a)return[];for(var b=[];0<a;)b.push(a%10),a=a/10>>0;return b.reverse()},shuffleArray:function(a){for(var b=[],c=[],d,e=0;e<a.length;e++)b.push(e);for(e=
0;e<a.length;e++){do d=Math.round(Math.random()*(b.length-1));while(b[d]==e&&1<b.length);c[b[d]]=a[e];b.splice(d,1)}return c},between:function(a,b,c){return Number(a)<=Number(c)&&Number(c)<=Number(b)},onTouch:function(a,b,c,d){b=b.getBoundingBoxToWorld();d=d||a.getLocation();(d=cc.rectContainsPoint(b,d))&&c&&a.stopPropagation();return d},isHover:function(a,b,c){var d=b.convertToNodeSpace(a.getLocation());b=b.getContentSize();b=new cc.Rect(0,0,b.width,b.height);return cc.rectContainsPoint(b,d)?(0!=
c&&a.stopPropagation(),!0):!1},getObjectTime:function(a){a=Math.max(0,a);return{d:Math.floor(a/86400),h:Math.floor(a/3600%24),m:Math.floor(a/60%60),s:Math.floor(a%60)}},getStringTime:function(a){a=Math.max(0,a);var b=Math.floor(a/86400),c=Math.floor(a/3600%24),d=Math.floor(a/60%60);a=Math.floor(a%60);return(0<b?b+"d:":"")+(9<c?c:"0"+c)+":"+(9<d?d:"0"+d)+":"+(9<a?a:"0"+a)},getValue:function(a,b,c){c=void 0===c?null:c;var d=null!=c?c.constructor:String;b=b.split(".");if(0==b.length)return d(c);for(var e in b)if(a=
a[b[e]],null===a||void 0===a)return c;return d(a)}};var TimeUtils=new (cc.Class.extend({ctor:function(){this._time_diff=0},setTimeServer:function(a){this._time_diff=this.getTime(!0)-a},getTime:function(a){return!0===a?Math.round((new Date).getTime()/1E3):Math.round((new Date).getTime()/1E3)-this._time_diff},getSystemTime:function(){var a=new Date;return Math.round(a.getTime()/1E3)-60*a.getTimezoneOffset()},getDays:function(a){return Math.floor(a/86400)},formatTime:function(a){var b=Math.max(0,a);a=Math.floor(b/86400);var c=Math.floor(b/3600%24),d=
Math.floor(b/60%60);b=Math.floor(b%60);return 0<a?(0<a?a+"d:":"")+(9<c?c:"0"+c)+"h":0<c?(9<c?c:"0"+c)+"h:"+(9<d?d:"0"+d)+"m":(9<d?d:"0"+d)+":"+(9<b?b:"0"+b)},formatDate:function(a,b,c){function d(a,b){var c=a+"";for(b=b||2;c.length<b;)c="0"+c;return c}var e="\x00 January February March April May June July August September October November December".split(" "),f=" Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "),g=" Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),
h=" Sun Mon Tue Wed Thu Fri Sat".split(" "),k=c?a.getUTCFullYear():a.getFullYear();b=b.replace(/(^|[^\\])yyyy+/g,"$1"+k);b=b.replace(/(^|[^\\])yy/g,"$1"+k.toString().substr(2,2));b=b.replace(/(^|[^\\])y/g,"$1"+k);k=(c?a.getUTCMonth():a.getMonth())+1;b=b.replace(/(^|[^\\])MMMM+/g,"$1"+e[0]);b=b.replace(/(^|[^\\])MMM/g,"$1"+f[0]);b=b.replace(/(^|[^\\])MM/g,"$1"+d(k));b=b.replace(/(^|[^\\])M/g,"$1"+k);var m=c?a.getUTCDate():a.getDate();b=b.replace(/(^|[^\\])dddd+/g,"$1"+g[0]);b=b.replace(/(^|[^\\])ddd/g,
"$1"+h[0]);b=b.replace(/(^|[^\\])dd/g,"$1"+d(m));b=b.replace(/(^|[^\\])d/g,"$1"+m);m=c?a.getUTCHours():a.getHours();b=b.replace(/(^|[^\\])HH+/g,"$1"+d(m));b=b.replace(/(^|[^\\])H/g,"$1"+m);var n=12<m?m-12:0==m?12:m;b=b.replace(/(^|[^\\])hh+/g,"$1"+d(n));b=b.replace(/(^|[^\\])h/g,"$1"+n);n=c?a.getUTCMinutes():a.getMinutes();b=b.replace(/(^|[^\\])mm+/g,"$1"+d(n));b=b.replace(/(^|[^\\])m/g,"$1"+n);n=c?a.getUTCSeconds():a.getSeconds();b=b.replace(/(^|[^\\])ss+/g,"$1"+d(n));b=b.replace(/(^|[^\\])s/g,"$1"+
n);n=c?a.getUTCMilliseconds():a.getMilliseconds();b=b.replace(/(^|[^\\])fff+/g,"$1"+d(n,3));n=Math.round(n/10);b=b.replace(/(^|[^\\])ff/g,"$1"+d(n));n=Math.round(n/10);b=b.replace(/(^|[^\\])f/g,"$1"+n);m=12>m?"AM":"PM";b=b.replace(/(^|[^\\])TT+/g,"$1"+m);b=b.replace(/(^|[^\\])T/g,"$1"+m.charAt(0));m=m.toLowerCase();b=b.replace(/(^|[^\\])tt+/g,"$1"+m);b=b.replace(/(^|[^\\])t/g,"$1"+m.charAt(0));m=-a.getTimezoneOffset();n=c||!m?"Z":0<m?"+":"-";if(!c){m=Math.abs(m);var p=m%60;n+=d(Math.floor(m/60))+
":"+d(p)}b=b.replace(/(^|[^\\])K/g,"$1"+n);a=(c?a.getUTCDay():a.getDay())+1;b=b.replace(new RegExp(g[0],"g"),g[a]);b=b.replace(new RegExp(h[0],"g"),h[a]);b=b.replace(new RegExp(e[0],"g"),e[k]);b=b.replace(new RegExp(f[0],"g"),f[k]);return b=b.replace(/\\(.)/g,"$1")}}));var app=app||{};app.local=!1;app.version="1.0.0 (e3887353)";app.loadConfig=function(a){app.config=new app.Config(a);HttpRest.CONFIG.HOST_AUTH=app.config.restAuthHost();HttpRest.CONFIG.HOST_API=app.config.restApiHost();HttpRest.CONFIG.VERSION=app.config.restVersion()};app.reloadGame=function(){try{window.location.reload()}catch(a){cc.error(a)}};
app.checkData=function(){var a=User.getTimestamp(),b=User.getScoreById(0).getSize(),c=app.config.treasure(0),d=app.config.treasure(1),e=User.getTreasure();e.setExpired(d);if(CUtils.between(c,d,a)&&0==e.getSize()){a=[b+3,b+8,b+14];Backend.saveTreasure(a,0,d);for(var f in a)e.add(a[f])}};app.hideSplash=function(){var a=document.getElementById("gameSplash");a&&a.parentNode&&a.parentNode.removeChild(a)};
app.runGame=function(){KApi.event(KApi.EVENT.FLASH_LOAD_START);Preloader.loadGame(function(){KApi.event(KApi.EVENT.FLASH_LOAD_END);cc.eventManager.addCustomListener(User.EVENT.GOT_LIFE,app.eventHandler.bind(this));AudioEngine.musicOn(User.getMusic());AudioEngine.effectOn(User.getSound());var a=new app.Scene.Game;cc.director.runScene(a);a.runAction(new cc.Sequence(new cc.CallFunc(AudioEngine.playEffect.bind(this,Resource.SND.OPEN_GAME)),new cc.DelayTime(3),new cc.CallFunc(AudioEngine.playMusic.bind(this,
Resource.SND.MUSIC_MAP))));null==User.getAgeRange()&&"GB"==User.getCountryCode()&&Popup.PopAskAge.show(null,0,a,15);app.config.intro()||(0<User.getScheduledRemoval()&&Popup.PopAccountDeletion.show(null,0,a,999),cc.isArray(app.config.systemGift())&&Popup.PopSystemGift.show({data:app.config.systemGift()},0,a,12),app.config.dailyReward()&&0!=User.getDailyReward()&&Popup.PopDailyReward.show(null,0,a,13),app.config.sendLife()&&Popup.PopSendLife.show(null,0,a,11),User.getTreasure().isActive()&&Popup.PopChallenge.show({mode:"start"},
0,a,10),User.getChallenge().isActive()&&30<=User.getScoreById(0).getSize()&&Popup.PopChallengeStart.show(null,0,a),User.getChallenge().noticeExpired(!0)&&30<=User.getScoreById(0).getSize()&&Popup.PopChallengeExpired.show(null,0,a),User.getLive().hasImmortality()&&Popup.PopTutorial.show({id:1},0,a,14))})};
app.loadMap=function(a){Preloader.loadMap(a,function(){if(0==a){var b=new app.Scene.Game;cc.director.runScene(b);User.getChallenge().noticeExpired(!0)&&Popup.PopChallengeExpired.show(null,.5,b)}else b=new app.Scene.Adventure(!1,a),cc.director.runScene(b)})};app.loadAdventure=function(a){Preloader.loadAdventure(function(){var b=new app.Scene.Adventure(!0,a||app.config.ol(2));cc.director.runScene(b)})};
app.loadChallenge=function(){var a=User.getChallenge().getMapId();Preloader.loadChallenge(a,function(){var b=new app.Scene.Challenge(a);cc.director.runScene(b)})};
app.loadClient=function(a,b,c){User.getLive().hasLive()||User.getLive().hasImmortality()||app.local?(Popup.close(Popup.PopBase),Preloader.loadClient(a,b.id,function(){KApi.updateRandom();KApi.event(KApi.EVENT.LEVEL_START,{st2:c?"TryAgain":"Map",st3:a+"v"+b.id+"v"+(b.ver||"0"),l:b.id,v:User.getScoreById(a).getSize(),data:{level_uuid:b.uuid||0}});1E3>a?Backend.levelStart(a,b.id,function(c){c?(cc.director.runScene(new app.Scene.Client(a,b)),AudioEngine.playMusic(Resource.SND.MUSIC_CL)):Popup.alert(Popup.ALERT.NETWORK)}):
User.getChallenge().levelStart(a,b.id,function(c){c?(cc.director.runScene(new app.Scene.Client(a,b)),AudioEngine.playMusic(Resource.SND.MUSIC_CL)):Popup.alert(Popup.ALERT.NETWORK)})})):app.openBuyLive()};
app.exitClient=function(a){cc.log("exit level");cc.game.canvas.style.cursor="auto";Popup.close(Popup.PopBase);cc.assert(void 0!=a.mapId,"invalid input");cc.assert(void 0!=a.levelId,"invalid input");for(var b=a.kt.it_used,c=0;c<b.length;c++)for(var d=0;d<b[c];d++)KApi.event(KApi.EVENT.BOOSTER_USE,{st1:c+1,st2:"in_level",st3:User.getAudience(),l:a.levelId,v:User.getScoreById(a.mapId).getSize()});b=KApi.setJSData(KApi.EVENT.LEVEL_CUSTOM,{});b.st1="level_end";b.data.data=KApi.setJSData(KApi.EVENT.LEVEL_END,
{}).data;b.data.data.number_of_auto_match=a.kt.auto_match;b.data.data.level_aim.score=a.kt.sc1;b.data.data.level_aim.background_broken=a.kt.background0;b.data.data.level_aim.chest=a.kt.treasure0;b.data.data.level_completed.score=a.kt.sc0;b.data.data.level_completed.background_broken=a.kt.background1;b.data.data.level_completed.chest=a.kt.treasure1;b.data.data.booster_bought_details=a.kt.it_bought.join(":");b.data.data.booster_used_details=a.kt.it_used.join(":");b.data.data.booster_bought=!!a.kt.it_bought.reduce(function(a,
b){return 0!=a||b},!1);b.data.data.booster_used=!!a.kt.it_used.reduce(function(a,b){return 0!=a||b},!1);b.data.level=a.levelId;b.data.level_max=User.getScoreById(a.mapId).getSize();b.data.level_name=a.mapId+"v"+a.levelId+"v"+(a.level.ver||"0");b.data.level_uuid=a.level.uuid||0;b.data.map_id=a.mapId;b.data.result="win"==a.status?String(a.keys):"press_exit"==a.status?"-1":"0";b.data.fail_reason="win"==a.status?"good":a.status;b.data.type_ego="0";b.data.finalized=1;b.data.time_given=0;b.data.time_made=
0;b.data.duration=a.kt.t;b.data.user_score=a.kt.sc0;b.data.target_score=a.kt.sc1;b.data.moves_given=a.kt.mv_i;b.data.moves_made=a.kt.mv_d;b.data.number_of_ego_shown=a.kt.ego;b.data.target1=a.kt.background0;b.data.target1_made=a.kt.background1;b.data.target2=a.kt.treasure0;b.data.target2_made=a.kt.treasure1;b.data.target3=a.kt.torch0;b.data.target3_made=a.kt.torch1;b.data.target4=a.kt.diamond0;b.data.target4_made=a.kt.diamond1;b.data.target5=a.kt.beetle0;b.data.target5_made=a.kt.beetle1;b.data.target6=
a.kt.rainbow0;b.data.target6_made=a.kt.rainbow1;b.data.target7=a.kt.rowblast0;b.data.target7_made=a.kt.rowblast1;b.data.target8=a.kt.columnblast0;b.data.target8_made=a.kt.columnblast1;b.data.target9=a.kt.crossblast0;b.data.target9_made=a.kt.crossblast1;b.data.target10=a.kt.stone0;b.data.target10_made=a.kt.stone1;KApi.event(KApi.EVENT.LEVEL_CUSTOM,b);"win"==a.status?(1E3>a.mapId?(b=User.getScoreById(a.mapId),a.opennext=b.getSize()<a.levelId,b.push(a.levelId,a.keys,a.score)):(a.opennext=!1,0<a.levelId&&
5>=a.levelId&&(a.coins=[300,500,700,1E3,2E3][a.levelId-1])),User.cleanOrb(),User.getCoins().addValue(a.coins)):(a.opennext=!1,User.cleanOrb(),User.getLive().addLives(-1));1E3>a.mapId?Backend.levelFinish(a.mapId,a.levelId,a,function(b){Preloader.loadMap(a.mapId,function(){var c=null;AudioEngine.playMusic(Resource.SND.MUSIC_MAP);c=0<a.mapId?new app.Scene.Adventure(!1,a.mapId):a.levelId==User.getScratch().getLevel()?new app.Scene.Game({scrollTo:User.getScoreById(0).getSize(),openAnim:!1}):new app.Scene.Game({scrollTo:a.levelId,
openAnim:a.opennext});cc.director.runScene(c);if(b)if("win"!==a.status){var d={};d.mapId=a.mapId;d.level=a.level;d.status=a.status;Popup.PopLoseLevel.show(d,0,c,1)}else if(0==a.mapId){User.getScratch().getLevel()==a.levelId&&User.getScratch().winLevel(a.levelId)&&(User.getScratch().isComplete()?Popup.PopScratchCard.show(null,0,c,15):Popup.PopSpinLevel.show(null,0,c,15));d={};d.mapId=a.mapId;d.level=a.level;d.keys=a.keys;d.coins=a.coins;d.opennext=a.opennext;Popup.PopWinLevel.show(d,0,c,20);if(a.opennext){app.config.openInvite(a.levelId)&&
Popup.PopInviteFriends.show({showFrom:"win_level_auto_open"},0,c,16);15==a.levelId&&Popup.PopSystemReward.show({coins:5E3},0,c,16);var e=User.getFriendsByLevel(a.levelId-1);if(0<e.length&&(app.config.behindNotif()&&Backend.rqBehind(a.levelId,app.config.behindReward(),e),0<=app.config.behindMode()&&15<a.levelId))for(var k in e)if(Popup.PopBehind.show({user0:User,user1:e[k],levelId:a.levelId},0,c,19),0==app.config.behindMode())break}var m=User.getHighScoreById(0).getLowerScore(a.levelId,a.score);if(m){e=
[];for(k in m){d=m[k];var n=User.getFriendById(d.fbId,1);n&&e.push({prof:n,score:d.score})}if(0<e.length&&(app.config.beatNotif()&&Backend.rqBeat(a.levelId,app.config.beatReward(),e.map(function(a){return a.prof})),Backend.ogBeatScore(a.levelId),0<=app.config.beatMode()&&15<a.levelId))for(k in d={prof:User,score:a.score},e)if((new Popup.PopBeat({user0:d,user1:e[k],levelId:a.levelId})).show(0,c,19),0==app.config.beatMode())break;Backend.ogBeatScore(a.levelId,a.score)}else 3==a.key?Backend.ogHighScore(a.score,
150):Backend.ogLevelComplete(a.mapId,a.levelId,a.keys,a.score);e=User.unlockOrbs();for(k in e)d=e[k],Popup.PopOrbUnlocked.show({item:d},0,c,17)}else d={},d.mapId=a.mapId,d.level=a.level,d.keys=a.keys,d.coins=a.coins,d.opennext=a.opennext,Popup.PopWinLevel.show(d,0,c,20),15==a.levelId&&a.opennext&&Popup.PopAdventureReward.show({mapId:a.mapId},0,c,18),Backend.ogLevelComplete(a.mapId,a.levelId,a.keys,a.score);else Popup.alert(Popup.ALERT.NETWORK,c)})}):User.getChallenge().levelFinish(a.mapId,a.levelId,
a,function(b,c){Preloader.loadChallenge(a.mapId,function(){var d=new app.Scene.Challenge(a.mapId);cc.director.runScene(d);if(b)if("win"!==a.status){var e={};e.mapId=a.mapId;e.level=a.level;e.status=a.status;e.viewmode="challenge";Popup.PopLoseLevel.show(e,0,d,1)}else e={},e.mapId=a.mapId,e.level=a.level,e.coins=a.coins,e.viewmode="challenge",Popup.PopWinLevel.show(e,0,d,20),5==a.levelId&&c&&Popup.PopChallengeReward.show(null,1,d,0);else Popup.alert(Popup.ALERT.NETWORK,d)})})};
app.exitPost=function(a,b){cc.assert(void 0!=a.mapId,"invalid input");Preloader.loadMap(a.mapId,function(){cc.game.canvas.style.cursor="auto";var c=null;AudioEngine.playMusic(Resource.SND.MUSIC_MAP);c=0==a.mapId?a.levelId==User.getScratch().getLevel()?new app.Scene.Game({scrollTo:User.getScoreById(0).getSize(),openAnim:!1}):new app.Scene.Game({scrollTo:a.levelId,openAnim:a.opennext}):new app.Scene.Adventure(!1,a.mapId);cc.director.runScene(c);if(b)Popup.alert(Popup.ALERT.NETWORK,c);else if("win"!==
a.status){var d={};d.mapId=a.mapId;d.level=a.level;d.status=a.status;Popup.PopLoseLevel.show(d,0,c,1)}else if(0==a.mapId){User.getScratch().getLevel()==a.levelId&&User.getScratch().winLevel(a.levelId)&&(User.getScratch().isComplete()?Popup.PopScratchCard.show(null,0,c,15):Popup.PopSpinLevel.show(null,0,c,15));d={};d.mapId=a.mapId;d.level=a.level;d.keys=a.keys;d.coins=a.coins;d.opennext=a.opennext;Popup.PopWinLevel.show(d,0,c,20);if(a.opennext){app.config.openInvite(a.levelId)&&Popup.PopInviteFriends.show({showFrom:"win_level_auto_open"},
0,c,16);15==a.levelId&&Popup.PopSystemReward.show({coins:5E3},0,c,16);var e=User.getFriendsByLevel(a.levelId-1);if(0<e.length&&(app.config.behindNotif()&&Backend.rqBehind(a.levelId,app.config.behindReward(),e),0<=app.config.behindMode()&&15<a.levelId))for(var f in e)if(Popup.PopBehind.show({user0:User,user1:e[f],levelId:a.levelId},0,c,19),0==app.config.behindMode())break}var g=User.getHighScoreById(0).getLowerScore(a.levelId,a.score);if(g){e=[];for(f in g){d=g[f];var h=User.getFriendById(d.fbId,1);
h&&e.push({prof:h,score:d.score})}if(0<e.length&&(app.config.beatNotif()&&Backend.rqBeat(a.levelId,app.config.beatReward(),e.map(function(a){return a.prof})),Backend.ogBeatScore(a.levelId),0<=app.config.beatMode()&&15<a.levelId))for(f in d={prof:User,score:a.score},e)if((new Popup.PopBeat({user0:d,user1:e[f],levelId:a.levelId})).show(0,c,19),0==app.config.beatMode())break;Backend.ogBeatScore(a.levelId,a.score)}else 3==a.key?Backend.ogHighScore(a.score,150):Backend.ogLevelComplete(a.mapId,a.levelId,
a.keys,a.score);e=User.unlockOrbs();for(f in e)d=e[f],Popup.PopOrbUnlocked.show({item:d},0,c,17)}else d={},d.mapId=a.mapId,d.level=a.level,d.keys=a.keys,d.coins=a.coins,d.opennext=a.opennext,Popup.PopWinLevel.show(d,0,c,20),15==a.levelId&&a.opennext&&Popup.PopAdventureReward.show({mapId:a.mapId},0,c,18),Backend.ogLevelComplete(a.mapId,a.levelId,a.keys,a.score)})};app.eventHandler=function(a){a.getEventName()==User.EVENT.GOT_LIFE&&AudioEngine.playEffect(Resource.SND.GOT_LIFE)};app.openBuyLive=function(){(new Popup.PopBuyLives).show()};
app.openBuyMoves=function(a,b,c){if(0==a||app.config.extraMoves()){var d={};d.mode=a;d.moves=b;d.callback=c;Popup.PopBuyMoves.show(d)}else c(!1)};app.loadEditor=function(){Preloader.loadEditor(function(){var a=new app.Scene.Editor;cc.director.runScene(a)})};app.loadEditorClient=function(a){Preloader.loadClient(0,101,function(){a.id=101;cc.director.runScene(new app.Scene.Client(0,a,!0))})};app.exitEditorClient=function(a){Editor.STO.current&&Editor.STO.current.setStats(a);app.loadEditor()};
app.loadMapEditor=function(){Preloader.loadGame(function(){var a=new cc.Scene;a.addChild(new MapEditor(159));cc.director.runScene(a)})};var AudioEngine=new (cc.Class.extend({_timePlayEffect:0,_timePlayMusic:0,_delay:0,ctor:function(){this._timePlayEffect=this._timePlayMusic=0;this._delay=50},musicOn:function(a){cc.audioEngine.setMusicVolume(a?1:0)},effectOn:function(a){cc.audioEngine.setEffectsVolume(a?1:0)},playMusic:function(a,b){cc.audioEngine.playMusic(a,b||!0)},playEffect:function(a,b){if(b)cc.audioEngine.playEffect(a,!1);else{var c=Math.floor(Date.now());c-this._timePlayEffect>this._delay&&(cc.audioEngine.playEffect(a,!1),this._timePlayEffect=
c)}}}));app=app||{};
app.Config=cc.Class.extend({_ol:null,_intro:null,_intro_skip:null,_one_sphere:null,_session:null,_audience:null,_userId:null,_userLocale:null,_bestPackages:null,_unlock_mode:null,_unlock_time:null,_gift_time:null,_open_invite:null,_send_life:null,_behind_mode:null,_behind_notif:null,_behind_reward:null,_beat_mode:null,_beat_notif:null,_beat_reward:null,_ogActions:null,_daily_reward:null,_extra_moves:null,_rewardUnlockOrb:null,_rewardSendLife:null,_rewardAdventure:null,_feedback:null,_appId:null,_weeklyChallenge:null,
_kontagent:null,_christmas_offer:null,_special_offer:null,_life_pop_mode:null,_treasure:null,_system_gift:null,_mobilePromotionAndroid:null,_mobilePromotionIOS:null,_mobilePromotionKindle:null,_restHost:null,_restKey:null,_rest_auth:null,_rest_api:null,_rest_version:null,_rest_salt:null,_locales:null,_tester:null,ctor:function(a){this._ol="9002002";this._intro_skip=this._intro="0";this._one_sphere="1";this._bestPackages="0:6,2:0,2:0";this._behind_mode=this._unlock_mode="0";this._behind_notif="1";
this._beat_mode="0";this._extra_moves=this._daily_reward=this._beat_notif="1";this._life_pop_mode="0";this._special_offer=this._christmas_offer=this._treasure="0:0";this._system_gift=null;this._feedback=this._send_life=this._ogActions="1";this._weeklyChallenge=this._appId="0";this._gift_time=this._unlock_time=86400;this._open_invite=[19,29,39,49,59,69,79,89,99,109,119];this._rewardUnlockOrb=200;this._rewardSendLife=10;this._behind_reward=this._beat_reward=150;this._rewardAdventure=1E4;this._restHost=
"https://rest-flashdev-lostjewels.peakcasual.net";this._restKey="B1*zR52e1rw67n?J6w3h";this._rest_salt="xzj{HvUW2lMfj~";this._locales="cs da de en es fi fr it nb nl nn pl pt ro ru sv tr".split(" ");this._qqq="0242af913664f48a6dfa949d0befdd6d 2edf17ad86cd1c3aa2b837e06ec7f205 5f442f00fbfb477ac286c7fa58fd899c 14f45d2d92e562fcf00850c8f2e0160b 00000000000000000000000000000000 3cbe571bab8dfd81109621e7ad115e2d 18b2625aa06912d59cdcb9e2815a2528 a2b1766b907cdc72015f2fbd49240b39 65761a05c68c5cd31bf1b9084f44c43f 24db16f3402ca94214c474878ab51682 3b3777b4bf364e9e4d5c888acf7cd686".split(" ");
cc.log("\n****** LOAD APP CONFIG ********\n");for(var b in a){var c=String(a[b]);switch(b){case "rest_auth":case "rest_api":c=decodeURIComponent(c);"/"==c.slice(-1)&&(c=c.substr(0,c.length-1));this["_"+b]=c;break;case "RESThost":c=decodeURIComponent(c);"/"==c.slice(-1)&&(c=c.substr(0,c.length-1));this._restHost=c;break;case "mobilePromotionIOS":case "mobilePromotionAndroid":case "mobilePromotionKindle":this["_"+b]=decodeURIComponent(c);break;case "kontagent":case "userId":case "ogActions":case "extra_moves":case "daily_reward":case "beat_mode":case "behind_mode":case "bestPackages":case "one_sphere":case "intro":case "send_life":case "ol":case "appId":case "weeklyChallenge":case "christmas_offer":case "special_offer":case "rest_version":this["_"+
b]=c;break;case "locale":this._userLocale=c;break;case "session":this._session=c;break;case "audienceTag":this._audience=c;break;case "system_gift":this._system_gift=Object(a[b]);break;case "buyLifesPop":this._life_pop_mode=c;break;case "unlock_type":this._unlock_mode=c;break;case "behind_mode_notification":this._behind_notif=c;break;case "beat_mode_notification":this._beat_notif=c;break;case "challenge":this._treasure=c;break;case "autoFeedback":this._feedback=c}}},update:function(a,b){this["_"+
a]=String(b)},restAuthHost:function(){return this._rest_auth},restApiHost:function(){return this._rest_api},restSalt:function(){return this._rest_salt},restVersion:function(){return this._rest_version},feedback:function(){return"1"===this._feedback},ol:function(a){var b=this._ol.split(":");if(0===a)return a=Number(b[0].substr(1,3));if(1===a)return a=Number(b[0].substr(1,3)),b=Number(b[0].substr(4,3)),0===b||b>a?a:b;if(2===a)return Number(b[1])||45},intro:function(){return"1"==this._intro},introSkip:function(){return"1"==
this._intro_skip},oneSphere:function(){return"1"===this._one_sphere},bestPackages:function(a){var b=this._bestPackages.split(",");return b[a]?b[a].split(":"):[]},unlockMode:function(){return Number(this._unlock_mode)||0},unlockTime:function(){return Number(this._unlock_time)},giftTime:function(){return Number(this._gift_time)},openInvite:function(a){return-1!=this._open_invite.indexOf(a)},sendLife:function(){return"1"==this._send_life},behindMode:function(){return Number(this._behind_mode)||0},behindNotif:function(){return"1"===
this._behind_notif},beatMode:function(){return Number(this._beat_mode)||0},beatNotif:function(){return"1"===this._beat_notif},ogActions:function(){return"1"==this._ogActions},dailyReward:function(){return"1"===this._daily_reward},extraMoves:function(){return"1"===this._extra_moves},kontagent:function(){return"1"===this._kontagent},rewardUnlockOrb:function(){return this._rewardUnlockOrb},rewardSendLife:function(){return this._rewardSendLife},beatReward:function(){return this._beat_reward},behindReward:function(){return this._behind_reward},
lifePopMode:function(){return Number(this._life_pop_mode)},treasure:function(a){var b=this._treasure.split(":");if(0==a)return Number(b[0])||Number.MAX_VALUE-1;if(1==a)return Number(b[1])||0},christmasOffer:function(){return this._christmas_offer},specialOffer:function(){return this._special_offer},weeklyChallenge:function(){return this._weeklyChallenge},mobilePromotionAndroid:function(){return this._mobilePromotionAndroid},mobilePromotionIOS:function(){return this._mobilePromotionIOS},mobilePromotionKindle:function(){return this._mobilePromotionKindle},
restKey:function(){return this._restKey},locales:function(){return this._locales},systemGift:function(){return this._system_gift},rewardAdventure:function(){return this._rewardAdventure},restHost:function(){return this._restHost},audience:function(){return this._audience},session:function(){return this._session},userId:function(){return this._userId},userLocale:function(){return this._userLocale},qqq:function(){var a=MD5(this._userId),b;for(b in this._qqq)if(this._qqq[b]===a)return!0;return!1},dev:function(){return"191782660949142"!=
this._appId}});var Resource=Resource||{};Resource.OS={AUDIO_FORMAT:"object"===typeof window&&-1<window.navigator.userAgent.indexOf("FacebookCanvasDesktop")?"ogg":"mp3"};Resource.SPLASH={back:"splash/back.jpg",prog_back:"splash/prog_back.png",prog_front:"splash/prog_front.png",bt_ios:"splash/ios.png",bt_android:"splash/android.png",bt_kindle:"splash/kindle.png"};Resource.LANG={font:{type:"font",name:"Gnuolane",srcs:["gnuolanefree.ttf"]},locale:function(a){return cc.formatStr("data/%s.json",a)}};
Resource.ATLASES={CLIENT0_PNG:"atlases/client0.png",CLIENT0_LIST:"atlases/client0.plist",UI0_PNG:"atlases/ui0.png",UI0_LIST:"atlases/ui0.plist",ADV0_PNG:"atlases/adv0.png",ADV0_LIST:"atlases/adv0.plist",EDITOR0_PNG:"atlases/editor0.png",EDITOR0_LIST:"atlases/editor0.plist",CHALLENGE0_PNG:"atlases/challenge0.png",CHALLENGE0_LIST:"atlases/challenge0.plist"};
Resource.EDITOR={bt:function(a){return cc.formatStr("atlas/editor/bt_%s.png",a)},img:function(a){return cc.formatStr("atlas/editor/img_%s.png",a)},grid:function(a){return cc.formatStr("atlas/editor/grid/%s.png",a)},bt_arrow:"atlas/editor/bt_arrow.png",line:"atlas/editor/line.png"};
Resource.UI={panel_up:"atlas/ui/panel_top.png",panel_down:"atlas/ui/panel_bottom.png",panel_heart_back:"atlas/ui/heart/back.png",panel_heart_front:"atlas/ui/heart/front.png",panel_heart_middle:"atlas/ui/heart/middle.png",panel_heart_num:function(a){return cc.formatStr("atlas/ui/heart/num/%d.png",a)},panel_heart_infinit:"atlas/ui/heart/infinit.png",panel_value_back:"atlas/ui/value_back.png",bt:function(a,b){return void 0===b?cc.formatStr("atlas/ui/bt/bt_%s.png",a):cc.formatStr("atlas/ui/bt/bt_%s_%d.png",
a,b)},ico_coin:function(a){return cc.formatStr("atlas/ui/icon/coin%s.png",a)},ico_cash:function(a){return cc.formatStr("atlas/ui/icon/cash%s.png",a)},ico:function(a){return cc.formatStr("atlas/ui/icon/%s.png",a)},img:function(a){return cc.formatStr("atlas/ui/img/%s.png",a)}};
Resource.POP={empty:"atlas/pop/empty.png",bg:function(a){return cc.formatStr("atlas/pop/bg/%s.png",a)},bt:function(a,b){return void 0===b?cc.formatStr("atlas/pop/bt/bt_%s.png",a):cc.formatStr("atlas/pop/bt/bt_%s_%d.png",a,b)},img:function(a,b){return void 0===b?cc.formatStr("atlas/pop/img/img_%s.png",a):cc.formatStr("atlas/pop/img/img_%s_%d.png",a,b)},orb:function(a){return cc.formatStr("atlas/pop/orb/%s.png",a)},currency:function(a){return cc.formatStr("atlas/pop/currency/%s.png",a)},goal_num:function(a){return cc.formatStr("atlas/pop/goal/%d.png",
a)},goal_icon:function(a){return cc.formatStr("atlas/pop/goal/ico_%s.png",a)},num:function(a,b){return cc.formatStr("atlas/pop/num/%s_%s.png",a,b)},efect:function(a,b){return cc.formatStr("atlas/pop/efect/%s_%d.png",a,b)}};
Resource.CLIENT={grid:function(a){return cc.formatStr("atlas/client/gr/%d.png",a)},ruby:function(a){return cc.formatStr("atlas/client/ruby/%d.png",a)},goal_num:function(a){return cc.formatStr("atlas/client/goal/%d.png",a)},goal_back:"atlas/client/goal/panel.png",goal_done:"atlas/client/goal/done.png",goal_icon:function(a){return cc.formatStr("atlas/client/goal/ico_%s.png",a)},empty:"atlas/client/empty.png",jewel_simple:function(a){return cc.formatStr("atlas/client/jewel/s_%s.png",a)},jewel_titan:"atlas/client/jewel/titan.png",
jewel_icecube:"atlas/client/jewel/icecube.png",jewel_torch:"atlas/client/jewel/torch.png",jewel_chameleon:"atlas/client/jewel/chameleon.png",jewel_petrifier:function(a){return cc.formatStr("atlas/client/jewel/petrifier_%d.png",a)},jewel_snow:"atlas/client/jewel/snow.png",jewel_treasure:function(a){return cc.formatStr("atlas/client/jewel/treasure_%s.png",a)},jewel_stone:function(a){return cc.formatStr("atlas/client/jewel/stone_%s.png",a)},jewel_mirror:function(a){return cc.formatStr("atlas/client/jewel/mirror_%s.png",
a)},jewel_magicball:function(a){return cc.formatStr("atlas/client/jewel/magic_ball_%s.png",a)},jewel_diamond:function(a){return cc.formatStr("atlas/client/jewel/diamond_%s.png",a)},jewel_butterfly:function(a){return cc.formatStr("atlas/client/jewel/butterfly_%s.png",a)},jewel_beetle:function(a){return cc.formatStr("atlas/client/jewel/beetle_%s.png",a)},jewel_rainbow:function(a){return cc.formatStr("atlas/client/jewel/rainbow_%s.png",a)},jewel_ruby:function(a){return cc.formatStr("atlas/client/jewel/r_%s.png",
a)},jewel_lock:function(a){return cc.formatStr("atlas/client/jewel/lk_%s.png",a)},jewel_background:function(a){return cc.formatStr("atlas/client/jewel/bg_%s.png",a)},jewel_enigma:function(a){return cc.formatStr("atlas/client/jewel/enigma_%s.png",a)},jewel_frog:"atlas/client/jewel/frog.png",jewel_pearl:"atlas/client/jewel/pearl.png",jewel_shell:"atlas/client/jewel/shell.png",jewel_freeze:function(a){return cc.formatStr("atlas/client/jewel/freeze_%s.png",a)},jewel_magnet:function(a){return cc.formatStr("atlas/client/jewel/magnet_%s.png",
a)},jewel_bonus:function(a){return cc.formatStr("atlas/client/jewel/b_%s.png",a)},jewel_cloud:function(a){return cc.formatStr("atlas/client/jewel/cloud_%s.png",a)},jewel_select:"atlas/client/jewel/select.png",jewel_explode:function(a,b){return cc.formatStr("atlas/client/explode/exp_%s_%d.png",a,b)},jewel_infect:function(a,b){return cc.formatStr("atlas/client/infect/%s_%d.png",a,b)},jewel_efect:function(a,b){return cc.formatStr("atlas/client/efect/efect_%s_%d.png",a,b)},jewel_fire:function(a,b){return cc.formatStr("atlas/client/explode/fire_%s_%d.png",
a,b)},ui:function(a){return cc.formatStr("atlas/client/ui/%s.png",a)},spell:function(a){return cc.formatStr("atlas/client/spell/%s.png",a)},cursor:function(a){return cc.formatStr("atlas/client/cursor/%s.png",a)}};
Resource.MAP={ADV:{back:"map/bg_adv.jpg",arrow:"atlas/adv/arrow.png",title:function(a){return cc.formatStr("atlas/adv/title_%d.png",a)},building:function(a,b){return cc.formatStr("atlas/adv/building/%s%d.png",b,a)},building_reward:function(a){return cc.formatStr("map/b_%d.png",a)},complete:"atlas/adv/complete.png",sphere:"atlas/adv/sphere.png",obelisk:"atlas/adv/obelisk.png",obelisk_glow:"atlas/adv/obelisk_glow.png",num:function(a){return cc.formatStr("atlas/adv/num/%d.png",a)}},levels:function(a){return cc.formatStr("data/map_%d_levels.json",
a)},config:function(a){return cc.formatStr("data/map_%d_config.json",a)},segment:function(a){return cc.formatStr("map/%s.jpg",a)},back:function(a,b){return cc.formatStr("map/bg_%d_%d.jpg",a,b)},lk:function(a,b){return cc.formatStr("map/lk_%s_%s.jpg",a,b)},obelisk:"atlas/map/obelisk.png",sphere:"atlas/map/sphere.png",dot:"atlas/map/road.png",cloud0:"atlas/map/cloud0.png",cloud1:"atlas/map/cloud1.png",cloud2:"atlas/map/cloud2.png",lock:"atlas/map/lock.png",arrow:"atlas/map/arrow.png",poster:"atlas/map/poster.png",
empty:"atlas/map/empty.png",num:function(a){return cc.formatStr("atlas/map/num/%d.png",a)},portal:function(a){return cc.formatStr("atlas/map/portal/%d.png",a)},treasure:function(a){return cc.formatStr("atlas/map/treasure/%s.png",a)},avatar:function(a){return cc.formatStr("atlas/map/avatar/%s.png",a)}};
Resource.WEEKLY_CHALLENGE={back:function(a){return cc.formatStr("map/ch_%d.jpg",a)},img:function(a,b){return void 0===b?cc.formatStr("atlas/weekly_challenge/%s.png",a):cc.formatStr("atlas/weekly_challenge/%s_%s.png",a,b)}};
Resource.SND={MUSIC_MAP:"snd/music_map."+Resource.OS.AUDIO_FORMAT,MUSIC_CL:"snd/music_client."+Resource.OS.AUDIO_FORMAT,OPEN_POPUP:"snd/open_popup."+Resource.OS.AUDIO_FORMAT,OPEN_GAME:"snd/open_game."+Resource.OS.AUDIO_FORMAT,CLICK:"snd/click_button."+Resource.OS.AUDIO_FORMAT,PURCHASE:"snd/purchase."+Resource.OS.AUDIO_FORMAT,GOT_LIFE:"snd/got_life."+Resource.OS.AUDIO_FORMAT,CL_COLLECT_KEY:"snd/cl_collect_key."+Resource.OS.AUDIO_FORMAT,CL_OPEN_LOCK:"snd/cl_open_lock."+Resource.OS.AUDIO_FORMAT,CL_TAKE_RUBY:"snd/cl_take_ruby."+
Resource.OS.AUDIO_FORMAT,CL_MOVES_ADD:"snd/cl_moves_add."+Resource.OS.AUDIO_FORMAT,CL_MOVES_REM:"snd/cl_moves_rem."+Resource.OS.AUDIO_FORMAT,CL_FROZEN:"snd/cl_frozen."+Resource.OS.AUDIO_FORMAT,CL_PETRIFIER:"snd/cl_petrifier."+Resource.OS.AUDIO_FORMAT,CL_TORNADO:"snd/cl_tornado."+Resource.OS.AUDIO_FORMAT,CL_LIGHTNING:"snd/cl_lightning."+Resource.OS.AUDIO_FORMAT,CL_HAMMER:"snd/cl_hammer."+Resource.OS.AUDIO_FORMAT,CL_BOMB:"snd/cl_bomb."+Resource.OS.AUDIO_FORMAT,CL_LINE_BLAST:"snd/cl_line_blast."+Resource.OS.AUDIO_FORMAT,
CL_CROSS_BLAST:"snd/cl_cross_blast."+Resource.OS.AUDIO_FORMAT,CL_COLOR_BLAST:"snd/cl_color_blast."+Resource.OS.AUDIO_FORMAT,CL_RESHUFFLE:"snd/cl_reshuffle."+Resource.OS.AUDIO_FORMAT,CL_END_LEVEL:"snd/cl_end_level."+Resource.OS.AUDIO_FORMAT,CL_SWAP_ITEM:"snd/cl_swap_item."+Resource.OS.AUDIO_FORMAT,CL_SWAP_ITEM_BACK:"snd/cl_swap_item_back."+Resource.OS.AUDIO_FORMAT,CL_NEW_ITEM:function(a){return cc.formatStr("snd/cl_new_item%s."+Resource.OS.AUDIO_FORMAT,a)}};var Lang=new (cc.Class.extend({_data:null,F_GNUOLANE:"Gnuolane",UI_BT_SHOP:"ui_bt_shop",UI_BT_INVITE:"ui_bt_invite",UI_BT_INBOX:"ui_bt_inbox",POP_EXIT_GAME_MESSAGE:"pop_exit_game_message",POP_EXIT_GAME_BT_QUIT:"pop_exit_game_bt_quit",POP_EXIT_GAME_BT_CONTINUE:"pop_exit_game_bt_continue",POP_BUY_MOVES_TITLE:"pop_buy_moves_title",POP_BUY_MOVES_MSG:"pop_buy_moves_msg",POP_BUY_MOVES_BT_GIVEUP:"pop_buy_moves_bt_giveup",POP_BUY_MOVES_BT_BUY:"pop_buy_moves_bt_buy",POP_BUY_MOVES_BT_CANCEL:"pop_buy_moves_bt_cancel",
POP_BUY_LIVES_TITLE:"pop_buy_lives_title",POP_BUY_LIVES_LB0:"pop_buy_lives_lb0",POP_BUY_LIVES_LB1:"pop_buy_lives_lb1",POP_BUY_LIVES_LB2:"pop_buy_lives_lb2",POP_BUY_LIVES_BT0:"pop_buy_lives_bt0",POP_BUY_LIVES_BT1:"pop_buy_lives_bt1",POP_BUY_LIVES_MSG:"pop_buy_lives_msg",POP_BUY_CASH_TITLE:"pop_buy_cash_title",POP_BUY_CASH_BT_CREDIT:"pop_buy_cash_bt_credit",POP_BUY_CASH_BT_PACKAGE:"pop_buy_cash_bt_package",POP_BUY_MOB_TITLE:"pop_buy_mob_title",POP_BEGIN_LEVEL_TITLE:"pop_begin_level_title",POP_BEGIN_LEVEL_BOOSTERS:"pop_begin_level_boosters",
POP_BEGIN_LEVEL_BT_PLAY:"pop_begin_level_bt_play",POP_BEGIN_LEVEL_BT_INVITE:"pop_begin_level_bt_invite",POP_BEGIN_LEVEL_TOP_FRIENDS:"pop_begin_level_top_friends",POP_BEGIN_LEVEL_GL_MOVES:"pop_begin_level_gl_moves",POP_BEGIN_LEVEL_GL_BACKGROUND:"pop_begin_level_gl_background",POP_BEGIN_LEVEL_GL_TREASUSE:"pop_begin_level_gl_treasuse",POP_BEGIN_LEVEL_GL_TORCH:"pop_begin_level_gl_torch",POP_BEGIN_LEVEL_GL_BEETLE:"pop_begin_level_gl_beetle",POP_BEGIN_LEVEL_GL_DIAMOUND:"pop_begin_level_gl_diamound",POP_BEGIN_LEVEL_GL_ICECUBE:"pop_begin_level_gl_icecube",
POP_BEGIN_LEVEL_GL_BUTTERFLY:"pop_begin_level_gl_butterfly",POP_BEGIN_LEVEL_GL_RAINBOW:"pop_begin_level_gl_rainbow",POP_BEGIN_LEVEL_GL_ROWBLAST:"pop_begin_level_gl_rowblast",POP_BEGIN_LEVEL_GL_COLUMNBLAST:"pop_begin_level_gl_columnblast",POP_BEGIN_LEVEL_GL_CROSSBLAST:"pop_begin_level_gl_crossblast",POP_BEGIN_LEVEL_GL_STONE:"pop_begin_level_gl_stone",POP_BEGIN_LEVEL_GL_FROG:"pop_begin_level_gl_frog",POP_BEGIN_LEVEL_GL_MIRROR:"pop_begin_level_gl_mirror",POP_BEGIN_LEVEL_GL_MAGICBALL:"pop_begin_level_gl_magicball",
POP_BEGIN_LEVEL_GL_PEARL:"pop_begin_level_gl_pearl",POP_LOSE_LEVEL_TITLE:"pop_lose_level_title",POP_LOSE_LEVEL_BT_PLAY:"pop_lose_level_bt_play",POP_LOSE_LEVEL_BT_CONTINUE:"pop_lose_level_bt_continue",POP_LOSE_LEVEL_BT_INVITE:"pop_lose_level_bt_invite",POP_LOSE_LEVEL_TOP_FRIENDS:"pop_lose_level_top_friends",POP_LOSE_LEVEL_BOOSTERS:"pop_lose_level_boosters",POP_LOSE_LEVEL_NO_SPHERES:"pop_lose_level_no_spheres",POP_LOSE_LEVEL_NO_STARS:"pop_lose_level_no_stars",POP_LOSE_LEVEL_NO_MOVES:"pop_lose_level_no_moves",
POP_LOSE_LEVEL_NO_MATCHES:"pop_lose_level_no_matches",POP_LOSE_LEVEL_PRESS_EXIT:"pop_lose_level_press_exit",POP_LOSE_LEVEL_WIN:"pop_lose_level_win",POP_WIN_LEVEL_TITLE:"pop_win_level_title",POP_WIN_LEVEL_BT_PLAY:"pop_win_level_bt_play",POP_WIN_LEVEL_BT_INVITE:"pop_win_level_bt_invite",POP_WIN_LEVEL_TOP_FRIENDS:"pop_win_level_top_friends",POP_WIN_LEVEL_MSG:"pop_win_level_msg",POP_WIN_LEVEL_KEY:function(a){return cc.formatStr("pop_win_level_key%s",a)},POP_WIN_LEVEL_SPHERE:function(a){return cc.formatStr("pop_win_level_sphere%s",
a)},POP_WIN_LEVEL_VIEW0_MSG:"pop_win_level_view0_msg",POP_ASK_AGE_TITLE:"pop_ask_age_title",POP_ASK_AGE_BT_CONTINUE:"pop_ask_age_bt_continue",POP_ASK_AGE_MSG0:"pop_ask_age_msg0",POP_ASK_AGE_MSG1:"pop_ask_age_msg1",POP_INBOX_TITLE:"pop_inbox_title",POP_INBOX_BT_ACCEPT_ALL:"pop_inbox_bt_accept_all",POP_INBOX_BT_ACCEPT:"pop_inbox_bt_accept",POP_INBOX_BT_HELP:"pop_inbox_bt_help",POP_INBOX_REQUEST_HEADER_LIFE:"pop_inbox_request_header_life",POP_INBOX_REQUEST_HEADER_UNLOCK:"pop_inbox_request_header_unlock",
POP_INBOX_REQUEST_LIFE:"pop_inbox_request_life",POP_INBOX_REQUEST_UNLOCK:"pop_inbox_request_unlock",POP_INBOX_GIFT_HEADER_COINS:"pop_inbox_gift_header_coins",POP_INBOX_GIFT_HEADER_LIFE:"pop_inbox_gift_header_life",POP_INBOX_GIFT_HEADER_UNLOCK:"pop_inbox_gift_header_unlock",POP_INBOX_GIFT_COINS:"pop_inbox_gift_coins",POP_INBOX_GIFT_LIFE:"pop_inbox_gift_life",POP_INBOX_GIFT_UNLOCK:"pop_inbox_gift_unlock",POP_INBOX_EMPTY:"pop_inbox_empty",POP_SYSTEM_GIFT_TITLE:"pop_system_gift_title",POP_SYSTEM_GIFT_MSG0:"pop_system_gift_msg0",
POP_SYSTEM_GIFT_MSG1:"pop_system_gift_msg1",POP_SYSTEM_GIFT_ACCEPT:"pop_system_gift_accept",POP_BEAT_TITLE:"pop_beat_title",POP_BEAT_LB0:"pop_beat_lb0",POP_BEAT_LB1:"pop_beat_lb1",POP_BEAT_BT_CONTINUE:"pop_beat_bt_continue",POP_BEHIND_TITLE:"pop_behind_title",POP_BEHIND_LB0:"pop_behind_lb0",POP_BEHIND_LB1:"pop_behind_lb1",POP_BEHIND_BT_CONTINUE:"pop_behind_bt_continue",POP_CHAPTER_CLOSED:"pop_chapter_closed",POP_SYSTEM_REWARD_NAME:"pop_system_reward_name",POP_SYSTEM_REWARD_MSG:"pop_system_reward_msg",
POP_SYSTEM_REWARD_BT_CONTINUE:"pop_system_reward_bt_continue",POP_CHAPTER_UNLOCK_TITLE:"pop_chapter_unlock_title",POP_CHAPTER_UNLOCK_OPTION:"pop_chapter_unlock_option",POP_CHAPTER_UNLOCK_BT_BUY:"pop_chapter_unlock_bt_buy",POP_CHAPTER_UNLOCK_BT_HELP:"pop_chapter_unlock_bt_help",POP_CHAPTER_UNLOCK_BT_UNLOCK_NOW:"pop_chapter_unlock_bt_unlock_now",POP_CHAPTER_UNLOCK_BT_UNLOCK_FREE:"pop_chapter_unlock_bt_unlock_free",POP_CHAPTER_UNLOCK_LB_TIMER:"pop_chapter_unlock_lb_timer",POP_CHAPTER_UNLOCK_LB_TIMER2:"pop_chapter_unlock_lb_timer2",
POP_CHAPTER_UNLOCKED_TITLE:"pop_chapter_unlocked_title",POP_CHAPTER_UNLOCKED_MSG0:"pop_chapter_unlocked_msg0",POP_CHAPTER_UNLOCKED_BT_CONTINUE:"pop_chapter_unlocked_bt_continue",POP_SHOP_BT_BUY:"pop_shop_bt_buy",POP_SHOP_BT_PLAY:"pop_shop_bt_play",POP_SHOP_ACTIVE_ONE_TIME:"pop_shop_active_one_time",POP_SHOP_ACTIVE_FOREVER:"pop_shop_active_forever",POP_SHOP_UNLOCK_LEVEL:"pop_shop_unlock_level",POP_SHOP_EMPTY:"pop_shop_empty",POP_SPIN_LEVEL_TITLE:"pop_spin_level_title",POP_SPIN_LEVEL_MSG:"pop_spin_level_msg",
POP_SPIN_LEVEL_BT_PLAY:"pop_spin_level_bt_play",POP_ACCOUNT_DELETION_TITLE:"pop_account_deletion_title",POP_ACCOUNT_DELETION_BT_CANCEL:"pop_account_deletion_bt_cancel",POP_ACCOUNT_DELETION_BT_CONTINUE:"pop_account_deletion_bt_continue",POP_ACCOUNT_DELETION_MSG0:"pop_account_deletion_msg0",POP_ACCOUNT_DELETION_MSG1:"pop_account_deletion_msg1",POP_SCRATCH_CARD_BT_CLAIM:"pop_scratch_card_bt_claim",POP_CHALLENGE_TITLE:"pop_challenge_title",POP_CHALLENGE_MSG0:"pop_challenge_msg0",POP_CHALLENGE_BT_CONTINUE:"pop_challenge_bt_continue",
POP_CHALLENGE_BT_OPEN:"pop_challenge_bt_open",POP_CHALLENGE_BT_CLAIM:"pop_challenge_bt_claim",POP_INVITE_FRIENDS_TITLE:"pop_invite_friends_title",POP_INVITE_FRIENDS_BT_INVITE:"pop_invite_friends_bt_invite",POP_INVITE_FRIENDS_SELECT_ALL:"pop_invite_friends_select_all",POP_INVITE_FRIENDS_EMPTY:"pop_invite_friends_empty",POP_ASK_FRIENDS_TITLE:function(a){return cc.formatStr("pop_ask_friends_title%s",a)},POP_ASK_FRIENDS_ASK:function(a){return cc.formatStr("pop_ask_friends_ask%s",a)},POP_ASK_FRIENDS_SELECT_ALL:"pop_ask_friends_select_all",
POP_ASK_FRIENDS_TAB_ALL:"pop_ask_friends_tab_all",POP_ASK_FRIENDS_TAB_GAME:"pop_ask_friends_tab_game",POP_ASK_FRIENDS_EMPTY:"pop_ask_friends_empty",POP_DAILY_REWARD_TITLE:"pop_daily_reward_title",POP_DAILY_REWARD_DAYS:"pop_daily_reward_days",POP_DAILY_REWARD_BT_OK:"pop_daily_reward_bt_ok",POP_DAILY_REWARD_MSG0:"pop_daily_reward_msg0",POP_DAILY_REWARD_MSG1:"pop_daily_reward_msg1",POP_DAILY_REWARD_MSG2:"pop_daily_reward_msg2",POP_SEND_LIFE_TITLE:"pop_send_life_title",POP_SEND_LIFE_MSG0:"pop_send_life_msg0",
POP_SEND_LIFE_BT_SEND:"pop_send_life_bt_send",POP_SEND_LIFE_SELECT_ALL:"pop_send_life_select_all",POP_ORB_UNLOCKED_TITLE:"pop_orb_unlocked_title",POP_ORB_UNLOCKED_MSG:"pop_orb_unlocked_msg",POP_ORB_UNLOCKED_BT_OK:"pop_orb_unlocked_bt_ok",POP_ALERT_PROCESSING:"pop_alert_processing",POP_ALERT_NETWORK:"pop_alert_network",POP_ALERT_NO_CASH:"pop_alert_no_cash",POP_ALERT_NO_COINS:"pop_alert_no_coins",POP_ALERT_PURCHASE_FAILED:"pop_alert_purchase_failed",POP_ALERT_BT_RELOAD:"pop_alert_bt_reload",POP_WEEKLY_CHALLENGE_START_TITLE:"pop_weekly_challenge_start_title",
POP_WEEKLY_CHALLENGE_START_MSG:"pop_weekly_challenge_start_msg",POP_WEEKLY_CHALLENGE_START_BT_PLAY:"pop_weekly_challenge_start_bt_play",POP_WEEKLY_CHALLENGE_EXPIRED_TITLE:"pop_weekly_challenge_expired_title",POP_WEEKLY_CHALLENGE_EXPIRED_MSG:"pop_weekly_challenge_expired_msg",POP_WEEKLY_CHALLENGE_EXPIRED_BT_PLAY:"pop_weekly_challenge_expired_bt_play",POP_WEEKLY_CHALLENGE_REWARD_TITLE:"pop_weekly_challenge_reward_title",POP_WEEKLY_CHALLENGE_REWARD_BT_CLAIM:"pop_weekly_challenge_reward_bt_claim",POP_TUTORIAL_MSG:function(a){return cc.formatStr("pop_tutorial_msg%s",
a)},POP_TUTORIAL_CLOSE:"pop_tutorial_close",POP_ADVENTURE_REWARD_TITLE:"pop_adventure_reward_title",POP_ADVENTURE_REWARD_MSG:"pop_adventure_reward_msg",MAP_PRELOADER:"map_preloader",MAP_REWARD_MSG0:"map_reward_msg0",MAP_REWARD_MSG1:"map_reward_msg1",CHAPTER_NAME:function(a){return cc.formatStr("chapter_name_%s",a)},ORB_LB_BOUGHT:"orb_lb_bought",ORB_NAME:function(a){return cc.formatStr("orb_name_%s",a)},ORB_DESCRIPTION:function(a){return cc.formatStr("orb_desc_%s",a)},CL_GOAL_MOVES:"cl_goal_moves",
CL_GOAL_MOVESDONE:"cl_goal_movesdone",CL_GOAL_BACKGROUND:"cl_goal_background",CL_GOAL_TREASURE:"cl_goal_treasure",CL_GOAL_TORCH:"cl_goal_torch",CL_GOAL_BEETLE:"cl_goal_beetle",CL_GOAL_DIAMOND:"cl_goal_diamond",CL_GOAL_ICECUBE:"cl_goal_icecube",CL_GOAL_BUTTERFLY:"cl_goal_butterfly",CL_GOAL_RAINBOW:"cl_goal_rainbow",CL_GOAL_ROWBLAST:"cl_goal_rowblast",CL_GOAL_COLBLAST:"cl_goal_colblast",CL_GOAL_CROSSBLAST:"cl_goal_crossblast",CL_GOAL_STONE:"cl_goal_stone",CL_GOAL_FROG:"cl_goal_frog",CL_GOAL_MIRROR:"cl_goal_mirror",
CL_GOAL_MAGICBALL:"cl_goal_magicball",CL_GOAL_PEARL:"cl_goal_pearl",CL_EXIT_NOMATCH:"cl_exit_nomatch",CL_EXIT_NOMOVES:"cl_exit_nomoves",CL_EXIT_NOSPHERE:"cl_exit_nosphere",CL_EXIT_NOSTARS:"cl_exit_nostars",CL_EXIT_LEAVE:"cl_exit_leave",CL_EXIT_WIN:"cl_exit_win",CL_AUTORESHUFFLE:"cl_autoreshuffle",CL_ORB_BUY:"cl_orb_buy",CL_TUTORIAL:function(a){return cc.formatStr("cl_tutorial_%s",a)},ctor:function(){},getString:function(){var a=arguments;this._data||(this._data=cc.loader.getRes(Resource.LANG.locale(User.getLocale())),
cc.assert(this._data));cc.assert(0<a.length);var b=this._data[a[0]];return b?(a[0]=b,cc.formatStr.apply(this,a)):a[0]||"undefined"}}));var MoveUtils=cc.Layer.extend({target:null,shiftPressed:!1,origin:null,ctor:function(a){this._super();this.target=a;this.target.addChild(this);this.addListener(this);this.origin=new cc.LayerColor(cc.color(255,0,0,255),5,5);this.origin.ignoreAnchorPointForPosition(!1);this.origin.setVisible(!1)},addListener:function(a){"keyboard"in cc.sys.capabilities&&cc.eventManager.addListener({event:cc.EventListener.KEYBOARD,onKeyPressed:function(b,c){16==b&&(a.shiftPressed=!0);if(null!=a.target){a.origin.parent!=
a.target&&(a.origin.setPosition(a.target.getAnchorPoint().x*a.target.width,a.target.getAnchorPoint().y*a.target.height),a.target.addChild(a.origin));var d=a.shiftPressed?10:1;81==b&&a.target.setRotation(a.target.rotation+d);69==b&&a.target.setRotation(a.target.rotation-d);87==b&&a.target.setPositionY(a.target.getPositionY()+d);83==b&&a.target.setPositionY(a.target.getPositionY()-d);65==b&&a.target.setPositionX(a.target.getPositionX()-d);68==b&&a.target.setPositionX(a.target.getPositionX()+d);107==
b&&a.target.setScale(a.target.getScale()+.01*d);109==b&&a.target.setScale(a.target.getScale()-.01*d);cc.log(a.target.getPosition().x+","+a.target.getPosition().y+","+a.target.rotation+","+a.target.getScale())}},onKeyReleased:function(b,c){16==b&&(a.shiftPressed=!1)}},a)}});app.Events={PRESS_EXIT:"PRESS_EXIT",BUY_COINS:"BUY_COINS",BUY_CASH:"BUY_CASH"};var Preloader=new (cc.Class.extend({loadGame:function(a){var b=new Preloader.CLoadGame;a=new Preloader.SplashView(b,a);a.run();cc.director.runScene(a)},loadClient:function(a,b,c){a=new Preloader.CLoadClient(a,b);c=new Preloader.PopupView(a,c);c.setOpacity(50);c.runAction(new cc.FadeTo(.3,255));c.run();cc.director.getRunningScene().addChild(c,Number.MAX_VALUE-10)},loadMap:function(a,b){var c=new Preloader.CLoadMap(a);c=new Preloader.PopupView(c,b);c.setOpacity(50);c.runAction(new cc.FadeTo(.3,255));
c.run();cc.director.getRunningScene().addChild(c,Number.MAX_VALUE-10)},loadAdventure:function(a){var b=new Preloader.CLoadAdventure;a=new Preloader.PopupView(b,a);a.setOpacity(50);a.runAction(new cc.FadeTo(.3,255));a.run();cc.director.getRunningScene().addChild(a,Number.MAX_VALUE-10)},loadChallenge:function(a,b){var c=new Preloader.CLoadChallenge(a);c=new Preloader.PopupView(c,b);c.setOpacity(50);c.runAction(new cc.FadeTo(.3,255));c.run();cc.director.getRunningScene().addChild(c,Number.MAX_VALUE-
10)},loadEditor:function(a){var b=new Preloader.CLoadEditor;a=new Preloader.PopupView(b,a);a.setOpacity(50);a.runAction(new cc.FadeTo(.3,255));a.run();cc.director.getRunningScene().addChild(a,Number.MAX_VALUE-10)}}));
Preloader.Controller=cc.Class.extend({_resmaster:null,_ressecond:null,_tasks:null,_task:null,_progress:0,_total:0,_done:0,_error:!1,ctor:function(){this._resmaster=[];this._ressecond=[];this._task=null;this._tasks=[];this._done=this._total=this._progress=0;this._error=!1},init:function(){for(var a in this._tasks)this._total+=this._tasks[a].ratio},isFinish:function(){return this.getTotal()<=this.getDone()},complete:function(){for(var a in this._ressecond)cc.log(cc.formatStr("load background res[%s]",
this._ressecond[a])),cc.loader.load(this._ressecond[a],function(a,c,d){},function(a,c){a&&(cc.error(JSON.stringify(a)),Backend.feedback())})},update:function(){var a=this;this._task&&this._task.done()&&(cc.log(cc.formatStr("Task done [%s]",this._task.key)),this._done+=this._task.ratio,this._task=null);null==this._task&&0<this._tasks.length&&(this._task=this._tasks.shift(),this._task.done()||(cc.log(cc.formatStr("Task run [%s]",this._task.key)),this._task.run()));if(null==this._task&&0==this._tasks.length&&
0<this._resmaster.length){for(var b in this._resmaster)cc.log(cc.formatStr("load res[%s]",this._resmaster[b])),cc.loader.load(this._resmaster[b],function(a,b,e){},function(b,d){b?(cc.error(JSON.stringify(b)),a._error||(a._error=!0,Popup.alert(Popup.ALERT.NETWORK,app.Scene.getCurrent(),1))):a._done++});this._total+=this._resmaster.length;this._resmaster=[]}},getProgress:function(){var a=Math.min(this.getDone()/this.getTotal()||0,1);return this._progress=Math.max(this._progress,a)},getTotal:function(){return this._total+
this._resmaster.length},getDone:function(){return this._done}});
Preloader.CLoadGame=Preloader.Controller.extend({ctor:function(){this._super();this.init()},init:function(){var a=this;this._tasks.push({run:function(){Backend.init()},done:function(){return Backend.isReady()},ratio:1,key:"init backend"});this._tasks.push({run:function(){User.restGetData()},done:function(){return User.isReady()},ratio:1,key:"init user profile & products"});this._tasks.push({run:function(){User.getScoreById(0).restGetData()},done:function(){return User.getScoreById(0).isReady()},ratio:1,
key:"load user score, mapId:0"});this._tasks.push({run:function(){User.getChallenge().restGetData()},done:function(){return User.getChallenge().isReady()||!User.getChallenge().isActive()},ratio:1,key:"load weekly challenge"});this._tasks.push({_done:!1,run:function(){app.checkData();try{BGame.config.updateConsent&&Backend.acceptConsent()}catch(f){}a._resmaster.push(Resource.LANG.locale(User.getLocale()));if(User.getChallenge().isActive()||User.getChallenge().noticeExpired(!1))a._resmaster.push(Resource.ATLASES.CHALLENGE0_PNG),
a._resmaster.push(Resource.ATLASES.CHALLENGE0_LIST);var b=Math.ceil(Math.min(6*Math.ceil((User.getUnlock()+1)/6),app.config.ol(0))/2)-1,c=Math.ceil(User.getUnlock()/2)-1;c=Math.min(c,b);var d=Math.floor(b/3),e=Math.floor(Math.max(c-1,0)/3);b=Math.floor(Math.min(c+1,b)/3);for(c=0;c<e;c++)a._ressecond.push(Resource.MAP.segment(c));for(c=e;c<=b;c++)a._resmaster.push(Resource.MAP.segment(c));for(c=b+1;c<=d;c++)a._ressecond.push(Resource.MAP.segment(c));0==User.getScoreById(0).getSize()%10&&(d=Math.floor(User.getScoreById(0).getSize()/
10),d<app.config.ol(0)&&a._ressecond.push(Resource.MAP.lk(0,d)));this._done=!0},done:function(){return this._done},ratio:1,key:"check data, update resources"});this._resmaster.push(Resource.ATLASES.UI0_PNG,Resource.ATLASES.UI0_LIST,Resource.LANG.font,Resource.MAP.config(0),Resource.MAP.levels(0));this._super()},complete:function(){this._super();cc.spriteFrameCache.addSpriteFrames(Resource.ATLASES.UI0_LIST);(User.getChallenge().isActive()||User.getChallenge().noticeExpired(!1))&&cc.spriteFrameCache.addSpriteFrames(Resource.ATLASES.CHALLENGE0_LIST)}});
Preloader.CLoadClient=Preloader.Controller.extend({_mapId:0,_levelId:0,ctor:function(a,b){this._super();this._mapId=a;this._levelId=Number(b);this.init()},init:function(){this._resmaster.push(Resource.ATLASES.CLIENT0_PNG,Resource.ATLASES.CLIENT0_LIST);if(1E3>this._mapId)this._resmaster.push(Resource.MAP.back(this._mapId,0!==this._mapId?0:Math.floor((this._levelId-1)/10)));else{var a=User.getChallenge().getType();this._resmaster.push(Resource.WEEKLY_CHALLENGE.back(a))}this._super()},complete:function(){this._super();
cc.spriteFrameCache.addSpriteFrames(Resource.ATLASES.CLIENT0_LIST)}});
Preloader.CLoadMap=Preloader.Controller.extend({_mapId:null,ctor:function(a){this._super();this._mapId=a;this.init()},init:function(){var a=this;this._tasks.push({_score:null,run:function(){this._score=User.getScoreById(a._mapId);this._score.isReady()||this._score.restGetData()},done:function(){return this._score&&this._score.isReady()},ratio:1,key:"load score:"+a._mapId});this._resmaster.push(Resource.MAP.config(this._mapId),Resource.MAP.levels(this._mapId));if(0==this._mapId){var b=Math.ceil(Math.min(6*
Math.ceil((User.getUnlock()+1)/6),app.config.ol(0))/2)-1,c=Math.ceil(User.getUnlock()/2)-1,d=Math.floor(b/3),e=Math.floor(Math.max(c-1,0)/3);b=Math.floor(Math.min(c+1,b)/3);for(c=0;c<e;c++)a._ressecond.push(Resource.MAP.segment(c));for(c=e;c<=b;c++)a._resmaster.push(Resource.MAP.segment(c));for(c=b+1;c<=d;c++)a._ressecond.push(Resource.MAP.segment(c));0==User.getScoreById(0).getSize()%10&&(d=Math.floor(User.getScoreById(0).getSize()/10),d<app.config.ol(0)&&a._ressecond.push(Resource.MAP.lk(0,d)))}else this._resmaster.push(Resource.MAP.back(this._mapId,
0),Resource.ATLASES.ADV0_PNG,Resource.ATLASES.ADV0_LIST),14==User.getScoreById(this._mapId).getSize()&&this._ressecond.push(Resource.MAP.ADV.building_reward(this._mapId));this._super()},complete:function(){this._super();0!=this._mapId&&cc.spriteFrameCache.addSpriteFrames(Resource.ATLASES.ADV0_LIST)}});
Preloader.CLoadAdventure=Preloader.Controller.extend({ctor:function(){this._super();this._mapId=0;this.init()},init:function(){this._tasks.push({_scores:[],run:function(){for(var a=app.config.ol(2),b=12*Math.floor((a-22)/12)+22;b<=a;b++)this._scores[b]=User.getScoreById(b),this._scores[b].isReady()||this._scores[b].restGetData()},done:function(){return 0<this._scores.length&&this._scores.reduce(function(a,b){return a&&b.isReady()},!0)},ratio:1,key:"load scores: master"});this._tasks.push({_scores:[],
run:function(){for(var a=12*Math.floor((app.config.ol(2)-22)/12)+22-1;22<=a;a--)this._scores[a]=User.getScoreById(a),this._scores[a].isReady()||this._scores[a].restGetData()},done:function(){return 0<this._scores.length},ratio:1,key:"load scores: slave"});this._resmaster.push(Resource.ATLASES.ADV0_PNG,Resource.ATLASES.ADV0_LIST,Resource.MAP.ADV.back);this._super()},complete:function(){this._super();cc.spriteFrameCache.addSpriteFrames(Resource.ATLASES.ADV0_LIST)}});
Preloader.CLoadChallenge=Preloader.Controller.extend({ctor:function(a){this._super();this._mapId=a;this.init()},init:function(){var a=User.getChallenge().getType();this._resmaster.push(Resource.MAP.levels(this._mapId),Resource.WEEKLY_CHALLENGE.back(a));this._super()},complete:function(){this._super()}});
Preloader.CLoadEditor=Preloader.Controller.extend({ctor:function(){this._super();this._mapId=0;this.init()},init:function(){this._resmaster.push(Resource.ATLASES.EDITOR0_PNG,Resource.ATLASES.EDITOR0_LIST);this._super()},complete:function(){this._super();cc.spriteFrameCache.addSpriteFrames(Resource.ATLASES.EDITOR0_LIST)}});
Preloader.SplashView=cc.Scene.extend({_cbdone:null,_controller:null,_progBack:null,_progFront:null,_promo:null,ctor:function(a,b){this._super();this._cbdone=b;this._controller=a;this._promo=null!=app.config.mobilePromotionIOS()||null!=app.config.mobilePromotionAndroid()||null!=app.config.mobilePromotionKindle()},run:function(){var a=this,b=[];this._promo?b.push(Resource.SPLASH.back,Resource.SPLASH.prog_back,Resource.SPLASH.prog_front,Resource.SPLASH.bt_ios,Resource.SPLASH.bt_android,Resource.SPLASH.bt_kindle):
b.push(Resource.SPLASH.back,Resource.SPLASH.prog_back,Resource.SPLASH.prog_front);cc.loader.load(b,function(a,b,e){},function(){var b=new cc.Sprite(Resource.SPLASH.back);b.setAnchorPoint(0,0);a.addChild(b);a._progBack=new cc.Sprite(Resource.SPLASH.prog_back);a._progBack.setPosition(555,445);a._progFront=new cc.Sprite(Resource.SPLASH.prog_front);a._progFront.setPosition(555-.5*a._progFront.getContentSize().width,445);a._progFront.setAnchorPoint(0,.5);a._progFront.setScaleX(0);a.addChild(a._progBack);
a.addChild(a._progFront);var d=[];null!=app.config.mobilePromotionIOS()&&a._promo&&(b=new CButton(Resource.SPLASH.bt_ios,null,{b:.05},{b:-.15}),b.setCbUp(cc.sys.openURL.bind(this,app.config.mobilePromotionIOS())),a.addChild(b),d.push(b));null!=app.config.mobilePromotionAndroid()&&a._promo&&(b=new CButton(Resource.SPLASH.bt_android,null,{b:.05},{b:-.15}),b.setCbUp(cc.sys.openURL.bind(this,app.config.mobilePromotionAndroid())),a.addChild(b),d.push(b));null!=app.config.mobilePromotionKindle()&&a._promo&&
(b=new CButton(Resource.SPLASH.bt_kindle,null,{b:.05},{b:-.15}),b.setCbUp(cc.sys.openURL.bind(this,app.config.mobilePromotionKindle())),a.addChild(b),d.push(b));1==d.length?d[0].setPosition(570,95):2==d.length?(d[0].setPosition(485,90),d[1].setPosition(655,90)):3==d.length&&(d[0].setPosition(485,100),d[1].setPosition(655,100),d[2].setPosition(567,45));a.scheduleUpdate();app.hideSplash()})},update:function(a){this._controller.update();this._controller.isFinish()?(cc.log("loading completed"),this._controller.complete(),
this._progFront.setScaleX(1),this.unscheduleAllCallbacks(),this._cbdone&&this._cbdone()):this._progFront.setScaleX(this._controller.getProgress())},getMapId:function(){return 0},getLevelId:function(){return 0}});
Preloader.PopupView=cc.Layer.extend({_cbdone:null,_controller:null,_popup:null,_progBack:null,_progFront:null,ctor:function(a,b){this._super();this._cbdone=b;this._controller=a;this.addChild(new cc.LayerColor(new cc.Color(0,0,0,255*.86)));var c=this.getContentSize();this._popup=(new Popup.PopBase).buildBackground(320,150);this._popup.setPosition(.5*c.width,.5*c.height);this.addChild(this._popup);this._progBack=new cc.Sprite(Resource.SPLASH.s_prog_back);this._progBack.setPosition(160,50);this._progFront=
new cc.Sprite(Resource.SPLASH.s_prog_front);this._progFront.setPosition(160-.5*this._progFront.getContentSize().width,50);this._progFront.setAnchorPoint(0,.5);this._progFront.setScaleX(0);this._popup.addChild(this._progBack);this._popup.addChild(this._progFront);c=new CLabelTTF(Lang.getString(Lang.MAP_PRELOADER),26,this._popup.getContentSize().width-70,2);c.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);c.setPosition(160,75);this._popup.addChild(c);cc.eventManager.addListener({event:cc.EventListener.MOUSE,
onMouseMove:this.mouseStop.bind(this),onMouseDown:this.mouseStop.bind(this)},this)},mouseStop:function(a){a.stopPropagation()},run:function(){this.scheduleUpdate()},update:function(a){this._controller.update();this._controller.isFinish()?(cc.log("loading completed"),this._controller.complete(),this._progFront.setScaleX(1),this.unscheduleAllCallbacks(),this._cbdone&&this._cbdone()):this._progFront.setScaleX(this._controller.getProgress())}});var KApi=new (cc.Class.extend({_brw:null,_rnd:0,ctor:function(){this._brw=this.getBrowser()},event:function(a,b){b=b||{};this.setParams(a,b);this.setJSData(a,b);var c={};c.n=a;c.s=b.s?String(b.s):"";c.v=b.v?String(b.v):"";c.l=b.l?String(b.l):"";c.st1=b.st1?String(b.st1):"";c.st2=b.st2?String(b.st2):"";c.st3=b.st3?String(b.st3):"";c.data=b.data||{};c.data.timestamp=TimeUtils.getTime(!0);c.data.html5=1;c.data=Base64.encodeObject(c.data);if(app.config.kontagent())try{BGame.metrics.trackEvtMessage(c)}catch(d){cc.error(d)}},
updateRandom:function(){this._rnd=CUtils.random(1,2147483645)},setParams:function(a,b){var c=app.Scene.getCurrent();switch(a){case KApi.EVENT.FLASH_LOAD_START:b.st1=app.config.intro()?"newcomer":"returning";b.st2=app.config.session();b.st3="1";b.l="0";break;case KApi.EVENT.FLASH_LOAD_END:b.st1=app.config.intro()?"newcomer":"returning";b.st2=app.config.session();b.st3="1";b.l=User.getScoreById(0).getSize();break;case KApi.EVENT.INVITE:b.l=c?c.getLevelId():"0";break;case KApi.EVENT.CHAPTER_UNLOCK:b.l=
User.getScoreById(0).getSize();b.st1=User.getUnlock();break;case KApi.EVENT.LEVEL_START:b.st1=app.config.intro()?"newcomer":"returning";break;case KApi.EVENT.LIFE_SEND:b.st3=User.getScoreById(0).getSize();b.l=c?c.getLevelId():"0";break;case KApi.EVENT.PURCHASE:b.l=c&&app.Scene.isRunning(app.Scene.TAG.CLIENT)?c.getLevelId():"0"}return b},setJSData:function(a,b){if(b.data)return b;var c=app.Scene.getCurrent();b.data={};switch(a){case KApi.EVENT.FLASH_LOAD_START:b.data.brw=this._brw;b.data.brw_v="0";
b.data.fb_id=app.config.userId();b.data.game_id=this._rnd;b.data.map_id=0;b.data.locale=app.config.userLocale();b.data.inventory={};b.data.inventory.total_hard_currency=0;b.data.inventory.total_soft_currency=0;b.data.inventory.number_of_lives=0;break;case KApi.EVENT.FLASH_LOAD_END:case KApi.EVENT.LEVEL_START:case KApi.EVENT.SPENDING:case KApi.EVENT.LIFE_SEND:case KApi.EVENT.CHAPTER_UNLOCK:case KApi.EVENT.BOOSTER_USE:case KApi.EVENT.INVITE:b.data.brw=this._brw;b.data.brw_v="0";b.data.fb_id=User.getFbId();
b.data.game_id=this._rnd;b.data.map_id=c?c.getMapId():0;b.data.locale=User.getLocale();b.data.inventory={};b.data.inventory.total_hard_currency=User.getCash().getValue();b.data.inventory.total_soft_currency=User.getCoins().getValue();b.data.inventory.number_of_lives=User.getLive().getLives();break;case KApi.EVENT.LEVEL_END:b.data.session_id=app.config.session();b.data.fb_id=User.getFbId();b.data.game_id=this._rnd;b.data.map_id=c?c.getMapId():0;b.data.is_payer=User.isPayer()?!0:!1;b.data.inventory=
{};b.data.inventory.total_hard_currency=User.getCash().getValue();b.data.inventory.total_soft_currency=User.getCoins().getValue();b.data.inventory.number_of_lives=User.getLive().getLives();b.data.booster_bought=!1;b.data.booster_used=!1;b.data.number_of_auto_match=0;b.data.level_aim={};b.data.level_aim.score=0;b.data.level_aim.background_broken=0;b.data.level_aim.chest=0;b.data.level_completed={};b.data.level_completed.score=0;b.data.level_completed.background_broken=0;b.data.level_completed.chest=
0;break;case KApi.EVENT.LEVEL_CUSTOM:b.data.user_id=User.getFbId();b.data.game_id="";b.data.user_segment=User.getAudience()?User.getAudience():app.config.audience();b.data.is_payer=User.isPayer()?1:0;break;case KApi.EVENT.PURCHASE:b.data.fb_id=User.getFbId(),b.data.game_id=this._rnd,b.data.map_id=c?c.getMapId():0,b.data.is_payer=User.isPayer()?!0:!1,b.data.inventory={},b.data.inventory.total_hard_currency=User.getCash().getValue(),b.data.inventory.total_soft_currency=User.getCoins().getValue(),b.data.inventory.number_of_lives=
User.getLive().getLives()}return b},getBrowser:function(){try{var a=window.navigator.userAgent.toString();if(-1!=a.indexOf("Safari"))return"Safari";if(-1!=a.indexOf("Firefox"))return"Firefox";if(-1!=a.indexOf("Chrome"))return"Chrome";if(-1!=a.indexOf("IE"))return"Internet Explorer";if(-1!=a.indexOf("Opera"))return"Opera"}catch(b){}return"[Unknown Browser]"}}));
KApi.EVENT={FLASH_LOAD_START:"FlashLoadStart",FLASH_LOAD_END:"FlashLoadEnd",LEVEL_START:"LevelStart",LEVEL_END:"LevelEnd",LEVEL_CUSTOM:"_custom",SPENDING:"Spending",PURCHASE:"SocPurchase",LIFE_SEND:"LifeSend",CHAPTER_UNLOCK:"ChapterUnlock",BOOSTER_USE:"BoosterUse",INVITE:"Invite"};app.Scene=cc.Scene.extend({_onEnter:null,_layer:null,_mapId:null,_levelId:null,ctor:function(a){this._super();this._onEnter=null;this._layer=new cc.Layer;this._levelId=this._mapId=0;this.setTag(a);this.addChild(this._layer)},getMapId:function(){return this._mapId},getLevelId:function(){return this._levelId},setOnEnter:function(a){this._onEnter=a},onEnter:function(){this._super();this._onEnter&&this._onEnter()}});app.Scene.TAG={SPLASH:1,GAME:2,CLIENT:3,ADVENTURE:4,CHALLENGE:5,EDITOR:6};
app.Scene.isRunning=function(a){return cc.director.getRunningScene().getTag()===a};app.Scene.getCurrent=function(){return cc.director.getRunningScene()};app.Scene.Game=app.Scene.extend({ctor:function(a){this._super(app.Scene.TAG.GAME);this._mapId=0;this._layer.addChild(new Map.Default(a||{}));this._layer.addChild(new PanelSound(0));this._layer.addChild(new PanelSphere(0));this._layer.addChild(new PanelMiddle(0));this._layer.addChild(new PanelUp(0))},getLevelId:function(){return User.getScoreById(0).getSize()}});
app.Scene.Client=app.Scene.extend({ctor:function(a,b,c){this._super(app.Scene.TAG.CLIENT);this._mapId=Number(a);this._levelId=Number(b.id);if(1E3>this._mapId)var d=new cc.Sprite(Resource.MAP.back(a,0!==a?0:Math.floor((Number(b.id)-1)/10)));else d=User.getChallenge().getType(),d=new cc.Sprite(Resource.WEEKLY_CHALLENGE.back(d));d.setAnchorPoint(0,0);this._layer.addChild(d);this._layer.addChild(new Client(a,b,c));this._layer.addChild(new PanelSound(1));this._layer.addChild(new PanelUp(a))}});
app.Scene.Adventure=app.Scene.extend({ctor:function(a,b){this._super(app.Scene.TAG.ADVENTURE);!a&&21<b?(this._mapId=b,this._layer.addChild(new Map.Adventure(b)),this._layer.addChild(new PanelSound(3)),this._layer.addChild(new PanelSphere(b)),this._layer.addChild(new PanelUp(b))):(this._mapId=0,this._layer.addChild(new Map.Adventure.Menu(Math.floor((b-22)/12))),this._layer.addChild(new PanelSound(2)),this._layer.addChild(new PanelUp(0)))},getLevelId:function(){return User.getScoreById(this._mapId).getSize()}});
app.Scene.Challenge=app.Scene.extend({ctor:function(a){this._super(app.Scene.TAG.CHALLENGE);this._mapId=a;this._layer.addChild(new Map.Challenge(a));this._layer.addChild(new PanelSound(2));this._layer.addChild(new PanelUp(a))}});app.Scene.Editor=app.Scene.extend({ctor:function(){this._super(app.Scene.TAG.EDITOR);this._mapId=0;this._layer.addChild(new Editor)}});var LocalStorage=new (cc.Class.extend({ctor:function(){},setValue:function(a,b){try{if(window.localStorage)return window.localStorage.setItem(a,b),!0}catch(c){}return!1},getValue:function(a){try{if(window.localStorage)return window.localStorage.getItem(a)}catch(b){}return null},remValue:function(a){try{if(window.localStorage)return window.localStorage.removeItem(a),!0}catch(b){}return!1}}));var HttpRest=cc.Class.extend({_user:null,_pass:null,_fb_token:null,_access_token:null,_refresh_token:null,_timeout:null,_queue:null,_current:null,ctor:function(a,b){this._user=a;this._fb_token=b;this._refresh_token=this._access_token=null;this._timeout=24E4;this._queue=[];this._current=null},send:function(a){a&&this._queue.push(a);null==this._current&&0<this._queue.length&&(this._current=this._queue.shift(),this._access_token?this._send(this._current):this._auth(this._current))},_auth:function(a){var b=
this,c=null,d=cc.loader.getXMLHttpRequest();d.req_time=(new Date).getTime();d.req_obj=a;d.req_url=null!=this._refresh_token?HttpRest.CONFIG.HOST_AUTH+"/"+HttpRest.CONFIG.VERSION+"/auth/refresh_token":HttpRest.CONFIG.HOST_AUTH+"/"+HttpRest.CONFIG.VERSION+"/auth/exchange_fb_token";d.open(HttpRest.METHOD.POST,d.req_url,!0);d.timeout=this._timeout;null!=this._refresh_token?d.setRequestHeader("Authorization","Bearer "+this._refresh_token):(c={},c.fb_access_token=this._fb_token,c=JSON.stringify(c));d.onload=
function(){if(200===d.status){var c=JSON.parse(d.responseText);if("token"===c["class"]){b._access_token=c.properties.access_token;b._refresh_token=c.properties.refresh_token;b._send(a);return}}401===d.status&&null!=b._refresh_token?(b._refresh_token=null,b._auth(a)):b._onError(d)};d.onerror=function(){b._onError(d)};d.send(c);d.send_time=(new Date).getTime()},_send:function(a){var b=this,c=cc.loader.getXMLHttpRequest();c.req_time=(new Date).getTime();c.req_url=HttpRest.CONFIG.HOST_API+"/"+HttpRest.CONFIG.VERSION+
a.getPath();c.req_obj=a;c.open(a.getMethod(),c.req_url,!0);c.timeout=this._timeout;c.setRequestHeader("Authorization","Bearer "+b._access_token);c.setRequestHeader("AccessToken",b._fb_token);c.setRequestHeader("platform","flash");var d=a.getHeader(),e;for(e in d)c.setRequestHeader(e,d[e]);c.onload=function(){200>c.status||(200<=c.status&&400>c.status?b._onSuccess(c):(401===c.status&&(b._access_token=null),b._onError(c)))};c.onerror=function(){401===c.status&&(b._access_token=null)};c.send(a.getBody());
c.send_time=(new Date).getTime();cc.log("HttpRest: send - "+a.getPath())},_onSuccess:function(a){a.responseText?(this._current&&(this._current.onSuccess(a.responseText,a.getResponseHeader("country_code")),this._current=null),this.send(null)):this._onError(a)},_onError:function(a){var b=this;this._current?3>this._current.getAttempt()?(this._current.incAttempt(),cc.director.getScheduler().unschedule("schedule_rentry",this),cc.director.getScheduler().schedule(function(){cc.log("try send req again: "+
b._current.getPath());b._access_token?b._send(b._current):b._auth(b._current)},this,this._current.getAttempt(),0,0,!1,"schedule_rentry")):(cc.log("all attempts failed: "+this._current.getPath()),"object"==typeof newrelic&&0==a.status&&newrelic.addPageAction("network_err",{userId:this._user,url:a.req_url,time:(new Date).getTime()-a.req_time}),this._current.onError(a.responseText),this._current=null,this.send(null)):this.send(null)}});
HttpRest.Request=cc.Class.extend({_method:null,_attempt:0,_sign:0,_path:null,_body:null,_header:null,_cbSuccess:null,_cbError:null,_cbData:null,ctor:function(a,b,c,d,e,f){this._method=a;this._path=b;this._body=c?JSON.stringify(c):null;this._attempt=0;this._header={};this._cbSuccess=d||null;this._cbError=e||null;this._cbData=f||null;this._sign=HttpRest.Request.signId()},incAttempt:function(){this._attempt++},getAttempt:function(){return this._attempt},getPath:function(){return this._path+(0<=this._path.indexOf("?")?
"&":"?")+"_t="+Math.random()+"&_id="+this._sign+"&_r="+this._attempt},getMethod:function(){return this._method},getBody:function(){return this._body},addHeader:function(a,b){this._header[a]=b},getHeader:function(){return this._header},onSuccess:function(a,b){this._cbSuccess&&this._cbSuccess(a?JSON.parse(a):null,this._cbData,b)},onError:function(a){cc.log("req failed:"+a);this._cbError&&this._cbError(a,this._cbData)}});
HttpRest.Request.signId=function(){var a=HttpRest.Request._signId||1;HttpRest.Request._signId=a+1;return a};HttpRest.CONFIG={HOST_AUTH:"",HOST_API:"",VERSION:"v1.0"};HttpRest.METHOD={GET:"GET",POST:"POST",PUT:"PUT",DELETE:"DELETE",PATCH:"PATCH"};var Backend=new (cc.Class.extend({_ready:!1,_rest:null,_fbId:null,_fbToken:null,ctor:function(){},init:function(){this._fbInit()},isReady:function(){return this._ready},send:function(a){this._rest.send(a)},purchase:function(a,b,c){var d=this,e={coins:0,cash:0},f=function(c){cc.eventManager.dispatchCustomEvent(Backend.EVENT.PURCHASE_COMPLETE,{status:c,key:b,item:a})},g=app.Scene.getCurrent(),h={};h.items=cc.isArray(a)?a:[a];h.ownerId=0;h.mapId=g?g.getMapId():0;h.level=g?g.getLevelId():0;h.inLevel=
app.Scene.isRunning(app.Scene.TAG.CLIENT)?1:0;h.items.forEach(function(a){cc.assert(a.currency,"currency not defined");a.quantity=a.quantity||1;a.discountId=a.discountId||"";var b=Products.getProduct(a.productId).getPrice(a.currency,a.discountId);a.currency===Products.CURRENCY.COINS?e.coins+=Number(b.getAmount()):a.currency===Products.CURRENCY.CASH&&(e.cash+=Number(b.getAmount()))});g={};g.st1=h.items.map(function(a){return a.productId+(""!=a.discountId?"/"+a.discountId:"")}).join(",");g.st2=c?c:
1==h.inLevel?"in_level":"general";g.st3="0";g.l=h.level;g.v=0<e.cash?-parseInt(e.cash):parseInt(e.coins);KApi.event(KApi.EVENT.SPENDING,g);cc.log("buy ["+JSON.stringify(e)+"],["+JSON.stringify(h)+"]");e.coins>User.getCoins().getValue()?(Popup.alert(Popup.ALERT.NO_COINS),f(!1)):e.cash>User.getCash().getValue()?(Popup.alert(Popup.ALERT.NO_CASH),f(!1)):(this.send(new HttpRest.Request(HttpRest.METHOD.POST,"/users/"+this._fbId+"/products/purchase",h,function(a,b){Popup.close(Popup.PopAlert);var c=CUtils.getValue(a,
"properties.status"),g=CUtils.getValue(a,"properties.failReason","");if("completed"==c){for(var h in b)c=b[h],d.purchaseSuccess(c.productId,c.currency,c.discountId);User.getCoins().remValue(e.coins,!0);User.getCash().remValue(e.cash,!0);f(!0)}else"insufficient_coins"==g?(User.restGetCurrency(),Popup.alert(Popup.ALERT.NO_COINS)):"insufficient_crystals"==g?(User.restGetCurrency(),Popup.alert(Popup.ALERT.NO_CASH)):Popup.alert(Popup.ALERT.PURCHASE_FAILED),f(!1)},function(a,b){Popup.close(Popup.PopAlert);
Popup.alert(Popup.ALERT.PURCHASE_FAILED);f(!1)},h.items)),Popup.alert(Popup.ALERT.PROCESSING))},purchaseFB:function(a,b,c,d){cc.log("Purchase fb ["+a+","+b+"]");var e=this,f=app.Scene.getCurrent(),g=b?a+"/"+b:a,h=f?f.getLevelId():0;f=f?f.getMapId():0;d=d?Products.getMobile(a):null;var k=function(d){cc.eventManager.dispatchCustomEvent(Backend.EVENT.PURCHASE_COMPLETE,{status:d,key:c,item:{productId:a,discountId:b}})},m=function(a){Popup.close(Popup.PopAlert);e.purchaseSuccess(a.productId,a.currency,
a.discountId);User.setPayer(1);k(!0);KApi.event(KApi.EVENT.PURCHASE,{st1:a.productId,st2:a.amount,st3:a.currency})},n=function(){Popup.close(Popup.PopAlert);k(!1)};try{BGame.interactions.purchaseFBItem(g,1,null,h,f,d,m,n),Popup.alert(Popup.ALERT.PROCESSING)}catch(p){n()}},purchaseSuccess:function(a,b,c,d){cc.log("purchase product:["+a+","+b+","+c+","+d+"]");c=(a=Products.getProduct(a))?a.getDiscount(c):null;if(a){d||(b=Products.getProperty("immortality",a,c,Number,0),User.getLive().addImmortality(b));
if(a.hasType(Products.TYPE.PACKAGE)){b=Products.getProperty("coins",a,c,Number,0);var e=Products.getProperty("crystals",a,c,Number,0);User.getCoins().addValue(b,!0);User.getCash().addValue(e,!0)}else a.hasType(Products.TYPE.LIVES)?(b=Products.getProperty("lives",a,c,Number,0),User.getLive().addLives(b)):a.hasType(Products.TYPE.ORB)?User.boughtOrb(a.getId()):a.hasId(Products.IDS.PR_UNLOCK)?cc.eventManager.dispatchCustomEvent(Map.EVENT.UNLOCK_NEXT_CHAPTER,{type:"INAPP"}):a.hasId(Products.IDS.PR_MOVES_5)?
cc.log("purchase success:"+a.getId()):cc.assert(!1,"not implement");cc.eventManager.dispatchCustomEvent(Backend.EVENT.PURCHASE_SUCCESS,{prodId:a.getId()});if(!d&&c){d=c.getAdditional();for(var f in d)this.purchaseSuccess(d[f],null,null,!0)}}},levelStart:function(a,b,c){var d={};d.updateLives=User.getLive().hasImmortality()?"0":"1";d.updateLifeTimer=User.getLive().hasImmortality()?"0":"1";this.send(new HttpRest.Request(HttpRest.METHOD.PUT,"/users/"+this._fbId+"/maps/"+a+"/levels/"+b+"/start",d,function(a,
b){c(a&&"success"==a["class"])},function(a,b){c(!1)}))},chapterUnlock:function(a,b,c,d){a={resetUnlockTimer:!0};a.unlockedLocations=b;this.send(new HttpRest.Request(HttpRest.METHOD.PATCH,"/users/"+this._fbId,a,function(a,b){var c=a&&"success"===a["class"];if(c){var e=User.getInbox().getUnlock(),f;for(f in e)User.getInbox().deleteGift(e[f].id);User.getInbox().flushDump()}d(c)},function(a,b){d(!1)}))},levelFinish:function(a,b,c,d){var e=this;if("win"!=c.status)d(!0);else{var f={};f.updateLives=User.getLive().hasImmortality()?
"0":"1";f.score=c.score;f.earned=c.keys;f.coins=c.coins;e.newrelicEvent("win_level_send",{levelId:b});this.send(new HttpRest.Request(HttpRest.METHOD.PUT,"/users/"+this._fbId+"/maps/"+a+"/levels/"+b+"/win",f,function(a,c){cc.log("success",JSON.stringify(a));e.newrelicEvent("win_level_processed",{levelId:b,error:a&&"success"==a["class"]?0:1});d(a&&"success"==a["class"])},function(a,c){cc.log("error",JSON.stringify(a));e.newrelicEvent("win_level_processed",{levelId:b,error:1});d(!1)}))}},putCoins:function(a,
b){var c={};c.ingameCoins=a+User.getCoins().getValue();this.send(new HttpRest.Request(HttpRest.METHOD.PATCH,"/users/"+this._fbId,c,function(c,e){c&&"success"===c["class"]&&User.getCoins().addValue(a,!0);b&&b(c&&"success"===c["class"])},function(a,c){b&&b(!1)}))},putAgeRange:function(a,b){var c={};c.ageRange=a;this.send(new HttpRest.Request(HttpRest.METHOD.PATCH,"/users/"+this._fbId,c,function(c,e){c&&"success"===c["class"]&&User.setAgeRange(a);b&&b(c&&"success"===c["class"])},function(a,c){b&&b(!1)}))},
saveTreasure:function(a,b,c,d){var e=function(a,b){d&&d(a&&"success"===a["class"])},f=function(a,b){d&&d(!1)};1==b?(a=a.map(function(a){return{level:a,status:1==b?"rewarded":"not_rewarded"}}),Backend.send(new HttpRest.Request(HttpRest.METHOD.PATCH,"/users/"+this._fbId+"/treasure-chest-levels",a,e,f))):(a=a.map(function(a){return{level:a,expires:c}}),Backend.send(new HttpRest.Request(HttpRest.METHOD.POST,"/users/"+this._fbId+"/treasure-chest-levels",a,e,f)))},saveScratch:function(a,b,c){var d=function(a,
b){c&&c(a&&"success"===a["class"])},e=function(a,b){c&&c(!1)};if(1==b){var f=[];f.push({level:a,status:1==b?"rewarded":"not_rewarded"});Backend.send(new HttpRest.Request(HttpRest.METHOD.PATCH,"/users/"+this._fbId+"/daily-scratch-levels",f,d,e))}else f=[],f.push(a),Backend.send(new HttpRest.Request(HttpRest.METHOD.POST,"/users/"+this._fbId+"/daily-scratch-levels",f,d,e))},saveSound:function(a,b){var c=this;cc.director.getScheduler().unschedule("save_sound",c);cc.director.getScheduler().schedule(function(a,
b){var d={};d.sound=b?1:0;d.music=a?1:0;c.send(new HttpRest.Request(HttpRest.METHOD.PATCH,"/users/"+c._fbId,d))}.bind(c,a,b),c,5,0,0,!1,"save_sound")},acceptConsent:function(){Backend.send(new HttpRest.Request(HttpRest.METHOD.PATCH,"/users/"+this._fbId,{consent:!0}))},scheduledRemoval:function(a){var b={};b.scheduledRemoval=a;Backend.send(new HttpRest.Request(HttpRest.METHOD.PATCH,"/users/"+this._fbId,b))},rqInvite:function(a){a=a.map(function(a){return a.getFbId()});if(0!=a.length)try{BGame.interactions.inviteFriends2(a.join(","))}catch(b){cc.error(b)}},
rqAskLife:function(a){var b=[],c=[],d;for(d in a){var e=a[d];e.getInGame()&&b.push({fromUserId:this._fbId,toUserId:e.getFbId(),type:"life"});c.push(e.getFbId())}0<b.length&&Backend.send(new HttpRest.Request(HttpRest.METHOD.POST,"/requests",b));if(0<c.length)try{BGame.interactions.askLife2(c.join(","))}catch(f){cc.error(f)}},rqAskUnlock:function(a){var b=[],c=[],d;for(d in a){var e=a[d];e.getInGame()&&b.push({fromUserId:this._fbId,toUserId:e.getFbId(),type:"unlock"});c.push(e.getFbId())}0<b.length&&
Backend.send(new HttpRest.Request(HttpRest.METHOD.POST,"/requests",b));if(0<c.length)try{BGame.interactions.askUnlock2(c.join(","))}catch(f){cc.error(f)}},rqBeat:function(a,b,c){c=c.map(function(a){return a.getFbId()});if(0!=c.length)try{var d="friend_defeated;@coins@:"+b+";@LEVEL@:"+a+this._feedGift();BGame.interactions.appRequest2(d,c.join(","))}catch(e){cc.error(e)}},rqBehind:function(a,b,c){c=c.map(function(a){return a.getFbId()});if(0!=c.length)try{var d="friend_behind;@coins@:"+b+";@LEVEL@:"+
a+this._feedGift();BGame.interactions.appRequest2(d,c.join(","))}catch(e){cc.error(e)}},feedBeatFriend:function(a,b,c){try{var d="friend_defeated;@coins@:"+b+";@LEVEL@:"+a+this._feedGift();BGame.interactions.postToFeed(d,c,MD5(String(b),1))}catch(e){cc.error(e)}},feedBehindFriend:function(a,b,c){try{var d="friend_behind;@coins@:"+b+";@LEVEL@:"+a+this._feedGift();BGame.interactions.postToFeed(d,c,MD5(String(b),1))}catch(e){cc.error(e)}},feedUnlockChapter:function(a,b,c,d,e){try{var f="location_opened;@coins@:"+
c+";@friends@:"+e.join(",")+";@chapter@:"+b+";@chapterId@:"+a+this._feedGift();BGame.interactions.postToFeed(f,d,MD5(String(c),1))}catch(g){cc.error(g)}},feedUnlockOrb:function(a,b,c){try{var d="unlock_orb_"+a+";@coins@:"+b+this._feedGift();BGame.interactions.postToFeed(d,c,MD5(String(b),1))}catch(e){cc.error(e)}},feedWinLevel:function(a,b,c){try{var d="share_"+a+"_keys;@coins@:"+b+this._feedGift();BGame.interactions.postToFeed(d,c,MD5(String(b),1))}catch(e){cc.error(e)}},feedAdvCompleted:function(a,
b,c){try{var d="adventure_completed;@ADVENTURE@:"+a+";@coins@:"+b+this._feedGift();BGame.interactions.postToFeed(d,c,MD5(String(b),1))}catch(e){cc.error(e)}},_feedGift:function(){return";@giftCode@:159+"+MD5("159",1)+";"},ogHighScore:function(a,b){this._ogSend(["get_high_score",a,b],b,"coins")},ogLevelComplete:function(a,b,c,d){this._ogSend(["complete_level",b,c,d,a])},ogBeatScore:function(a){this._ogSend(["beat_your_score",a])},ogUnlockChapter:function(a,b){this._ogSend(["open_new_location",a],b,
"coins")},ogUnlockOrb:function(a){this._ogSend(["unlock_talisman",a])},feedback:function(a){},newrelicEvent:function(a,b){"object"==typeof newrelic&&(b=b||{},b.time=b.time||(new Date).getTime(),b.userId=b.userId||this._fbId,newrelic.addPageAction(a,b))},_ogSend:function(a,b,c){if(app.config.ogActions())try{if(void 0!=b&&void 0!=c){var d=CUtils.random(2E4,1E6),e=["sharedBy=-2"];e[1]="giftCode="+d+" "+MD5(d,1);e[2]="hash="+MD5(c+b);e[3]=c+"="+b;BGame.utils.publishAction(a.join(":"),"?"+e.join("&"))}else BGame.utils.publishAction(a.join(":"))}catch(f){cc.error(f)}},
_fbInit:function(){var a=this,b=function(b){cc.log("FB login done");cc.director.getScheduler().unschedule("wait_fb_login",a);a._fbId||(a._fbId=b.authResponse.userID,a._fbToken=b.authResponse.accessToken,a._rest=new HttpRest(a._fbId,a._fbToken),FB.api("me?fields=id,first_name,last_name,picture,currency",function(b){if(b&&b.id===a._fbId){void 0==b.currency&&(b.currency={user_currency:"USD",currency_exchange:10,currency_exchange_inverse:.1,usd_exchange:1,usd_exchange_inverse:1,currency_offset:100});
if(b.currency){Products.CURRENCY.USER.unshift(b.currency.user_currency);try{BGame.userCurrencyInfo=b.currency}catch(f){cc.error(f)}}Products.init(b.id,b.payment_mobile_pricepoints,b.currency);User.init(b.id,b.currency);User.setProperties(b);User.getInbox().run();a._ready=!0;c()}else cc.log("bad response: "+JSON.stringify(b)),Popup.alert(Popup.ALERT.NETWORK)}))},c=function(){var a=User.getFriends();FB.api("me?fields=friends.limit(500){id,first_name,last_name,picture}",function(b){if(b&&b.friends&&
b.friends.data)for(var c in b.friends.data){var d=b.friends.data[c];a.add(new User.Friends.Item(d.id,!0,d))}a.restGetData();a.cleanCash()});FB.api("me?fields=invitable_friends.limit(500){id,first_name,last_name,picture}",function(b){if(b&&b.invitable_friends&&b.invitable_friends.data){for(var c in b.invitable_friends.data){var d=b.invitable_friends.data[c];a.add(new User.Friends.Item(d.id,!1,d))}a.cleanCash()}})};cc.director.getScheduler().schedule(function(){"undefined"!==typeof FB?(FB.getLoginStatus(function(a){"connected"===
a.status?b(a):cc.log("FB login status: "+JSON.stringify(a))}),cc.log("query fb token"+Math.random())):cc.log("wait fb sdk"+Math.random())},a,1,cc.REPEAT_FOREVER,0,!1,"wait_fb_login")}}));Backend.EVENT={PURCHASE_SUCCESS:"BK_PURCHASE_SUCCESS",PURCHASE_COMPLETE:"BK_PURCHASE_COMPLETE"};var UserBase=cc.Class.extend({_fbId:0,_ingame:!1,_firstName:null,_lastName:null,_picture:null,_timeGift:0,ctor:function(a,b){this._fbId=a;this._ingame=b;this._picture=this._lastName=this._firstName=null;this._timeGift=0},getFbId:function(){return this._fbId},hasFbId:function(a){return this._fbId==a},getFirstName:function(){return this._firstName},getLastName:function(){return this._lastName},getName:function(){return this._firstName+" "+this._lastName},getPicture:function(){return this._picture},
getInGame:function(){return this._ingame},setProperties:function(a){a&&(this._firstName=a.first_name||this._firstName,this._lastName=a.last_name||this._lastName,a.picture&&a.picture.data&&(this._picture=a.picture.data.url))}}),User=new (UserBase.extend({_ready:!1,_score:null,_highScore:null,_orbs:null,_inbox:null,_friends:null,_audience:null,_unlock:null,_unlocktimer:null,_locale:null,_coins:null,_cash:null,_live:null,_si:null,_paid:null,_ageRange:null,_dailyReward:0,_timestamp:0,_treasure:null,_scratch:null,
_challenge:null,_offers:null,_sound:null,_music:null,_currency:null,_countryCode:null,_scheduledRemoval:0,ctor:function(){this._super(0,!0);this._score={};this._highScore={};this._orbs=null},init:function(a,b){this._fbId=a;this._locale="en";this._audience=null;this._si=this._timestamp=this._dailyReward=this._paid=this._unlocktimer=this._unlock=0;this._coins=new CValue(0,User.EVENT.UPDATE_COINS);this._cash=new CValue(0,User.EVENT.UPDATE_CASH);this._live=new User.Live;this._inbox=new User.Inbox(a);
this._treasure=new User.Treasure;this._scratch=new User.Scratch;this._friends=new User.Friends(a);this._challenge=new User.Challenge(a);this._offers=new User.Offers(a);this._music=this._sound=1;this._currency=b},isReady:function(){return this._ready},restGetData:function(){cc.assert(this._fbId,"User init required");var a=this,b=4,c=0,d=function(a,b){Popup.alert(Popup.ALERT.NETWORK)},e=function(){b--;0<b||(a._ready=!0,a.unlockOrbs(c),a.discountOrb(c))};Backend.send(new HttpRest.Request(HttpRest.METHOD.GET,
"/users/"+this._fbId,null,function(b,d,h){b=b.properties;TimeUtils.setTimeServer(Number(b.timestamp));a._countryCode=h;a._audience=b.audienceTag?b.audienceTag:null;a._timestamp=Number(b.timestamp);a._si=parseInt(Number(b.timestamp)/86400);a._live.update(b.lives,b.totalLives,b.timeact);a._unlock=b.unlockedLocations?Number(b.unlockedLocations):a._unlock;a._unlocktimer=b.unlock_timer?Number(b.unlock_timer):0;a._paid=b.paidUser?Number(b.paidUser):a._paid;a._scheduledRemoval=b.scheduledRemoval?Number(b.scheduledRemoval):
0;b.locale&&(a._locale=b.locale.substring(0,2),-1==app.config.locales().indexOf(a._locale)&&(cc.log("unsupported locale:"+a._locale),a._locale="en"));0<b.dailyReward&&(a._dailyReward=(Number(b.dailyReward)-1)%5+1);b.ingameCoins&&a._coins.setValue(Number(b.ingameCoins),!0);b.ingameMoney&&a._cash.setValue(Number(b.ingameMoney),!0);b.immortalityRewardTimer&&a._live.setImmortality(Number(b.immortalityRewardTimer));b.music&&(a._music=Number(b.music));b.sound&&(a._sound=Number(b.sound));b.level&&(c=Number(b.level));
b.ageRange&&(a._ageRange=b.ageRange);e()},d));Backend.send(new HttpRest.Request(HttpRest.METHOD.GET,"/users/"+this._fbId+"/treasure-chest-levels",null,function(b,c){var d=a.getTreasure(),f;for(f in b.properties){var g=b.properties[f].properties;d.add(Number(g.level),"rewarded"==g.status?1:0)}e()},d));Backend.send(new HttpRest.Request(HttpRest.METHOD.GET,"/users/"+this._fbId+"/daily-scratch-levels",null,function(b,c){var d=a.getScratch(),f;for(f in b.properties){var g=b.properties[f].properties;d.add(Number(g.level),
"rewarded"==g.status?1:0)}e()},d));d=new HttpRest.Request(HttpRest.METHOD.GET,"/users/"+this._fbId+"/products",null,function(b,c){Products.loadFromJson(b);a.loadOrbs();for(var d in b.properties){var f=b.properties[d].properties;1==f.purchased&&a.boughtOrb(f.productId)}e()},d);d.addHeader("currencyInfo",Base64.encodeObject(this._currency));Backend.send(d)},restGetCurrency:function(){var a=this;Backend.send(new HttpRest.Request(HttpRest.METHOD.GET,"/users/"+this._fbId,null,function(b,c){var d=b.properties;
d.ingameCoins&&a._coins.setValue(Number(d.ingameCoins),!0);d.ingameMoney&&a._cash.setValue(Number(d.ingameMoney),!0)},function(a,c){Popup.alert(Popup.ALERT.NETWORK)}))},getScheduledRemoval:function(){return this._scheduledRemoval},getCoins:function(){return this._coins},getCash:function(){return this._cash},getLive:function(){return this._live},getScoreById:function(a){this._score[a]||(this._score[a]=new User.Score(this._fbId,a));return this._score[a]},getHighScoreById:function(a){this._highScore[a]||
(this._highScore[a]=new User.HighScore(this._fbId,a));return this._highScore[a]},getInbox:function(){return this._inbox},setPayer:function(a){this._paid=a},isPayer:function(){return 1==this._paid},getLocale:function(){return this._locale},getDailyReward:function(){return this._dailyReward},getUnlock:function(){return this._unlock},setUnlock:function(a){this._unlock=a},getUnlockTimer:function(){return this._unlocktimer},setUnlockTimer:function(a){this._unlocktimer=a},getTimestamp:function(){return this._timestamp},
getTreasure:function(){return this._treasure},getScratch:function(){return this._scratch},getChallenge:function(){return this._challenge},getOffers:function(){return this._offers},setSound:function(a){this._sound=a?1:0},getSound:function(){return 1==this._sound},setMusic:function(a){this._music=a?1:0},getMusic:function(){return 1==this._music},setAgeRange:function(a){this._ageRange=a},getAgeRange:function(){return this._ageRange},getCountryCode:function(){return this._countryCode},getAudience:function(){return this._audience},
getFriends:function(a){switch(a){case 0:return this._friends.getList(0);case 1:return this._friends.getList(1);case 2:return this._friends.getList(2);default:return this._friends}},getFriendById:function(a,b){return this._friends.getItem(a,b)},getFriendsByLevel:function(a){return this._friends.getListByLevel(a)},getGiftTime:function(a){return Number.MAX_VALUE-1},loadOrbs:function(){cc.assert(Products.isReady(),"Products ready required");this._orbs=Products.getProductByType(Products.TYPE.ORB).map(function(a){return new User.Orb(a)})},
getOrbs:function(a){a=a||0;return this._orbs.filter(function(b){return!b.isLocked()&&(0===a||1===a&&b.isPermanent()||2===a&&!b.isPermanent())?!0:!1})},unlockOrbs:function(a){var b=[];void 0===a&&(a=this.getScoreById(0).getSize());for(var c in this._orbs){var d=this._orbs[c];d.isLocked()&&d.getLevel()<=a&&b.push(d);d.setLocked(d.getLevel()>a);d.update()}return b},getRecommendedOrbs:function(a){var b=[Products.IDS.OR_TORNADO,Products.IDS.OR_ADD_4_LIVES,Products.IDS.OR_COMBO_BAR,Products.IDS.OR_LIGHTNING,
Products.IDS.OR_UNLOCK,Products.IDS.OR_CROSS_BLAST,Products.IDS.OR_HAMMER,Products.IDS.OR_RESHUFFLE,Products.IDS.OR_COLOR_BLASTER,Products.IDS.OR_PROTECTION,Products.IDS.OR_BOMB,Products.IDS.OR_SUPER_BOMB,Products.IDS.OR_FIRE_BLAST,Products.IDS.OR_UNDO,Products.IDS.OR_LAST_RECOUNT,Products.IDS.OR_HAND],c=this.getOrbs(),d=[],e;for(e in a){var f=b[a[e]-1],g;for(g in c)if(c[g].hasId(f)){d.push(c[g]);break}}return d},getRandomOrbs:function(a,b,c){var d=[],e=this.getOrbs(),f;for(f in e){var g=e[f];g.isBought()==
b&&g.isPermanent()==c&&d.push(g)}for(;d.length>a;)d.splice(CUtils.random(0,d.length-1),1);return d},discountOrb:function(a){var b=this.getOrbs().filter(function(a){return(a=Products.getProduct(a.getId()))&&a.getDiscount("daily_offer")});0==b.length||5>=a||(a=this._si%b.length,b[a]&&b[a].setDiscount("daily_offer"))},boughtOrb:function(a){for(var b in this._orbs){var c=this._orbs[b];if(c.hasId(a)){c.setBought(!0);c.update("bought");return}}cc.assert(!1,"Orb ["+a+"] not found")},cleanOrb:function(){for(var a in this._orbs){var b=
this._orbs[a];b.setBought(b.isBought()&&b.isPermanent())}}}));
User.Score=cc.Class.extend({_ready:!1,_mapId:null,_fbId:null,_data:null,ctor:function(a,b){this._ready=!1;this._fbId=a;this._mapId=b;this._data={}},init:function(){},isReady:function(){return this._ready},restGetData:function(){var a=this;Backend.send(new HttpRest.Request(HttpRest.METHOD.GET,"/users/"+this._fbId+"/maps/"+this._mapId+"/levels",null,function(b){a._ready=!0;for(var c in b.properties){var d=b.properties[c].properties;a._data[d.stage]={id:Number(d.stage),score:Number(d.score),key:Number(d.earned)}}b=
0;for(c in a._data)b=Math.max(b,a._data[c].id);for(c=1;c<=b;c++)a._data[c]||(a._data[c]={id:c,score:0,key:1},cc.log("Fix level:"+c));cc.log("load score success mapId:"+a._mapId);cc.eventManager.dispatchCustomEvent(User.EVENT.UPDATE_SCORE,a)},function(){Popup.alert(Popup.ALERT.NETWORK)}))},getFbId:function(){return this._fbId},getMapId:function(){return this._mapId},getData:function(a){return this._data[a]||{level:a,score:0,key:0}},getKey:function(a){return this._data[a]?this._data[a].key:0},getKeys:function(){var a=
0,b;for(b in this._data)a+=this._data[b].key;return a},getScore:function(a){return this._data[a]?this._data[a].score:0},getSize:function(){return Object.keys(this._data).length},push:function(a,b,c){0<b?(this._data[a]||(this._data[a]={id:Number(a),score:0,key:0}),a=this._data[a],b>a.key?(a.key=b,a.score=c):b==a.key&&(a.score=Math.max(a.score,c))):cc.warn("trying push keys==0")}});
User.HighScore=cc.Class.extend({_fbId:0,_mapId:0,_data:null,_query:null,ctor:function(a,b){this._fbId=a;this._mapId=b;this._data={};this._query={}},query:function(a,b){var c=this,d=a+":"+b,e=this._query[d]||0;if(!(60>TimeUtils.getTime()-e)){this._query[d]=TimeUtils.getTime();d=[];e=User.getFriends(1);for(var f in e){var g=e[f];(0!=this._mapId||g.getLevel()>=a)&&d.push(g.getFbId())}f=new HttpRest.Request(HttpRest.METHOD.GET,"/users/"+this._fbId+"/maps/"+this._mapId+"/high-scores?userCount=5&startLevel="+
a+"&endLevel="+b,null,function(a,b){var d=a.properties,e=[],f;for(f in d){var g=d[f].properties;e.push(g.level);c._data[g.level]=g.scores.map(function(a){return{fbId:a.userId,score:Number(a.score),pos:Number(a.position)}})}cc.eventManager.dispatchCustomEvent(User.EVENT.UPDATE_HIGHSCORE,{list:e})},function(a,b){});f.addHeader("Friends",JSON.stringify(d));Backend.send(f)}},getFbId:function(){return this._fbId},getMapId:function(){return this._mapId},getData:function(a,b){if(this._data[a])return this._data[a].slice();
b&&this.query(a,a);return null},getLowerScore:function(a,b){var c=this.getData(a,!1);return c?c.filter(function(a){return a.score<b}):null}});
User.Inbox=cc.Class.extend({_fbId:0,_gift:null,_unlock:null,_request:null,_dump:null,_querytime:0,ctor:function(a){this._fbId=a;this._gift=[];this._unlock=[];this._request=[];this._dump=[]},run:function(){cc.director.getScheduler().unschedule("update_inbox",this);cc.director.getScheduler().schedule(this.query,this,300,cc.REPEAT_FOREVER,0,!1,"update_inbox");this.query()},query:function(a){if(!(60>TimeUtils.getTime()-this._querytime)){this._querytime=TimeUtils.getTime();var b=this;Backend.send(new HttpRest.Request(HttpRest.METHOD.POST,
"/batch",[{requestId:1,url:"/v1.0/users/"+this._fbId+"/requests",method:"GET",query:{platform:"flash"},headers:{"Content-type":"application/json"},body:""},{requestId:2,url:"/v1.0/users/"+this._fbId+"/gifts",method:"GET",query:{platform:"flash"},headers:{"Content-type":"application/json"},body:""}],function(c,d){var e;for(e in c){var f=c[e];if(200==f.code)if(1==f.requestId)for(e in b._request=[],f=f.body.properties,f)"request"===f[e]["class"]&&(d=f[e].properties,b._request.push({from:d.fromUserId,
type:d.type,id:d.id}));else if(2==f.requestId)for(e in b._gift=[],b._unlock=[],f=f.body.properties,f)"gift"===f[e]["class"]&&(d=f[e].properties,"unlock"===d.type&&b._unlock.push({from:d.fromUserId,id:d.id}),"active"===d.status&&b._gift.push({from:d.fromUserId,type:d.type,value:d.value||0,id:d.id}))}b.pushDump();cc.eventManager.dispatchCustomEvent(User.EVENT.UPDATE_INBOX,{force:a||!1})},function(a,b){}))}},getSize:function(){return this._gift.length+this._request.length},getGift:function(){return this._gift.slice()},
getUnlock:function(){return this._unlock.slice()},getRequest:function(){return this._request.slice()},enableGift:function(a){var b=this.findGift(a)||{};this.pushDump(a,"gift","enable");cc.eventManager.dispatchCustomEvent(User.EVENT.UPDATE_INBOX,{force:!0});"life"==b.type?User.getLive().addLives(1):"coins"==b.type&&User.getCoins().addValue(b.value,!0)},enableRequest:function(a){this.pushDump(a,"request","enable");cc.eventManager.dispatchCustomEvent(User.EVENT.UPDATE_INBOX,{force:!0})},deleteGift:function(a){this.pushDump(a,
"gift","delete");cc.eventManager.dispatchCustomEvent(User.EVENT.UPDATE_INBOX,{force:!0})},deleteRequest:function(a){this.pushDump(a,"request","delete");cc.eventManager.dispatchCustomEvent(User.EVENT.UPDATE_INBOX,{force:!0})},findGift:function(a){for(var b in this._gift)if(this._gift[b].id==a)return this._gift[b];return null},findRequest:function(a){for(var b in this._request)if(this._request[b].id==a)return this._request[b];return null},pushDump:function(a,b,c){if(void 0!=a)if(c={id:a,type:b,action:c},
this._dump.push(c),"gift"==b){var d=this.findGift(a)||{};c.type2=d.type;c.from=d.from}else"request"==b&&(d=this.findRequest(a)||{},c.type2=d.type,c.from=d.from);for(var e in this._dump)d=this._dump[e],"gift"===d.type?this._gift=this._gift.filter(function(a){return a.id!=d.id}):this._request=this._request.filter(function(a){return a.id!=d.id})},flushDump:function(){cc.log("flush");var a=[],b=[],c=[],d=[],e=[];if(0!=this._dump.length){for(var f in this._dump){var g=this._dump[f];"gift"==g.type&&"enable"==
g.action?(a.push(g.id),"life"!=g.type2&&"unlock"!=g.type2||!g.from||e.push(g.from+":send_coins")):"gift"==g.type&&"delete"==g.action?b.push(g.id):"request"==g.type&&"enable"==g.action?(c.push(g.id),"life"==g.type2&&g.from?e.push(g.from+":send_life"):"unlock"==g.type2&&g.from&&e.push(g.from+":send_unlock")):"request"==g.type&&"delete"==g.action&&d.push(g.id)}this._dump=[];0<a.length&&Backend.send(new HttpRest.Request(HttpRest.METHOD.POST,"/users/"+this._fbId+"/gifts/accept",a,null,null));0<b.length&&
Backend.send(new HttpRest.Request(HttpRest.METHOD.DELETE,"/users/"+this._fbId+"/gifts",b,null,null));0<c.length&&Backend.send(new HttpRest.Request(HttpRest.METHOD.POST,"/users/"+this._fbId+"/requests/accept",c,null,null));0<d.length&&Backend.send(new HttpRest.Request(HttpRest.METHOD.DELETE,"/users/"+this._fbId+"/requests",d,null,null));try{0<e.length&&BGame.interactions.multipleAppRequest2(e.join(","))}catch(h){cc.error(h)}}}});
User.Live=cc.Class.extend({_lives:0,_freeze:0,_total:0,_timeact:0,_timelive:0,_timenext:0,_immortality:0,ctor:function(){this._timelive=this._timeact=this._total=this._freeze=this._lives=0;this._timenext=1800;this._immortality=0;cc.director.getScheduler().schedule(this.updateTime.bind(this),this,1,cc.REPEAT_FOREVER,0,!1)},addLives:function(a){this._lives=Math.max(0,Math.min(this._total,this._lives+a));0<a&&cc.eventManager.dispatchCustomEvent(User.EVENT.GOT_LIFE,this)},getLives:function(){return this._lives+
this._freeze},getTotal:function(){return this._total},getTimeLive:function(){return this._timelive},hasLive:function(){return 0<this._lives},isFull:function(){return this._total<=this._lives+this._freeze},setImmortality:function(a){this._immortality=a},addImmortality:function(a){var b=TimeUtils.getTime();this._immortality=this._immortality>b?this._immortality+a:b+a},hasImmortality:function(){return this._immortality>TimeUtils.getTime()},getImmortalityTime:function(){return Math.max(0,this._immortality-
TimeUtils.getTime())},update:function(a,b,c){this._lives=Number(a);this._total=Number(b);this._timeact=Number(c);this._timelive=0},updateTime:function(){var a=TimeUtils.getTime();if(this._total>this._lives+this._freeze){0==this._timeact&&(this._timeact=a);this._timelive=a-this._timeact;if(this._timelive>=this._timenext){var b=Math.floor(this._timelive/this._timenext);this._timeact+=b*this._timenext;this._lives=Math.min(this._lives+b+this._freeze,this._total);this._lives+this._freeze>=this._total?
this._timeact=this._timelive=0:this._timelive=this._timenext-a+this._timeact;cc.eventManager.dispatchCustomEvent(User.EVENT.GOT_LIFE,this)}else this._timelive=this._timenext-a+this._timeact;cc.eventManager.dispatchCustomEvent(User.EVENT.UPDATE_LIVE,this)}else if(0!=this._timelive||0!=this._timeact||a<=this._immortality)this._timeact=this._timelive=0,cc.eventManager.dispatchCustomEvent(User.EVENT.UPDATE_LIVE,this)}});
User.Treasure=cc.Class.extend({_list:null,_expired:0,ctor:function(){this._list=[];this._exptime=0},add:function(a,b){this._list.push({l:a,s:b||0,id:this._list.length})},setExpired:function(a){this._expired=a},getExpired:function(){return this._expired},getSize:function(){return this._list.length},getList:function(){return this._list},isActive:function(){return TimeUtils.getTime()<this._expired&&0<this._list.reduce(function(a,b){return 0==b.s?a+1:a},0)},hasTreasure:function(a){for(var b in this._list){var c=
this._list[b];if(c.l==a&&0==c.s)return!0}return!1},givePrise:function(a){for(var b in this._list){var c=this._list[b];c.l==a&&0==c.s&&(c.s=1)}}});
User.Scratch=cc.Class.extend({_list:null,ctor:function(){this._list=[]},add:function(a,b){this._list.push({l:a,s:b})},newLevel:function(a){do{var b=CUtils.random(10,a);for(var c in this._list)this._list[c].l==b&&(b=0)}while(0==b);Backend.saveScratch(b);this.add(b,0);return b},winLevel:function(a){var b=this._list[this._list.length-1];return b&&b.l==a?(b.s=1,Backend.saveScratch(b.l,b.s),cc.eventManager.dispatchCustomEvent(User.EVENT.UPDATE_SCRATCH),!0):!1},getLevel:function(){var a=this._list[this._list.length-
1];return a&&0==a.s?a.l:0},isComplete:function(){if(4>this._list.length)return!1;for(var a in this._list)if(0==this._list[a].s)return!1;return!0}});
User.Challenge=cc.Class.extend({_storageKey:"WEEKLY_CHALLENGE",_fbId:0,_type:0,_mapId:0,_dateStart:null,_dateFinish:null,_level:0,_ready:!1,_valid:!0,ctor:function(a){this._fbId=a;a=(new Date).getTimezoneOffset();var b=Math.abs(a)/60,c=Math.abs(a)%60;a=(0>a?"+":"-")+(10>b?"0"+b:b)+":"+(10>c?"0"+c:c);b=app.config.weeklyChallenge().split(",");this._type=Number(b[0])||0;this._mapId=Number(b[1])||0;this._dateStart=new Date(b[2]+a);this._dateFinish=new Date(b[3]+a);this._valid=!(isNaN(this._type)||isNaN(this._mapId)||
isNaN(this._dateStart.getTime())||isNaN(this._dateFinish.getTime()));this._ready=!1;this._level=0},getType:function(){return this._type},getMapId:function(){return this._mapId},getLevel:function(){return this._level},getLeftTime:function(){return Math.max(0,Math.round((this._dateFinish-new Date)/1E3))},noticeExpired:function(a){if(this.isActive()||!this._valid)return!1;var b=null!=LocalStorage.getValue(this._storageKey+this._type);a&&LocalStorage.remValue(this._storageKey+this._type);return b},isActive:function(){var a=
new Date;return this._valid&&5>this._level&&this._dateStart<a&&a<this._dateFinish},isReady:function(){return this._ready},restGetData:function(){var a=this;Backend.send(new HttpRest.Request(HttpRest.METHOD.GET,"/users/"+this._fbId+"/maps/"+this._mapId+"/bf-challenge",null,function(b,c){a._level=Number(b.properties.level);a._valid=a._valid&&0<=a._level&&5>a._level;a._ready=!0;a.isActive()&&LocalStorage.setValue(a._storageKey+a._type,!0)},function(b,c){a._valid=!1;a._ready=!0}))},levelStart:function(a,
b,c){a={};a.updateLives=User.getLive().hasImmortality()?"0":"1";a.updateLifeTimer=User.getLive().hasImmortality()?"0":"1";Backend.send(new HttpRest.Request(HttpRest.METHOD.PUT,"/users/"+this._fbId+"/maps/"+this._mapId+"/bf-challenge/"+b+"/start",a,function(a,b){c&&c(a&&"success"==a["class"])},function(a,b){c&&c(!1)}))},levelFinish:function(a,b,c,d){var e=this;"win"!=c.status?(e._level=Math.max(e._level-1,0),d&&d(!0)):(a={},a.updateLives=User.getLive().hasImmortality()?"0":"1",a.coins=c.coins,Backend.send(new HttpRest.Request(HttpRest.METHOD.PUT,
"/users/"+this._fbId+"/maps/"+this._mapId+"/bf-challenge/"+b+"/win",a,function(a,g){e._level="win"===c.status?Math.max(e._level,b):Math.max(e._level-1,0);5<=e._level&&LocalStorage.remValue(e._storageKey+e._type);d&&d(a&&"bf-challenge"==a["class"],Number(a.properties.prevLevel)+1==c.levelId)},function(a,b){d&&d(!1)})))}});
User.Offers=cc.Class.extend({_fbId:0,_list:null,ctor:function(a){this._fbId=a;this._list={};a=TimeUtils.getSystemTime();var b=app.config.specialOffer().split(":"),c={};c.timeStart=Number(b[0])||Number.MAX_VALUE-1;c.timeFinish=Number(b[1])||0;c.enabled=c.timeStart<a&&a<c.timeFinish;this._list.special_offer=c},isActive:function(a){a=this._list[a];return void 0==a?!1:a.enabled&&TimeUtils.getSystemTime()<a.timeFinish},getExpired:function(a){a=this._list[a];return void 0==a?0:Math.max(0,a.timeFinish-TimeUtils.getSystemTime())}});
User.Orb=cc.Class.extend({_id:null,_optId:null,_panelId:0,_shopId:0,_tutId:0,_level:0,_canused:0,_permanent:0,_discount:null,_bought:!1,_locked:!0,ctor:function(a){this._id=a.getId();this._optId=a.hasProperty("field")?a.getProperty("field",String).substr(3):0;this._panelId=a.hasProperty("panel_index")?a.getProperty("panel_index",Number):0;this._shopId=a.hasProperty("shop_index")?a.getProperty("shop_index",Number):0;this._tutId=a.hasProperty("tutorial_id")?a.getProperty("tutorial_id",Number):0;this._level=
a.hasProperty("open_level")?a.getProperty("open_level",Number):0;this._canused=a.hasProperty("nrofuse")?a.getProperty("nrofuse",Number):1;this._permanent=a.hasProperty("permanent")?a.getProperty("permanent",Number):0;this._discount=null;this._bought=!1;this._locked=!0},getId:function(){return this._id},hasId:function(a){return this._id==a},getOptId:function(){return this._optId},getPanelId:function(){return this._panelId},getShopId:function(){return this._shopId},getTutId:function(){return this._tutId},
getLevel:function(){return this._level},getCanUsed:function(){return this._canused},isPermanent:function(){return 0!=this._permanent},setDiscount:function(a){this._discount=a},getDiscount:function(){return this._discount},hasDiscount:function(){return null!=this._discount},setLocked:function(a){this._locked=a},isLocked:function(){return this._locked},setBought:function(a){this._bought=a},isBought:function(){return this._bought},update:function(a){cc.eventManager.dispatchCustomEvent(User.EVENT.UPDATE_ORB,
{orb:this,action:a})},getPurchaseData:function(){var a={};a.productId=this.getId();a.discountId=this.getDiscount();a.currency=this.isPermanent()?Products.CURRENCY.CASH:Products.CURRENCY.COINS;return a}});
User.Friends=cc.Class.extend({_fbId:null,_list:null,_cash:null,_dumpGift:null,ctor:function(a){this._fbId=a;this._cash={};this._list=[];this._dumpGift=[]},add:function(a){this._list.push(a)},getList:function(a){var b=this._cash.list;b||(b={0:this._list.slice(),1:this._list.filter(function(a){return a.getInGame()}),2:this._list.filter(function(a){return!a.getInGame()})},this._cash.list=b);return b[a].slice()},getListByLevel:function(a){var b=this._cash["lv_"+a];b||(b=this.getList(1).filter(function(b){return b.getLevel()==
a}),this._cash["lv_"+a]=b);return b},getItem:function(a,b){var c=this.getList(b||0),d;for(d in c)if(c[d].hasFbId(a))return c[d];return null},cleanCash:function(){this._cash={}},restGetData:function(){var a=this,b=this.getList(1).map(function(a){return a.getFbId()}),c=new HttpRest.Request(HttpRest.METHOD.GET,"/users/"+this._fbId+"/friends",null,function(b,c){var d=b.properties,e;for(e in d){var h=d[e].properties,k=a.getItem(h.userId,1);k&&k.setProperties(h)}},function(a,b){});c.addHeader("Friends",
JSON.stringify(b));Backend.send(c)},sendGift:function(a,b){var c=TimeUtils.getTime(),d=cc.isArray(a)?a:[a],e;for(e in d){var f=d[e];0>f.getGiftTime(c)&&(this._dumpGift.push(f),f.setGiftTime(c),KApi.event(KApi.EVENT.LIFE_SEND,{st1:b||"",v:f.getFbId()}))}cc.director.getScheduler().unschedule("flush_dump_gift",this);cc.director.getScheduler().schedule(this.flushDumpGift.bind(this),this,1,0,0,!1,"flush_dump_gift");cc.eventManager.dispatchCustomEvent(User.EVENT.UPDATE_FRIEND,{data:d})},flushDumpGift:function(){var a=
this;if(0!=this._dumpGift.length){var b=this._dumpGift.map(function(b){return{fromUserId:a._fbId,toUserId:b.getFbId(),type:"life",value:"1"}}),c=this._dumpGift.map(function(a){return a.getFbId()+":send_life"});Backend.send(new HttpRest.Request(HttpRest.METHOD.POST,"/gifts",b,function(a,b){var c=b.length*app.config.rewardSendLife();Backend.putCoins(c,function(){cc.eventManager.dispatchCustomEvent(User.EVENT.SEND_LIFE_REWARD,{data:b,reward:c})})},function(a,b){},this._dumpGift));try{BGame.interactions.multipleAppRequest2(c.join(","))}catch(d){cc.error(d)}this._dumpGift=
[]}}});User.Friends.Item=UserBase.extend({_level:0,_giftTime:0,ctor:function(a,b,c){this._super(a,b);this._giftTime=this._level=0;this.setProperties(c)},setProperties:function(a){this._super(a);a.level&&(this._level=Number(a.level));a.actionTimer&&(this._giftTime=Number(a.actionTimer))},getLevel:function(){return this._level},setGiftTime:function(a){this._giftTime=a},getGiftTime:function(a){a=a||TimeUtils.getTime();return this._giftTime+app.config.giftTime()-a}});
User.EVENT={UPDATE_COINS:"USER_UPDATE_COINS",UPDATE_CASH:"USER_UPDATE_CASH",UPDATE_LIVE:"USER_UPDATE_LIVE",UPDATE_ORB:"USER_UPDATE_ORB",UPDATE_SCORE:"USER_UPDATE_SCORE",UPDATE_HIGHSCORE:"USER_UPDATE_HIGHSCORE",UPDATE_INBOX:"USER_UPDATE_INBOX",UPDATE_FRIEND:"USER_UPDATE_FRIEND",UPDATE_SCRATCH:"USER_UPDATE_SCRATCH",SEND_LIFE_REWARD:"USER_SEND_LIFE_REWARD",GOT_LIFE:"USER_GOT_LIVE"};var Products=new (cc.Class.extend({_ready:!1,_items:null,_fbId:null,_mobile:null,_currency:null,ctor:function(){this._ready=!1;this._items=[];this._mobile=this._fbId=null},init:function(a,b,c){this._fbId=a;this._mobile=new Products.Mobile(b);this._currency=c},isReady:function(){return this._ready},loadFromJson:function(a){for(var b in a.properties){var c=a.properties[b].properties;switch(c.type){case Products.TYPE.ORB:case Products.TYPE.PACKAGE:case Products.TYPE.LIVES:case Products.TYPE.CONSUMABLE:this._items.push(new Products.Item(c));
break;default:cc.assert(!1,"unknown product type: "+c.type)}}this._ready=!0},getProduct:function(a){for(var b in this._items){var c=this._items[b];if(c.getId()==a)return c}cc.log("Product ["+a+"] not found");return null},getProductByType:function(a){return this._items.filter(function(b){return b.hasType(a)})},getMobile:function(a){if(void 0==a)return this._mobile;a=this.getProduct(a);if(!a)return null;var b=a.getPrice(Products.CURRENCY.USER);if(!b)return null;b=b.getAmount();var c=a.getProperty("min_price",
Number);a=a.getProperty("max_price",Number);return isNaN(b)||isNaN(c)||isNaN(a)?null:this._mobile.getPriceId(b,c,a)}}));
Products.Item=cc.Class.extend({_id:null,_type:null,_prices:null,_discounts:null,_props:null,ctor:function(a){this._id=a.productId;this._type=a.type;this._prices={};this._discounts={};if(a.prices)for(var b in a.prices){var c=a.prices[b];this._prices[c.currency]=new Products.Price(c)}if(a.discounts)for(b in a.discounts)c=a.discounts[b],this._discounts[c.discountId]=new Products.Discount(c);this._props={};a=a.props;for(b in a)"immortality_time"===b?this._props._immortality=a[b]:this._props["_"+b]=a[b]},
getId:function(){return this._id},hasId:function(a){return this._id==a},getType:function(){return this._type},hasType:function(a){return this._type==a},getDiscount:function(a){return this._discounts[a]||null},getPrice:function(a,b){if(!a)return null;if(b){var c=this.getDiscount(b);return c?c.getPrice(a):null}if(cc.isArray(a)){for(c in a)if(this._prices[a[c]])return this._prices[a[c]];return null}return this._prices[a]||null},hasProperty:function(a){return void 0!==this._props["_"+a]},getProperty:function(a,
b){var c=this._props["_"+a];return b?b(c):c}});Products.Price=cc.Class.extend({_currency:null,_amount:0,_percentage:0,ctor:function(a){this._currency=a.currency;this._amount=a.amount;this._percentage=a.percentage||0},getCurrency:function(){return this._currency},getAmount:function(){return this._amount},getAmountInt:function(){return parseInt(this._amount)},getPercentage:function(){return this._percentage}});
Products.Discount=cc.Class.extend({_id:null,_prices:null,_props:null,_additional:null,ctor:function(a){this._id=a.discountId;this._additional=a.additional_items;this._prices={};this._props={};if(a.prices)for(var b in a.prices){var c=a.prices[b];this._prices[c.currency]=new Products.Price(c)}a=a.props;for(b in a)"immortality_time"===b?this._props._immortality=a[b]:this._props["_"+b]=a[b]},getId:function(){return this._id},getAdditional:function(){return this._additional},getPrice:function(a){if(cc.isArray(a)){for(var b in a)if(this._prices[a[b]])return this._prices[a[b]];
return null}return this._prices[a]||null},hasProperty:function(a){return void 0!==this._props["_"+a]},getProperty:function(a,b){var c=this._props["_"+a];return b?b(c):c}});
Products.Mobile=cc.Class.extend({_currency:null,_list:null,ctor:function(a){var b=this;try{this._currency=a.user_currency,this._list=a.pricepoints||[]}catch(c){this._currency=null,this._list=[]}this._list=this._list.filter(function(a){return"US"==a.country&&a.currency==b._currency})},getPriceId:function(a,b,c){var d=Number.MAX_VALUE,e=null,f;for(f in this._list){var g=this._list[f],h=Number(g.payer_amount);!isNaN(h)&&Math.abs(h-a)<d&&CUtils.between(b,c,h)&&(d=Math.abs(h-a),e=g.pricepoint_id)}return e},
isAvailable:function(){return"USD"==this._currency&&0<this._list.length}});Products.hasProperty=function(a,b,c){return c&&c.hasProperty(a)||b&&b.hasProperty(a)};Products.getProperty=function(a,b,c,d,e){return void 0===e||Products.hasProperty(a,b,c)?c&&c.getProperty(a,d)||b&&b.getProperty(a,d):e};
Products.IDS={OR_TORNADO:"tornado",OR_ADD_4_LIVES:"additional_4_lives",OR_COMBO_BAR:"combo_bar",OR_LIGHTNING:"lightning",OR_UNLOCK:"unlock",OR_CROSS_BLAST:"cross_blast",OR_HAMMER:"hammer",OR_RESHUFFLE:"reshuffle",OR_COLOR_BLASTER:"color_blaster",OR_PROTECTION:"protection",OR_BOMB:"bomb",OR_SUPER_BOMB:"super_bomb",OR_FIRE_BLAST:"fire_blast",OR_UNDO:"undo",OR_LAST_RECOUNT:"lastrecount",OR_HAND:"hand",PK_CASH5:"crystals5",PK_CASH10:"crystals10",PK_CASH20:"crystals20",PK_CASH27:"crystals27",PK_CASH57:"crystals57",
PK_CASH120:"crystals120",PK_CASH320:"crystals320",PK_CASH600:"crystals600",PK_COINS11500:"coins11500",PK_COINS27000:"coins27000",PK_CASH25COINS12500AB:"crystals25coins12500AB",PK_CASH50COINS50000:"crystals50coins50000",PK_MOB_CASH7:"mob_crystals7",PK_MOB_CASH30:"mob_crystals30",PK_MOB_CASH60:"mob_crystals60",PK_MOB_CASH120:"mob_crystals120",PK_MOB_CASH150:"mob_crystals150",PK_SPECIAL_OFFER:"special_offer",PR_UNLOCK:"unlock_location",PR_FULL_LIVES:"fullset_lives",PR_3_LIVES:"3_lives",PR_MOVES_5:"5_moves",
PR_IMMORTALITY:"immortality"};Products.TYPE={ORB:"orb",PACKAGE:"package",LIVES:"lives",CONSUMABLE:"consumable"};Products.CURRENCY={CASH:"crystals",COINS:"coins",USER:["USD"]};var Popup=Popup||{};Popup._running=[];Popup._add=function(a){Popup._running.push(a);cc.log("Popup._add:"+Popup.getSize())};Popup._remove=function(a){a=Popup._running.indexOf(a);-1!=a&&Popup._running.splice(a,1);cc.log("Popup._remove:"+Popup.getSize())};Popup.getSize=function(){return Popup._running.length};Popup.ALERT={NETWORK:2,NO_CASH:3,NO_COINS:4,PROCESSING:5,PURCHASE_FAILED:6};
Popup.PopBase=cc.Node.extend({_args:null,_ext:null,_wSize:null,_size:null,_moveTo:null,_build:!1,_closed:!1,_hasClose:!1,_btClose:null,_runLayer:null,_onClose:null,ctor:function(a){this._super();this._ext=new CExtNode(this);this._args=a||{};this._wSize=cc.director.getWinSize();this._closed=this._build=!1;this._hasClose=!0;this._onClose=null;this._args.showFrom||(this._args.showFrom="")},build:function(){cc.assert(this._size,"unknown size");this._build=!0;this.addChild(this.buildBackground(this._size.width,
this._size.height));this._hasClose&&(this._btClose=new CButton(Resource.POP.bt("close"),null,{b:.05},{b:-.15}),this._btClose.setPosition(.5*this._size.width-10,.5*this._size.height-10),this._btClose.setCbUp(this.close.bind(this)),this.addChild(this._btClose,100))},buildBackground:function(a,b){var c,d;a=Math.max(75,a);b=Math.max(75,b);var e=new cc.LayerColor(new cc.Color(11,73,79,230),a,b);e.ignoreAnchorPointForPosition(!1);e.setAnchorPoint(.5,.5);var f=new cc.Sprite(Resource.POP.bg("glow"));f.setScaleX(a/
f.getContentSize().width);f.setScaleY(b/f.getContentSize().height);f.setPosition(.5*a,.5*b);e.addChild(f);for(c=d=0;;){var g=new cc.Sprite(Resource.POP.bg("pattern"));g.setAnchorPoint(0,0);var h=g.getContentSize();var k=Math.ceil(a/h.width);var m=Math.ceil(b/h.height);f=a/(k*h.width);var n=b/(m*h.height);g.setScaleX(f);g.setScaleY(n);e.addChild(g);d<k?(g.setPosition(h.width*f*d,h.height*n*c),d++):c<m&&(d=0,c++,g.setPosition(h.width*f*d,h.height*n*c),d++);if(d>=k&&c>=m-1)break}g=new cc.Sprite(Resource.POP.bg("frame_inside_corner"));
g.setAnchorPoint(1,1);g.setPosition(a-5,b-5);e.addChild(g);g=new cc.Sprite(Resource.POP.bg("frame_inside_corner"));g.setAnchorPoint(1,1);g.setRotation(-90);g.setPosition(5,b-5);e.addChild(g);g=new cc.Sprite(Resource.POP.bg("frame_inside_corner"));g.setAnchorPoint(1,1);g.setRotation(180);g.setPosition(5,5);e.addChild(g);g=new cc.Sprite(Resource.POP.bg("frame_inside_corner"));g.setAnchorPoint(1,1);g.setRotation(90);g.setPosition(a-5,5);e.addChild(g);for(d=0;!(g=new cc.Sprite(Resource.POP.bg("frame_inside")),
g.setAnchorPoint(0,0),h=g.getContentSize(),k=Math.ceil(a/h.width),f=(a-42)/(k*h.width),g.setScaleX(f),g.setPosition(h.width*f*d+21,5),e.addChild(g),g=new cc.Sprite(Resource.POP.bg("frame_inside")),g.setAnchorPoint(0,1),g.setFlippedY(!0),g.setScaleX(f),g.setPosition(h.width*f*d+21,b-5),e.addChild(g),d++,d>=k););for(c=0;!(g=new cc.Sprite(Resource.POP.bg("frame_inside")),g.setAnchorPoint(0,0),h=g.getContentSize(),m=Math.ceil(b/h.width),f=(b-42)/(m*h.width),g.setScaleX(f),g.setRotation(-90),g.setPosition(a-
5,h.width*f*c+21),e.addChild(g),g=new cc.Sprite(Resource.POP.bg("frame_inside")),g.setAnchorPoint(0,1),g.setFlippedY(!0),g.setScaleX(f),g.setRotation(-90),g.setPosition(5,h.width*f*c+21),e.addChild(g),c++,c>=m););f=new cc.Scale9Sprite(Resource.POP.bg("corner_frame"),new cc.Rect(10,50,0,0));f.setContentSize(.5*a+17,.5*b+17);f.setAnchorPoint(1,1);f.setPosition(a+17,b+17);e.addChild(f);f=new cc.Scale9Sprite(Resource.POP.bg("corner_frame"),new cc.Rect(10,50,0,0));f.setContentSize(.5*b+17,.5*a+17);f.setAnchorPoint(1,
1);f.setRotation(90);f.setPosition(a+17,-17);e.addChild(f);f=new cc.Scale9Sprite(Resource.POP.bg("corner_frame"),new cc.Rect(10,50,0,0));f.setContentSize(.5*a+17,.5*b+17);f.setAnchorPoint(1,1);f.setRotation(180);f.setPosition(-17,-17);e.addChild(f);f=new cc.Scale9Sprite(Resource.POP.bg("corner_frame"),new cc.Rect(10,50,0,0));f.setContentSize(.5*b+17,.5*a+17);f.setAnchorPoint(1,1);f.setRotation(270);f.setPosition(-17,b+17);e.addChild(f);return e},run:function(){this._build||this.build();this.isClosed()?
this._runLayer.removeFromParent():(this._moveTo?this.setPosition(this._moveTo):this.setPosition(Math.round(.5*this._wSize.width),Math.round(.5*this._wSize.height)),this.setOpacity(0),this.setScale(.8),this._runLayer.addChild(this),this._runLayer.setLocalZOrder(this.getLocalZOrder()),this._runLayer.close=this.close.bind(this),this._runLayer.setVisible(!1),Popup._add(this),this.validateZOrder(),this.runAction((new cc.ScaleTo(.3,1)).easing(cc.easeBackOut())))},validateZOrder:function(){var a=null,b=
this._runLayer.getParent();b||(b=cc.director.getRunningScene());for(var c in b.getChildren()){var d=b.getChildren()[c];d instanceof Popup.PopLayer&&(null==a||a.getLocalZOrder()<=d.getLocalZOrder()?(a&&a.isVisible()&&a.setVisible(!1),a=d):d.setVisible(!1))}a&&!a.isVisible()&&(a.setVisible(!0),AudioEngine.playEffect(Resource.SND.OPEN_POPUP))},show:function(a,b,c){this.setLocalZOrder(c||0);Popup.show(this,b,a)},close:function(){this._closed||(this._closed=!0,this.runAction(new cc.Sequence((new cc.ScaleTo(.3,
.8*this.getScale())).easing(cc.easeBackIn()),new cc.CallFunc(function(){this._runLayer.removeFromParent();Popup._remove(this);this.validateZOrder();this._onClose&&this._onClose()},this))))},cleanup:function(){this._super();Popup._remove(this)},setOnClose:function(a){if(null===this._onClose)this._onClose=a;else{var b=this._onClose;this._onClose=function(){b();a()}}},isClosed:function(){return this._closed}});
Popup.show=function(a,b,c){b||(b=cc.director.getRunningScene());a._runLayer=new Popup.PopLayer;c?b.runAction(new cc.Sequence([new cc.DelayTime(c),new cc.CallFunc(function(){b.addChild(a._runLayer);a.run()})])):(b.addChild(a._runLayer),a.run())};Popup.alert=function(a,b,c){(new Popup.PopAlert({type:a})).show(c,b,Number.MAX_VALUE-10)};
Popup.close=function(a,b){b||(b=cc.director.getRunningScene());for(var c in b.getChildren()){var d=b.getChildren()[c];if(d instanceof Popup.PopLayer)if(a)for(var e in d.getChildren()){var f=d.getChildren()[e];f instanceof a&&f instanceof Popup.PopBase&&f.close()}else d.close()}};Popup.PopLayer=cc.Layer.extend({_ext:null,_back:null,ctor:function(){this._super();this._ext=new CExtNode(this);this._ext.stopMouseEvent();this._back=new cc.LayerColor(new cc.Color(0,0,0,255*.86));this.addChild(this._back)},getBack:function(){return this._back},close:function(){}});Popup.PopAlert=Popup.PopBase.extend({_type:null,ctor:function(a){this._super(a);this._size=new cc.Size(365,140);this._hasClose=!1;this._type=this._args.type||Popup.ALERT.NETWORK},build:function(){var a=new cc.Sprite(Resource.POP.empty);if(a&&1==a.getContentSize().width){a="";switch(this._type){case Popup.ALERT.PROCESSING:a=Lang.getString(Lang.POP_ALERT_PROCESSING);break;case Popup.ALERT.NETWORK:a=Lang.getString(Lang.POP_ALERT_NETWORK);break;case Popup.ALERT.NO_CASH:a=Lang.getString(Lang.POP_ALERT_NO_CASH);
this._hasClose=!0;this.setOnClose(function(){Popup.PopBuyCash.show({active:"cash"},0,null,20)});break;case Popup.ALERT.NO_COINS:a=Lang.getString(Lang.POP_ALERT_NO_COINS);this._hasClose=!0;this.setOnClose(function(){Popup.PopBuyCash.show(null,0,null,20)});break;case Popup.ALERT.PURCHASE_FAILED:a=Lang.getString(Lang.POP_ALERT_PURCHASE_FAILED),this._hasClose=!0}this._super();a=new CLabelTTF(a,26,this._size.width-50,2);a.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);a.setPosition(0,
0);this.addChild(a);this._type==Popup.ALERT.NETWORK&&(a.setPosition(0,24),a=new CButton(Resource.POP.bt("green_2"),null,{b:.05},{b:-.15}),a.setText(Lang.getString(Lang.POP_ALERT_BT_RELOAD),20,1),a.setScaleY(.9),a.setPosition(0,-22),a.setCbUp(app.reloadGame.bind(this)),this.addChild(a),Backend.feedback())}else{try{BGame.utils.drawErrorPopup2()}catch(b){alert("Connection error"),cc.error(JSON.stringify(b))}Backend.feedback();this.close()}}});Popup.PopExitGame=Popup.PopBase.extend({ctor:function(a){this._super(a);this._size=new cc.Size(500,360)},build:function(){this._super();var a=new cc.Sprite(Resource.POP.img("000"));a.setPosition(0,135);this.addChild(a);a=new CLabelTTF(Lang.getString(Lang.POP_EXIT_GAME_MESSAGE),36,this._size.width-100,2);a.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);this.addChild(a);a=new CButton(Resource.POP.bt("reed"),null,{b:.05},{b:-.15});a.setText(Lang.getString(Lang.POP_EXIT_GAME_BT_QUIT),
20,1);a.setPosition(-120,-115);a.setCbUp(this.clickQuit.bind(this));this.addChild(a);var b=new CButton(Resource.POP.bt("green_2"),null,{b:.05},{b:-.15});b.setText(Lang.getString(Lang.POP_EXIT_GAME_BT_CONTINUE),20,1);b.setPosition(a.getPositionX()+a.getContentSize().width+40,a.getPositionY());b.setCbUp(this.close.bind(this));this.addChild(b)},clickQuit:function(){this.close();this.setOnClose(function(){cc.eventManager.dispatchCustomEvent(app.Events.PRESS_EXIT)})}});
Popup.PopExitGame.show=function(a,b,c,d){(new Popup.PopExitGame(a)).show(b,c,d)};Popup.PopBuyMoves=Popup.PopBase.extend({_ext:null,_orbs:null,_items:null,_callback:null,_status:!1,ctor:function(a){this._super(a);this._ext=new CExtNode(this);this._ext.addCustomListener(Backend.EVENT.PURCHASE_COMPLETE,this.eventHandler.bind(this));this._ext.addCustomListener(Backend.EVENT.PURCHASE_SUCCESS,this.eventHandler.bind(this));this._args.mode=Math.max(0,Math.min(3,this._args.mode))||0;this._args.moves=this._args.moves||0;this._size=new cc.Size(420,515);this._callback=this._args.callback;
this._hasClose=!1;this._items=[];this._status=!1},build:function(){this._super();var a=this,b=new CLabelTTF(Lang.getString(Lang.POP_BUY_MOVES_TITLE),22,this._size.width-100,2);b.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);b.setPosition(0,parseInt(.5*this._size.height)-42);this.addChild(b);b=new cc.Sprite(Resource.POP.img("001"));b.setScaleX((b.getContentSize().width-1)/b.getContentSize().width);b.setPosition(0,parseInt(.5*this._size.height)-170);this.addChild(b);var c=
new cc.Sprite(Resource.POP.img("002"));c.setPosition(b.getPositionX(),b.getPositionY()-.5*b.getContentSize().height*b.getScaleY());this.addChild(c);c=new cc.Sprite(Resource.POP.img("002"));c.setPosition(b.getPositionX(),b.getPositionY()+.5*b.getContentSize().height*b.getScaleY());this.addChild(c);c=new CLabelTTF(Lang.getString(Lang.POP_BUY_MOVES_MSG),50,b.getContentSize().width-50,2);c.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);c.setPosition(b.getPosition());this.addChild(c);
this._orbs=User.getRandomOrbs(this._args.mode,!1,!1);this._orbs.length!=this._args.mode?this._orbs=[]:0<this._orbs.length&&(b=this._orbs.map(function(a){var b=new cc.Sprite(Resource.POP.orb("back_on"));a=new cc.Sprite(Resource.POP.orb(a.getId()));a.setPosition(.5*b.getContentSize().width,.5*b.getContentSize().height);b.addChild(a);b.setScale(.39);return b}),1==b.length?(b[0].setPosition(0,-65),this.addChild(b[0])):2==b.length?(b[0].setPosition(-50,-65),b[1].setPosition(50,-65),this.addChild(b[0]),
this.addChild(b[1])):3==b.length&&(b[0].setPosition(-90,-65),b[1].setPosition(0,-65),b[2].setPosition(90,-65),this.addChild(b[0]),this.addChild(b[1]),this.addChild(b[2])));c=Products.getProduct(Products.IDS.PR_MOVES_5);var d=0==this._args.mode?null:"extra"+this._args.mode+(0<this._orbs.length?"_orb":"");b=c.getPrice(Products.CURRENCY.CASH,d);this._items.push({productId:c.getId(),currency:Products.CURRENCY.CASH,discountId:d});for(var e in this._orbs)this._items.push({productId:this._orbs[e].getId(),
currency:Products.CURRENCY.COINS,discountId:"gift_offer"});e=new CButton(Resource.POP.bt("green_2"),null,{b:.05},{b:-.15});e.setPosition(0,0==this._orbs.length?-114:-145);e.setCbUp(this.clickBuy.bind(this));c=new CLabelTTF(Lang.getString(Lang.POP_BUY_MOVES_BT_BUY),20,130,1);c.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);c.setPosition(85,.5*e.getContentSize().height-1);c.setAnchorPoint(.5,.5);e.addChild(c);c=new CLabelTTF(b.getAmountInt(),20,30,2);c.setAlignment(cc.TEXT_ALIGNMENT_CENTER,
cc.VERTICAL_TEXT_ALIGNMENT_CENTER);c.setPosition(200,.5*e.getContentSize().height-1);c.setAnchorPoint(.5,.5);e.addChild(c);b=new cc.Sprite(Resource.POP.currency("cash_3"));b.setFlippedX(!0);b.setScale(.7);b.setPosition(165,32);e.addChild(b);b=new CButton(Resource.POP.bt("reed"),null,{b:.05},{b:-.15});b.setText(Lang.getString(0==this._args.moves?Lang.POP_BUY_MOVES_BT_GIVEUP:Lang.POP_BUY_MOVES_BT_CANCEL),20,1);b.setPosition(0,e.getPositionY()-60);b.setCbUp(this.close.bind(this));this.addChild(b);this.addChild(e);
this.setOnClose(function(){a._callback&&a._callback(a._status)})},clickBuy:function(){Backend.purchase(this._items,this.getInstanceId(),"pop_buy_moves")},eventHandler:function(a){var b=a.getEventName();a=a.getUserData()||{};b==Backend.EVENT.PURCHASE_COMPLETE&&a.key==this.getInstanceId()&&a.status&&(this._status=!0,this.close())}});Popup.PopBuyMoves.show=function(a,b,c,d){(new Popup.PopBuyMoves(a)).show(b,c,d)};Popup.PopBuyLives=Popup.PopBase.extend({_ext:null,ctor:function(a){this._super(a);this._size=new cc.Size(1==app.config.lifePopMode()?520:580,510);this._hasClose=!0;this._ext=new CExtNode(this)},build:function(){this._super();var a=new CLabelTTF(Lang.getString(Lang.POP_BUY_LIVES_TITLE),28,this._size.width-100,2);a.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);a.setPosition(0,.5*this._size.height-49);this.addChild(a);if(1==app.config.lifePopMode()){var b=this.buildAskFriends();
a=this.buildBuyFullLive();b.setPosition(-110,45);a.setPosition(110,45);this.addChild(b);this.addChild(a)}else{b=this.buildAskFriends();a=this.buildBuy3Live();var c=this.buildBuyFullLive();b.setPosition(-180,45);a.setPosition(0,45);c.setPosition(180,45);this.addChild(b);this.addChild(a);this.addChild(c)}a=new CLabelTTF(Lang.getString(Lang.POP_BUY_LIVES_MSG),22,this._size.width-100,2);a.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);a.setPosition(0,-195);this.addChild(a);this._ext.addCustomListener(Backend.EVENT.PURCHASE_COMPLETE,
this.eventHandler.bind(this))},buildAskFriends:function(){var a=new cc.Sprite(Resource.POP.img("058")),b=a.getContentSize(),c=new CLabelTTF(Lang.getString(Lang.POP_BUY_LIVES_LB0),20,b.width-10,2);c.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);c.setPosition(.5*b.width,239);a.addChild(c);c=new CButton(Resource.POP.bt("blue"),null,{b:.05},{b:-.15});c.setText(Lang.getString(Lang.POP_BUY_LIVES_BT0),20,1);c.setPosition(.5*b.width,-40);c.setCbUp(this.clickAskFriends.bind(this));
a.addChild(c);b=User.getFriends(0);for(c=0;3>c;c++){var d=CUtils.random(0,b.length-1),e=b[d];b.splice(d,1);d=new cc.Node;d.addChild(new cc.Sprite(Resource.POP.img("060")),2);d.addChild(new cc.Sprite(Resource.POP.img("061")),0);e&&cc.textureCache.addImage(e.getPicture(),function(a){if(a instanceof cc.Texture2D){var b=.5*(a.width-Math.round(60/63*a.width));b=new cc.rect(b,0,a.width-b,a.height);a=new cc.Sprite(a,b);a.setScale(60/a.getContentSize().width);this.addChild(a)}},d);e=new cc.Sprite(Resource.POP.img("062"));
d.addChild(e,2);0==c?(d.setPosition(78,170),e.setPosition(0,-30)):1==c?(d.setPosition(40,74),e.setPosition(-12,-32),e.setRotation(21)):(d.setPosition(115,74),e.setPosition(9,-32));a.addChild(d)}return a},buildBuyFullLive:function(){var a=new cc.Sprite(Resource.POP.img("058")),b=a.getContentSize(),c=new CLabelTTF(Lang.getString(Lang.POP_BUY_LIVES_LB1),20,b.width-10,2);c.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);c.setPosition(.5*b.width,239);a.addChild(c);var d=new cc.Sprite(Resource.POP.img("059"));
d.setPosition(.5*b.width,150);a.addChild(d);d=new cc.Sprite(Resource.POP.currency("cash_2"));d.setPosition(50,50);d.setScale(.65);a.addChild(d);d=Products.getProduct(Products.IDS.PR_FULL_LIVES);c=d.getPrice(Products.CURRENCY.CASH);c=new CLabelTTF(c.getAmountInt(),26,0,2);c.setAlignment(cc.TEXT_ALIGNMENT_LEFT,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);c.setPosition(99,47);a.addChild(c);c=new CButton(Resource.POP.bt("green_0"),null,{b:.05},{b:-.15});c.setText(Lang.getString(Lang.POP_BUY_LIVES_BT1),20,1);c.setPosition(.5*
b.width,-40);c.setCbUp(this.clickBuy.bind(this,d.getId()));a.addChild(c);return a},buildBuy3Live:function(){var a=new cc.Sprite(Resource.POP.img("058")),b=a.getContentSize(),c=new CLabelTTF(Lang.getString(Lang.POP_BUY_LIVES_LB2),20,b.width-10,2);c.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);c.setPosition(.5*b.width,239);a.addChild(c);var d=new cc.Sprite(Resource.POP.img("075"));d.setPosition(.5*b.width,150);a.addChild(d);d=new cc.Sprite(Resource.POP.currency("cash_2"));
d.setPosition(50,50);d.setScale(.65);a.addChild(d);d=Products.getProduct(Products.IDS.PR_3_LIVES);c=d.getPrice(Products.CURRENCY.CASH);c=new CLabelTTF(c.getAmountInt(),26,0,2);c.setAlignment(cc.TEXT_ALIGNMENT_LEFT,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);c.setPosition(99,47);a.addChild(c);c=new CButton(Resource.POP.bt("green_0"),null,{b:.05},{b:-.15});c.setText(Lang.getString(Lang.POP_BUY_LIVES_BT1),20,1);c.setPosition(.5*b.width,-40);c.setCbUp(this.clickBuy.bind(this,d.getId()));a.addChild(c);return a},
eventHandler:function(a){a.getEventName()==Backend.EVENT.PURCHASE_COMPLETE&&(a=a.getUserData()||{},a.key==this.getInstanceId()&&a.status&&this.close())},clickAskFriends:function(){(new Popup.PopAskFriends).show()},clickBuy:function(a){Backend.purchase({productId:a,currency:Products.CURRENCY.CASH},this.getInstanceId(),"pop_buy_life")}});Popup.PopBeginLevel=Popup.PopBase.extend({_ext:null,_btPlay:null,_level:null,_keys:null,_mapId:null,_board:null,ctor:function(a){this._super(a);this._size=new cc.Size(420,535);this._ext=new CExtNode(this);this._ext.addCustomListener(User.EVENT.UPDATE_HIGHSCORE,this.eventHandler.bind(this));cc.assert(void 0!==this._args.mapId,"invalid parameters");cc.assert(this._args.level,"invalid parameters");this._mapId=this._args.mapId;this._level=this._args.level;this._keys=this._args.keys||0},build:function(){if("challenge"==
this._args.viewmode)this._moveTo=new cc.Point(Math.round(.5*this._wSize.width),Math.round(.5*this._wSize.height));else{this._moveTo=new cc.Point(Math.round(.5*this._wSize.width)-80,Math.round(.5*this._wSize.height));this._board=new cc.Sprite(Resource.POP.bg("friends"));this._board.setPosition(325,0);this.addChild(this._board,0);var a=new CLabelTTF(Lang.getString(Lang.POP_BEGIN_LEVEL_TOP_FRIENDS),22,this._board.getContentSize().width-40,2);a.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);
a.setPosition(112,444);this._board.addChild(a,1)}this._super();var b=new cc.Sprite(Resource.POP.img("006"));b.setPosition(0,.5*this._size.height+3);this.addChild(b,1);b=new CLabelTTF(Lang.getString(Lang.POP_BEGIN_LEVEL_TITLE,this._level.id),26,b.getContentSize().width-70,2);b.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);b.setPosition(0,.5*this._size.height+2);this.addChild(b,1);if("challenge"==this._args.viewmode){b=User.getChallenge().getLevel();var c=new cc.Sprite(Resource.WEEKLY_CHALLENGE.img("pop/decor"));
c.setScaleX((this._size.width-36)/c.getContentSize().width);c.setScaleY(295/c.getContentSize().height);c.setPosition(0,107);this.addChild(c);c=new cc.Sprite(Resource.WEEKLY_CHALLENGE.img("pop/lenta"));c.setPosition(0,145);this.addChild(c);for(var d=[{x:56,y:34,r:-13},{x:132,y:48,r:-6},{x:208,y:50,r:0},{x:284,y:48,r:6},{x:360,y:34,r:13}],e=0;5>e;e++)a=new CLabelTTF(e+1,22,0,2),a.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER),a.setPosition(d[e].x-5+2*e,d[e].y+40),c.addChild(a,
1),a=new cc.Sprite(Resource.WEEKLY_CHALLENGE.img("pop/butterfly",e<b?e:"empty")),a.setPosition(d[e].x,d[e].y),a.setRotation(d[e].r),c.addChild(a,1),e==b&&(a=new cc.Sprite(Resource.WEEKLY_CHALLENGE.img("pop/butterfly_glow")),a.runAction(new cc.RepeatForever(new cc.Sequence([new cc.ScaleTo(1,1.05),new cc.ScaleTo(1,1)]))),a.setPosition(d[e].x,d[e].y),a.setRotation(d[e].r),c.addChild(a,0))}else this.loadKeys(),this.loadFriend(!0);this.loadGoals();this.loadOrbs();this._btPlay=new CButton(Resource.POP.bt("green_0"),
null,{b:.05},{b:-.15});this._btPlay.setText(Lang.getString(Lang.POP_BEGIN_LEVEL_BT_PLAY),20,1);this._btPlay.setPosition(0,-212);this._btPlay.setCbUp(this.clickPlay.bind(this));this.addChild(this._btPlay)},loadGoals:function(){var a=new Client.Goal(this._level),b=[];3>b.length&&0<a.getGoalMoves()&&b.push(new Popup.PopBeginLevel.GoalMovesDone(a.getGoalMoves()));3>b.length&&0<a.getGoalBackground()&&b.push(new Popup.PopBeginLevel.GoalBackground(a.getGoalBackground()));3>b.length&&0<a.getGoalTreasure()&&
b.push(new Popup.PopBeginLevel.GoalTreasure(a.getGoalTreasure()));3>b.length&&0<a.getGoalTorch()&&b.push(new Popup.PopBeginLevel.GoalTorch(a.getGoalTorch()));3>b.length&&0<a.getGoalBeetle()&&b.push(new Popup.PopBeginLevel.GoalBeetle(a.getGoalBeetle()));3>b.length&&0<a.getGoalDiamond()&&b.push(new Popup.PopBeginLevel.GoalDiamond(a.getGoalDiamond()));3>b.length&&0<a.getGoalIceCube()&&b.push(new Popup.PopBeginLevel.GoalIceCube(a.getGoalIceCube()));3>b.length&&0<a.getGoalButterfly()&&b.push(new Popup.PopBeginLevel.GoalButterfly(a.getGoalButterfly()));
3>b.length&&0<a.getGoalRainbow()&&b.push(new Popup.PopBeginLevel.GoalRainbow(a.getGoalRainbow()));3>b.length&&0<a.getGoalRowBlast()&&b.push(new Popup.PopBeginLevel.GoalRowBlast(a.getGoalRowBlast()));3>b.length&&0<a.getGoalColumnBlast()&&b.push(new Popup.PopBeginLevel.GoalColumnBlast(a.getGoalColumnBlast()));3>b.length&&0<a.getGoalCrossBlast()&&b.push(new Popup.PopBeginLevel.GoalCrossBlast(a.getGoalCrossBlast()));3>b.length&&0<a.getGoalStone()&&b.push(new Popup.PopBeginLevel.GoalStone(a.getGoalStone()));
3>b.length&&0<a.getGoalFrog()&&b.push(new Popup.PopBeginLevel.GoalFrog(a.getGoalFrog()));3>b.length&&0<a.getGoalMirror()&&b.push(new Popup.PopBeginLevel.GoalMirror(a.getGoalMirror()));3>b.length&&0<a.getGoalMagicBall()&&b.push(new Popup.PopBeginLevel.GoalMagicBall(a.getGoalMagicBall()));3>b.length&&0<a.getGoalPearl()&&b.push(new Popup.PopBeginLevel.GoalPearl(a.getGoalPearl()));if("challenge"==this._args.viewmode)1==b.length?(b[0].setAnchorPoint(.5,.5),b[0].setScale(1.1),b[0].setPosition(0,15),this.addChild(b[0])):
1<b.length&&(b[0].setAnchorPoint(.5,.5),b[0].setScale(1.1),b[0].setPosition(.25*-this._size.width,15),this.addChild(b[0]),b[1].setAnchorPoint(.5,.5),b[1].setScale(1.1),b[1].setPosition(.25*this._size.width,15),this.addChild(b[1]));else{a=1==b.length?40:2==b.length?80:140;for(var c=0;c<b.length;c++){var d=b[c];d.setPosition(-180,a-80*c);this.addChild(d)}}},loadOrbs:function(){var a=new cc.Sprite(Resource.POP.img("010"));a.setPosition(0,-55);this.addChild(a,0);var b=new CLabelTTF(Lang.getString(Lang.POP_BEGIN_LEVEL_BOOSTERS),
26,a.getContentSize().width-70,2);b.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);b.setPosition(.5*a.getContentSize().width,.5*a.getContentSize().height-1);a.addChild(b);a=this._level.rec.split(":");a=User.getRecommendedOrbs(a);b=function(a){if(!a.isBought()){var b={};b.productId=a.getId();b.discountId=a.getDiscount();b.currency=a.isPermanent()?Products.CURRENCY.CASH:Products.CURRENCY.COINS;Backend.purchase(b,null,"pop_begin_level")}};for(var c=(this._size.width-190)/3,
d=.5*-(this._size.width-190),e=0;4>e;e++){var f=new Popup.OrbSmall;f.setPosition(d+e*c,-115);this.addChild(f);a[e]&&(f.setSound(Resource.SND.PURCHASE),f.setItem(a[e]),f.setClick(b.bind(this,a[e])))}},loadKeys:function(){var a=new cc.Sprite(Resource.POP.img("007"));a.setPosition(67,105);this.addChild(a,0);a=new cc.Sprite(Resource.POP.img(0<this._keys?0==this._mapId?"009":"123":"008"));var b=new cc.Sprite(Resource.POP.img(1<this._keys?0==this._mapId?"009":"123":"008")),c=new cc.Sprite(Resource.POP.img(2<
this._keys?0==this._mapId?"009":"123":"008"));a.setPosition(127,159);a.setScale(.63);b.setPosition(10,124);b.setScale(.76);c.setPosition(123,36);c.setScale(1);this.addChild(a);this.addChild(b);this.addChild(c)},loadFriend:function(a){var b;do(b=this._board.getChildByTag(1))&&this._board.removeChild(b);while(b);a=User.getHighScoreById(this._mapId).getData(this._level.id,a)||[];b=User.getFriends(2);for(var c=0;6>c&&(0<a.length||0<b.length);){var d=a.shift(),e=d?User.getFriendById(d.fbId,1):null;!e&&
d&&User.getFbId()===d.fbId&&(e=User);if(!d&&0<b.length){var f=CUtils.random(0,b.length-1);e=b[f];b.splice(f,1)}e&&(d=new Popup.PopBeginLevel.FriendItem(e,d?d.score:0),d.setTag(1),d.setPosition(112,70+64*(5-c)),this._board.addChild(d),c++)}},clickPlay:function(){var a=this;this.setOnClose(function(){app.loadClient(a._mapId,a._level)});this.close()},eventHandler:function(a){a.getEventName()==User.EVENT.UPDATE_HIGHSCORE&&-1!=a.getUserData().list.indexOf(Number(this._level.id))&&this.loadFriend(!1)}});
Popup.PopBeginLevel.show=function(a,b,c,d){(new Popup.PopBeginLevel(a)).show(b,c,d)};
Popup.PopBeginLevel.FriendItem=cc.Sprite.extend({ctor:function(a,b){this._super(Resource.POP.img("063"));var c=new cc.Sprite(Resource.POP.img("064"));c.setPosition(29,29);this.addChild(c,1);c=new cc.Sprite(Resource.POP.img("065"));c.setPosition(29,29);this.addChild(c);cc.textureCache.addImage(a.getPicture(),function(a){if(a instanceof cc.Texture2D){var b=.5*(a.width-Math.round(.95*a.width));b=new cc.rect(b,0,a.width-b,a.height);a=new cc.Sprite(a,b);a.setScale(38/a.getContentSize().width);a.setPosition(29,
29);this.addChild(a)}},this);c=new CLabelTTF(a.getFirstName(),18,75,7);c.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);c.setPosition(93,37);this.addChild(c);if(a.getInGame()){if(c=new cc.Sprite(Resource.POP.img("067")),c.setPosition(65,16),this.addChild(c),c=new CLabelTTF(b,16,55,4),c.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER),c.setPosition(103,16),this.addChild(c),a instanceof User.Friends.Item){var d=new cc.Sprite(Resource.POP.img("068"));
d.setPosition(174,31);d.setVisible(0<a.getGiftTime());this.addChild(d);var e=new CButton(Resource.POP.img("066"),null,{b:.05},{b:-.15});e.setPosition(174,31);e.setVisible(!d.isVisible());e.setCbUp(function(){d.setVisible(!0);e.setVisible(!1);User.getFriends().sendGift(a,"pop_begin_level")});this.addChild(e)}}else c=new CButton(Resource.POP.bt("green_3"),null,{b:.05},{b:-.15}),c.setText(Lang.getString(Lang.POP_BEGIN_LEVEL_BT_INVITE),20,1),c.setPosition(168,29),c.setScale(.85),c.setCbUp(Popup.PopInviteFriends.show.bind(this,
{showFrom:"begin_level"},0,null,100)),this.addChild(c)}});
Popup.PopBeginLevel.GoalMovesDone=cc.Node.extend({ctor:function(a){this._super();this.setContentSize(125,65);this.setAnchorPoint(0,0);var b=new CLabelTTF(Lang.getString(Lang.POP_BEGIN_LEVEL_GL_MOVES),22,this.getContentSize().width,2);b.setAnchorPoint(.5,1);b.setPosition(.5*this.getContentSize().width,this.getContentSize().height);var c=new cc.Sprite(Resource.POP.goal_icon("arrow"));c.setScale(.7);c.setPosition(.3*this.getContentSize().width,10);c.setRotation(90);c.runAction(new cc.RepeatForever(new cc.Sequence(new cc.MoveBy(.5,
3,0),new cc.MoveBy(.5,-3,0))));var d=new cc.Sprite(Resource.POP.goal_icon("arrow"));d.setFlippedY(!0);d.setScale(.7);d.setPosition(.3*this.getContentSize().width,27);d.setRotation(90);d.runAction(new cc.RepeatForever(new cc.Sequence(new cc.MoveBy(.5,-3,0),new cc.MoveBy(.5,3,0))));a=this.buildNumber(a);a.setPosition(.75*this.getContentSize().width,18);this.addChild(b);this.addChild(c);this.addChild(d);this.addChild(a)},buildNumber:function(a,b){b=b||new cc.Node;b.removeAllChildren();var c=CUtils.numToArray(a),
d=0;0==c.length&&c.push(0);for(var e in c){var f=new cc.Sprite(Resource.POP.goal_num(c[e]));f.setAnchorPoint(0,0);f.setPosition(d,0);d+=f.getContentSize().width;b.addChild(f)}b.setContentSize(0,0);c=b.getBoundingBoxToWorld();b.setContentSize(c.width,c.height);b.setAnchorPoint(.5,.5);b.setScale(.9);return b}});
Popup.PopBeginLevel.GoalBackground=cc.Node.extend({ctor:function(a){this._super();this.setContentSize(125,65);this.setAnchorPoint(0,0);var b=new CLabelTTF(Lang.getString(Lang.POP_BEGIN_LEVEL_GL_BACKGROUND),22,this.getContentSize().width,2);b.setAnchorPoint(.5,1);b.setPosition(.5*this.getContentSize().width,this.getContentSize().height);var c=new cc.Sprite(Resource.POP.goal_icon("background"));c.setPosition(.3*this.getContentSize().width,18);a=this.buildNumber(a);a.setPosition(.75*this.getContentSize().width,
18);this.addChild(b);this.addChild(c);this.addChild(a)},buildNumber:function(a,b){b=b||new cc.Node;b.removeAllChildren();var c=CUtils.numToArray(a),d=0;0==c.length&&c.push(0);for(var e in c){var f=new cc.Sprite(Resource.POP.goal_num(c[e]));f.setAnchorPoint(0,0);f.setPosition(d,0);d+=f.getContentSize().width;b.addChild(f)}b.setContentSize(0,0);c=b.getBoundingBoxToWorld();b.setContentSize(c.width,c.height);b.setAnchorPoint(.5,.5);b.setScale(.9);return b}});
Popup.PopBeginLevel.GoalTreasure=cc.Node.extend({ctor:function(a){this._super();this.setContentSize(125,65);this.setAnchorPoint(0,0);var b=new CLabelTTF(Lang.getString(Lang.POP_BEGIN_LEVEL_GL_TREASUSE),22,this.getContentSize().width,2);b.setAnchorPoint(.5,1);b.setPosition(.5*this.getContentSize().width,this.getContentSize().height);var c=new cc.Sprite(Resource.POP.goal_icon("treasure"));c.setPosition(.3*this.getContentSize().width,18);a=this.buildNumber(a);a.setPosition(.75*this.getContentSize().width,
18);this.addChild(b);this.addChild(c);this.addChild(a)},buildNumber:function(a,b){b=b||new cc.Node;b.removeAllChildren();var c=CUtils.numToArray(a),d=0;0==c.length&&c.push(0);for(var e in c){var f=new cc.Sprite(Resource.POP.goal_num(c[e]));f.setAnchorPoint(0,0);f.setPosition(d,0);d+=f.getContentSize().width;b.addChild(f)}b.setContentSize(0,0);c=b.getBoundingBoxToWorld();b.setContentSize(c.width,c.height);b.setAnchorPoint(.5,.5);b.setScale(.9);return b}});
Popup.PopBeginLevel.GoalTorch=cc.Node.extend({ctor:function(a){this._super();this.setContentSize(125,65);this.setAnchorPoint(0,0);var b=new CLabelTTF(Lang.getString(Lang.POP_BEGIN_LEVEL_GL_TORCH),22,this.getContentSize().width,2);b.setAnchorPoint(.5,1);b.setPosition(.5*this.getContentSize().width,this.getContentSize().height);var c=new cc.Sprite(Resource.POP.goal_icon("torch"));c.setPosition(.3*this.getContentSize().width,18);a=this.buildNumber(a);a.setPosition(.75*this.getContentSize().width,16);
this.addChild(b);this.addChild(c);this.addChild(a)},buildNumber:function(a,b){b=b||new cc.Node;b.removeAllChildren();var c=CUtils.numToArray(a),d=0;0==c.length&&c.push(0);for(var e in c){var f=new cc.Sprite(Resource.POP.goal_num(c[e]));f.setAnchorPoint(0,0);f.setPosition(d,0);d+=f.getContentSize().width;b.addChild(f)}b.setContentSize(0,0);c=b.getBoundingBoxToWorld();b.setContentSize(c.width,c.height);b.setAnchorPoint(.5,.5);b.setScale(.9);return b}});
Popup.PopBeginLevel.GoalBeetle=cc.Node.extend({ctor:function(a){this._super();this.setContentSize(125,65);this.setAnchorPoint(0,0);var b=new CLabelTTF(Lang.getString(Lang.POP_BEGIN_LEVEL_GL_BEETLE),22,this.getContentSize().width,2);b.setAnchorPoint(.5,1);b.setPosition(.5*this.getContentSize().width,this.getContentSize().height);var c=new cc.Sprite(Resource.POP.goal_icon("beetle"));c.setPosition(.3*this.getContentSize().width,18);a=this.buildNumber(a);a.setPosition(.75*this.getContentSize().width,
16);this.addChild(b);this.addChild(c);this.addChild(a)},buildNumber:function(a,b){b=b||new cc.Node;b.removeAllChildren();var c=CUtils.numToArray(a),d=0;0==c.length&&c.push(0);for(var e in c){var f=new cc.Sprite(Resource.POP.goal_num(c[e]));f.setAnchorPoint(0,0);f.setPosition(d,0);d+=f.getContentSize().width;b.addChild(f)}b.setContentSize(0,0);c=b.getBoundingBoxToWorld();b.setContentSize(c.width,c.height);b.setAnchorPoint(.5,.5);b.setScale(.9);return b}});
Popup.PopBeginLevel.GoalDiamond=cc.Node.extend({ctor:function(a){this._super();this.setContentSize(125,65);this.setAnchorPoint(0,0);var b=new CLabelTTF(Lang.getString(Lang.POP_BEGIN_LEVEL_GL_DIAMOUND),22,this.getContentSize().width,2);b.setAnchorPoint(.5,1);b.setPosition(.5*this.getContentSize().width,this.getContentSize().height);var c=new cc.Sprite(Resource.POP.goal_icon("diamond"));c.setPosition(.3*this.getContentSize().width,18);a=this.buildNumber(a);a.setPosition(.75*this.getContentSize().width,
16);this.addChild(b);this.addChild(c);this.addChild(a)},buildNumber:function(a,b){b=b||new cc.Node;b.removeAllChildren();var c=CUtils.numToArray(a),d=0;0==c.length&&c.push(0);for(var e in c){var f=new cc.Sprite(Resource.POP.goal_num(c[e]));f.setAnchorPoint(0,0);f.setPosition(d,0);d+=f.getContentSize().width;b.addChild(f)}b.setContentSize(0,0);c=b.getBoundingBoxToWorld();b.setContentSize(c.width,c.height);b.setAnchorPoint(.5,.5);b.setScale(.9);return b}});
Popup.PopBeginLevel.GoalIceCube=cc.Node.extend({ctor:function(a){this._super();this.setContentSize(125,65);this.setAnchorPoint(0,0);var b=new CLabelTTF(Lang.getString(Lang.POP_BEGIN_LEVEL_GL_ICECUBE),22,this.getContentSize().width,2);b.setAnchorPoint(.5,1);b.setPosition(.5*this.getContentSize().width,this.getContentSize().height);var c=new cc.Sprite(Resource.POP.goal_icon("icecube"));c.setPosition(.3*this.getContentSize().width,18);a=this.buildNumber(a);a.setPosition(.75*this.getContentSize().width,
16);this.addChild(b);this.addChild(c);this.addChild(a)},buildNumber:function(a,b){b=b||new cc.Node;b.removeAllChildren();var c=CUtils.numToArray(a),d=0;0==c.length&&c.push(0);for(var e in c){var f=new cc.Sprite(Resource.POP.goal_num(c[e]));f.setAnchorPoint(0,0);f.setPosition(d,0);d+=f.getContentSize().width;b.addChild(f)}b.setContentSize(0,0);c=b.getBoundingBoxToWorld();b.setContentSize(c.width,c.height);b.setAnchorPoint(.5,.5);b.setScale(.9);return b}});
Popup.PopBeginLevel.GoalButterfly=cc.Node.extend({ctor:function(a){this._super();this.setContentSize(125,65);this.setAnchorPoint(0,0);var b=new CLabelTTF(Lang.getString(Lang.POP_BEGIN_LEVEL_GL_BUTTERFLY),22,this.getContentSize().width,2);b.setAnchorPoint(.5,1);b.setPosition(.5*this.getContentSize().width,this.getContentSize().height);var c=new cc.Sprite(Resource.POP.goal_icon("butterfly"));c.setPosition(.3*this.getContentSize().width,18);a=this.buildNumber(a);a.setPosition(.75*this.getContentSize().width,
18);this.addChild(b);this.addChild(c);this.addChild(a)},buildNumber:function(a,b){b=b||new cc.Node;b.removeAllChildren();var c=CUtils.numToArray(a),d=0;0==c.length&&c.push(0);for(var e in c){var f=new cc.Sprite(Resource.POP.goal_num(c[e]));f.setAnchorPoint(0,0);f.setPosition(d,0);d+=f.getContentSize().width;b.addChild(f)}b.setContentSize(0,0);c=b.getBoundingBoxToWorld();b.setContentSize(c.width,c.height);b.setAnchorPoint(.5,.5);b.setScale(.9);return b}});
Popup.PopBeginLevel.GoalRainbow=cc.Node.extend({ctor:function(a){this._super();this.setContentSize(125,65);this.setAnchorPoint(0,0);var b=new CLabelTTF(Lang.getString(Lang.POP_BEGIN_LEVEL_GL_RAINBOW),22,this.getContentSize().width,2);b.setAnchorPoint(.5,1);b.setPosition(.5*this.getContentSize().width,this.getContentSize().height);var c=new cc.Sprite(Resource.POP.goal_icon("rainbow"));c.setScale(.9);c.setPosition(.3*this.getContentSize().width,18);a=this.buildNumber(a);a.setPosition(.75*this.getContentSize().width,
18);this.addChild(b);this.addChild(c);this.addChild(a)},buildNumber:function(a,b){b=b||new cc.Node;b.removeAllChildren();var c=CUtils.numToArray(a),d=0;0==c.length&&c.push(0);for(var e in c){var f=new cc.Sprite(Resource.POP.goal_num(c[e]));f.setAnchorPoint(0,0);f.setPosition(d,0);d+=f.getContentSize().width;b.addChild(f)}b.setContentSize(0,0);c=b.getBoundingBoxToWorld();b.setContentSize(c.width,c.height);b.setAnchorPoint(.5,.5);b.setScale(.9);return b}});
Popup.PopBeginLevel.GoalRowBlast=cc.Node.extend({ctor:function(a){this._super();this.setContentSize(125,65);this.setAnchorPoint(0,0);var b=new CLabelTTF(Lang.getString(Lang.POP_BEGIN_LEVEL_GL_ROWBLAST),22,this.getContentSize().width,2);b.setAnchorPoint(.5,1);b.setPosition(.5*this.getContentSize().width,this.getContentSize().height);var c=new cc.Sprite(Resource.POP.goal_icon("rowblast"));c.setScale(.9);c.setPosition(.3*this.getContentSize().width,16);a=this.buildNumber(a);a.setPosition(.75*this.getContentSize().width,
18);this.addChild(b);this.addChild(c);this.addChild(a)},buildNumber:function(a,b){b=b||new cc.Node;b.removeAllChildren();var c=CUtils.numToArray(a),d=0;0==c.length&&c.push(0);for(var e in c){var f=new cc.Sprite(Resource.POP.goal_num(c[e]));f.setAnchorPoint(0,0);f.setPosition(d,0);d+=f.getContentSize().width;b.addChild(f)}b.setContentSize(0,0);c=b.getBoundingBoxToWorld();b.setContentSize(c.width,c.height);b.setAnchorPoint(.5,.5);b.setScale(.9);return b}});
Popup.PopBeginLevel.GoalColumnBlast=cc.Node.extend({ctor:function(a){this._super();this.setContentSize(125,65);this.setAnchorPoint(0,0);var b=new CLabelTTF(Lang.getString(Lang.POP_BEGIN_LEVEL_GL_COLUMNBLAST),22,this.getContentSize().width,2);b.setAnchorPoint(.5,1);b.setPosition(.5*this.getContentSize().width,this.getContentSize().height);var c=new cc.Sprite(Resource.POP.goal_icon("colblast"));c.setScale(.9);c.setPosition(.3*this.getContentSize().width,16);a=this.buildNumber(a);a.setPosition(.75*this.getContentSize().width,
18);this.addChild(b);this.addChild(c);this.addChild(a)},buildNumber:function(a,b){b=b||new cc.Node;b.removeAllChildren();var c=CUtils.numToArray(a),d=0;0==c.length&&c.push(0);for(var e in c){var f=new cc.Sprite(Resource.POP.goal_num(c[e]));f.setAnchorPoint(0,0);f.setPosition(d,0);d+=f.getContentSize().width;b.addChild(f)}b.setContentSize(0,0);c=b.getBoundingBoxToWorld();b.setContentSize(c.width,c.height);b.setAnchorPoint(.5,.5);b.setScale(.9);return b}});
Popup.PopBeginLevel.GoalCrossBlast=cc.Node.extend({ctor:function(a){this._super();this.setContentSize(125,65);this.setAnchorPoint(0,0);var b=new CLabelTTF(Lang.getString(Lang.POP_BEGIN_LEVEL_GL_CROSSBLAST),22,this.getContentSize().width,2);b.setAnchorPoint(.5,1);b.setPosition(.5*this.getContentSize().width,this.getContentSize().height);var c=new cc.Sprite(Resource.POP.goal_icon("crossblast"));c.setScale(.9);c.setPosition(.3*this.getContentSize().width,16);a=this.buildNumber(a);a.setPosition(.75*this.getContentSize().width,
18);this.addChild(b);this.addChild(c);this.addChild(a)},buildNumber:function(a,b){b=b||new cc.Node;b.removeAllChildren();var c=CUtils.numToArray(a),d=0;0==c.length&&c.push(0);for(var e in c){var f=new cc.Sprite(Resource.POP.goal_num(c[e]));f.setAnchorPoint(0,0);f.setPosition(d,0);d+=f.getContentSize().width;b.addChild(f)}b.setContentSize(0,0);c=b.getBoundingBoxToWorld();b.setContentSize(c.width,c.height);b.setAnchorPoint(.5,.5);b.setScale(.9);return b}});
Popup.PopBeginLevel.GoalStone=cc.Node.extend({ctor:function(a){this._super();this.setContentSize(125,65);this.setAnchorPoint(0,0);var b=new CLabelTTF(Lang.getString(Lang.POP_BEGIN_LEVEL_GL_STONE),22,this.getContentSize().width,2);b.setAnchorPoint(.5,1);b.setPosition(.5*this.getContentSize().width,this.getContentSize().height);var c=new cc.Sprite(Resource.POP.goal_icon("stone"));c.setScale(.9);c.setPosition(.3*this.getContentSize().width,16);a=this.buildNumber(a);a.setPosition(.75*this.getContentSize().width,
18);this.addChild(b);this.addChild(c);this.addChild(a)},buildNumber:function(a,b){b=b||new cc.Node;b.removeAllChildren();var c=CUtils.numToArray(a),d=0;0==c.length&&c.push(0);for(var e in c){var f=new cc.Sprite(Resource.POP.goal_num(c[e]));f.setAnchorPoint(0,0);f.setPosition(d,0);d+=f.getContentSize().width;b.addChild(f)}b.setContentSize(0,0);c=b.getBoundingBoxToWorld();b.setContentSize(c.width,c.height);b.setAnchorPoint(.5,.5);b.setScale(.9);return b}});
Popup.PopBeginLevel.GoalFrog=cc.Node.extend({ctor:function(a){this._super();this.setContentSize(125,65);this.setAnchorPoint(0,0);var b=new CLabelTTF(Lang.getString(Lang.POP_BEGIN_LEVEL_GL_FROG),22,this.getContentSize().width,2);b.setAnchorPoint(.5,1);b.setPosition(.5*this.getContentSize().width,this.getContentSize().height);var c=new cc.Sprite(Resource.POP.goal_icon("frog"));c.setScale(.9);c.setPosition(.3*this.getContentSize().width,18);a=this.buildNumber(a);a.setPosition(.75*this.getContentSize().width,
18);this.addChild(b);this.addChild(c);this.addChild(a)},buildNumber:function(a,b){b=b||new cc.Node;b.removeAllChildren();var c=CUtils.numToArray(a),d=0;0==c.length&&c.push(0);for(var e in c){var f=new cc.Sprite(Resource.POP.goal_num(c[e]));f.setAnchorPoint(0,0);f.setPosition(d,0);d+=f.getContentSize().width;b.addChild(f)}b.setContentSize(0,0);c=b.getBoundingBoxToWorld();b.setContentSize(c.width,c.height);b.setAnchorPoint(.5,.5);b.setScale(.9);return b}});
Popup.PopBeginLevel.GoalMirror=cc.Node.extend({ctor:function(a){this._super();this.setContentSize(125,65);this.setAnchorPoint(0,0);var b=new CLabelTTF(Lang.getString(Lang.POP_BEGIN_LEVEL_GL_MIRROR),22,this.getContentSize().width,2);b.setAnchorPoint(.5,1);b.setPosition(.5*this.getContentSize().width,this.getContentSize().height);var c=new cc.Sprite(Resource.POP.goal_icon("mirror"));c.setScale(.9);c.setPosition(.3*this.getContentSize().width,18);a=this.buildNumber(a);a.setPosition(.75*this.getContentSize().width,
18);this.addChild(b);this.addChild(c);this.addChild(a)},buildNumber:function(a,b){b=b||new cc.Node;b.removeAllChildren();var c=CUtils.numToArray(a),d=0;0==c.length&&c.push(0);for(var e in c){var f=new cc.Sprite(Resource.POP.goal_num(c[e]));f.setAnchorPoint(0,0);f.setPosition(d,0);d+=f.getContentSize().width;b.addChild(f)}b.setContentSize(0,0);c=b.getBoundingBoxToWorld();b.setContentSize(c.width,c.height);b.setAnchorPoint(.5,.5);b.setScale(.9);return b}});
Popup.PopBeginLevel.GoalMagicBall=cc.Node.extend({ctor:function(a){this._super();this.setContentSize(125,65);this.setAnchorPoint(0,0);var b=new CLabelTTF(Lang.getString(Lang.POP_BEGIN_LEVEL_GL_MAGICBALL),22,this.getContentSize().width,2);b.setAnchorPoint(.5,1);b.setPosition(.5*this.getContentSize().width,this.getContentSize().height);var c=new cc.Sprite(Resource.POP.goal_icon("magicball"));c.setPosition(.3*this.getContentSize().width,18);a=this.buildNumber(a);a.setPosition(.75*this.getContentSize().width,
18);this.addChild(b);this.addChild(c);this.addChild(a)},buildNumber:function(a,b){b=b||new cc.Node;b.removeAllChildren();var c=CUtils.numToArray(a),d=0;0==c.length&&c.push(0);for(var e in c){var f=new cc.Sprite(Resource.POP.goal_num(c[e]));f.setAnchorPoint(0,0);f.setPosition(d,0);d+=f.getContentSize().width;b.addChild(f)}b.setContentSize(0,0);c=b.getBoundingBoxToWorld();b.setContentSize(c.width,c.height);b.setAnchorPoint(.5,.5);b.setScale(.9);return b}});
Popup.PopBeginLevel.GoalPearl=cc.Node.extend({ctor:function(a){this._super();this.setContentSize(125,65);this.setAnchorPoint(0,0);var b=new CLabelTTF(Lang.getString(Lang.POP_BEGIN_LEVEL_GL_PEARL),22,this.getContentSize().width,2);b.setAnchorPoint(.5,1);b.setPosition(.5*this.getContentSize().width,this.getContentSize().height);var c=new cc.Sprite(Resource.POP.goal_icon("pearl"));c.setPosition(.3*this.getContentSize().width,18);a=this.buildNumber(a);a.setPosition(.75*this.getContentSize().width,18);
this.addChild(b);this.addChild(c);this.addChild(a)},buildNumber:function(a,b){b=b||new cc.Node;b.removeAllChildren();var c=CUtils.numToArray(a),d=0;0==c.length&&c.push(0);for(var e in c){var f=new cc.Sprite(Resource.POP.goal_num(c[e]));f.setAnchorPoint(0,0);f.setPosition(d,0);d+=f.getContentSize().width;b.addChild(f)}b.setContentSize(0,0);c=b.getBoundingBoxToWorld();b.setContentSize(c.width,c.height);b.setAnchorPoint(.5,.5);b.setScale(.9);return b}});Popup.PopLoseLevel=Popup.PopBase.extend({_ext:null,_status:null,_mapId:0,_level:null,_board:null,ctor:function(a){this._super(a);this._size=new cc.Size(420,535);this._ext=new CExtNode(this);this._ext.addCustomListener(User.EVENT.UPDATE_HIGHSCORE,this.eventHandler.bind(this));this._status=a.status;this._mapId=a.mapId;this._level=a.level},build:function(){if("challenge"==this._args.viewmode)this._moveTo=new cc.Point(Math.round(.5*this._wSize.width),Math.round(.5*this._wSize.height));else{this._moveTo=
new cc.Point(Math.round(.5*this._wSize.width)-80,Math.round(.5*this._wSize.height));this._board=new cc.Sprite(Resource.POP.bg("friends"));this._board.setPosition(325,0);this.addChild(this._board,0);var a=new CLabelTTF(Lang.getString(Lang.POP_LOSE_LEVEL_TOP_FRIENDS),22,this._board.getContentSize().width-40,2);a.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);a.setPosition(112,444);this._board.addChild(a,1)}this._super();var b=this,c=new cc.Sprite(Resource.POP.img("006"));c.setPosition(0,
.5*this._size.height+3);this.addChild(c,1);c=new CLabelTTF(Lang.getString(Lang.POP_LOSE_LEVEL_TITLE,this._level.id),26,c.getContentSize().width-70,2);c.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);c.setPosition(0,.5*this._size.height+2);this.addChild(c,1);var d="";if("no_moves"==this._status)d=Lang.getString(Lang.POP_LOSE_LEVEL_NO_MOVES);else if("no_matches"==this._status)d=Lang.getString(Lang.POP_LOSE_LEVEL_NO_MATCHES);else if("no_sphere"==this._status)d=Lang.getString(Lang.POP_LOSE_LEVEL_NO_SPHERES);
else if("press_exit"==this._status)d=Lang.getString(Lang.POP_LOSE_LEVEL_PRESS_EXIT);else{cc.assert(!1,"unknown exit status");return}if("challenge"==this._args.viewmode){c=Math.max(User.getChallenge().getLevel(),this._level.id);var e=new cc.Sprite(Resource.WEEKLY_CHALLENGE.img("pop/decor"));e.setScaleX((this._size.width-36)/e.getContentSize().width);e.setScaleY(295/e.getContentSize().height);e.setPosition(0,107);this.addChild(e);d=new CLabelTTF(d,24,this._size.width-100,2);d.setAlignment(cc.TEXT_ALIGNMENT_CENTER,
cc.VERTICAL_TEXT_ALIGNMENT_CENTER);d.setPosition(0,215);this.addChild(d);d=new cc.Sprite(Resource.POP.img("011"));d.setPosition(-10,40);d.setScale(.85);this.addChild(d,0);d=new cc.Sprite(Resource.WEEKLY_CHALLENGE.img("pop/lenta"));d.setPosition(0,110);this.addChild(d);e=[{x:56,y:34,r:-13},{x:132,y:48,r:-6},{x:208,y:50,r:0},{x:284,y:48,r:6},{x:360,y:34,r:13}];for(var f=0;5>f;f++)a=new CLabelTTF(f+1,22,0,2),a.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER),a.setPosition(e[f].x-
5+2*f,e[f].y+40),d.addChild(a,1),a=new cc.Sprite(Resource.WEEKLY_CHALLENGE.img("pop/butterfly",f+1<c?f:"empty")),a.setPosition(e[f].x,e[f].y),a.setRotation(e[f].r),d.addChild(a,1),f+1==c&&(a=new cc.Sprite(Resource.WEEKLY_CHALLENGE.img("pop/butterfly_glow")),a.runAction(new cc.RepeatForever(new cc.Sequence([new cc.ScaleTo(1,1.05),new cc.ScaleTo(1,1)]))),a.setPosition(e[f].x,e[f].y),a.setRotation(e[f].r),d.addChild(a,0),a=new cc.Sprite(Resource.WEEKLY_CHALLENGE.img("pop/butterfly_check2")),a.setPosition(e[f].x,
e[f].y+5),d.addChild(a,2));this.loadOrbs();c=new CButton(Resource.POP.bt("green_2"),null,{b:.05},{b:-.15});c.setText(Lang.getString(Lang.POP_LOSE_LEVEL_BT_CONTINUE),20,1);c.setPosition(0,-212);c.setCbUp(function(){b.close()})}else d=new CLabelTTF(d,24,this._size.width-100,2),d.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER),d.setPosition(0,210),this.addChild(d),d=new cc.Sprite(Resource.POP.img("011")),d.setPosition(-10,95),this.addChild(d,0),this.loadFriend(!0),this.loadOrbs(),
c=new CButton(Resource.POP.bt("green_2"),null,{b:.05},{b:-.15}),c.setText(Lang.getString(Lang.POP_LOSE_LEVEL_BT_PLAY),20,1),c.setPosition(0,-212),c.setCbUp(function(){b.setOnClose(function(){app.loadClient(b._mapId,b._level,!0)});b.close();Popup.close(Popup.PopBase)});this.addChild(c)},loadOrbs:function(){var a=new cc.Sprite(Resource.POP.img("010"));a.setPosition(0,-55);this.addChild(a,0);var b=new CLabelTTF(Lang.getString(Lang.POP_LOSE_LEVEL_BOOSTERS),26,a.getContentSize().width-70,2);b.setAlignment(cc.TEXT_ALIGNMENT_CENTER,
cc.VERTICAL_TEXT_ALIGNMENT_CENTER);b.setPosition(.5*a.getContentSize().width,.5*a.getContentSize().height-1);a.addChild(b);a=this._level.rec.split(":");a=User.getRecommendedOrbs(a);b=function(a){if(!a.isBought()){var b={};b.productId=a.getId();b.discountId=a.getDiscount();b.currency=a.isPermanent()?Products.CURRENCY.CASH:Products.CURRENCY.COINS;Backend.purchase(b,null,"pop_lose_level")}};for(var c=(this._size.width-190)/3,d=.5*-(this._size.width-190),e=0;4>e;e++){var f=new Popup.OrbSmall;f.setPosition(d+
e*c,-115);this.addChild(f);a[e]&&(f.setSound(Resource.SND.PURCHASE),f.setItem(a[e]),f.setClick(b.bind(this,a[e])))}},loadFriend:function(a){var b;do(b=this._board.getChildByTag(1))&&this._board.removeChild(b);while(b);a=User.getHighScoreById(this._mapId).getData(this._level.id,a)||[];b=User.getFriends(2);for(var c=0;6>c&&(0<a.length||0<b.length);){var d=a.shift(),e=d?User.getFriendById(d.fbId,1):null;!e&&d&&User.getFbId()===d.fbId&&(e=User);if(!d&&0<b.length){var f=CUtils.random(0,b.length-1);e=b[f];
b.splice(f,1)}e&&(d=new Popup.PopLoseLevel.FriendItem(e,d?d.score:0),d.setTag(1),d.setPosition(112,70+64*(5-c)),this._board.addChild(d),c++)}},eventHandler:function(a){a.getEventName()==User.EVENT.UPDATE_HIGHSCORE&&-1!=a.getUserData().list.indexOf(Number(this._level.id))&&this.loadFriend(!1)}});Popup.PopLoseLevel.show=function(a,b,c,d){(new Popup.PopLoseLevel(a)).show(b,c,d)};
Popup.PopLoseLevel.FriendItem=cc.Sprite.extend({ctor:function(a,b){this._super(Resource.POP.img("063"));var c=new cc.Sprite(Resource.POP.img("064"));c.setPosition(29,29);this.addChild(c,1);c=new cc.Sprite(Resource.POP.img("065"));c.setPosition(29,29);this.addChild(c);cc.textureCache.addImage(a.getPicture(),function(a){if(a instanceof cc.Texture2D){var b=.5*(a.width-Math.round(.95*a.width));b=new cc.rect(b,0,a.width-b,a.height);a=new cc.Sprite(a,b);a.setScale(38/a.getContentSize().width);a.setPosition(29,
29);this.addChild(a)}},this);c=new CLabelTTF(a.getFirstName(),18,75,7);c.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);c.setPosition(93,37);this.addChild(c);if(a.getInGame()){if(c=new cc.Sprite(Resource.POP.img("067")),c.setPosition(65,16),this.addChild(c),c=new CLabelTTF(b,16,55,4),c.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER),c.setPosition(103,16),this.addChild(c),a instanceof User.Friends.Item){var d=new cc.Sprite(Resource.POP.img("068"));
d.setPosition(174,31);d.setVisible(0<a.getGiftTime());this.addChild(d);var e=new CButton(Resource.POP.img("066"),null,{b:.05},{b:-.15});e.setPosition(174,31);e.setVisible(!d.isVisible());e.setCbUp(function(){d.setVisible(!0);e.setVisible(!1);User.getFriends().sendGift(a,"pop_lose_level")});this.addChild(e)}}else c=new CButton(Resource.POP.bt("green_3"),null,{b:.05},{b:-.15}),c.setText(Lang.getString(Lang.POP_LOSE_LEVEL_BT_INVITE),20,1),c.setPosition(168,29),c.setScale(.85),c.setCbUp(Popup.PopInviteFriends.show.bind(this,
{showFrom:"failed_level"},0,null,100)),this.addChild(c)}});Popup.PopWinLevel=Popup.PopBase.extend({_ext:null,_mapId:0,_level:null,_keys:0,_coins:0,_board:null,ctor:function(a){this._super(a);this._size=new cc.Size(420,535);this._ext=new CExtNode(this);this._ext.addCustomListener(User.EVENT.UPDATE_HIGHSCORE,this.eventHandler.bind(this));this._mapId=a.mapId;this._level=a.level;this._keys=Math.max(1,Math.min(3,a.keys));this._coins=a.coins},build:function(){if("challenge"==this._args.viewmode)this._moveTo=new cc.Point(Math.round(.5*this._wSize.width),Math.round(.5*
this._wSize.height));else{this._moveTo=new cc.Point(Math.round(.5*this._wSize.width)-80,Math.round(.5*this._wSize.height));this._board=new cc.Sprite(Resource.POP.bg("friends"));this._board.setPosition(325,0);this.addChild(this._board,0);var a=new CLabelTTF(Lang.getString(Lang.POP_WIN_LEVEL_TOP_FRIENDS),22,this._board.getContentSize().width-40,2);a.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);a.setPosition(112,444);this._board.addChild(a,1)}this._super();var b=this,c=new cc.Sprite(Resource.POP.img("006"));
c.setPosition(0,.5*this._size.height+3);this.addChild(c,1);c=new CLabelTTF(Lang.getString(Lang.POP_WIN_LEVEL_TITLE,this._level.id),26,c.getContentSize().width-70,2);c.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);c.setPosition(0,.5*this._size.height+2);this.addChild(c,1);if("challenge"==this._args.viewmode){c=User.getChallenge().getLevel();var d=new cc.Sprite(Resource.WEEKLY_CHALLENGE.img("pop/decor"));d.setScaleX((this._size.width-36)/d.getContentSize().width);d.setScaleY(325/
d.getContentSize().height);d.setPosition(0,107);this.addChild(d);d=new cc.Sprite(Resource.WEEKLY_CHALLENGE.img("map/lotos_glow"));d.setPosition(0,45);this.addChild(d);var e=new cc.Sprite(Resource.WEEKLY_CHALLENGE.img("map/lotos"));e.setPosition(d.getPositionX()+7,d.getPositionY()-13);this.addChild(e);for(d=0;d<c;d++){var f=.2*d+.2,g=new cc.Sprite(Resource.WEEKLY_CHALLENGE.img("map/lotos_anim",d));g.setOpacity(0);g.setPosition(e.getPosition());g.runAction(new cc.Sequence([new cc.DelayTime(f),(new cc.FadeIn(.5)).easing(cc.easeOut(.2))]));
this.addChild(g)}5<=c&&cc.loader.load("particle/weekly_challenge_start.plist",function(a,c){if(!a){var d=new cc.ParticleSystem("particle/weekly_challenge_start.plist");d.setPosition(e.getPosition());d.stopSystem();d.runAction(new cc.Sequence([new cc.DelayTime(1.5),new cc.CallFunc(function(){d.resetSystem()})]));b.addChild(d,100)}});f=new cc.Sprite(Resource.WEEKLY_CHALLENGE.img("pop/lenta"));f.setPosition(0,170);this.addChild(f);g=[{x:56,y:34,r:-13},{x:132,y:48,r:-6},{x:208,y:50,r:0},{x:284,y:48,r:6},
{x:360,y:34,r:13}];for(d=0;5>d;d++)a=new CLabelTTF(d+1,22,0,2),a.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER),a.setPosition(g[d].x-5+2*d,g[d].y+40),f.addChild(a,1),a=new cc.Sprite(Resource.WEEKLY_CHALLENGE.img("pop/butterfly",d<c?d:"empty")),a.setPosition(g[d].x,g[d].y),a.setRotation(g[d].r),f.addChild(a,1),d==c&&(a=new cc.Sprite(Resource.WEEKLY_CHALLENGE.img("pop/butterfly_glow")),a.runAction(new cc.RepeatForever(new cc.Sequence([new cc.ScaleTo(1,1.05),new cc.ScaleTo(1,
1)]))),a.setPosition(g[d].x,g[d].y),a.setRotation(g[d].r),f.addChild(a,0));c=new CLabelTTF(Lang.getString(Lang.POP_WIN_LEVEL_VIEW0_MSG),22,150,2);c.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);c.setPosition(0,135);this.addChild(c)}else this.loadKeys(),this.loadFriend(!0);c=new cc.Sprite(Resource.POP.img("012"));c.setPosition(0,-110);this.addChild(c,0);c=new cc.Sprite(Resource.POP.img("013"));c.setPosition(-118,-116);this.addChild(c,0);c=new CLabelTTF(Lang.getString(Lang.POP_WIN_LEVEL_MSG,
this._coins),20,190,2);c.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);c.setPosition(90,-110);this.addChild(c);c=this.buildNumber(this._coins);c.setPosition(-75,-115);this.addChild(c);c=new CButton(Resource.POP.bt("green_2"),null,{b:.05},{b:-.15});c.setText(Lang.getString(Lang.POP_WIN_LEVEL_BT_PLAY),20,1);c.setPosition(0,-205);c.setCbUp(this.close.bind(this));this.addChild(c);this._args.opennext&&this.setOnClose(function(){cc.eventManager.dispatchCustomEvent(Map.EVENT.OPEN_NEXT_LEVEL,
{levelId:b._level.id})})},loadFriend:function(a){var b;do(b=this._board.getChildByTag(1))&&this._board.removeChild(b);while(b);a=User.getHighScoreById(this._mapId).getData(this._level.id,a)||[];b=User.getFriends(2);for(var c=0;6>c&&(0<a.length||0<b.length);){var d=a.shift(),e=d?User.getFriendById(d.fbId,1):null;!e&&d&&User.getFbId()===d.fbId&&(e=User);if(!d&&0<b.length){var f=CUtils.random(0,b.length-1);e=b[f];b.splice(f,1)}e&&(d=new Popup.PopWinLevel.FriendItem(e,d?d.score:0),d.setTag(1),d.setPosition(112,
70+64*(5-c)),this._board.addChild(d),c++)}},loadKeys:function(){sp=new cc.Sprite(Resource.POP.img("007"));sp.setPosition(67,105);this.addChild(sp,0);var a=new cc.Sprite(Resource.POP.img(0<this._keys?0==this._mapId?"009":"123":"008")),b=new cc.Sprite(Resource.POP.img(1<this._keys?0==this._mapId?"009":"123":"008")),c=new cc.Sprite(Resource.POP.img(2<this._keys?0==this._mapId?"009":"123":"008"));a.setPosition(127,159);a.setScale(.63);b.setPosition(10,124);b.setScale(.76);c.setPosition(123,36);c.setScale(1);
this.addChild(a);this.addChild(b);this.addChild(c);a=new CLabelTTF(Lang.getString(Lang.POP_WIN_LEVEL_KEY(this._keys)),22,150,2);a.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);a.setAnchorPoint(.5,1);a.setPosition(-110,210);this.addChild(a);a=new CLabelTTF(Lang.getString(Lang.POP_WIN_LEVEL_SPHERE(this._keys)),20,150,2);a.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);a.setPosition(-110,30);this.addChild(a)},eventHandler:function(a){a.getEventName()==
User.EVENT.UPDATE_HIGHSCORE&&-1!=a.getUserData().list.indexOf(Number(this._level.id))&&this.loadFriend(!1)},buildNumber:function(a,b){b=b||new cc.Node;b.removeAllChildren();var c=CUtils.numToArray(a),d=0;0==c.length&&c.push(0);for(var e in c){var f=new cc.Sprite(Resource.POP.goal_num(c[e]));f.setAnchorPoint(0,0);f.setPosition(d,0);d+=f.getContentSize().width;b.addChild(f)}b.setContentSize(0,0);c=b.getBoundingBoxToWorld();b.setContentSize(c.width,c.height);b.setAnchorPoint(.5,.5);b.setScale(.9);return b}});
Popup.PopWinLevel.show=function(a,b,c,d){(new Popup.PopWinLevel(a)).show(b,c,d)};
Popup.PopWinLevel.FriendItem=cc.Sprite.extend({ctor:function(a,b){this._super(Resource.POP.img("063"));var c=new cc.Sprite(Resource.POP.img("064"));c.setPosition(29,29);this.addChild(c,1);c=new cc.Sprite(Resource.POP.img("065"));c.setPosition(29,29);this.addChild(c);cc.textureCache.addImage(a.getPicture(),function(a){if(a instanceof cc.Texture2D){var b=.5*(a.width-Math.round(.95*a.width));b=new cc.rect(b,0,a.width-b,a.height);a=new cc.Sprite(a,b);a.setScale(38/a.getContentSize().width);a.setPosition(29,
29);this.addChild(a)}},this);c=new CLabelTTF(a.getFirstName(),18,75,7);c.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);c.setPosition(93,37);this.addChild(c);if(a.getInGame()){if(c=new cc.Sprite(Resource.POP.img("067")),c.setPosition(65,16),this.addChild(c),c=new CLabelTTF(b,16,55,4),c.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER),c.setPosition(103,16),this.addChild(c),a instanceof User.Friends.Item){var d=new cc.Sprite(Resource.POP.img("068"));
d.setPosition(174,31);d.setVisible(0<a.getGiftTime());this.addChild(d);var e=new CButton(Resource.POP.img("066"),null,{b:.05},{b:-.15});e.setPosition(174,31);e.setVisible(!d.isVisible());e.setCbUp(function(){d.setVisible(!0);e.setVisible(!1);User.getFriends().sendGift(a,"pop_win_level")});this.addChild(e)}}else c=new CButton(Resource.POP.bt("green_3"),null,{b:.05},{b:-.15}),c.setText(Lang.getString(Lang.POP_WIN_LEVEL_BT_INVITE),20,1),c.setPosition(168,29),c.setScale(.85),c.setCbUp(Popup.PopInviteFriends.show.bind(this,
{showFrom:"win_level"},0,null,100)),this.addChild(c)}});Popup.PopChapterClosed=Popup.PopBase.extend({ctor:function(a){this._super(a);this._size=new cc.Size(360,140)},build:function(){this._super();var a=new CLabelTTF(Lang.getString(Lang.POP_CHAPTER_CLOSED),20,this._size.width-50,2);a.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);this.addChild(a)}});Popup.PopChapterUnlock=Popup.PopBase.extend({_ext:null,_lkFriends:null,_lkKeys:null,_lkSphere:null,_curKeys:0,_reqKeys:0,_lockId:0,_helpCount:0,ctor:function(a){this._super(a);this._size=new cc.Size(450,585);this._hasClose=!0;this._ext=new CExtNode(this)},build:function(){this._super();var a=User.getScoreById(0);this._curKeys=a.getKeys();this._lockId=Map.Utils.getLockId(0,a.getSize())+1;this._reqKeys=Map.Utils.getKeys(0,this._lockId);this._helpCount=0;if(0==this._reqKeys)this.clickUnlock("sphere");
else{a=new cc.Sprite(Resource.POP.img("006"));a.setPosition(0,.5*this._size.height+3);this.addChild(a,1);a=new CLabelTTF(Lang.getString(Lang.POP_CHAPTER_UNLOCK_TITLE),26,a.getContentSize().width-70,2);a.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);a.setPosition(0,.5*this._size.height+2);this.addChild(a,1);var b=new CLabelTTF(Lang.getString(Lang.POP_CHAPTER_UNLOCK_OPTION),26,this._size.width-70,2);b.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);
b.setPosition(0,.5*this._size.height-45);this.addChild(b);this._lkFriends=this.buildUnlock("friends");this._lkFriends.setPosition(0,105);this.addChild(this._lkFriends);b=User.getInbox().getUnlock();a=[];for(var c in b){var d=User.getFriendById(b[c].from,1);d&&a.push(d)}c=new Popup.PopChapterUnlock.Friend(a[0]);c.setPosition(this._lkFriends.getPositionX()+4,this._lkFriends.getPositionY()+80);this.addChild(c);c=new Popup.PopChapterUnlock.Friend(a[1]);c.setPosition(this._lkFriends.getPositionX()-90,
this._lkFriends.getPositionY()+20);this.addChild(c);c=new Popup.PopChapterUnlock.Friend(a[2]);c.setPosition(this._lkFriends.getPositionX()+92,this._lkFriends.getPositionY()+20);this.addChild(c);this._helpCount=a.length;this._lkFriends.setDesaturation(3>this._helpCount);2<this._helpCount?(a=new CButton(Resource.POP.bt("green_2"),null,{b:.05},{b:-.15}),a.setText(Lang.getString(Lang.POP_CHAPTER_UNLOCK_BT_UNLOCK_NOW),20,1),a.setPosition(this._lkFriends.getPositionX(),this._lkFriends.getPositionY()-110),
a.setCbUp(this.clickUnlock.bind(this,"friends")),this.addChild(a)):(a=new CButton(Resource.POP.bt("fb_0"),null,{b:.05},{b:-.15}),a.setPosition(this._lkFriends.getPositionX(),this._lkFriends.getPositionY()-110),a.setCbUp(this.clickAskHelp.bind(this)),this.addChild(a),b=new CLabelTTF(Lang.getString(Lang.POP_CHAPTER_UNLOCK_BT_HELP),20,a.getContentSize().width-90,1),b.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER),b.setPosition(143,.5*a.getContentSize().height-1),b.setAnchorPoint(.5,
.5),a.addChild(b));this._lkKeys=this.buildUnlock("keys");this._lkKeys.setPosition(90,-113);this.addChild(this._lkKeys);a=new CButton(Resource.POP.bt("green_0"),null,{b:.05},{b:-.15});a.setPosition(this._lkKeys.getPositionX(),this._lkKeys.getPositionY()-104);a.setCbUp(this.clickUnlock.bind(this,"keys"));this.addChild(a);c=new cc.Sprite(Resource.POP.currency("cash_0"));c.setPosition(130,.5*a.getContentSize().height-2);a.addChild(c);c=Products.getProduct(Products.IDS.PR_UNLOCK).getPrice(Products.CURRENCY.CASH,
1==this._helpCount?"one_friend":2==this._helpCount?"two_friends":null);b=new CLabelTTF(Lang.getString(Lang.POP_CHAPTER_UNLOCK_BT_BUY,c.getAmountInt()),20,a.getContentSize().width-75,1);b.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);b.setPosition(65,.5*a.getContentSize().height-1);b.setAnchorPoint(.5,.5);a.addChild(b);this._lkSphere=this.buildUnlock("sphere");this._lkSphere.setPosition(-90,-113);this.addChild(this._lkSphere);0!=app.config.unlockMode()?(a=new CButton(Resource.POP.bt("green_0"),
null,{b:.05},{b:-.15}),a.setText(Lang.getString(Lang.POP_CHAPTER_UNLOCK_BT_UNLOCK_FREE),20,1),a.setPosition(this._lkSphere.getPositionX(),this._lkSphere.getPositionY()-104),a.setCbUp(this.clickUnlock.bind(this,"free")),this.addChild(a)):this._curKeys>=this._reqKeys?(a=new CButton(Resource.POP.bt("green_0"),null,{b:.05},{b:-.15}),a.setText(Lang.getString(Lang.POP_CHAPTER_UNLOCK_BT_UNLOCK_NOW),20,1),a.setPosition(this._lkSphere.getPositionX(),this._lkSphere.getPositionY()-104),a.setCbUp(this.clickUnlock.bind(this,
"sphere")),this.addChild(a)):(this._lkSphere.setDesaturation(this._curKeys<this._reqKeys),a=new cc.Sprite(Resource.POP.img("051")),a.setPosition(this._lkSphere.getPositionX()-4,this._lkSphere.getPositionY()-104),this.addChild(a),b=new CLabelTTF(this._curKeys+"/"+this._reqKeys,22,a.getContentSize().width-20,4),b.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER),b.setPosition(a.getPositionX(),a.getPositionY()-2),this.addChild(b));0==User.getUnlockTimer()&&User.setUnlockTimer(TimeUtils.getTime());
2==app.config.unlockMode()?this.clickUnlock("free"):0>app.config.unlockTime()-TimeUtils.getTime()+User.getUnlockTimer()?this.clickUnlock("timer"):(c=new CLabelTTF("",16,this._size.width-70,2),c.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER),c.setPosition(0,30-.5*this._size.height),c.runAction(new cc.RepeatForever(new cc.Sequence([new cc.CallFunc(function(){var a=app.config.unlockTime()-TimeUtils.getTime()+User.getUnlockTimer();a=CUtils.getObjectTime(a);0!=a.d?this.setString(Lang.getString(Lang.POP_CHAPTER_UNLOCK_LB_TIMER,
a.d,a.h,a.m,a.s)):this.setString(Lang.getString(Lang.POP_CHAPTER_UNLOCK_LB_TIMER2,a.h,a.m,a.s))},c),new cc.DelayTime(1)]))),this.addChild(c));this._ext.addCustomListener(Backend.EVENT.PURCHASE_COMPLETE,this.eventHandler.bind(this))}},buildUnlock:function(a){var b=new CSprite(Resource.POP.empty),c=new cc.Sprite(Resource.POP.img("046"));c.runAction(new cc.RepeatForever(new cc.Sequence([new cc.RotateTo(10,180),new cc.RotateTo(10,360)])));b.addChild(c,1);"friends"==a?(c=new cc.Sprite(Resource.POP.img("045")),
c.setPosition(-47,-39),c.runAction(new cc.RepeatForever(new cc.Sequence([new cc.RotateTo(10,-180),new cc.RotateTo(10,-360)]))),b.addChild(c,0),c=new cc.Sprite(Resource.POP.img("048")),c.setPosition(0,-9),b.addChild(c,1)):("keys"==a?(c=new cc.Sprite(Resource.POP.img("045")),c.setPosition(42,-33),c.runAction(new cc.RepeatForever(new cc.Sequence([new cc.RotateTo(10,-180),new cc.RotateTo(10,-360)]))),b.addChild(c,0),c=new cc.Sprite(Resource.POP.img("049")),c.setPosition(0,-9)):(c=new cc.Sprite(Resource.POP.img("045")),
c.setPosition(-50,30),c.runAction(new cc.RepeatForever(new cc.Sequence([new cc.RotateTo(10,-180),new cc.RotateTo(10,-360)]))),b.addChild(c,0),c=new cc.Sprite(Resource.POP.img("050")),c.setPosition(0,2)),b.addChild(c,2));b.addChild(new cc.Sprite(Resource.POP.img("047")),1);return b},clickUnlock:function(a){"free"===a?(a={},a.productId=Products.IDS.PR_UNLOCK,a.currency=Products.CURRENCY.CASH,a.discountId="free",Backend.purchase(a,this.getInstanceId(),"pop_chapter_unlock")):"keys"===a?(a={},a.productId=
Products.IDS.PR_UNLOCK,a.currency=Products.CURRENCY.CASH,a.discountId=1==this._helpCount?"one_friend":2==this._helpCount?"two_friends":null,Backend.purchase(a,this.getInstanceId(),"pop_chapter_unlock")):"friends"===a?(cc.eventManager.dispatchCustomEvent(Map.EVENT.UNLOCK_NEXT_CHAPTER,{type:"FRIENDS"}),KApi.event(KApi.EVENT.CHAPTER_UNLOCK,{v:this._helpCount,st2:"help_received"}),this.close()):"sphere"===a?(cc.eventManager.dispatchCustomEvent(Map.EVENT.UNLOCK_NEXT_CHAPTER,{type:"KEYS"}),KApi.event(KApi.EVENT.CHAPTER_UNLOCK,
{v:this._helpCount,st2:"sphere"}),this.close()):"timer"===a&&(cc.eventManager.dispatchCustomEvent(Map.EVENT.UNLOCK_NEXT_CHAPTER,{type:"UNLOCK_TIMER"}),KApi.event(KApi.EVENT.CHAPTER_UNLOCK,{v:this._helpCount,st2:"automatic"}),this.close())},clickAskHelp:function(){(new Popup.PopAskFriends({mode:1})).show()},eventHandler:function(a){a.getEventName()==Backend.EVENT.PURCHASE_COMPLETE&&(a=a.getUserData()||{},a.key==this.getInstanceId()&&a.status&&(a.item&&"free"==a.item.discountId?KApi.event(KApi.EVENT.CHAPTER_UNLOCK,
{v:this._helpCount,st2:"free"}):KApi.event(KApi.EVENT.CHAPTER_UNLOCK,{v:this._helpCount,st2:"bought"}),this.close()))}});Popup.PopChapterUnlock.show=function(a,b,c,d){(new Popup.PopChapterUnlock(a)).show(b,c,d)};
Popup.PopChapterUnlock.Friend=cc.Node.extend({_avatar:null,ctor:function(a){this._super();this._avatar=new cc.Node;this._avatar.addChild(new cc.Sprite(Resource.POP.img("053")));this._avatar.addChild(new cc.Sprite(Resource.POP.img("052")),10);this.addChild(this._avatar);a?(cc.textureCache.addImage(a.getPicture(),function(a){if(a instanceof cc.Texture2D){var b=.5*(a.width-Math.round(1*a.width));b=new cc.rect(b,0,a.width-b,a.height);a=new cc.Sprite(a,b);a.setScale(61/a.getContentSize().width);this._avatar.addChild(a)}},
this),a=new cc.Sprite(Resource.POP.img("054")),a.setPosition(30,-18)):(a=new CButton(Resource.POP.bt("plus_0"),null,{b:.05},{b:-.15}),a.setPosition(28,-26),a.setCbUp(this.clickAskHelp.bind(this)));this.addChild(a)},clickAskHelp:function(){(new Popup.PopAskFriends({mode:1})).show()}});Popup.PopChapterUnlocked=Popup.PopBase.extend({_id:0,_reward:0,ctor:function(a){this._super(a);this._size=new cc.Size(580,470);cc.assert(a&&a.id,"unknown chapter id");this._id=a.id;this._reward=1===this._id?5E3:Math.min(100*this._id,1E4)},build:function(){this._super();var a=this,b=new CLabelTTF(Lang.getString(Lang.POP_CHAPTER_UNLOCKED_TITLE,Lang.getString(Lang.CHAPTER_NAME(this._id))),28,this._size.width-70,2);b.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);b.setPosition(0,
183);this.addChild(b);b=new CLabelTTF(Lang.getString(Lang.POP_CHAPTER_UNLOCKED_MSG0),24,this._size.width-70,2);b.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);b.setPosition(0,-42);this.addChild(b);b=new CButton(Resource.POP.bt("green_0"),null,{b:.05},{b:-.15});b.setText(Lang.getString(Lang.POP_CHAPTER_UNLOCKED_BT_CONTINUE),20,1);b.setPosition(0,-183);b.setCbUp(this.close.bind(this));this.addChild(b);b=new cc.Sprite(Resource.POP.img("044"));b.setScale(.8);b.setPosition(30,
-128);this.addChild(b);b=new CLabelTTF(this._reward,24,0,2);b.setAlignment(cc.TEXT_ALIGNMENT_RIGHT,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);b.setPosition(-26,-130);this.addChild(b);b=new cc.Sprite(Resource.POP.img("057"));b.setPosition(0,70);this.addChild(b);b=new cc.Sprite(Resource.POP.img("056"));b.setPosition(0,70);this.addChild(b,2);cc.textureCache.addImage(Resource.MAP.lk(0,this._id-1),function(a){a instanceof cc.Texture2D&&(a=new cc.Sprite(a),a.setPosition(0,70),this.addChild(a,1))},this);this.setOnClose(function(){Backend.putCoins(a._reward);
Backend.ogUnlockChapter(a._id,500)})}});Popup.PopChristmasOffer=Popup.PopBase.extend({_ext:null,_productId:null,_discountId:null,ctor:function(a){this._super(a);this._size=new cc.Size(450,400);this._moveTo=new cc.Point(.5*this._wSize.width,.5*this._wSize.height-10);this._ext=new CExtNode(this);this._productId=Products.IDS.PK_CASH50COINS50000;this._discountId="christmas_offer"},build:function(){this._super();var a=this,b=Products.getProduct(this._productId);if(b=b?b.getPrice(Products.CURRENCY.USER,this._discountId):null){var c=new cc.Sprite(Resource.POP.img("004"));
c.setPosition(0,.5*this._size.height+3);this.addChild(c,1);c=new CLabelTTF("Easter Offer",26,c.getContentSize().width-70,2);c.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);c.setPosition(0,.5*this._size.height+2);this.addChild(c,1);c=new cc.Sprite("img/chistmasoffer.png");c.setPosition(10,10);this.addChild(c);c=new CLabelTTF("00:00:00",26,150,1);c.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);c.setPosition(125,-99);c.runAction(new cc.RepeatForever(new cc.Sequence([new cc.CallFunc(function(){this.setString(TimeUtils.formatTime(User.getOffers().getExpired("christmas_offer")))},
c),new cc.DelayTime(1)])));this.addChild(c);c=new CButton(Resource.POP.bt("green_2"),null,{b:.05},{b:-.15});c.setText(b.getCurrency()+" "+b.getAmount(),20,1);c.setPosition(0,-145);c.setCbUp(function(){Backend.purchaseFB(a._productId,a._discountId,a.getInstanceId())});this.addChild(c);this._ext.addCustomListener(Backend.EVENT.PURCHASE_COMPLETE,this.eventHandler.bind(this))}else this.close()},eventHandler:function(a){a.getEventName()==Backend.EVENT.PURCHASE_COMPLETE&&(a=a.getUserData()||{},a.key==this.getInstanceId()&&
a.status&&this.close())}});Popup.PopChristmasOffer.show=function(a,b,c,d){(new Popup.PopChristmasOffer(a)).show(b,c,d)};Popup.PopSpecialOffer=Popup.PopBase.extend({_ext:null,_productId:null,_discountId:null,ctor:function(a){this._super(a);this._size=new cc.Size(450,400);this._moveTo=new cc.Point(.5*this._wSize.width,.5*this._wSize.height-10);this._ext=new CExtNode(this);this._productId=Products.IDS.PK_SPECIAL_OFFER;this._discountId=User.isPayer()?"halloween_payer":"halloween_nonpayer"},build:function(){this._super();var a=this,b=Products.getProduct(this._productId);if(b=b?b.getPrice(Products.CURRENCY.USER,this._discountId):
null){var c=new cc.Sprite(Resource.POP.img("004"));c.setPosition(0,.5*this._size.height+3);this.addChild(c,1);c=new CLabelTTF("Special Offer",26,c.getContentSize().width-70,2);c.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);c.setPosition(0,.5*this._size.height+2);this.addChild(c,1);c=new cc.Sprite("img/special_offer_"+(User.isPayer()?1:0)+".png");c.setPosition(10,10);this.addChild(c);c=new CLabelTTF("00:00:00",26,150,1);c.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);
c.setPosition(125,-99);c.runAction(new cc.RepeatForever(new cc.Sequence([new cc.CallFunc(function(){this.setString(TimeUtils.formatTime(User.getOffers().getExpired("special_offer")))},c),new cc.DelayTime(1)])));this.addChild(c);c=new CButton(Resource.POP.bt("green_2"),null,{b:.05},{b:-.15});c.setText(b.getCurrency()+" "+b.getAmount(),20,1);c.setPosition(0,-145);c.setCbUp(function(){Backend.purchaseFB(a._productId,a._discountId,a.getInstanceId())});this.addChild(c);this._ext.addCustomListener(Backend.EVENT.PURCHASE_COMPLETE,
this.eventHandler.bind(this))}else this.close()},eventHandler:function(a){a.getEventName()==Backend.EVENT.PURCHASE_COMPLETE&&(a=a.getUserData()||{},a.key==this.getInstanceId()&&a.status&&this.close())}});Popup.PopSpecialOffer.show=function(a,b,c,d){(new Popup.PopSpecialOffer(a)).show(b,c,d)};Popup.PopShop=Popup.PopBase.extend({_select:null,_scIco:null,_scMsg0:null,_scMsg1:null,_btBuy:null,_btPlay:null,ctor:function(a){this._super(a);this._size=new cc.Size(612,550);this._select=null},build:function(){this._super();for(var a=(this._size.width-120)/6,b=.5*-(this._size.width-120),c=0;7>c;c++){var d=new Popup.OrbSmall;d.setPosition(b+c*a,206);d.setName("orb_"+c);this.addChild(d);d=new Popup.OrbSmall;d.setPosition(b+c*a,88);d.setName("orb_"+(7+c));this.addChild(d)}a=User.getOrbs().filter(function(a){return a.hasId(Products.IDS.OR_HAMMER)||
a.hasId(Products.IDS.OR_LIGHTNING)||a.hasId(Products.IDS.OR_CROSS_BLAST)||a.hasId(Products.IDS.OR_BOMB)||a.hasId(Products.IDS.OR_FIRE_BLAST)||a.hasId(Products.IDS.OR_HAND)||a.hasId(Products.IDS.OR_UNLOCK)||a.hasId(Products.IDS.OR_SUPER_BOMB)||a.hasId(Products.IDS.OR_COLOR_BLASTER)}).sort(function(a,b){return a.getShopId()-b.getShopId()});for(c=0;c<Math.min(a.length,14);c++)d=this.getChildByName("orb_"+c),d.setItem(a[c]),d.setClick(this.onClickOrb.bind(this,a[c]));d=new cc.Sprite(Resource.POP.img("002"));
d.setScaleX(this._size.width/d.getContentSize().width);d.setPosition(-1,10);this.addChild(d);this._scIco=new Popup.OrbBig;this._scIco.setPosition(-170,-130);this._scIco.setVisible(!1);this._scMsg0=new CLabelTTF("",20,300,2);this._scMsg0.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);this._scMsg0.setAnchorPoint(.5,1);this._scMsg0.setPosition(125,-5);this._scMsg0.setVisible(!1);this._scMsg1=new CLabelTTF("",22,300,1);this._scMsg1.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);
this._scMsg1.setAnchorPoint(.5,1);this._scMsg1.setPosition(125,-5);this._scMsg1.setVisible(!1);this._btBuy=new CButton(Resource.POP.bt("green_0"),null,{b:.05},{b:-.15});this._btBuy.setText(Lang.getString(Lang.POP_SHOP_BT_BUY),20,1);this._btBuy.setSound(Resource.SND.PURCHASE);this._btBuy.setPosition(125,-210);this._btBuy.setCbUp(this.onClickBuy.bind(this));this._btBuy.setVisible(!1);this._btPlay=new CButton(Resource.POP.bt("green_0"),null,{b:.05},{b:-.15});this._btPlay.setText(Lang.getString(Lang.POP_SHOP_BT_PLAY),
20,1);this._btPlay.setPosition(125,-220);this._btPlay.setCbUp(this.close.bind(this));this._btPlay.setVisible(!1);this.addChild(this._btPlay);app.Scene.isRunning(app.Scene.TAG.CLIENT)&&(this._btBuy.setPosition(125,-160),this._btPlay.setVisible(!0));this.addChild(this._scIco);this.addChild(this._scMsg0);this.addChild(this._scMsg1);this.addChild(this._btBuy);0<a.length?this.chooseOrb(a[0]):(d=new CLabelTTF(Lang.getString(Lang.POP_SHOP_EMPTY),28,this._size.width-70,2),d.setAlignment(cc.TEXT_ALIGNMENT_CENTER,
cc.VERTICAL_TEXT_ALIGNMENT_CENTER),d.setPosition(-1,-95),this.addChild(d));this._ext.addCustomListener(User.EVENT.UPDATE_ORB,this.eventHandler.bind(this))},onClickOrb:function(a){a&&(this.chooseOrb(a),cc.log(a.getId()))},onClickBuy:function(){this._select&&Backend.purchase(this._select.getPurchaseData(),"pop_shop")},chooseOrb:function(a){this._select=a;this._scIco.setItem(a);this._scIco.setVisible(!0);this._scMsg0.setString(Lang.getString(Lang.ORB_DESCRIPTION(a.getId())));this._scMsg0.setVisible(!0);
this._scMsg1.setString(Lang.getString(a.isPermanent()?Lang.POP_SHOP_ACTIVE_FOREVER:Lang.POP_SHOP_ACTIVE_ONE_TIME));this._scMsg1.setColor(a.isPermanent()?new cc.Color(60,183,66):new cc.Color(10,244,114));this._scMsg1.setVisible(!0);var b=new cc.Color(0,0,0,255);this._scMsg1.enableStroke(b,1);this._scMsg1.enableShadow(b,cc.size(0,0),2);this._scMsg1.setPositionY(this._scMsg0.getPositionY()-this._scMsg0.getContentSize().height-25);this._btPlay.isVisible()||this._btBuy.setPositionY(Math.min(this._scMsg1.getPositionY()-
this._scMsg1.getContentSize().height-35,-185));this._btBuy.setVisible(!a.isBought())},eventHandler:function(a){var b=a.getEventName();a=a.getUserData()||{};b==User.EVENT.UPDATE_ORB&&a.orb==this._select&&this.chooseOrb(this._select)}});Popup.PopShop.show=function(a,b,c,d){(new Popup.PopShop(a)).show(b,c,d)};Popup.PopBuyCash=Popup.PopBase.extend({_btCredit:null,_btPackage:null,_btMobile:null,ctor:function(a){this._super(a);this._size=new cc.Size(620,580)},build:function(){this._super();var a=new cc.Sprite(Resource.POP.img("004"));a.setPosition(0,.5*this._size.height+3);this.addChild(a,1);a=new CLabelTTF(Lang.getString(Lang.POP_BUY_CASH_TITLE),26,a.getContentSize().width-70,2);a.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);a.setPosition(0,.5*this._size.height+2);this.addChild(a,
1);a=new cc.Sprite(Resource.POP.img("032"));a.setPosition(0,-303);this.addChild(a);this._btCredit=new CButton(Resource.POP.bt("tab0"));this._btCredit.setText(Lang.getString(Lang.POP_BUY_CASH_BT_CREDIT),20,1);this._btCredit.setPosition(-191,234);this._btCredit.setCbUp(this.clickCredit.bind(this));this._btPackage=new CButton(Resource.POP.bt("tab1"));this._btPackage.setText(Lang.getString(Lang.POP_BUY_CASH_BT_PACKAGE),20,1);this._btPackage.setPosition(-34,234);this._btPackage.setCbUp(this.clickPackage.bind(this));
this._btMobile=new CButton(Resource.POP.bt("buy_mob"));this._btMobile.setPosition(200,240);this._btMobile.setCbUp(this.clickMobile.bind(this));this._btMobile.setVisible(Products.getMobile().isAvailable()&&"en"==User.getLocale());a=new cc.Sprite(Resource.POP.img("014"));a.setScaleX((this._size.width-6)/a.getContentSize().width);a.setScaleY(1.5);a.setPosition(0,213);this.addChild(this._btCredit);this.addChild(this._btPackage);this.addChild(this._btMobile);this.addChild(a);"cash"==this._args.active?
this.clickCredit():this.clickPackage()},buildCredits:function(){var a=new cc.Node,b=app.config.bestPackages(0),c=[Products.getProduct(Products.IDS.PK_CASH5),Products.getProduct(Products.IDS.PK_CASH27),Products.getProduct(Products.IDS.PK_CASH57),Products.getProduct(Products.IDS.PK_CASH120),Products.getProduct(Products.IDS.PK_CASH320),Products.getProduct(Products.IDS.PK_CASH600)].filter(function(a,b,c){return a?!0:!1});User.isPayer()&&(c=c.reverse());for(var d=0;d<c.length;d++){var e=new Popup.PopBuyCash.Credit(User.isPayer()?
c.length-1-d:d,c[d],b);e.setPosition(-3,160-77*d);a.addChild(e)}return a},buildPackages:function(){var a=new Popup.PopBuyCash.Package(Products.getProduct(Products.IDS.PK_COINS11500)),b=new Popup.PopBuyCash.Package(Products.getProduct(Products.IDS.PK_CASH25COINS12500AB)),c=new Popup.PopBuyCash.Package(Products.getProduct(Products.IDS.PK_COINS27000)),d=new Popup.PopBuyCash.Package(Products.getProduct(Products.IDS.PK_CASH50COINS50000));a.setPosition(-145,99);b.setPosition(145,99);c.setPosition(-145,
-138);d.setPosition(145,-138);var e=new cc.Node;e.addChild(a);e.addChild(b);e.addChild(c);e.addChild(d);return e},clickCredit:function(){this._btCredit.setSpriteFrame(Resource.POP.bt("tab1"));this._btPackage.setSpriteFrame(Resource.POP.bt("tab0"));this.removeChildByTag(10);this.addChild(this.buildCredits(),0,10)},clickPackage:function(){this._btCredit.setSpriteFrame(Resource.POP.bt("tab0"));this._btPackage.setSpriteFrame(Resource.POP.bt("tab1"));this.removeChildByTag(10);this.addChild(this.buildPackages(),
0,10)},clickMobile:function(){Popup.PopBuyMobile.show();this.close()}});Popup.PopBuyCash.show=function(a,b,c,d){(new Popup.PopBuyCash(a)).show(b,c,d)};
Popup.PopBuyCash.Credit=cc.Sprite.extend({ctor:function(a,b,c){this._super(Resource.POP.img("021"));var d=b.getPrice(Products.CURRENCY.USER);var e=0;var f=Products.getProperty("immortality",b,null,Number,0);if(b.hasId(Products.IDS.PK_CASH5)){e=0;var g=new cc.Sprite(Resource.POP.currency("cash_1"));g.setPosition(58,37);this.addChild(g);g=new cc.Sprite(Resource.POP.img("024"));g.setAnchorPoint(0,.5);g.setPosition(111,36);this.addChild(g)}else b.hasId(Products.IDS.PK_CASH27)?(e=7.4,g=new cc.Sprite(Resource.POP.currency("cash_2")),
g.setPosition(58,36),this.addChild(g),g=new cc.Sprite(Resource.POP.img("025")),g.setAnchorPoint(0,.5),g.setPosition(111,36),this.addChild(g)):b.hasId(Products.IDS.PK_CASH57)?(e=12.3,g=new cc.Sprite(Resource.POP.currency("cash_3")),g.setPosition(58,36),this.addChild(g),g=new cc.Sprite(Resource.POP.img("026")),g.setAnchorPoint(0,.5),g.setPosition(111,36),this.addChild(g)):b.hasId(Products.IDS.PK_CASH120)?(e=16.7,g=new cc.Sprite(Resource.POP.currency("cash_4")),g.setPosition(58,36),this.addChild(g),
g=new cc.Sprite(Resource.POP.img("027")),g.setAnchorPoint(0,.5),g.setPosition(111,36),this.addChild(g)):b.hasId(Products.IDS.PK_CASH320)?(e=22,g=new cc.Sprite(Resource.POP.currency("cash_5")),g.setPosition(58,36),this.addChild(g),g=new cc.Sprite(Resource.POP.img("028")),g.setAnchorPoint(0,.5),g.setPosition(111,36),this.addChild(g)):b.hasId(Products.IDS.PK_CASH600)&&(e=25,g=new cc.Sprite(Resource.POP.currency("cash_6")),g.setPosition(58,35),this.addChild(g),g=new cc.Sprite(Resource.POP.img("029")),
g.setAnchorPoint(0,.5),g.setPosition(111,36),this.addChild(g));c[0]==a+1?(g=new cc.Sprite(Resource.POP.img("031")),g.setPosition(-5,45),this.addChild(g)):c[1]==a+1&&(g=new cc.Sprite(Resource.POP.img("030")),g.setPosition(-5,45),this.addChild(g));0<e&&(a=new cc.Sprite(Resource.POP.img("023")),e=new CLabelTTF(e+"% off",22,80,2),e.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER),e.setPosition(80,25),a.addChild(e),a.setPosition(279,65),this.addChild(a));0<f&&(a=new cc.Sprite(Resource.POP.img("022")),
e=new CLabelTTF(Math.ceil(f/3600)+" hr",24,40,4),e.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER),e.setPosition(35,37),a.setPosition(267,29),a.addChild(e),this.addChild(a));d=new CLabelTTF(d.getCurrency()+" "+d.getAmount(),24,110,1);d.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);d.setPosition(425,37);this.addChild(d);d=new CButton(Resource.POP.bt("buy"),null,{b:.05},{b:-.15});d.setPosition(526,39);d.setCbUp(this.onClickBuy.bind(this,b.getId(),
void 0));this.addChild(d)},onClickBuy:function(a,b){Backend.purchaseFB(a,b)}});
Popup.PopBuyCash.Package=cc.Sprite.extend({ctor:function(a){this._super(Resource.POP.img("015"));var b=this.getContentSize(),c=a.getPrice(Products.CURRENCY.USER),d=new cc.Sprite(function(){if(a.hasId(Products.IDS.PK_COINS11500))return Resource.POP.img("016");if(a.hasId(Products.IDS.PK_CASH25COINS12500AB))return Resource.POP.img("017");if(a.hasId(Products.IDS.PK_COINS27000))return Resource.POP.img("018");if(a.hasId(Products.IDS.PK_CASH50COINS50000))return Resource.POP.img("019");cc.assert(!1,"Product id not found ["+
a.getId()+"]")}());d.setPosition(.5*b.width,.5*b.height);this.addChild(d);d=new cc.Sprite(Resource.POP.img("020"));d.setPosition(185,14);b=new CLabelTTF(c.getCurrency()+" "+c.getAmount(),24,90,1);b.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);b.setPosition(152,14);c=new CButton(Resource.POP.bt("buy"),null,{b:.05},{b:-.15});c.setPosition(235,14);c.setCbUp(this.onClickBuy.bind(this,a.getId(),void 0));this.addChild(d);this.addChild(b);this.addChild(c)},onClickBuy:function(a,
b){Backend.purchaseFB(a,b)}});Popup.PopBuyMobile=Popup.PopBase.extend({ctor:function(a){this._super(a);this._size=new cc.Size(615,480)},build:function(){this._super();var a=new cc.Sprite(Resource.POP.img("004"));a.setPosition(0,.5*this._size.height+3);this.addChild(a,1);a=new CLabelTTF(Lang.getString(Lang.POP_BUY_MOB_TITLE),26,a.getContentSize().width-70,2);a.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);a.setPosition(0,.5*this._size.height+2);this.addChild(a,1);a=[Products.getProduct(Products.IDS.PK_MOB_CASH7),
Products.getProduct(Products.IDS.PK_MOB_CASH30),Products.getProduct(Products.IDS.PK_MOB_CASH60),Products.getProduct(Products.IDS.PK_MOB_CASH120),Products.getProduct(Products.IDS.PK_MOB_CASH150)].filter(function(a){return a?!0:!1});for(var b=app.config.bestPackages(2),c=0;c<a.length;c++){var d=new Popup.PopBuyMobile.Credit(c,a[c],b);d.setPosition(-3,150-80*c);this.addChild(d)}}});Popup.PopBuyMobile.show=function(a,b,c,d){(new Popup.PopBuyMobile(a)).show(b,c,d)};
Popup.PopBuyMobile.Credit=cc.Sprite.extend({ctor:function(a,b,c){this._super(Resource.POP.img("021"));var d=b.getPrice(Products.CURRENCY.USER);if(b.hasId(Products.IDS.PK_MOB_CASH7)){var e=new cc.Sprite(Resource.POP.currency("cash_1"));e.setPosition(58,37);this.addChild(e);e=new cc.Sprite(Resource.POP.img("109"));e.setAnchorPoint(0,.5);e.setPosition(111,36);this.addChild(e)}else b.hasId(Products.IDS.PK_MOB_CASH30)?(e=new cc.Sprite(Resource.POP.currency("cash_2")),e.setPosition(58,36),this.addChild(e),
e=new cc.Sprite(Resource.POP.img("110")),e.setAnchorPoint(0,.5),e.setPosition(111,36),this.addChild(e)):b.hasId(Products.IDS.PK_MOB_CASH60)?(e=new cc.Sprite(Resource.POP.currency("cash_3")),e.setPosition(58,36),this.addChild(e),e=new cc.Sprite(Resource.POP.img("111")),e.setAnchorPoint(0,.5),e.setPosition(111,36),this.addChild(e)):b.hasId(Products.IDS.PK_MOB_CASH120)?(e=new cc.Sprite(Resource.POP.currency("cash_4")),e.setPosition(58,36),this.addChild(e),e=new cc.Sprite(Resource.POP.img("027")),e.setAnchorPoint(0,
.5),e.setPosition(111,36),this.addChild(e)):b.hasId(Products.IDS.PK_MOB_CASH150)&&(e=new cc.Sprite(Resource.POP.currency("cash_5")),e.setPosition(58,36),this.addChild(e),e=new cc.Sprite(Resource.POP.img("112")),e.setAnchorPoint(0,.5),e.setPosition(111,36),this.addChild(e));c[0]==a+1?(e=new cc.Sprite(Resource.POP.img("031")),e.setPosition(-5,45),this.addChild(e)):c[1]==a+1&&(e=new cc.Sprite(Resource.POP.img("030")),e.setPosition(-5,45),this.addChild(e));a=new CLabelTTF(d.getCurrency()+" "+d.getAmount(),
24,110,1);a.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);a.setPosition(400,37);this.addChild(a);a=new CButton(Resource.POP.bt("buy"),null,{b:.05},{b:-.15});a.setPosition(526,39);a.setCbUp(this.onClickBuy.bind(this,b.getId(),void 0));this.addChild(a)},onClickBuy:function(a,b){Backend.purchaseFB(a,b,this.getInstanceId(),!0)}});Popup.PopInviteFriends=Popup.PopBase.extend({_checkOn:!1,_checkAll:null,_scrollBar:null,_listView:null,ctor:function(a){this._super(a);this._size=new cc.Size(635,555);this._checkOn=!0},build:function(){this._super();var a=this,b=new cc.Sprite(Resource.POP.img("005"));b.setPosition(0,.5*this._size.height+3);this.addChild(b,1);b=new CLabelTTF(Lang.getString(Lang.POP_INVITE_FRIENDS_TITLE),26,b.getContentSize().width-70,2);b.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);b.setPosition(0,
.5*this._size.height+2);this.addChild(b,1);b=new cc.Sprite(Resource.POP.img("002"));b.setScaleX(this._size.width/b.getContentSize().width);b.setPosition(-1,226);this.addChild(b);b=new cc.Sprite(Resource.POP.img("002"));b.setScaleX(this._size.width/b.getContentSize().width);b.setPosition(-1,-190);this.addChild(b);b=new CButton(Resource.POP.bt("green_2"),null,{b:.05},{b:-.15});b.setText(Lang.getString(Lang.POP_INVITE_FRIENDS_BT_INVITE),20,1);b.setPosition(150,-227);b.setCbUp(this.onClickInvite.bind(this));
this.addChild(b,1);this._checkAll=new Popup.PopInviteFriends.CheckAll;this._checkAll.setPosition(-270,-243);this._checkAll.setCbClick(this.onClickCheckAll.bind(this));this.addChild(this._checkAll,1);this._scrollBar=new Popup.ScrollBar(388);this._scrollBar.setPosition(270,-175);this._scrollBar.setCbValueChanged(function(){var b=a._scrollBar.getValue();a._listView.jumpToPercentVertical(100*b)});this.addChild(this._scrollBar,1);this._listView=new ccui.ListView;this._listView.setDirection(ccui.ScrollView.DIR_VERTICAL);
this._listView.setContentSize(new cc.Size(550,410));this._listView.setBounceEnabled(!0);this._listView.setMagneticType(ccui.ListView.MAGNETIC_TOP);this._listView.setMagneticAllowedOutOfBoundary(!1);this._listView.setPosition(-290,-186);this._listView.addCCSEventListener(function(b,c){if(c==ccui.ScrollView.EVENT_CONTAINER_MOVED){var d=a._listView,e=d.getContentSize().height-d.getInnerContainer().getContentSize().height;0==e?a._scrollBar.setVisible(!1):(d=d.getInnerContainer().getPositionY(),a._scrollBar.setVisible(!0),
a._scrollBar.setValue((e-d)/e))}},this);this._listView.getInnerContainer().setPositionY(6);this._listView.jumpToPercentVertical(0);this.addChild(this._listView);b=User.getFriends(2);for(var c=this.onClickCheckItem.bind(this),d=0;d<b.length;d+=3){var e=new Popup.PopInviteFriends.FriendsRow(this._listView.getContentSize().width,b.slice(d,d+3),c);this._listView.pushBackCustomItem(e)}0==b.length&&(b=new CLabelTTF(Lang.getString(Lang.POP_INVITE_FRIENDS_EMPTY),22,this._size.width-70,2),b.setAlignment(cc.TEXT_ALIGNMENT_CENTER,
cc.VERTICAL_TEXT_ALIGNMENT_CENTER),b.setPosition(0,150),this.addChild(b));this.onClickCheckAll()},onClickInvite:function(){var a=this._listView.getItems(),b=[],c=[],d;for(d in a)b=b.concat(a[d].getChildren());for(d in b)a=b[d],a.isCheck()&&c.push(a.getUser());KApi.event(KApi.EVENT.INVITE,{st1:c.length,st3:this._args.showFrom});Backend.rqInvite(c);this.close()},onClickCheckAll:function(){this._checkAll.setCheck(this._checkOn);var a=this._listView.getItems(),b=[],c;for(c in a)b=b.concat(a[c].getChildren());
for(c in b)b[c].setCheck(this._checkOn);this._checkOn=!this._checkOn},onClickCheckItem:function(){var a=!0,b=this._listView.getItems(),c=[],d;for(d in b)c=c.concat(b[d].getChildren());for(d in c)a=a&&c[d].isCheck();this._checkAll.setCheck(a);this._checkOn=!a}});Popup.PopInviteFriends.show=function(a,b,c,d){(new Popup.PopInviteFriends(a)).show(b,c,d)};
Popup.PopInviteFriends.CheckAll=cc.Node.extend({_checkbox:null,_label:null,_onTouch:null,_cbClick:null,ctor:function(){this._super();this._onTouch=!1;this._cbClick=null;this._checkbox=new Popup.CheckBox;this._checkbox.setPosition(15,15);this.addChild(this._checkbox);this._label=new CLabelTTF(Lang.getString(Lang.POP_INVITE_FRIENDS_SELECT_ALL),22,250,4);this._label.setAlignment(cc.TEXT_ALIGNMENT_LEFT,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);this._label.setAnchorPoint(0,.5);this._label.setPosition(35,15);
this.addChild(this._label);cc.eventManager.addListener({event:cc.EventListener.MOUSE,onMouseDown:this.mouseDown.bind(this),onMouseUp:this.mouseUp.bind(this)},this)},setCbClick:function(a){this._cbClick=a},setCheck:function(a){this._checkbox.setValue(a)},isCheck:function(){return this._checkbox.getValue()},mouseDown:function(a){CUtils.onTouch(a,this,!0)&&(AudioEngine.playEffect(Resource.SND.CLICK),this._onTouch=!0)},mouseUp:function(a){CUtils.onTouch(a,this,!0)&&this._onTouch&&this._cbClick&&this._cbClick();
this._onTouch=!1}});
Popup.PopInviteFriends.FriendItem=cc.Node.extend({_avatar:null,_user:null,_checkbox:null,_lbFirstName:null,_lbLastName:null,_touchOn:!1,_touchPos:null,_cbClick:null,ctor:function(a,b,c){cc.assert(b,"null user");this._super();this._cbClick=c;this._touchOn=!1;this._user=b;this._checkbox=new Popup.CheckBox(!0);this._checkbox.setPosition(15,28);this.addChild(this._checkbox);this._avatar=new cc.Node;this._avatar.addChild(new cc.Sprite(Resource.POP.img("039")));this._avatar.addChild(new cc.Sprite(Resource.POP.img("038")),10);
this._avatar.setPosition(60,28);this.addChild(this._avatar);cc.textureCache.addImage(b.getPicture(),function(a){if(a instanceof cc.Texture2D){var b=.5*(a.width-Math.round(45/47*a.width));b=new cc.rect(b,0,a.width-b,a.height);a=new cc.Sprite(a,b);a.setScale(45/a.getContentSize().width);this._avatar.addChild(a)}},this);this._lbFirstName=new CLabelTTF(b.getFirstName(),18,a-90,4);this._lbFirstName.setAlignment(cc.TEXT_ALIGNMENT_LEFT,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);this._lbFirstName.setAnchorPoint(0,
.5);this._lbFirstName.setPosition(90,38);this.addChild(this._lbFirstName);this._lbLastName=new CLabelTTF(b.getLastName(),18,a-90,4);this._lbLastName.setAlignment(cc.TEXT_ALIGNMENT_LEFT,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);this._lbLastName.setAnchorPoint(0,.5);this._lbLastName.setPosition(90,15);this.addChild(this._lbLastName);this.setContentSize(cc.size(a,56));cc.eventManager.addListener({event:cc.EventListener.MOUSE,onMouseDown:this.mouseDown.bind(this),onMouseUp:this.mouseUp.bind(this)},this)},getUser:function(){return this._user},
setCheck:function(a){this._checkbox.setValue(a)},isCheck:function(){return this._checkbox.getValue()},mouseDown:function(a){CUtils.onTouch(a,this,!0)&&(AudioEngine.playEffect(Resource.SND.CLICK),this._touchOn=!0,this._touchPos=a.getLocation())},mouseUp:function(a){CUtils.onTouch(a,this,!0)&&this._touchOn&&3>CUtils.distance(this._touchPos,a.getLocation())&&(this._checkbox.setValue(!this._checkbox.getValue()),this._cbClick());this._touchOn=!1}});
Popup.PopInviteFriends.FriendsRow=ccui.Widget.extend({ctor:function(a,b,c){this._super();for(var d=0;d<b.length;d++){var e=new Popup.PopInviteFriends.FriendItem(a/3-5,b[d],c);e.setPosition(d*a/3,0);this.addChild(e);0===d&&this.setContentSize(a,e.getContentSize().height+4)}}});Popup.PopAskAge=Popup.PopBase.extend({_ext:null,_btContinue:null,_lbMessage:null,_items:null,ctor:function(a){this._super(a);this._size=new cc.Size(470,320);this._hasClose=!1;this._ext=new CExtNode(this)},build:function(){this._super();var a=new cc.Sprite(Resource.POP.img("005"));a.setPosition(0,.5*this._size.height+3);this.addChild(a,1);a=new CLabelTTF(Lang.getString(Lang.POP_ASK_AGE_TITLE),22,a.getContentSize().width-70,1);a.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);
a.setPosition(0,.5*this._size.height+2);this.addChild(a,1);this._lbMessage=new CLabelTTF(Lang.getString(Lang.POP_ASK_AGE_MSG0),22,this._size.width-70,11);this._lbMessage.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);this._lbMessage.setPosition(0,-40);this.addChild(this._lbMessage);this._btContinue=new CButton(Resource.POP.bt("green_2"),null,{b:.05},{b:-.15});this._btContinue.setText(Lang.getString(Lang.POP_ASK_AGE_BT_CONTINUE),20,1);this._btContinue.setPosition(0,.5*-this._size.height+
55);this._btContinue.setCbUp(this.onContinue.bind(this));this._btContinue.setEnabled(!1);this.addChild(this._btContinue);this._items=[];this._items.push(new Popup.PopAskAge.AgeRange(0,"13 - 17",this.onCheckItem.bind(this)));this._items.push(new Popup.PopAskAge.AgeRange(1,"18 - 34",this.onCheckItem.bind(this)));this._items.push(new Popup.PopAskAge.AgeRange(2,"35 - 49",this.onCheckItem.bind(this)));this._items.push(new Popup.PopAskAge.AgeRange(3,"50 +",this.onCheckItem.bind(this)));for(a=0;a<this._items.length;a++){var b=
this._items[a];b.setPositionX(0===a||2===a?-90:90);b.setPositionY(0===a||1===a?90:30);this.addChild(b)}},onCheckItem:function(a){for(var b in this._items){var c=this._items[b];c!==a&&c.setCheck(!1)}a.isCheck()&&0<a.getId()?this._btContinue.setEnabled(!0):this._btContinue.setEnabled(!1);a.isCheck()&&0===a.getId()?(this._lbMessage.setStringStyle(12),this._lbMessage.setString(Lang.getString(Lang.POP_ASK_AGE_MSG1))):(this._lbMessage.setStringStyle(11),this._lbMessage.setString(Lang.getString(Lang.POP_ASK_AGE_MSG0)))},
onContinue:function(){for(var a=0;a<this._items.length;a++)if(this._items[a].isCheck()){Backend.putAgeRange("1-5",this.close.bind(this));break}}});Popup.PopAskAge.show=function(a,b,c,d){(new Popup.PopAskAge(a)).show(b,c,d)};
Popup.PopAskAge.AgeRange=cc.Node.extend({_id:0,_checkbox:null,_touchOn:!1,_touchPos:null,_cbClick:null,ctor:function(a,b,c){this._super();this._id=a;this._cbClick=c;this._touchOn=!1;this._size=cc.size(155,40);this.setContentSize(this._size);this.setAnchorPoint(.5,.5);a=new cc.Sprite(Resource.POP.img("125"));a.setAnchorPoint(0,.5);a.setPosition(0,.5*this._size.height);this.addChild(a);b=new CLabelTTF(b,24,a.getContentSize().width-50,11);b.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);
b.setAnchorPoint(.5,.5);b.setPosition(.5*a.getContentSize().width,.5*a.getContentSize().height-3);a.addChild(b);this._checkbox=new Popup.CheckBox(!1);this._checkbox.setPosition(135,.5*this._size.height);this.addChild(this._checkbox);cc.eventManager.addListener({event:cc.EventListener.MOUSE,onMouseDown:this.mouseDown.bind(this),onMouseUp:this.mouseUp.bind(this)},this)},getId:function(){return this._id},setCheck:function(a){this._checkbox.setValue(a)},isCheck:function(){return this._checkbox.getValue()},
mouseDown:function(a){CUtils.onTouch(a,this,!0)&&(AudioEngine.playEffect(Resource.SND.CLICK),this._touchOn=!0,this._touchPos=a.getLocation())},mouseUp:function(a){CUtils.onTouch(a,this,!0)&&this._touchOn&&3>CUtils.distance(this._touchPos,a.getLocation())&&(this._checkbox.setValue(!this._checkbox.getValue()),this._cbClick(this));this._touchOn=!1}});Popup.PopAskFriends=Popup.PopBase.extend({_mode:0,_checkOn:!1,_checkAll:null,_scrollBar:null,_listView:null,_btAllFriends:null,_btGameFriends:null,_empty:null,ctor:function(a){this._super(a);this._size=new cc.Size(598,555);this._checkOn=!0;this._mode=this._args.mode?this._args.mode:0},build:function(){this._super();var a=this,b=new CLabelTTF(Lang.getString(Lang.POP_ASK_FRIENDS_TITLE(this._mode)),28,this._size.width-70,2);b.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);b.setPosition(0,
230);this.addChild(b);b=new Popup.PopAskFriends.Tabs;b.setPosition(0,180);b.setClick(this.onClickTab.bind(this));this.addChild(b,1);b=new cc.Sprite(Resource.POP.img("002"));b.setScaleX(this._size.width/b.getContentSize().width);b.setPosition(-1,-190);this.addChild(b);this._empty=new CLabelTTF(Lang.getString(Lang.POP_ASK_FRIENDS_EMPTY),22,this._size.width-70,2);this._empty.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);this._empty.setPosition(0,20);this.addChild(this._empty);
b=new CButton(Resource.POP.bt("green_2"),null,{b:.05},{b:-.15});b.setText(Lang.getString(Lang.POP_ASK_FRIENDS_ASK(this._mode)),20,1);b.setPosition(150,-227);b.setCbUp(this.onClickSend.bind(this));this.addChild(b,1);this._checkAll=new Popup.PopAskFriends.CheckAll;this._checkAll.setPosition(-270,-243);this._checkAll.setCbClick(this.onClickCheckAll.bind(this));this.addChild(this._checkAll,1);this._scrollBar=new Popup.ScrollBar(326);this._scrollBar.setPosition(254,-175);this._scrollBar.setCbValueChanged(function(){var b=
a._scrollBar.getValue();a._listView.jumpToPercentVertical(100*b)});this.addChild(this._scrollBar,1);this._listView=new ccui.ListView;this._listView.setDirection(ccui.ScrollView.DIR_VERTICAL);this._listView.setContentSize(new cc.Size(520,348));this._listView.setBounceEnabled(!0);this._listView.setMagneticType(ccui.ListView.MAGNETIC_TOP);this._listView.setMagneticAllowedOutOfBoundary(!1);this._listView.setPosition(-271,-186);this._listView.addCCSEventListener(function(b,d){if(d==ccui.ScrollView.EVENT_CONTAINER_MOVED){var c=
a._listView,f=c.getContentSize().height-c.getInnerContainer().getContentSize().height;0==f?a._scrollBar.setVisible(!1):(c=c.getInnerContainer().getPositionY(),a._scrollBar.setVisible(!0),a._scrollBar.setValue((f-c)/f))}},this);this.addChild(this._listView);this.onClickTab(0)},onClickSend:function(){var a=this._listView.getItems(),b=[],c=[],d;for(d in a)b=b.concat(a[d].getChildren());for(d in b)b[d].isCheck()&&c.push(b[d].getUser());0==this._mode?Backend.rqAskLife(c):1==this._mode?Backend.rqAskUnlock(c):
cc.assert(!1,"unknown mode value");this.close()},onClickTab:function(a){a=User.getFriends(0===a?0:1);this._empty.setVisible(0===a.length);var b=this.onClickCheckItem.bind(this);this._listView.removeAllItems();for(var c=0;c<a.length;c+=3){var d=new Popup.PopAskFriends.FriendsRow(this._listView.getContentSize().width,a.slice(c,c+3),b);this._listView.pushBackCustomItem(d)}this._listView.getInnerContainer().setPositionY(5);this._listView.jumpToPercentVertical(0);this._checkOn=!0;this.onClickCheckAll()},
onClickCheckAll:function(){this._checkAll.setCheck(this._checkOn);var a=this._listView.getItems(),b=[],c;for(c in a)b=b.concat(a[c].getChildren());for(c in b)b[c].setCheck(this._checkOn);this._checkOn=!this._checkOn},onClickCheckItem:function(){var a=!0,b=this._listView.getItems(),c=[],d;for(d in b)c=c.concat(b[d].getChildren());for(d in c)a=a&&c[d].isCheck();this._checkAll.setCheck(a);this._checkOn=!a}});Popup.PopAskFriends.show=function(a,b,c,d){(new Popup.PopAskFriends(a)).show(b,c,d)};
Popup.PopAskFriends.Tabs=cc.Sprite.extend({_bt0:null,_bt1:null,_line:null,_cbClick:null,_touchOn:null,ctor:function(){this._super(Resource.POP.img("040"));this._line=new cc.Sprite(Resource.POP.img("041"));this._line.setPosition(379,8);this._line.setFlippedX(!0);this._bt0=new cc.Node;this._bt0.setContentSize(cc.size(155,35));this._bt0.setPosition(133,5);this._bt1=new cc.Node;this._bt1.setContentSize(cc.size(155,35));this._bt1.setPosition(305,5);var a=new CLabelTTF(Lang.getString(Lang.POP_ASK_FRIENDS_TAB_ALL),
18,140,2);a.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);a.setPosition(.5*this._bt0.getContentSize().width,.5*this._bt0.getContentSize().height);this._bt0.addChild(a);a=new CLabelTTF(Lang.getString(Lang.POP_ASK_FRIENDS_TAB_GAME),18,140,2);a.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);a.setPosition(.5*this._bt1.getContentSize().width,.5*this._bt1.getContentSize().height);this._bt1.addChild(a);this.addChild(this._line);this.addChild(this._bt0);
this.addChild(this._bt1);cc.eventManager.addListener({event:cc.EventListener.MOUSE,onMouseDown:this.mouseDown.bind(this),onMouseUp:this.mouseUp.bind(this)},this)},setClick:function(a){this._cbClick=a},mouseDown:function(a){CUtils.onTouch(a,this._bt0,!0)?(AudioEngine.playEffect(Resource.SND.CLICK),this._touchOn=this._bt0):CUtils.onTouch(a,this._bt1,!0)&&(AudioEngine.playEffect(Resource.SND.CLICK),this._touchOn=this._bt1)},mouseUp:function(a){CUtils.onTouch(a,this._bt0,!0)&&this._touchOn==this._bt0&&
this._cbClick?(this._cbClick(0),this._line.setPosition(379,8),this._line.setFlippedX(!0)):CUtils.onTouch(a,this._bt1,!0)&&this._touchOn==this._bt1&&this._cbClick&&(this._cbClick(1),this._line.setPosition(213,7),this._line.setFlippedX(!1));this._touchOn=null}});
Popup.PopAskFriends.CheckAll=cc.Node.extend({_checkbox:null,_label:null,_onTouch:null,_cbClick:null,ctor:function(){this._super();this._onTouch=!1;this._cbClick=null;this._checkbox=new Popup.CheckBox;this._checkbox.setPosition(15,15);this.addChild(this._checkbox);this._label=new CLabelTTF(Lang.getString(Lang.POP_ASK_FRIENDS_SELECT_ALL),22,250,4);this._label.setAlignment(cc.TEXT_ALIGNMENT_LEFT,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);this._label.setAnchorPoint(0,.5);this._label.setPosition(35,15);this.addChild(this._label);
cc.eventManager.addListener({event:cc.EventListener.MOUSE,onMouseDown:this.mouseDown.bind(this),onMouseUp:this.mouseUp.bind(this)},this)},setCbClick:function(a){this._cbClick=a},setCheck:function(a){this._checkbox.setValue(a)},isCheck:function(){return this._checkbox.getValue()},mouseDown:function(a){CUtils.onTouch(a,this,!0)&&(AudioEngine.playEffect(Resource.SND.CLICK),this._onTouch=!0)},mouseUp:function(a){CUtils.onTouch(a,this,!0)&&this._onTouch&&this._cbClick&&this._cbClick();this._onTouch=!1}});
Popup.PopAskFriends.FriendItem=cc.Node.extend({_avatar:null,_user:null,_checkbox:null,_lbFirstName:null,_lbLastName:null,_touchOn:!1,_touchPos:null,_cbClick:null,ctor:function(a,b,c){cc.assert(b,"null user");this._super();this._cbClick=c;this._touchOn=!1;this._user=b;this._checkbox=new Popup.CheckBox(!0);this._checkbox.setPosition(15,28);this.addChild(this._checkbox);this._avatar=new cc.Node;this._avatar.addChild(new cc.Sprite(Resource.POP.img("039")));this._avatar.addChild(new cc.Sprite(Resource.POP.img("038")),
10);this._avatar.setPosition(60,28);this.addChild(this._avatar);cc.textureCache.addImage(b.getPicture(),function(a){if(a instanceof cc.Texture2D){var b=.5*(a.width-Math.round(45/47*a.width));b=new cc.rect(b,0,a.width-b,a.height);a=new cc.Sprite(a,b);a.setScale(45/a.getContentSize().width);this._avatar.addChild(a)}},this);this._lbFirstName=new CLabelTTF(b.getFirstName(),18,a-90,4);this._lbFirstName.setAlignment(cc.TEXT_ALIGNMENT_LEFT,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);this._lbFirstName.setAnchorPoint(0,
.5);this._lbFirstName.setPosition(90,38);this.addChild(this._lbFirstName);this._lbLastName=new CLabelTTF(b.getLastName(),18,a-90,4);this._lbLastName.setAlignment(cc.TEXT_ALIGNMENT_LEFT,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);this._lbLastName.setAnchorPoint(0,.5);this._lbLastName.setPosition(90,15);this.addChild(this._lbLastName);this.setContentSize(cc.size(a,56));cc.eventManager.addListener({event:cc.EventListener.MOUSE,onMouseDown:this.mouseDown.bind(this),onMouseUp:this.mouseUp.bind(this)},this)},getUser:function(){return this._user},
setCheck:function(a){this._checkbox.setValue(a)},isCheck:function(){return this._checkbox.getValue()},mouseDown:function(a){CUtils.onTouch(a,this,!0)&&(AudioEngine.playEffect(Resource.SND.CLICK),this._touchOn=!0,this._touchPos=a.getLocation())},mouseUp:function(a){CUtils.onTouch(a,this,!0)&&this._touchOn&&3>CUtils.distance(this._touchPos,a.getLocation())&&(this._checkbox.setValue(!this._checkbox.getValue()),this._cbClick());this._touchOn=!1}});
Popup.PopAskFriends.FriendsRow=ccui.Widget.extend({ctor:function(a,b,c){this._super();for(var d=0;d<b.length;d++){var e=new Popup.PopAskFriends.FriendItem(a/3-5,b[d],c);e.setPosition(d*a/3,0);this.addChild(e);0===d&&this.setContentSize(a,e.getContentSize().height+4)}}});Popup.PopDailyReward=Popup.PopBase.extend({_prices:null,_bonus:0,_reward:0,ctor:function(a){this._super(a);this._size=new cc.Size(590,465);this._prices=[0,100,150,250,350,500];this._bonus=100;this._reward=this._prices[User.getDailyReward()]},build:function(){this._super();var a=this;var b=new CLabelTTF(Lang.getString(Lang.POP_DAILY_REWARD_TITLE),34,this._size.width-70,2);b.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);b.setPosition(0,184);this.addChild(b);for(var c=0;5>
c;c++){var d=c<User.getDailyReward(),e=new cc.Node;e.addChild(new cc.Sprite(Resource.POP.img(d?"042":"043")));b=new CLabelTTF(Lang.getString(Lang.POP_DAILY_REWARD_DAYS,c+1),18,80,4);b.setHorizontalAlignment(cc.TEXT_ALIGNMENT_CENTER);b.setPosition(0,d?-53:-46);e.addChild(b);b=new CLabelTTF("+"+this._prices[c+1],20,80,5);b.setHorizontalAlignment(cc.TEXT_ALIGNMENT_CENTER);b.setPosition(-2,d?14:10);e.addChild(b);0==c?e.setPosition(-214,82):1==c?e.setPosition(-107,55):2==c?e.setPosition(0,82):3==c?e.setPosition(107,
55):4==c&&e.setPosition(214,82);this.addChild(e)}c="";5!=User.getDailyReward()?c=Lang.getString(Lang.POP_DAILY_REWARD_MSG0,this._prices[User.getDailyReward()+1]):(c=Lang.getString(Lang.POP_DAILY_REWARD_MSG1,this._bonus),this._reward+=this._bonus);b=new cc.Sprite(Resource.POP.img("044"));b.setPosition(25,-70);this.addChild(b);b=new CLabelTTF(Lang.getString(Lang.POP_DAILY_REWARD_MSG2),22,0,2);b.setAlignment(cc.TEXT_ALIGNMENT_RIGHT,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);b.setPosition(-75,-70);this.addChild(b);
b=new CLabelTTF("+"+this._prices[User.getDailyReward()],28,50,2);b.setAlignment(cc.TEXT_ALIGNMENT_LEFT,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);b.setPosition(95,-70);this.addChild(b);b=new CLabelTTF(c,22,this._size.width-70,2);b.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);b.setPosition(0,-118);this.addChild(b);b=new CButton(Resource.POP.bt("green_2"),null,{b:.05},{b:-.15});b.setText(Lang.getString(Lang.POP_DAILY_REWARD_BT_OK),20,1);b.setPosition(0,-180);b.setCbUp(this.close.bind(this));
this.addChild(b,1);this.setOnClose(function(){Backend.putCoins(a._reward,null)})}});Popup.PopDailyReward.show=function(a,b,c,d){(new Popup.PopDailyReward(a)).show(b,c,d)};Popup.PopBeat=Popup.PopBase.extend({_user0:null,_user1:null,_levelId:0,ctor:function(a){this._super(a);this._size=new cc.Size(420,534);this._user0=a.user0;this._user1=a.user1;this._levelId=a.levelId},build:function(){this._super();var a=new cc.Sprite(Resource.POP.img("003"));a.setPosition(0,.5*this._size.height+3);this.addChild(a,1);var b=new CLabelTTF(Lang.getString(Lang.POP_BEAT_TITLE),26,a.getContentSize().width-70,2);b.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);b.setPosition(0,
.5*this._size.height+2);this.addChild(b,1);b=new CLabelTTF(Lang.getString(Lang.POP_BEAT_LB0),24,this._size.width-70,2);b.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);b.setPosition(0,218);this.addChild(b,1);b=new cc.Sprite(Resource.POP.img("069"));b.setPosition(-52,88);this.addChild(b);a=new CLabelTTF(this._user0.prof.getFirstName(),18,75,5);a.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);a.setPosition(85,167);b.addChild(a);a=new CLabelTTF(this._user0.score,
18,40,5);a.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);a.setPosition(100,136);b.addChild(a);a=new cc.Sprite(Resource.POP.img("067"));a.setPosition(65,136);b.addChild(a);a=new cc.Sprite(Resource.POP.img("060"));a.setPosition(87,86);b.addChild(a,1);cc.textureCache.addImage(this._user0.prof.getPicture(),function(a){if(a instanceof cc.Texture2D){var b=.5*(a.width-Math.round(60/63*a.width));b=new cc.rect(b,0,a.width-b,a.height);a=new cc.Sprite(a,b);a.setScale(63/a.getContentSize().width);
a.setPosition(87,86);this.addChild(a)}},b);b=new cc.Sprite(Resource.POP.img("070"));b.setPosition(61,34);this.addChild(b);a=new CLabelTTF(this._user1.prof.getFirstName(),18,75,5);a.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);a.setPosition(85,58);b.addChild(a);a=new CLabelTTF(this._user1.score,18,40,5);a.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);a.setPosition(100,85);b.addChild(a);a=new cc.Sprite(Resource.POP.img("067"));a.setPosition(65,
86);b.addChild(a);a=new cc.Sprite(Resource.POP.img("060"));a.setPosition(84,137);b.addChild(a,1);cc.textureCache.addImage(this._user1.prof.getPicture(),function(a){if(a instanceof cc.Texture2D){var b=.5*(a.width-Math.round(60/63*a.width));b=new cc.rect(b,0,a.width-b,a.height);a=new cc.Sprite(a,b);a.setScale(63/a.getContentSize().width);a.setPosition(84,137);this.addChild(a)}},b);b=this._user1.prof.getFirstName();b=new CLabelTTF(Lang.getString(Lang.POP_BEAT_LB1,b),20,this._size.width-70,2);b.setAlignment(cc.TEXT_ALIGNMENT_CENTER,
cc.VERTICAL_TEXT_ALIGNMENT_CENTER);b.setPosition(0,-100);this.addChild(b,1);a=new cc.Sprite(Resource.POP.img("044"));a.setPosition(32,-158);this.addChild(a,1);b=new CLabelTTF(app.config.beatReward(),22,75,2);b.setAlignment(cc.TEXT_ALIGNMENT_RIGHT,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);b.setAnchorPoint(1,.5);b.setPosition(-12,-157);this.addChild(b,1);b=new CButton(Resource.POP.bt("green_0"),null,{b:.05},{b:-.15});b.setText(Lang.getString(Lang.POP_BEAT_BT_CONTINUE),20,1);b.setPosition(0,-212);b.setCbUp(this.close.bind(this));
this.addChild(b);this.setOnClose(function(){Backend.putCoins(app.config.beatReward())})}});Popup.PopBehind=Popup.PopBase.extend({_user0:null,_user1:null,_levelId:0,ctor:function(a){this._super(a);this._size=new cc.Size(420,534);this._user0=a.user0;this._user1=a.user1;this._levelId=a.levelId},build:function(){this._super();var a=new cc.Sprite(Resource.POP.img("003"));a.setPosition(0,.5*this._size.height+3);this.addChild(a,1);a=new CLabelTTF(Lang.getString(Lang.POP_BEHIND_TITLE),26,a.getContentSize().width-70,2);a.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);a.setPosition(0,
.5*this._size.height+2);this.addChild(a,1);a=new CLabelTTF(Lang.getString(Lang.POP_BEHIND_LB0,this._levelId),20,this._size.width-70,2);a.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);a.setPosition(0,218);this.addChild(a,1);var b=new cc.Sprite(Resource.POP.img("069"));b.setPosition(-52,78);this.addChild(b);a=new CLabelTTF(this._user0.getFirstName(),18,75,5);a.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);a.setPosition(86,142);b.addChild(a);a=new cc.Sprite(Resource.POP.img("060"));
a.setPosition(87,86);b.addChild(a,1);cc.textureCache.addImage(this._user0.getPicture(),function(a){if(a instanceof cc.Texture2D){var b=.5*(a.width-Math.round(60/63*a.width));b=new cc.rect(b,0,a.width-b,a.height);a=new cc.Sprite(a,b);a.setScale(63/a.getContentSize().width);a.setPosition(87,86);this.addChild(a)}},b);b=new cc.Sprite(Resource.POP.img("070"));b.setPosition(61,24);this.addChild(b);a=new CLabelTTF(this._user1.getFirstName(),18,75,5);a.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);
a.setPosition(85,58);b.addChild(a);a=new cc.Sprite(Resource.POP.img("060"));a.setPosition(84,137);b.addChild(a,1);cc.textureCache.addImage(this._user1.getPicture(),function(a){if(a instanceof cc.Texture2D){var b=.5*(a.width-Math.round(60/63*a.width));b=new cc.rect(b,0,a.width-b,a.height);a=new cc.Sprite(a,b);a.setScale(63/a.getContentSize().width);a.setPosition(84,137);this.addChild(a)}},b);a=this._user1.getFirstName();a=new CLabelTTF(Lang.getString(Lang.POP_BEHIND_LB1,a),20,this._size.width-70,2);
a.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);a.setPosition(0,-110);this.addChild(a,1);a=new cc.Sprite(Resource.POP.img("044"));a.setPosition(32,-158);this.addChild(a,1);a=new CLabelTTF(app.config.behindReward(),22,75,2);a.setAlignment(cc.TEXT_ALIGNMENT_RIGHT,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);a.setAnchorPoint(1,.5);a.setPosition(-12,-157);this.addChild(a,1);a=new CButton(Resource.POP.bt("green_0"),null,{b:.05},{b:-.15});a.setText(Lang.getString(Lang.POP_BEHIND_BT_CONTINUE),
20,1);a.setPosition(0,-212);a.setCbUp(this.close.bind(this));this.addChild(a);this.setOnClose(function(){Backend.putCoins(app.config.behindReward())})}});Popup.PopBehind.show=function(a,b,c,d){(new Popup.PopBehind(a)).show(b,c,d)};Popup.PopInbox=Popup.PopBase.extend({_ext:null,_empty:null,_scrollBar:null,_listView:null,_btAccept:null,ctor:function(a){this._super(a);this._size=new cc.Size(635,570);this._ext=new CExtNode(this)},build:function(){this._super();var a=this,b=new cc.Sprite(Resource.POP.img("006"));b.setPosition(0,.5*this._size.height+3);this.addChild(b,1);b=new CLabelTTF(Lang.getString(Lang.POP_INBOX_TITLE),26,b.getContentSize().width-70,2);b.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);
b.setPosition(0,.5*this._size.height+2);this.addChild(b,1);b=new cc.Sprite(Resource.POP.img("002"));b.setScaleX(this._size.width/b.getContentSize().width);b.setPosition(-1,226);this.addChild(b);b=new cc.Sprite(Resource.POP.img("002"));b.setScaleX(this._size.width/b.getContentSize().width);b.setPosition(-1,-190);this.addChild(b);this._empty=new CLabelTTF(Lang.getString(Lang.POP_INBOX_EMPTY),28,this._size.width-70,2);this._empty.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);
this._empty.setPosition(0,40);this.addChild(this._empty);this._btAccept=new CButton(Resource.POP.bt("green_2"),null,{b:.05},{b:-.15});this._btAccept.setText(Lang.getString(Lang.POP_INBOX_BT_ACCEPT_ALL),20,1);this._btAccept.setPosition(0,-227);this._btAccept.setCbUp(this.clickAccept.bind(this));this.addChild(this._btAccept);this._scrollBar=new Popup.ScrollBar(388);this._scrollBar.setPosition(270,-175);this._scrollBar.setCbValueChanged(function(){var b=a._scrollBar.getValue();a._listView.jumpToPercentVertical(100*
b)});this.addChild(this._scrollBar,1);this._listView=new ccui.ListView;this._listView.setDirection(ccui.ScrollView.DIR_VERTICAL);this._listView.setContentSize(new cc.Size(550,410));this._listView.setBounceEnabled(!0);this._listView.setMagneticType(ccui.ListView.MAGNETIC_TOP);this._listView.setMagneticAllowedOutOfBoundary(!1);this._listView.setPosition(-290,-186);this._listView.addCCSEventListener(function(b,d){if(d==ccui.ScrollView.EVENT_CONTAINER_MOVED){var c=a._listView,f=c.getContentSize().height-
c.getInnerContainer().getContentSize().height;0==f?a._scrollBar.setVisible(!1):(c=c.getInnerContainer().getPositionY(),a._scrollBar.setVisible(!0),a._scrollBar.setValue((f-c)/f))}},this);this._listView.getInnerContainer().setPositionY(6);this._listView.jumpToPercentVertical(0);this.addChild(this._listView);this.updateContent();this._ext.addCustomListener(User.EVENT.UPDATE_INBOX,this.eventHandler.bind(this));this.setOnClose(function(){User.getInbox().flushDump()});User.getInbox().query(!0)},updateContent:function(){this._listView.removeAllItems();
var a=User.getInbox();if(0===a.getSize())this._empty.setVisible(!0),this._btAccept.setVisible(!1);else{this._empty.setVisible(!1);this._btAccept.setVisible(!0);var b=this._listView.getContentSize().width,c=a.getGift(),d=a.getRequest();if(0<d.length)for(var e in d)a=d[e],"life"==a.type?this._listView.pushBackCustomItem(new Popup.PopInbox.Header(b,Lang.getString(Lang.POP_INBOX_REQUEST_HEADER_LIFE))):"unlock"==a.type&&this._listView.pushBackCustomItem(new Popup.PopInbox.Header(b,Lang.getString(Lang.POP_INBOX_REQUEST_HEADER_UNLOCK))),
this._listView.pushBackCustomItem(new Popup.PopInbox.ItemRequest(b,d[e]));if(0<c.length)for(e in c)a=c[e],"coins"==a.type||"golf"==a.type?this._listView.pushBackCustomItem(new Popup.PopInbox.Header(b,Lang.getString(Lang.POP_INBOX_GIFT_HEADER_COINS))):"life"==a.type?this._listView.pushBackCustomItem(new Popup.PopInbox.Header(b,Lang.getString(Lang.POP_INBOX_GIFT_HEADER_LIFE))):"unlock"==a.type&&this._listView.pushBackCustomItem(new Popup.PopInbox.Header(b,Lang.getString(Lang.POP_INBOX_GIFT_HEADER_UNLOCK))),
this._listView.pushBackCustomItem(new Popup.PopInbox.ItemGift(b,a));this._listView.pushBackCustomItem(new Popup.PopInbox.Footer(b));this._listView.jumpToPercentVertical(100*this._scrollBar.getValue())}},eventHandler:function(a){var b=a.getEventName();a=a.getUserData();b==User.EVENT.UPDATE_INBOX&&a&&1==a.force&&this.updateContent()},clickAccept:function(){var a=this._listView.getItems(),b;for(b in a){var c=a[b];c.clickAccept&&c.clickAccept()}this.close()}});
Popup.PopInbox.show=function(a,b,c,d){(new Popup.PopInbox(a)).show(b,c,d)};
Popup.PopInbox.ItemGift=ccui.Widget.extend({_data:null,_user:null,ctor:function(a,b){this._super();this._user=(this._data=b)?User.getFriendById(b.from,1):null;var c=cc.size(a,50);this.setContentSize(c);var d=new cc.Sprite(Resource.POP.img("071"));d.setPosition(parseInt(.5*c.width),parseInt(.5*c.height));this.addChild(d);c=new cc.Sprite(Resource.POP.img("064"));c.setScale(.9);c.setPosition(26,24);d.addChild(c,2);var e=new cc.Sprite(Resource.POP.img("065"));e.setScale(.9);e.setPosition(c.getPosition());
d.addChild(e,0);this._user&&(cc.textureCache.addImage(this._user.getPicture(),function(a){if(a instanceof cc.Texture2D){var b=.5*(a.width-Math.round(.95*a.width));b=new cc.rect(b,0,a.width-b,a.height);a=new cc.Sprite(a,b);a.setScale(34.2/a.getContentSize().width);a.setPosition(26,24);this.addChild(a)}},d),c=new CLabelTTF(this._user.getFirstName(),18,75,1),c.setAlignment(cc.TEXT_ALIGNMENT_LEFT,cc.VERTICAL_TEXT_ALIGNMENT_CENTER),c.setAnchorPoint(0,.5),c.setPosition(52,23),d.addChild(c));e=this._user?
this._user.getFirstName():"Friend";"coins"===this._data.type||"gold"===this._data.type?(c=new cc.Sprite(Resource.POP.img("044")),c.setScale(.73),c.setPosition(146,16),d.addChild(c),c=new CLabelTTF(Lang.getString(Lang.POP_INBOX_GIFT_COINS,e,this._data.value),16,270,1),c.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER),c.setPosition(309,23),d.addChild(c)):"life"===this._data.type?(c=new cc.Sprite(Resource.POP.img("072")),c.setScale(.9),c.setRotation(-10),c.setPosition(138,21),
d.addChild(c),c=new CLabelTTF(Lang.getString(Lang.POP_INBOX_GIFT_LIFE,e),16,270,1),c.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER),c.setPosition(309,23),d.addChild(c)):"unlock"===this._data.type&&(c=new cc.Sprite(Resource.POP.img("073")),c.setScale(.95),c.setPosition(148,25),d.addChild(c),c=new CLabelTTF(Lang.getString(Lang.POP_INBOX_GIFT_UNLOCK,e),16,270,1),c.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER),c.setPosition(309,23),d.addChild(c));c=
new CButton(Resource.POP.bt("green_3"),null,{b:.05},{b:-.15});c.setText(Lang.getString(Lang.POP_INBOX_BT_ACCEPT),18,1);c.setPosition(490,25);c.setCbUp(this.clickAccept.bind(this));d.addChild(c);c=new CButton(Resource.POP.bt("close_1"),null,{b:.05},{b:-.15});c.setPosition(535,44);c.setCbUp(this.clickDelete.bind(this));d.addChild(c)},clickAccept:function(){User.getInbox().enableGift(this._data.id)},clickDelete:function(){User.getInbox().deleteGift(this._data.id)}});
Popup.PopInbox.ItemRequest=ccui.Widget.extend({_data:null,_user:null,ctor:function(a,b){this._super();this._user=(this._data=b)?User.getFriendById(b.from,1):null;var c=cc.size(a,50);this.setContentSize(c);var d=new cc.Sprite(Resource.POP.img("071"));d.setPosition(parseInt(.5*c.width),parseInt(.5*c.height));this.addChild(d);c=new cc.Sprite(Resource.POP.img("064"));c.setScale(.9);c.setPosition(26,24);d.addChild(c,2);var e=new cc.Sprite(Resource.POP.img("065"));e.setScale(.9);e.setPosition(c.getPosition());
d.addChild(e,0);this._user&&(cc.textureCache.addImage(this._user.getPicture(),function(a){if(a instanceof cc.Texture2D){var b=.5*(a.width-Math.round(.95*a.width));b=new cc.rect(b,0,a.width-b,a.height);a=new cc.Sprite(a,b);a.setScale(34.2/a.getContentSize().width);a.setPosition(26,24);this.addChild(a)}},d),c=new CLabelTTF(this._user.getFirstName(),18,75,1),c.setAlignment(cc.TEXT_ALIGNMENT_LEFT,cc.VERTICAL_TEXT_ALIGNMENT_CENTER),c.setAnchorPoint(0,.5),c.setPosition(52,23),d.addChild(c));this._user&&
this._user.getFirstName();"life"===this._data.type?(c=new cc.Sprite(Resource.POP.img("072")),c.setScale(.9),c.setRotation(-10),c.setPosition(138,21),d.addChild(c),c=new CLabelTTF(Lang.getString(Lang.POP_INBOX_REQUEST_LIFE),16,270,1),c.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER),c.setPosition(309,23),d.addChild(c)):"unlock"===this._data.type&&(c=new cc.Sprite(Resource.POP.img("073")),c.setScale(.95),c.setPosition(148,25),d.addChild(c),c=new CLabelTTF(Lang.getString(Lang.POP_INBOX_REQUEST_UNLOCK),
16,270,1),c.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER),c.setPosition(309,23),d.addChild(c));c=new CButton(Resource.POP.bt("green_3"),null,{b:.05},{b:-.15});c.setText(Lang.getString(Lang.POP_INBOX_BT_HELP),18,1);c.setPosition(490,25);c.setCbUp(this.clickAccept.bind(this));d.addChild(c);c=new CButton(Resource.POP.bt("close_1"),null,{b:.05},{b:-.15});c.setPosition(535,44);c.setCbUp(this.clickDelete.bind(this));d.addChild(c)},clickAccept:function(){User.getInbox().enableRequest(this._data.id)},
clickDelete:function(){User.getInbox().deleteRequest(this._data.id)}});Popup.PopInbox.Header=ccui.Widget.extend({ctor:function(a,b){this._super();var c=cc.size(a,40);this.setContentSize(c);var d=new CLabelTTF(b,22,a,2);d.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);d.setPosition(.5*c.width,.5*c.height-6);this.addChild(d)}});Popup.PopInbox.Footer=ccui.Widget.extend({ctor:function(a){this._super();a=cc.size(a,10);this.setContentSize(a)}});Popup.PopSystemGift=Popup.PopBase.extend({_btAccept:null,_data:null,ctor:function(a){this._super(a);this._size=new cc.Size(430,510);this._hasClose=!1},build:function(){this._super();var a=this;this._data=this._args.data||[];var b=0,c=0;for(e in this._data){var d=this._data[e];"coins"==d.gift_type?b=Number(d.gift_value)||0:"crystals"==d.gift_type&&(c=Number(d.gift_value)||0)}if(0==b&&0==c)this.close();else{var e=new cc.Sprite(Resource.POP.img("003"));e.setPosition(0,.5*this._size.height+3);this.addChild(e,
1);e=new CLabelTTF(Lang.getString(Lang.POP_SYSTEM_GIFT_TITLE),26,e.getContentSize().width-70,2);e.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);e.setPosition(0,.5*this._size.height+2);this.addChild(e,1);b=new Popup.PopSystemGift.GiftBox(c,b,function(){a._btAccept.setVisible(!0)});b.setPosition(0,24);this.addChild(b);this._btAccept=new CButton(Resource.POP.bt("green_2"),null,{b:.05},{b:-.15});this._btAccept.setText(Lang.getString(Lang.POP_SYSTEM_GIFT_ACCEPT),20,1);this._btAccept.setPosition(0,
-205);this._btAccept.setCbUp(this.clickAccept.bind(this));this._btAccept.setVisible(!1);this.addChild(this._btAccept)}},clickAccept:function(){var a=[],b;for(b in this._data){var c=this._data[b];"coins"==c.gift_type?User.getCoins().addValue(c.gift_value,!0):"crystals"==c.gift_type&&User.getCash().addValue(c.gift_value,!0);a.push(c.giftId)}Backend.send(new HttpRest.Request(HttpRest.METHOD.POST,"/users/"+User.getFbId()+"/gifts/accept",a,null,null));this.close()}});
Popup.PopSystemGift.GiftBox=cc.Sprite.extend({_cash:0,_coins:0,_cap:null,_arrow:null,_callback:null,_frames:null,_msg0:null,_msg1:null,ctor:function(a,b,c){this._super(Resource.POP.img("113"));this._cash=Number(a)||0;this._coins=Number(b)||0;this._callback=c||null;var d=this;this._frames=[];for(a=0;10>a;a++)b=Resource.POP.efect("a",a),this._frames.push(cc.spriteFrameCache.getSpriteFrame(b));this._msg0=new CLabelTTF(Lang.getString(Lang.POP_SYSTEM_GIFT_MSG0),30,200,4);this._msg0.setAlignment(cc.TEXT_ALIGNMENT_CENTER,
cc.VERTICAL_TEXT_ALIGNMENT_CENTER);this._msg0.setPosition(80,300);this._msg0.setRotation(-48);this.addChild(this._msg0,1);this._msg1=new CLabelTTF(Lang.getString(Lang.POP_SYSTEM_GIFT_MSG1),36,280,4);this._msg1.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);this._msg1.setPosition(170,345);this._msg1.setOpacity(0);this.addChild(this._msg1,1);this._cap=new cc.Sprite(Resource.POP.img("114"));this._cap.setAnchorPoint(1,0);this._cap.setPosition(271,118);this.addChild(this._cap);
this._arrow=new cc.Sprite(Resource.POP.img("115"));this._arrow.setPosition(237,292);this._arrow.runAction(new cc.RepeatForever(new cc.Sequence(new cc.MoveBy(.5,-5,-5),new cc.MoveBy(.5,5,5))));this.addChild(this._arrow);cc.eventManager.addListener({event:cc.EventListener.MOUSE,onMouseDown:function(a){CUtils.isHover(a,d)&&(AudioEngine.playEffect(Resource.SND.CLICK),d.open())}},d)},open:function(){cc.eventManager.removeListeners(this);this._arrow.runAction(new cc.Sequence(new cc.FadeTo(.3,50),new cc.RemoveSelf));
this._cap.runAction(new cc.RotateBy(.4,180));this._cap.runAction(new cc.Sequence(new cc.DelayTime(.1),new cc.FadeTo(.28,50),new cc.RemoveSelf));this._msg0.runAction(new cc.FadeTo(.2,0));this._msg1.runAction(new cc.Sequence(new cc.DelayTime(.5),new cc.FadeTo(.2,255)));if(0<this._cash&&0<this._coins){var a=new cc.Sprite(Resource.POP.img("116"));a.setAnchorPoint(.5,0);a.setScale(.2);a.setPosition(168,130);a.runAction(new cc.ScaleTo(.25,1));this.addChild(a);var b=this.buildNumber(this._cash);b.setScale(.7);
b.setPosition(50,60);a.addChild(b);b=this.buildNumber(this._coins);b.setScale(.7);b.setPosition(170,110);a.addChild(b)}else 0<this._cash?(a=new cc.Sprite(Resource.POP.img("118")),a.setAnchorPoint(.5,0),a.setScale(.2),a.setPosition(152,120),a.runAction(new cc.ScaleTo(.25,1)),a.runAction(new cc.MoveTo(.25,152,100)),this.addChild(a),b=this.buildNumber(this._cash),b.setPosition(130,120),a.addChild(b)):0<this._coins&&(a=new cc.Sprite(Resource.POP.img("117")),a.setAnchorPoint(.5,0),a.setScale(.2),a.setPosition(157,
129),a.runAction(new cc.ScaleTo(.25,1)),this.addChild(a),b=this.buildNumber(this._coins),b.setPosition(160,157),a.addChild(b));this.runAction(new cc.RepeatForever(new cc.Sequence([new cc.CallFunc(this.buildEffect.bind(this)),new cc.CallFunc(this.buildEffect.bind(this)),new cc.CallFunc(this.buildEffect.bind(this)),new cc.CallFunc(this.buildEffect.bind(this)),new cc.CallFunc(this.buildEffect.bind(this)),new cc.CallFunc(this.buildEffect.bind(this)),new cc.CallFunc(this.buildEffect.bind(this)),new cc.CallFunc(this.buildEffect.bind(this)),
new cc.DelayTime(CUtils.random(.5,1)),new cc.CallFunc(this.buildEffect.bind(this)),new cc.CallFunc(this.buildEffect.bind(this)),new cc.CallFunc(this.buildEffect.bind(this)),new cc.CallFunc(this.buildEffect.bind(this)),new cc.CallFunc(this.buildEffect.bind(this)),new cc.CallFunc(this.buildEffect.bind(this)),new cc.CallFunc(this.buildEffect.bind(this)),new cc.CallFunc(this.buildEffect.bind(this)),new cc.DelayTime(CUtils.random(1.5,2)),new cc.CallFunc(this.buildEffect.bind(this)),new cc.CallFunc(this.buildEffect.bind(this)),
new cc.CallFunc(this.buildEffect.bind(this)),new cc.CallFunc(this.buildEffect.bind(this)),new cc.CallFunc(this.buildEffect.bind(this)),new cc.CallFunc(this.buildEffect.bind(this)),new cc.CallFunc(this.buildEffect.bind(this)),new cc.CallFunc(this.buildEffect.bind(this)),new cc.DelayTime(CUtils.random(2,3))])));this._callback&&this._callback()},buildNumber:function(a){var b=new cc.Node;b.removeAllChildren();a=CUtils.numToArray(a);var c=0;0==a.length&&a.push(0);for(var d in a){var e=new cc.Sprite(Resource.POP.num("a",
a[d]));e.setAnchorPoint(0,0);e.setPosition(c,0);c+=e.getContentSize().width;b.addChild(e)}b.setContentSize(0,0);d=b.getBoundingBoxToWorld();b.setContentSize(d.width,d.height);b.setAnchorPoint(.5,.5);b.setScale(.9);return b},buildEffect:function(){var a=new cc.Point(CUtils.random(10,this.getContentSize().width-10),CUtils.random(10,this.getContentSize().height-10)),b=new cc.Point(CUtils.random(10,this.getContentSize().width-10),CUtils.random(10,this.getContentSize().height-10)),c=new cc.Sprite(this._frames[0]);
c.runAction(new cc.RepeatForever(new cc.Animate(new cc.Animation(this._frames,.055))));c.setScale(.7);c.setOpacity(50);c.setPosition(0,0);c.setPosition(a);c.runAction(new cc.Sequence(new cc.FadeTo(.1,255),new cc.MoveTo(CUtils.distance(a,b)/50,b),new cc.RemoveSelf));this.addChild(c,10)}});Popup.PopSystemGift.show=function(a,b,c,d){(new Popup.PopSystemGift(a)).show(b,c,d)};Popup.PopSystemReward=Popup.PopBase.extend({_coins:0,ctor:function(a){this._super(a);this._size=new cc.Size(400,500);this._coins=this._args.coins||0},build:function(){this._super();var a=this;if(0==this._coins)this.close();else{var b=new cc.Sprite(Resource.UI.img("007"));b.setPosition(0,183);b.setScale(.81);this.addChild(b);b=new cc.Sprite(Resource.POP.img("120"));b.setPosition(0,150);this.addChild(b);b=new cc.Sprite(Resource.POP.img("121"));b.setPosition(0,15);this.addChild(b);b=new cc.Sprite(Resource.POP.img("044"));
b.setPosition(0,-15);this.addChild(b);b=new CLabelTTF(Lang.getString(Lang.POP_SYSTEM_REWARD_NAME,User.getFirstName()),30,this._size.width-70,2);b.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);b.setPosition(0,100);this.addChild(b);b=new CLabelTTF(Lang.getString(Lang.POP_SYSTEM_REWARD_MSG),26,this._size.width-70,2);b.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);b.setPosition(0,-115);this.addChild(b);b=new CLabelTTF(this._coins,28,150,2);b.setAlignment(cc.TEXT_ALIGNMENT_CENTER,
cc.VERTICAL_TEXT_ALIGNMENT_CENTER);b.setPosition(0,30);this.addChild(b);b=new CButton(Resource.POP.bt("green_2"),null,{b:.05},{b:-.15});b.setText(Lang.getString(Lang.POP_SYSTEM_REWARD_BT_CONTINUE),20,1);b.setPosition(0,-200);b.setCbUp(this.close.bind(this));this.addChild(b);this.setOnClose(function(){Backend.putCoins(a._coins)})}}});Popup.PopSystemReward.show=function(a,b,c,d){(new Popup.PopSystemReward(a)).show(b,c,d)};Popup.PopOrbUnlocked=Popup.PopBase.extend({_item:null,ctor:function(a){this._super(a);this._size=new cc.Size(420,500);this._item=a.item},build:function(){this._super();var a=this,b=new cc.Sprite(Resource.POP.img("074"));b.setScale(.819);b.setPosition(1,66);this.addChild(b);b=new CLabelTTF(Lang.getString(Lang.POP_ORB_UNLOCKED_TITLE),28,this._size.width-75,2);b.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);b.setPosition(0,175);this.addChild(b);b=new cc.Sprite(Resource.POP.orb("back_on"));
b.setScale(.87);b.setPosition(-1,30);this.addChild(b);b=new cc.Sprite(Resource.POP.orb(this._item.getId()));b.setScale(.87);b.setPosition(0,30);this.addChild(b);b=Lang.getString(Lang.ORB_NAME(this._item.getId()));b=new CLabelTTF(Lang.getString(Lang.POP_ORB_UNLOCKED_MSG,b),24,this._size.width-75,2);b.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);b.setPosition(0,-114);this.addChild(b);b=new CButton(Resource.POP.bt("green_2"),null,{b:.05},{b:-.15});b.setText(Lang.getString(Lang.POP_ORB_UNLOCKED_BT_OK),
20,1);b.setPosition(0,-196);b.setCbUp(this.close.bind(this));this.addChild(b);this.setOnClose(function(){Backend.ogUnlockOrb(a._item.getOptId());Backend.putCoins(app.config.rewardUnlockOrb())})}});Popup.PopOrbUnlocked.show=function(a,b,c,d){(new Popup.PopOrbUnlocked(a)).show(b,c,d)};Popup.PopSendLife=Popup.PopBase.extend({_checkAll:null,_items:null,_checkOn:!1,ctor:function(a){this._super(a);this._size=new cc.Size(655,525);this._items=[];this._checkOn=!0},build:function(){this._super();for(var a=TimeUtils.getTime(),b=User.getFriends(1).filter(function(b){return 0>b.getGiftTime(a)});12<b.length;){var c=CUtils.random(0,b.length-1);b.splice(c,1)}if(0==b.length)this.close();else{c=new cc.Sprite(Resource.POP.img("005"));c.setPosition(0,.5*this._size.height+3);this.addChild(c,1);c=
new CLabelTTF(Lang.getString(Lang.POP_SEND_LIFE_TITLE),26,c.getContentSize().width-70,2);c.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);c.setPosition(0,.5*this._size.height+2);this.addChild(c,1);c=new CLabelTTF(Lang.getString(Lang.POP_SEND_LIFE_MSG0),28,this._size.width-70,2);c.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);c.setPosition(0,210);this.addChild(c);c=new cc.Sprite(Resource.POP.img("002"));c.setScaleX(this._size.width/c.getContentSize().width);
c.setPosition(-1,172);this.addChild(c);c=new cc.Sprite(Resource.POP.img("002"));c.setScaleX(this._size.width/c.getContentSize().width);c.setPosition(-1,-175);this.addChild(c);c=new CButton(Resource.POP.bt("green_2"),null,{b:.05},{b:-.15});c.setText(Lang.getString(Lang.POP_SEND_LIFE_BT_SEND),20,1);c.setPosition(187,-212);c.setCbUp(this.clickSend.bind(this));this.addChild(c,1);this._checkAll=new Popup.PopSendLife.CheckAll;this._checkAll.setPosition(-280,-228);this._checkAll.setCbClick(this.clickCheckAll.bind(this));
this.addChild(this._checkAll,1);var d=c=0,e=parseInt(.3*this._size.width),f;for(f in b){var g=new Popup.PopSendLife.Item(e,b[f],this.clickCheck.bind(this));g.setPosition(-300+206*c,90-80*d);this.addChild(g);this._items.push(g);2>c?c++:(c=0,d++)}this.clickCheckAll()}},clickSend:function(){var a=this._items.filter(function(a){return a.isCheck()&&0>a.getUser().getGiftTime()}).map(function(a){return a.getUser()});User.getFriends().sendGift(a,"pop_send_life");this.close()},clickCheckAll:function(){this._checkAll.setCheck(this._checkOn);
for(var a in this._items)this._items[a].setCheck(this._checkOn);this._checkOn=!this._checkOn},clickCheck:function(){var a=!0,b;for(b in this._items)a=a&&this._items[b].isCheck();this._checkAll.setCheck(a);this._checkOn=!a}});Popup.PopSendLife.show=function(a,b,c,d){(new Popup.PopSendLife(a)).show(b,c,d)};
Popup.PopSendLife.CheckAll=cc.Node.extend({_checkbox:null,_label:null,_onTouch:null,_cbClick:null,ctor:function(){this._super();this._onTouch=!1;this._cbClick=null;this._checkbox=new Popup.CheckBox;this._checkbox.setPosition(15,15);this.addChild(this._checkbox);this._label=new CLabelTTF(Lang.getString(Lang.POP_SEND_LIFE_SELECT_ALL),22,250,4);this._label.setAlignment(cc.TEXT_ALIGNMENT_LEFT,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);this._label.setAnchorPoint(0,.5);this._label.setPosition(35,15);this.addChild(this._label);
cc.eventManager.addListener({event:cc.EventListener.MOUSE,onMouseDown:this.mouseDown.bind(this),onMouseUp:this.mouseUp.bind(this)},this)},setCbClick:function(a){this._cbClick=a},setCheck:function(a){this._checkbox.setValue(a)},isCheck:function(){return this._checkbox.getValue()},mouseDown:function(a){CUtils.onTouch(a,this,!0)&&(AudioEngine.playEffect(Resource.SND.CLICK),this._onTouch=!0)},mouseUp:function(a){CUtils.onTouch(a,this,!0)&&this._onTouch&&this._cbClick&&this._cbClick();this._onTouch=!1}});
Popup.PopSendLife.Item=cc.Node.extend({_avatar:null,_user:null,_checkbox:null,_touchOn:!1,_touchPos:null,_cbClick:null,ctor:function(a,b,c){cc.assert(b,"null user");this._super();this._cbClick=c;this._touchOn=!1;this._user=b;this._checkbox=new Popup.CheckBox(!0);this._checkbox.setPosition(14,11);this.addChild(this._checkbox);var d=new cc.Sprite(Resource.POP.img("068"));d.setPosition(18,48);d.setScale(.53);d.setVisible(0<b.getGiftTime());this.addChild(d);var e=new CButton(Resource.POP.img("066"),null,
{b:.05},{b:-.15});e.setPosition(d.getPosition());e.setScale(d.getScale());e.setVisible(!d.isVisible());e.setCbUp(function(){d.setVisible(!0);e.setVisible(!1);User.getFriends().sendGift(b,"pop_send_life")});this.addChild(e);this._avatar=new cc.Node;this._avatar.addChild(new cc.Sprite(Resource.POP.img("061")));this._avatar.addChild(new cc.Sprite(Resource.POP.img("060")),10);this._avatar.setPosition(72,28);this.addChild(this._avatar);cc.textureCache.addImage(b.getPicture(),function(a){if(a instanceof
cc.Texture2D){var b=.5*(a.width-Math.round(60/63*a.width));b=new cc.rect(b,0,a.width-b,a.height);a=new cc.Sprite(a,b);a.setScale(60/a.getContentSize().width);this._avatar.addChild(a)}},this);c=new CLabelTTF(b.getFirstName(),18,a-110,4);c.setAlignment(cc.TEXT_ALIGNMENT_LEFT,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);c.setAnchorPoint(0,.5);c.setPosition(110,42);this.addChild(c);c=new CLabelTTF(b.getLastName(),18,a-110,4);c.setAlignment(cc.TEXT_ALIGNMENT_LEFT,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);c.setAnchorPoint(0,
.5);c.setPosition(110,11);this.addChild(c);this.setContentSize(cc.size(a,56));cc.eventManager.addListener({event:cc.EventListener.MOUSE,onMouseDown:this.mouseDown.bind(this),onMouseUp:this.mouseUp.bind(this)},this._checkbox)},getUser:function(){return this._user},setCheck:function(a){this._checkbox.setValue(a)},isCheck:function(){return this._checkbox.getValue()},mouseDown:function(a){CUtils.onTouch(a,this._checkbox,!0)&&(AudioEngine.playEffect(Resource.SND.CLICK),this._touchOn=!0,this._touchPos=
a.getLocation())},mouseUp:function(a){CUtils.onTouch(a,this._checkbox,!0)&&this._touchOn&&3>CUtils.distance(this._touchPos,a.getLocation())&&(this._checkbox.setValue(!this._checkbox.getValue()),this._cbClick());this._touchOn=!1}});Popup.PopSpinLevel=Popup.PopBase.extend({_cells:null,_column_spin:0,_levelId:0,_btPlay:null,ctor:function(a){this._super(a);this._size=new cc.Size(467,370);this._cells=[];this._column_spin=0;this._levelId=10},build:function(){this._super();var a=new cc.Sprite(Resource.POP.img("004"));a.setPosition(0,.5*this._size.height+3);this.addChild(a,1);a=new CLabelTTF(Lang.getString(Lang.POP_SPIN_LEVEL_TITLE),26,a.getContentSize().width-70,2);a.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);
a.setPosition(0,.5*this._size.height+2);this.addChild(a,1);a=new cc.Sprite(Resource.POP.img("080"));a.setScaleX((this._size.width-6)/a.getContentSize().width);a.setPosition(0,87);this.addChild(a);a=new cc.Sprite(Resource.POP.img("002"));a.setScaleX((this._size.width-2)/a.getContentSize().width);a.setPosition(-1,114);this.addChild(a);a=new CLabelTTF(Lang.getString(Lang.POP_SPIN_LEVEL_MSG),30,this._size.width-70,2);a.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);a.setPosition(0,
84);this.addChild(a);this._btPlay=new CButton(Resource.POP.bt("green_0"),null,{b:.05},{b:-.15});this._btPlay.setText(Lang.getString(Lang.POP_SPIN_LEVEL_BT_PLAY),20,1);this._btPlay.setPosition(0,-127);this._btPlay.setCbUp(this.clickPlay.bind(this));this._btPlay.setVisible(!1);this.addChild(this._btPlay);this._cells[0]=new Popup.PopSpinLevel.Cell;this._cells[1]=new Popup.PopSpinLevel.Cell;this._cells[2]=new Popup.PopSpinLevel.Cell;this._cells[3]=new Popup.PopSpinLevel.Cell;for(a=0;4>a;a++){var b=this._cells[a];
b.setPosition(-172+115*a,-12);this.addChild(b)}this._levelId=User.getScratch().getLevel();0!=this._levelId?this.startSpin(this._levelId,!1):(a=User.getScoreById(0).getSize(),this._levelId=User.getScratch().newLevel(a),this.startSpin(this._levelId,!0))},startSpin:function(a,b){for(var c=0;4>c;c++){var d=this._cells[c].getContainer();d.mode="spin";d.swap=2*c+10;d.val=CUtils.random(0,9);var e=parseInt(a/Math.pow(10,3-c)%10);e=new cc.Sprite(Resource.POP.num("a",b?0:e));d.addChild(e)}b?this.schedule(this.updateSpin.bind(this,
a),.01,cc.REPEAT_FOREVER,1,"spin_update"):this.completeSpin()},sleepSpin:function(a){this._runLayer.isVisible()&&(this.unscheduleAllCallbacks(),this.startSpin(this._levelId,!0))},updateSpin:function(a){if(this._runLayer.isVisible())for(var b=0;4>b;b++){var c=this._cells[b].getContainer();var d=c.getChildrenCount();if(0<c.swap&&3>d){b==this._column_spin&&c.swap--;var e=new cc.Sprite(Resource.POP.num("a",parseInt(0==c.swap?a/Math.pow(10,3-b)%10:c.val%10)));e.setPositionY(c.getChildren()[d-1].getPositionY()+
80);c.addChild(e);c.val++}1<d&&(d=c.getChildren()[0],-110>d.getPositionY()+c.getPositionY()&&d.removeFromParent(),1==c.getChildrenCount()&&(c.mode="back",this._column_spin=Math.min(3,this._column_spin+1)));"spin"==c.mode?c.setPositionY(c.getPositionY()-2*b-10):"back"==c.mode&&(d=c.getChildren()[0],0>d.getPositionY()+c.getPositionY()?c.setPositionY(c.getPositionY()+6):(c.mode="",c.setPositionY(-d.getPositionY()),3==b&&this.completeSpin()))}else this.unscheduleAllCallbacks(),this.schedule(this.sleepSpin.bind(this,
a),.01,cc.REPEAT_FOREVER,0,"spin_sleep")},completeSpin:function(){this.unschedule(this.updateSpin);this._btPlay.setVisible(!0)},clickPlay:function(){this.close();var a={};a.level=Map.Utils.getLevel(0,this._levelId);a.mapId=0;a.keys=User.getScoreById(0).getKey(this._levelId);Popup.PopBeginLevel.show(a)}});Popup.PopSpinLevel.show=function(a,b,c,d){(new Popup.PopSpinLevel(a)).show(b,c,d)};
Popup.PopSpinLevel.Cell=cc.Sprite.extend({_mask:null,_container:null,ctor:function(){this._super(Resource.POP.img("078"));var a=this.getContentSize();this._mask=new cc.ClippingNode(new cc.Sprite(Resource.POP.img("078")));this._mask.setPosition(.5*a.width,.5*a.height);this.addChild(this._mask);this._container=new cc.Node;this._mask.addChild(this._container);a=new cc.Sprite(Resource.POP.img("079"));a.setPosition(this._mask.getPosition());this.addChild(a)},getContainer:function(){return this._container}});Popup.PopScratchCard=Popup.PopBase.extend({_ext:null,_btClaim:null,_scratch:null,_items:null,_prise:0,ctor:function(a){this._super(a);this._size=new cc.Size(460,450);this._hasClose=this._touchOn=!1;this._items=[];this._prise=0},build:function(){this._super();var a=new cc.Sprite(Resource.POP.img("081"));a.setPosition(0,158);this.addChild(a);this._btClaim=new CButton(Resource.POP.bt("green_0"),null,{b:.05},{b:-.15});this._btClaim.setText(Lang.getString(Lang.POP_SCRATCH_CARD_BT_CLAIM),20,1);this._btClaim.setPosition(0,
-170);this._btClaim.setCbUp(this.givePrise.bind(this));this._btClaim.setVisible(!1);this.addChild(this._btClaim);a=new Popup.PopScratchCard.Scratch(this.scratchComplete.bind(this));a.setPosition(0,-18);this.addChild(a);this._prise=this.getPrise();for(this._items.push(new Popup.PopScratchCard.Prise(this._prise),new Popup.PopScratchCard.Prise(this._prise),new Popup.PopScratchCard.Prise(this._prise));6>this._items.length;){var b=CUtils.random(8,12);b!=this._items[0].getPriseId()&&b!=this._items[this._items.length-
1].getPriseId()&&this._items.push(new Popup.PopScratchCard.Prise(b))}this._items=CUtils.shuffleArray(this._items);for(b=0;b<this._items.length;b++){var c=105*parseInt(b%3)+63,d=105*parseInt(b/3)+70,e=this._items[b];e.setPosition(c,d);a.addChild(e)}},getPrise:function(){var a=Math.round(9999*Math.random())+1;if(100>=a)return 9;if(100<a&&200>=a)return 10;a=Math.round(9999*Math.random())+1;return 1>=a?8:1<a&&50>=a?7:50<a&&1E3>=a?6:1E3<a&&5E3>=a?5:4},givePrise:function(){switch(this._prise){case 1:Backend.putCoins(100,
this.close.bind(this));break;case 2:Backend.putCoins(200,this.close.bind(this));break;case 3:Backend.putCoins(500,this.close.bind(this));break;case 4:Backend.putCoins(1E3,this.close.bind(this));break;case 5:Backend.putCoins(2E3,this.close.bind(this));break;case 6:Backend.putCoins(5E3,this.close.bind(this));break;case 7:Backend.putCoins(1E4,this.close.bind(this));break;case 8:Backend.putCoins(1E5,this.close.bind(this));break;case 9:Backend.purchase({productId:Products.IDS.PK_CASH5,currency:Products.CURRENCY.COINS,
discountId:"scratch_card"},this.getInstanceId(),"pop_scratch_card");this.close();break;case 10:Backend.purchase({productId:Products.IDS.PR_IMMORTALITY,currency:Products.CURRENCY.COINS,discountId:"scratch_card"},this.getInstanceId(),"pop_scratch_card"),this.close()}this._prise=0},scratchComplete:function(){this._btClaim.setVisible(!0);for(var a in this._items){var b=this._items[a];b.getPriseId()==this._prise&&b.anim()}}});
Popup.PopScratchCard.show=function(a,b,c,d){(new Popup.PopScratchCard(a)).show(b,c,d)};
Popup.PopScratchCard.Scratch=cc.Sprite.extend({_wsize:null,_eraser:null,_scratch:null,_dots:null,_touchOn:!1,_complete:null,ctor:function(a){this._super(Resource.POP.img("082"));this._wsize=cc.director.getWinSize();this._dots=[];this._touchOn=!1;this._complete=a;a=new cc.Sprite(Resource.POP.img("083"));var b=a.getContentSize();a.setScale(this._wsize.width/b.width,this._wsize.height/b.height);a.setAnchorPoint(0,0);this._scratch=new cc.RenderTexture(b.width,b.height);this._scratch.setPosition(.5*b.width,
.5*b.height);this._scratch.begin();a.visit();this._scratch.end();this.addChild(this._scratch,100);this._eraser=new cc.Sprite(Resource.POP.img("119"));this._eraser.setScaleY(this._wsize.width/this._wsize.height);this._eraser.setBlendFunc(cc.ZERO,cc.ONE_MINUS_SRC_ALPHA);for(a=0;48>a;a++)b=new cc.Point(38*parseInt(a%8)+35,33*parseInt(a/8)+38),this._dots.push(b);cc.eventManager.addListener({event:cc.EventListener.MOUSE,onMouseMove:this.mouseMove.bind(this),onMouseDown:this.mouseDown.bind(this),onMouseUp:this.mouseUp.bind(this)},
this)},erase:function(a){for(var b=this._dots.length-1;0<=b;b--)30>CUtils.distance(this._dots[b],a)&&this._dots.splice(b,1);this._dots&&0==this._dots.length&&this._complete&&(this._complete(),this._complete=null);a.x*=this._wsize.width/this.getContentSize().width;a.y*=this._wsize.height/this.getContentSize().height;this._scratch.begin();this._eraser.setPosition(a);this._eraser.visit();this._scratch.end()},mouseDown:function(a){CUtils.onTouch(a,this,!0)&&(AudioEngine.playEffect(Resource.SND.CLICK),
this._touchOn=!0,this.erase(this.convertToNodeSpace(a.getLocation())))},mouseMove:function(a){this._touchOn&&this.erase(this.convertToNodeSpace(a.getLocation()))},mouseUp:function(a){this._touchOn=!1}});
Popup.PopScratchCard.Prise=cc.Node.extend({_priseId:0,_icon:null,ctor:function(a){this._super();this._priseId=a;this._icon=this.getIcon(a);this._icon.setPosition(5,10);this.addChild(this._icon,1)},getPriseId:function(){return this._priseId},getIcon:function(a){switch(a-1){case 0:return new cc.Sprite(Resource.POP.img("086"));case 1:return new cc.Sprite(Resource.POP.img("087"));case 2:return new cc.Sprite(Resource.POP.img("088"));case 3:return new cc.Sprite(Resource.POP.img("089"));case 4:return new cc.Sprite(Resource.POP.img("090"));
case 5:return new cc.Sprite(Resource.POP.img("091"));case 6:return new cc.Sprite(Resource.POP.img("092"));case 7:return new cc.Sprite(Resource.POP.img("093"));case 8:return new cc.Sprite(Resource.POP.img("094"));case 9:return new cc.Sprite(Resource.POP.img("095"));case 10:return new cc.Sprite(Resource.POP.img("096"));case 11:return new cc.Sprite(Resource.POP.img("097"))}},anim:function(){var a=new cc.Sprite(Resource.POP.img("085"));a.runAction(new cc.RepeatForever(new cc.Sequence(new cc.RotateTo(1,
180),new cc.RotateTo(1,360))));this.addChild(a,0);this._icon.runAction(new cc.RepeatForever(new cc.Sequence(new cc.ScaleTo(.5,1.1),new cc.ScaleTo(.5,.9))))}});Popup.PopChallenge=Popup.PopBase.extend({_mode:null,_id:null,_levelId:null,ctor:function(a){this._super(a);this._mode=this._args.mode;this._id=this._args.id||0;this._levelId=this._args.levelId||0;this._size=new cc.Size(460,"start"==this._mode?555:380)},build:function(){"start"==this._args.mode?(this._super(),this.buildModeStart()):"open"==this._args.mode?(this._hasClose=!1,this._super(),this.buildModeOpen()):"claim"==this._args.mode&&(this._hasClose=!1,this._super(),this.buildModeClaim());var a=new cc.Sprite(Resource.POP.img("004"));
a.setPosition(0,.5*this._size.height+3);this.addChild(a,1);a=new CLabelTTF(Lang.getString(Lang.POP_CHALLENGE_TITLE),26,a.getContentSize().width-70,2);a.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);a.setPosition(0,.5*this._size.height+2);this.addChild(a,1)},buildModeStart:function(){var a=new cc.Sprite(Resource.POP.img("098"));a.setPosition(-20,-65);this.addChild(a);a=new cc.Sprite(Resource.POP.img("099"));a.setPosition(87,-60);this.addChild(a);a=new cc.Sprite(Resource.POP.img("100"));
a.setScale(.8);a.setRotation(-21);a.setPosition(-79,160);this.addChild(a);a=new cc.Sprite(Resource.POP.img("101"));a.setScale(.8);a.setRotation(23);a.setPosition(81,160);this.addChild(a);a=new cc.Sprite(Resource.POP.img("102"));a.setScale(.9);a.setPosition(-13,64);this.addChild(a);a=new CLabelTTF(Lang.getString(Lang.POP_CHALLENGE_MSG0),30,this._size.width-70,1);a.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);a.setPosition(0,-155);this.addChild(a);a=new CLabelTTF("00:00:00",
26,150,1);a.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);a.setPosition(-30,-68);a.runAction(new cc.RepeatForever(new cc.Sequence([new cc.CallFunc(function(){var a=User.getTreasure().getExpired()-TimeUtils.getTime();this.setString(CUtils.getStringTime(a))},a),new cc.DelayTime(1)])));this.addChild(a);a=new CButton(Resource.POP.bt("green_0"),null,{b:.05},{b:-.15});a.setText(Lang.getString(Lang.POP_CHALLENGE_BT_CONTINUE),20,1);a.setPosition(0,-225);a.setCbUp(this.close.bind(this));
this.addChild(a)},buildModeOpen:function(){var a=new cc.Sprite(Resource.POP.img(0==this._id?"100":1==this._id?"101":"102"));a.setPosition(0,22);this.addChild(a);a=new CButton(Resource.POP.bt("green_0"),null,{b:.05},{b:-.15});a.setText(Lang.getString(Lang.POP_CHALLENGE_BT_OPEN),20,1);a.setPosition(0,-133);a.setCbUp(this.close.bind(this));this.addChild(a)},buildModeClaim:function(){var a=new cc.Sprite(Resource.POP.img("103"));a.setPosition(1,4);this.addChild(a);0==this._id?(a=new cc.Sprite(Resource.POP.img("104")),
a.setPosition(6,54),this.addChild(a),a=new cc.Sprite(Resource.POP.img("094")),a.setPosition(-75,-30),this.addChild(a),a=new cc.Sprite(Resource.POP.img("090")),a.setPosition(100,-35),this.addChild(a)):1==this._id?(a=new cc.Sprite(Resource.POP.img("105")),a.setPosition(6,54),this.addChild(a),a=new cc.Sprite(Resource.POP.img("107")),a.setPosition(-90,-30),this.addChild(a),a=new cc.Sprite(Resource.POP.img("091")),a.setPosition(100,25),this.addChild(a)):2==this._id&&(a=new cc.Sprite(Resource.POP.img("106")),
a.setPosition(6,54),this.addChild(a),a=new cc.Sprite(Resource.POP.img("108")),a.setPosition(-90,-35),this.addChild(a),a=new cc.Sprite(Resource.POP.img("092")),a.setPosition(105,-25),this.addChild(a));a=new CButton(Resource.POP.bt("green_0"),null,{b:.05},{b:-.15});a.setText(Lang.getString(Lang.POP_CHALLENGE_BT_CLAIM),20,1);a.setPosition(0,-133);a.setCbUp(this.clickClaim.bind(this));this.addChild(a)},clickClaim:function(){var a=this;Backend.saveTreasure([this._levelId],1,0,function(b){b&&(User.getTreasure().givePrise(a._levelId),
0==a._id?Backend.purchase({productId:Products.IDS.PK_CASH5,currency:Products.CURRENCY.COINS,discountId:"challenge"},null,"pop_challenge"):1==a._id?Backend.purchase({productId:Products.IDS.PK_CASH10,currency:Products.CURRENCY.COINS,discountId:"challenge"},null,"pop_challenge"):2==a._id&&Backend.purchase({productId:Products.IDS.PK_CASH20,currency:Products.CURRENCY.COINS,discountId:"challenge"},null,"pop_challenge"));a.close()})}});
Popup.PopChallenge.show=function(a,b,c,d){(new Popup.PopChallenge(a)).show(b,c,d)};Popup.PopTutorial=Popup.PopBase.extend({_mask:null,_node:null,ctor:function(a){this._super(a);this._size=new cc.Size(500,360)},build:function(){this._super();this.removeAllChildren();this._mask=new cc.RenderTexture(760,650);this._mask.clear(0,0,0,255*.86);this._mask.setOpacity(220);this._mask.setVisible(!1);var a=new cc.Sprite(Resource.POP.img("119"));a.setScale(2.5,1.5);a.setRotation(-2);a.setBlendFunc(cc.ZERO,cc.ONE_MINUS_SRC_ALPHA);a.setPosition(410,630);this._mask.begin();a.visit();this._mask.end();
this.addChild(this._mask);this._mask.runAction(new cc.Sequence(new cc.DelayTime(.2),new cc.Show,new cc.FadeTo(.2,255)));this._runLayer.getBack().runAction(new cc.Sequence(new cc.DelayTime(.2),new cc.Hide));this._node=new cc.Node;this._node.setCascadeOpacityEnabled(!0);this._node.addChild(new cc.Sprite(Resource.UI.img("007")),1);this._node.setPosition(-220,140);a=new CLabelTTF(Lang.getString(Lang.POP_TUTORIAL_MSG(0)),22,450,1);a.setAlignment(cc.TEXT_ALIGNMENT_LEFT,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);
a.setAnchorPoint(0,.5);a.setPosition(70,0);var b=new CLabelTTF(Lang.getString(Lang.POP_TUTORIAL_CLOSE),18,450,2);b.setAlignment(cc.TEXT_ALIGNMENT_LEFT,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);b.setAnchorPoint(0,.5);b.setPosition(370,.5*-a.getContentSize().height-30);var c=new cc.Sprite(Resource.UI.img("008"));c.setPosition(240,.5*-a.getContentSize().height-10);var d=new cc.Sprite(Resource.UI.img("008"));d.setPosition(240,.5*a.getContentSize().height+10);this._node.addChild(a);this._node.addChild(b);this._node.addChild(c);
this._node.addChild(d);this.addChild(this._node);cc.eventManager.addListener({event:cc.EventListener.MOUSE,onMouseUp:this.mouseClick.bind(this)},this)},mouseClick:function(a){this._runLayer.isVisible()&&(AudioEngine.playEffect(Resource.SND.CLICK),this._mask.runAction(new cc.FadeTo(.1,0)),this._node.runAction(new cc.FadeTo(.3,0)),this.close())}});Popup.PopTutorial.show=function(a,b,c,d){(new Popup.PopTutorial(a)).show(b,c,d)};Popup.PopAdventureReward=Popup.PopBase.extend({ctor:function(a){this._super(a);this._size=new cc.Size(420,525)},build:function(){this._super();var a=new cc.Sprite(Resource.POP.img("074"));a.setScale(.84);a.setPosition(0,50);this.addChild(a);a=new cc.Sprite(Resource.MAP.ADV.building_reward(this._args.mapId));a.setPosition(0,20);this.addChild(a);a=new cc.Sprite(Resource.POP.img("122"));a.setPosition(-136,-153);this.addChild(a);a=new CLabelTTF(Lang.getString(Lang.POP_ADVENTURE_REWARD_TITLE),30,this._size.width-
100,2);a.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);a.setPosition(0,203);this.addChild(a);a=new CLabelTTF(Lang.getString(Lang.POP_ADVENTURE_REWARD_MSG,app.config.rewardAdventure()),30,270,2);a.setAlignment(cc.TEXT_ALIGNMENT_LEFT,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);a.setPosition(23,-160);this.addChild(a);a=new CButton(Resource.POP.bt("green_0"),null,{b:.05},{b:-.15});a.setText(Lang.getString(Lang.POP_BEAT_BT_CONTINUE),20,1);a.setPosition(0,-214);a.setCbUp(this.close.bind(this));
this.addChild(a);this.setOnClose(function(){Backend.putCoins(app.config.rewardAdventure())})}});Popup.PopAdventureReward.show=function(a,b,c,d){(new Popup.PopAdventureReward(a)).show(b,c,d)};Popup.PopAccountDeletion=Popup.PopBase.extend({ctor:function(a){this._super(a);this._size=new cc.Size(467,370);this._hasClose=!1},build:function(){this._super();var a=TimeUtils.getTime(!1),b=User.getScheduledRemoval();a=TimeUtils.getDays(Math.max(b-a,0));var c=new cc.Sprite(Resource.POP.img("004"));c.setPosition(0,.5*this._size.height+3);this.addChild(c,1);c=new CLabelTTF(Lang.getString(Lang.POP_ACCOUNT_DELETION_TITLE),26,c.getContentSize().width-70,2);c.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);
c.setPosition(0,.5*this._size.height+2);this.addChild(c,1);a=new CLabelTTF(Lang.getString(Lang.POP_ACCOUNT_DELETION_MSG0,a+1),30,this._size.width-70,2);a.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);a.setPosition(0,75);this.addChild(a);b=TimeUtils.formatDate(new Date(1E3*b),"MM/dd/yyyy");b=new CLabelTTF(Lang.getString(Lang.POP_ACCOUNT_DELETION_MSG1,b),30,this._size.width-70,2);b.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);b.setPosition(0,-40);
this.addChild(b);b=new CButton(Resource.POP.bt("green_0"),null,{b:.05},{b:-.15});b.setText(Lang.getString(Lang.POP_ACCOUNT_DELETION_BT_CONTINUE),20,1);b.setPosition(-100,-127);b.setCbUp(this.close.bind(this));this.addChild(b);b=new CButton(Resource.POP.bt("reed"),null,{b:.05},{b:-.15});b.setText(Lang.getString(Lang.POP_ACCOUNT_DELETION_BT_CANCEL),20,1);b.setPosition(100,-127);b.setCbUp(this.onCancelDeletion.bind(this));this.addChild(b)},onCancelDeletion:function(){Backend.scheduledRemoval(0);this.close()}});
Popup.PopAccountDeletion.show=function(a,b,c,d){(new Popup.PopAccountDeletion(a)).show(b,c,d)};Popup.PopChallengeStart=Popup.PopBase.extend({ctor:function(a){this._super(a);this._size=new cc.Size(460,580);this._moveTo=new cc.Point(.5*this._wSize.width,.5*this._wSize.height-10)},build:function(){this._super();var a=this,b=new cc.Sprite(Resource.POP.img("004"));b.setPosition(0,.5*this._size.height+3);this.addChild(b,1);b=new CLabelTTF(Lang.getString(Lang.POP_WEEKLY_CHALLENGE_START_TITLE),26,b.getContentSize().width-70,2);b.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);
b.setPosition(0,.5*this._size.height+2);this.addChild(b,1);var c=new cc.Sprite(Resource.WEEKLY_CHALLENGE.img("pop/snote"));c.setPosition(0,120);this.addChild(c);b=[cc.spriteFrameCache.getSpriteFrame(Resource.WEEKLY_CHALLENGE.img("pop/snote_anim",0)),cc.spriteFrameCache.getSpriteFrame(Resource.WEEKLY_CHALLENGE.img("pop/snote_anim",1)),cc.spriteFrameCache.getSpriteFrame(Resource.WEEKLY_CHALLENGE.img("pop/snote_anim",2)),cc.spriteFrameCache.getSpriteFrame(Resource.WEEKLY_CHALLENGE.img("pop/snote_anim",
3))];var d=new cc.Sprite(b[0]);d.runAction(new cc.RepeatForever(new cc.Animate(new cc.Animation(b,.28))));d.setPosition(155,195);c.addChild(d);cc.loader.load("particle/weekly_challenge_start.plist",function(b,d){if(!b){var e=new cc.ParticleSystem("particle/weekly_challenge_start.plist");e.setPosition(c.getPosition());a.addChild(e,100)}});b=new cc.Sprite(Resource.POP.img("124"));b.setScaleX((this._size.width-36)/b.getContentSize().width);b.setPosition(0,-45);this.addChild(b);b=new CLabelTTF(Lang.getString(Lang.POP_WEEKLY_CHALLENGE_START_MSG),
28,400,2);b.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);b.setPosition(0,-45);this.addChild(b);b=new cc.Sprite(Resource.POP.img("098"));b.setPosition(-20,-155);this.addChild(b);b=new cc.Sprite(Resource.POP.img("099"));b.setPosition(87,-150);this.addChild(b);b=new CLabelTTF("00:00:00",26,150,1);b.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);b.setPosition(-30,-158);b.runAction(new cc.RepeatForever(new cc.Sequence([new cc.CallFunc(function(){this.setString(CUtils.getStringTime(User.getChallenge().getLeftTime()))},
b),new cc.DelayTime(1)])));this.addChild(b);b=new CButton(Resource.POP.bt("green_0"),null,{b:.05},{b:-.15});b.setText(Lang.getString(Lang.POP_WEEKLY_CHALLENGE_START_BT_PLAY),20,1);b.setPosition(0,-235);b.setCbUp(function(){a.close();app.loadChallenge()});this.addChild(b)}});Popup.PopChallengeStart.show=function(a,b,c,d){(new Popup.PopChallengeStart(a)).show(b,c,d)};Popup.PopChallengeReward=Popup.PopBase.extend({ctor:function(a){this._super(a);this._size=new cc.Size(460,380);this._hasClose=!1},build:function(){this._super();var a=this,b=new cc.Sprite(Resource.WEEKLY_CHALLENGE.img("pop/decor"));b.setScaleX((this._size.width-36)/b.getContentSize().width);b.setScaleY((this._size.height-36)/b.getContentSize().height);b.setPosition(0,0);this.addChild(b);b=new cc.Sprite(Resource.POP.img("004"));b.setPosition(0,.5*this._size.height+3);this.addChild(b,1);b=new CLabelTTF(Lang.getString(Lang.POP_WEEKLY_CHALLENGE_REWARD_TITLE),
26,b.getContentSize().width-70,2);b.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);b.setPosition(0,.5*this._size.height+2);this.addChild(b,1);b=new cc.Sprite(Resource.POP.img("103"));b.setPosition(1,4);this.addChild(b);var c=new cc.Sprite(Resource.WEEKLY_CHALLENGE.img("pop/prize"));c.setPosition(0,35);this.addChild(c);cc.loader.load("particle/weekly_challenge_start.plist",function(b,e){if(!b){var d=new cc.ParticleSystem("particle/weekly_challenge_start.plist");d.setPosition(c.getPosition());
a.addChild(d,100)}});b=new CButton(Resource.POP.bt("green_0"),null,{b:.05},{b:-.15});b.setText(Lang.getString(Lang.POP_WEEKLY_CHALLENGE_REWARD_BT_CLAIM),20,1);b.setPosition(0,-133);b.setCbUp(function(){Backend.purchase({productId:Products.IDS.PK_CASH20,currency:Products.CURRENCY.COINS,discountId:"bf_challenge"},null,"pop_weekly_challenge_reward");a.close()});this.addChild(b)}});Popup.PopChallengeReward.show=function(a,b,c,d){(new Popup.PopChallengeReward(a)).show(b,c,d)};Popup.PopChallengeExpired=Popup.PopBase.extend({ctor:function(a){this._super(a);this._size=new cc.Size(460,580);this._moveTo=new cc.Point(.5*this._wSize.width,.5*this._wSize.height-10)},build:function(){this._super();var a=this,b=new cc.Sprite(Resource.POP.img("004"));b.setPosition(0,.5*this._size.height+3);this.addChild(b,1);b=new CLabelTTF(Lang.getString(Lang.POP_WEEKLY_CHALLENGE_EXPIRED_TITLE),26,b.getContentSize().width-70,2);b.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);
b.setPosition(0,.5*this._size.height+2);this.addChild(b,1);var c=new cc.Sprite(Resource.WEEKLY_CHALLENGE.img("pop/snote"));c.setPosition(0,120);this.addChild(c);b=[cc.spriteFrameCache.getSpriteFrame(Resource.WEEKLY_CHALLENGE.img("pop/snote_anim",0)),cc.spriteFrameCache.getSpriteFrame(Resource.WEEKLY_CHALLENGE.img("pop/snote_anim",1)),cc.spriteFrameCache.getSpriteFrame(Resource.WEEKLY_CHALLENGE.img("pop/snote_anim",2)),cc.spriteFrameCache.getSpriteFrame(Resource.WEEKLY_CHALLENGE.img("pop/snote_anim",
3))];var d=new cc.Sprite(b[0]);d.runAction(new cc.RepeatForever(new cc.Animate(new cc.Animation(b,.28))));d.setPosition(155,195);c.addChild(d);cc.loader.load("particle/weekly_challenge_start.plist",function(b,d){if(!b){var e=new cc.ParticleSystem("particle/weekly_challenge_start.plist");e.setPosition(c.getPosition());a.addChild(e,100)}});b=new CLabelTTF(Lang.getString(Lang.POP_WEEKLY_CHALLENGE_EXPIRED_MSG),42,400,10);b.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);b.setPosition(0,
-95);this.addChild(b);b=new CButton(Resource.POP.bt("green_0"),null,{b:.05},{b:-.15});b.setText(Lang.getString(Lang.POP_WEEKLY_CHALLENGE_EXPIRED_BT_PLAY),24,1);b.setPosition(0,-235);b.setCbUp(function(){a.close()});this.addChild(b)}});Popup.PopChallengeExpired.show=function(a,b,c,d){(new Popup.PopChallengeExpired(a)).show(b,c,d)};Popup.OrbSmall=cc.Node.extend({_item:null,_cbClick:null,_ext:null,_sound:null,ctor:function(){this._super();this._ext=new CExtNode(this);this._sound=Resource.SND.CLICK;this.updateContent();this._ext.addCustomListener(User.EVENT.UPDATE_ORB,this.eventHandler.bind(this))},setSound:function(a){this._sound=a},setItem:function(a){this._item=a;this.updateContent()},getItem:function(){return this._item},eventHandler:function(a){var b=a.getEventName();a=a.getUserData()||{};b==User.EVENT.UPDATE_ORB&&a.orb==
this._item&&this.updateContent()},updateContent:function(){this.removeAllChildren();if(this._item){var a=new CButton(Resource.POP.orb("back_on"),{b:0},{b:.08});a.setSound(this._sound);var b=new cc.Sprite(Resource.POP.orb(this._item.getId()));b.setPosition(.5*a.getContentSize().width,.5*a.getContentSize().height);a.addChild(b);a.setScale(.39);a.setCbDown(this.onClick.bind(this));this.addChild(a);if(this._item.isBought())b=new CLabelTTF(Lang.getString(Lang.ORB_LB_BOUGHT),18,74,4),b.setAlignment(cc.TEXT_ALIGNMENT_CENTER,
cc.VERTICAL_TEXT_ALIGNMENT_CENTER),b.setPosition(0,-50),this.addChild(b);else{b=Products.getProduct(this._item.getId());a=this._item.getDiscount();a=b.getPrice([Products.CURRENCY.CASH,Products.CURRENCY.COINS],a);a.getCurrency()==Products.CURRENCY.CASH?b=new cc.Sprite(Resource.POP.currency("cash_0")):(b=new cc.Sprite(Resource.POP.currency("coin_0")),b.setScale(.6));a=new CLabelTTF(Number(a.getAmount()),18,0,2);a.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);var c=b.getContentSize().width*
b.getScale()+a.getContentSize().width+6;b.setPosition(.5*-c+b.getContentSize().width*b.getScale()*.5,-50);a.setPosition(b.getPositionX()+.5*b.getContentSize().width*b.getScale()+.5*a.getContentSize().width+4,b.getPositionY()-1);this.addChild(b);this.addChild(a);this._item.hasDiscount()&&(b=new cc.Sprite(Resource.POP.img("076")),b.setPosition(26,8),this.addChild(b))}}else this.addChild(new cc.Sprite(Resource.POP.orb("back_off")))},setClick:function(a){this._cbClick=a},onClick:function(){this._cbClick&&
this._cbClick()}});Popup.OrbBig=cc.Node.extend({_item:null,_ext:null,ctor:function(){this._super();this._ext=new CExtNode(this);this.updateContent();this._ext.addCustomListener(User.EVENT.UPDATE_ORB,this.eventHandler.bind(this))},eventHandler:function(a){var b=a.getEventName();a=a.getUserData()||{};b==User.EVENT.UPDATE_ORB&&a.orb==this._item&&this.updateContent()},setItem:function(a){this._item=a;this.updateContent()},updateContent:function(){this.removeAllChildren();if(this._item){var a=new cc.Sprite(Resource.POP.orb("back_on"));
a.setScale(.87);var b=new cc.Sprite(Resource.POP.orb(this._item.getId()));var c=new CLabelTTF(Lang.getString(Lang.ORB_NAME(this._item.getId())),24,200,2);c.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);c.setAnchorPoint(.5,1);c.setPosition(0,125);this.addChild(a);this.addChild(b,1);this.addChild(c);this._item.isBought()||(b=Products.getProduct(this._item.getId()),a=this._item.getDiscount(),a=b.getPrice([Products.CURRENCY.CASH,Products.CURRENCY.COINS],a),a.getCurrency()==
Products.CURRENCY.CASH?b=new cc.Sprite(Resource.POP.currency("cash_0")):(b=new cc.Sprite(Resource.POP.currency("coin_0")),b.setScale(.6)),a=new CLabelTTF(Number(a.getAmount()),22,0,2),a.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER),c=b.getContentSize().width*b.getScale()+a.getContentSize().width+20,b.setPosition(.5*-c+b.getContentSize().width*b.getScale()*.5,-105),a.setPosition(b.getPositionX()+.5*b.getContentSize().width*b.getScale()+.5*a.getContentSize().width+10,b.getPositionY()),
this.addChild(b),this.addChild(a),this._item.hasDiscount()&&(b=new cc.Sprite(Resource.POP.img("077")),b.setPosition(74,27),this.addChild(b,2)))}}});Popup.CheckBox=cc.Sprite.extend({_mark:null,ctor:function(a){this._super(Resource.POP.img("033"));this._mark=new cc.Sprite(Resource.POP.img("034"));this._mark.setPosition(14,16);this._mark.setVisible(a);this.addChild(this._mark)},setValue:function(a){this._mark.setVisible(a)},getValue:function(){return this._mark.isVisible()}});Popup.ScrollBar=cc.Node.extend({_middle:null,_arrowBottom:null,_arrowTop:null,_dragDrop:null,_touch:null,_touchDeltaY:0,_minY:0,_maxY:0,_value:0,_cbValueChanged:null,ctor:function(a){this._super();this._touch=null;this._touchDeltaY=0;this._minY=70;this._maxY=a-this._minY-2;this._value=0;this._middle=new cc.Sprite(Resource.POP.img("035"));this._dragDrop=new cc.Sprite(Resource.POP.img("036"));this._arrowBottom=new cc.Sprite(Resource.POP.img("037"));this._arrowTop=new cc.Sprite(Resource.POP.img("037"));
this._arrowBottom.setFlippedY(!0);this._arrowBottom.setAnchorPoint(.5,0);this._arrowBottom.setPosition(13,0);this._arrowTop.setAnchorPoint(.5,1);this._arrowTop.setPosition(13,a);this._middle.setPosition(12.5,.5*a);this._middle.setScaleY((a-30)/this._middle.getContentSize().height);this._dragDrop.setPosition(12.5,.5*a);this.addChild(this._middle);this.addChild(this._arrowBottom);this.addChild(this._arrowTop);this.addChild(this._dragDrop);cc.eventManager.addListener({event:cc.EventListener.MOUSE,onMouseMove:this.mouseMove.bind(this),
onMouseDown:this.mouseDown.bind(this),onMouseUp:this.mouseUp.bind(this)},this);this.setValue(0)},setValue:function(a){this._touch||this._moveTo(a)},getValue:function(){return this._value},setCbValueChanged:function(a){this._cbValueChanged=a},_moveTo:function(a){this._value=Math.max(0,Math.min(1,a));this._cbValueChanged&&this._touch&&this._cbValueChanged(this._value);this._dragDrop.setPositionY(this._maxY-(this._maxY-this._minY)*this._value)},mouseMove:function(a){this._touch==this._dragDrop&&(a.stopPropagation(),
a=this.convertToNodeSpace(a.getLocation()),this._moveTo((this._maxY-Math.min(Math.max(this._touchDeltaY+a.y,this._minY),this._maxY))/(this._maxY-this._minY)))},mouseDown:function(a){CUtils.onTouch(a,this._dragDrop,!0)?(AudioEngine.playEffect(Resource.SND.CLICK),this._touch=this._dragDrop,this._touchDeltaY=this._dragDrop.getPositionY()-this.convertToNodeSpace(a.getLocation()).y):CUtils.onTouch(a,this._arrowBottom,!0)?(AudioEngine.playEffect(Resource.SND.CLICK),this._touch=this._arrowBottom):CUtils.onTouch(a,
this._arrowTop,!0)&&(AudioEngine.playEffect(Resource.SND.CLICK),this._touch=this._arrowTop)},mouseUp:function(a){CUtils.onTouch(a,this._arrowBottom,!0)&&this._touch==this._arrowBottom?this._moveTo(this._value+.1):CUtils.onTouch(a,this._arrowTop,!0)&&this._touch==this._arrowTop&&this._moveTo(this._value-.1);this._touch=null}});var PanelUp=cc.Sprite.extend({_ext:null,_heart:null,_coins:null,_cash:null,_shop:null,_inbox:null,_notif:null,ctor:function(){this._super(Resource.UI.panel_up);this._ext=new CExtNode(this);this._ext.stopMouseEvent();this._ext.addCustomListener(User.EVENT.UPDATE_CASH,this.eventHandler.bind(this));this._ext.addCustomListener(User.EVENT.UPDATE_COINS,this.eventHandler.bind(this));this._ext.addCustomListener(User.EVENT.UPDATE_LIVE,this.eventHandler.bind(this));this._ext.addCustomListener(User.EVENT.UPDATE_INBOX,
this.eventHandler.bind(this));var a=this.getContentSize(),b=cc.director.getWinSize();this.setAnchorPoint(0,1);this.setPosition(0,b.height);this._heart=new PanelUp.Heart(User.getLive());this._shop=new CButton(Resource.UI.bt("yellow"),null,{b:.1},{b:-.15});this._shop.setText(Lang.getString(Lang.UI_BT_SHOP),20,3);this._shop.setCbDown(Popup.PopShop.show);this._inbox=new CButton(Resource.UI.bt("yellow"),null,{b:.1},{b:-.15});this._inbox.setText(Lang.getString(Lang.UI_BT_INBOX),20,3);this._inbox.setCbUp(Popup.PopInbox.show);
this._notif=new PanelUp.Notif(User.getInbox().getSize());this._coins=new PanelUp.Coins(User.getCoins().getValue());this._cash=new PanelUp.Cash(User.getCash().getValue());this._heart.setPosition(.5*a.width,23);this._shop.setPosition(56,39);this._inbox.setPosition(689,this._shop.getPositionY());this._notif.setPosition(726,50);this._coins.setPosition(273,this._shop.getPositionY());this._cash.setPosition(162,this._shop.getPositionY());this.addChild(this._coins);this.addChild(this._cash);this.addChild(this._heart);
this.addChild(this._shop);this.addChild(this._inbox);this.addChild(this._notif)},eventHandler:function(a){a.getEventName()==User.EVENT.UPDATE_COINS?this._coins.setValue(a.getUserData()):a.getEventName()==User.EVENT.UPDATE_CASH?this._cash.setValue(a.getUserData()):a.getEventName()==User.EVENT.UPDATE_LIVE?this._heart.update(a.getUserData()):a.getEventName()==User.EVENT.UPDATE_INBOX&&this._notif.setValue(User.getInbox().getSize())}});
PanelUp.Notif=cc.Sprite.extend({_lb:null,ctor:function(a){this._super(Resource.UI.img("000"));var b=this.getContentSize();this._lb=new CLabelTTF("99",14,40,0,0,!0);this._lb.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);this._lb.setPosition(.5*b.width,.5*b.height-1);this.addChild(this._lb);this.setValue(a)},setValue:function(a){a=Math.min(99,a);this._lb.setString(cc.formatStr("%d",a));this.setVisible(0<a)}});
PanelUp.Heart=cc.Node.extend({_bt:null,_stencil:null,_mask:null,_number:null,_infinite:null,_tf:null,ctor:function(a){this._super();var b=new cc.Sprite(Resource.UI.panel_heart_back),c=new cc.Sprite(Resource.UI.panel_heart_front);c.setPosition(2,8);var d=new cc.Sprite(Resource.UI.panel_value_back);d.setPosition(70,16);this._tf=new CLabelTTF("00:00",16,40);this._tf.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);this._tf.setPosition(75,14);this._bt=new CButton(Resource.UI.bt("add"),
null,{b:.1},{b:-.15});this._bt.setCbUp(app.openBuyLive);this._bt.setPosition(106,6);var e=new cc.Sprite(Resource.UI.panel_heart_middle);e.setAnchorPoint(0,0);this._stencil=new cc.Sprite(Resource.UI.panel_heart_middle);this._stencil.setAnchorPoint(0,0);this._stencil.setScaleY(1);this._mask=new cc.ClippingNode(this._stencil);this._mask.setAlphaThreshold(!0);this._mask.setPosition(-34,-22);this._mask.addChild(e);this._number=new cc.Sprite(Resource.UI.panel_heart_num(0));this._number.setPosition(0,-1);
this._infinite=new cc.Sprite(Resource.UI.panel_heart_infinit);this._infinite.setPosition(0,0);this.addChild(d);this.addChild(this._tf);this.addChild(this._bt);this.addChild(b);this.addChild(this._mask);this.addChild(c);this.addChild(this._number);this.addChild(this._infinite);this.update(a)},update:function(a){if(a.hasImmortality())this._infinite.setVisible(!0),this._number.setVisible(!1),this._bt.setVisible(!1),this._stencil.setScaleY(1),this._mask.visit(),this._tf.setString(TimeUtils.formatTime(a.getImmortalityTime()));
else{var b=a.getLives(),c=a.getTotal();this._infinite.setVisible(!1);this._number.setVisible(!0);this._bt.setVisible(!0);this._number.setSpriteFrame(Resource.UI.panel_heart_num(b));this._stencil.setScaleY(b/c);this._mask.visit();this._tf.setString(TimeUtils.formatTime(a.getTimeLive()))}}});
PanelUp.Coins=cc.Sprite.extend({_bt:null,_ico:null,_lb:null,_value:null,ctor:function(a){this._super(Resource.UI.panel_value_back);this._value=a;a=this.getContentSize();this._ico=new cc.Sprite(Resource.UI.ico_coin("0"));this._ico.setPosition(5,.5*a.height);this._lb=new CLabelTTF(cc.formatStr("%d",this._value),16,this.getContentSize().width);this._lb.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);this._lb.setPosition(.5*this.getContentSize().width,.5*this.getContentSize().height);
this._bt=new CButton(Resource.UI.bt("add"),null,{b:.1},{b:-.15});this._bt.setPosition(this.getContentSize().width-5,5);this._bt.setCbUp(Popup.PopBuyCash.show);this.addChild(this._lb);this.addChild(this._bt);this.addChild(this._ico)},setValue:function(a){var b=parseInt((a-this._value)/5);-0==b?b=-1:0==b&&(b=1);this.unscheduleAllCallbacks();this.schedule(function(){if(a==this._value)this.unscheduleAllCallbacks();else if(this._value<a){this._value=Math.min(a,this._value+b);var c=new cc.Sprite(Resource.UI.ico_coin("0"));
c.setPosition(-220,-150);c.runAction(new cc.Sequence(new cc.JumpTo(.25,this._ico.getPosition(),-90,1),new cc.RemoveSelf));this.addChild(c)}else this._value=Math.max(a,this._value+b);this._lb.setString(cc.formatStr("%d",this._value))},.1,cc.REPEAT_FOREVER)}});
PanelUp.Cash=cc.Sprite.extend({_bt:null,_ico:null,_lb:null,_value:null,ctor:function(a){this._super(Resource.UI.panel_value_back);this._value=a;a=this.getContentSize();this._ico=new cc.Sprite(Resource.UI.ico_cash("0"));this._ico.setPosition(5,.5*a.height);this._lb=new CLabelTTF(cc.formatStr("%d",this._value),16,this.getContentSize().width);this._lb.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);this._lb.setPosition(.5*this.getContentSize().width,.5*this.getContentSize().height);
this._bt=new CButton(Resource.UI.bt("add"),null,{b:.1},{b:-.15});this._bt.setPosition(this.getContentSize().width-5,5);this._bt.setCbUp(Popup.PopBuyCash.show.bind(this,{active:"cash"}));this.addChild(this._lb);this.addChild(this._bt);this.addChild(this._ico)},setValue:function(a){var b=parseInt((a-this._value)/5);-0==b?b=-1:0==b&&(b=1);this.unscheduleAllCallbacks();this.schedule(function(){a==this._value?this.unscheduleAllCallbacks():this._value=this._value<a?Math.min(a,this._value+b):Math.max(a,
this._value+b);this._lb.setString(cc.formatStr("%d",this._value))},.1,cc.REPEAT_FOREVER)}});var PanelSound=cc.Sprite.extend({_mode:0,_btExit:null,_btSound:null,_btMusic:null,_musicOff:null,_soundOff:null,ctor:function(a){this._super(Resource.UI.panel_down);this._mode=a;this.setAnchorPoint(0,0);this.setPosition(0==this._mode?-53:0,0);this._btExit=new CButton(Resource.UI.bt("exit"),null,{b:.1},{b:-.15});this._btSound=new CButton(Resource.UI.bt("sound"),null,{b:.1},{b:-.15});this._btSound.setCbUp(this.clickSound.bind(this));this._btMusic=new CButton(Resource.UI.bt("music"),null,{b:.1},{b:-.15});
this._btMusic.setCbUp(this.clickMusic.bind(this));this._musicOff=new cc.Sprite(Resource.UI.bt("sound_off"));this._musicOff.setPosition(25,22);this._musicOff.setRotation(8);this._musicOff.setVisible(!User.getMusic());this._btMusic.addChild(this._musicOff);this._soundOff=new cc.Sprite(Resource.UI.bt("sound_off"));this._soundOff.setPosition(25,22);this._soundOff.setRotation(8);this._soundOff.setVisible(!User.getSound());this._btSound.addChild(this._soundOff);this._btMusic.setPosition(140,25);this._btSound.setPosition(85,
25);this._btExit.setPosition(30,25);this._btExit.setCbUp(this.clickExit.bind(this));this.addChild(this._btExit);this.addChild(this._btSound);this.addChild(this._btMusic);cc.eventManager.addListener({event:cc.EventListener.MOUSE,onMouseMove:this.stopPropagation.bind(this),onMouseDown:this.stopPropagation.bind(this)},this)},stopPropagation:function(a){var b=this.convertToNodeSpace(a.getLocation()),c=this.getContentSize();c=new cc.Rect(0,0,c.width,c.height);cc.rectContainsPoint(c,b)&&a.stopPropagation()},
clickSound:function(){User.setSound(!User.getSound());AudioEngine.effectOn(User.getSound());this._soundOff.setVisible(!User.getSound());Backend.saveSound(User.getMusic(),User.getSound())},clickMusic:function(){User.setMusic(!User.getMusic());AudioEngine.musicOn(User.getMusic());this._musicOff.setVisible(!User.getMusic());Backend.saveSound(User.getMusic(),User.getSound())},clickExit:function(){0!=this._mode&&(1==this._mode?Popup.PopExitGame.show():2==this._mode?app.loadMap(0):3==this._mode&&app.loadAdventure(app.Scene.getCurrent().getMapId()))}});var PanelSphere=cc.Sprite.extend({_ext:null,_key:null,ctor:function(a){this._super(Resource.UI.panel_down);this._ext=new CExtNode(this);this._key=0;this.setFlippedX(!0);this.setAnchorPoint(1,0);this.setPosition(cc.director.getWinSize().width+65,0);var b=this,c=new cc.Sprite(Resource.UI.img(0==a?"006":"009"));c.setPosition(50,23);this.addChild(c);a=new CLabelTTF(cc.formatStr("%s / %s",User.getScoreById(a).getKeys(),0==a?30*app.config.ol(1):45),16,0,1);a.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);
a.setAnchorPoint(0,.5);a.setPosition(67,23);this.addChild(a);"keyboard"in cc.sys.capabilities&&cc.eventManager.addListener({event:cc.EventListener.KEYBOARD,onKeyPressed:function(a,c){b._key=a},onKeyReleased:function(a,c){b._key=0}},b);cc.eventManager.addListener({event:cc.EventListener.MOUSE,onMouseMove:function(a){CUtils.isHover(a,b)},onMouseDown:function(a){CUtils.isHover(a,b)&&(86==b._key?alert(app.version):69==b._key&&app.config.dev()&&app.loadEditor(),b._key=0)}},b)}});var PanelMiddle=cc.Node.extend({_ext:null,_dailyEvent:null,_bonus:null,ctor:function(a){this._super();this._ext=new CExtNode(this);this._ext.addCustomListener(User.EVENT.UPDATE_SCRATCH,this.eventHandler.bind(this));this._dailyEvent=new CButton(Resource.UI.ico("daily_event"),null,{b:.07},{b:-.15});this._dailyEvent.setPosition(55,110);this._dailyEvent.setCbUp(Popup.PopSpinLevel.show);this._dailyEvent.setVisible(this.showDailyEvent());this.addChild(this._dailyEvent);var b={x:704,y:534};this._bonus=new CButton(Resource.UI.ico("bonus"),
null,{b:.07},{b:-.15});this._bonus.setCbUp(app.loadAdventure.bind(this));this._bonus.setPosition(b);this._bonus.setVisible(this.showBonus());this.addChild(this._bonus);this._bonus.isVisible()?b.y-=70:b.y+=30;User.getChallenge().isActive()&&30<=User.getScoreById(0).getSize()&&(a=new PanelMiddle.ChallengeIcon,a.setPosition(b.x,b.y-80),this.addChild(a),b.y-=105);User.getOffers().isActive("special_offer")&&(a=new PanelMiddle.SpecialOffer,a.setPosition(b.x,b.y-90),this.addChild(a),b.y-=115)},showDailyEvent:function(){var a=
1&30<=User.getScoreById(0).getSize();return a&=!User.getScratch().isComplete()},showBonus:function(){return 1&30<=User.getScoreById(0).getSize()},eventHandler:function(a){a.getEventName()==User.EVENT.UPDATE_SCRATCH&&this._dailyEvent.setVisible(this.showDailyEvent())}});
PanelMiddle.ChallengeIcon=cc.Node.extend({ctor:function(){this._super();var a=this,b=new CButton(Resource.UI.ico("weekly_challenge"),null,{b:.07},{b:-.15});b.setPosition(0,50);b.setCbUp(Popup.PopChallengeStart.show);var c=new cc.Sprite(Resource.UI.ico("timer"));(new CExtNode(c)).stopMouseEvent();var d=new CLabelTTF("00:00:00",16,c.getContentSize().width-25,1);d.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);d.runAction(new cc.RepeatForever(new cc.Sequence([new cc.CallFunc(function(){var b=
User.getChallenge().getLeftTime();this.setString(TimeUtils.formatTime(b));0>=b&&(a.removeFromParent(),User.getChallenge().noticeExpired(!0)&&(Popup.close(Popup.PopChallengeStart),Popup.PopChallengeExpired.show()))},d),new cc.DelayTime(1)])));this.addChild(c);this.addChild(d);this.addChild(b)}});
PanelMiddle.ChristmasOffer=cc.Node.extend({ctor:function(){this._super();var a=this,b=new CButton(Resource.UI.ico("christmas_offer"),null,{b:.07},{b:-.15});b.setPosition(0,55);b.setScale(.95);b.setCbUp(Popup.PopChristmasOffer.show);var c=new cc.Sprite(Resource.UI.ico("timer"));(new CExtNode(c)).stopMouseEvent();var d=new CLabelTTF("00:00:00",16,c.getContentSize().width-25,1);d.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);d.runAction(new cc.RepeatForever(new cc.Sequence([new cc.CallFunc(function(){var b=
User.getOffers().getExpired("christmas_offer");this.setString(TimeUtils.formatTime(b));0>=b&&a.removeFromParent()},d),new cc.DelayTime(1)])));this.addChild(c);this.addChild(d);this.addChild(b)}});
PanelMiddle.SpecialOffer=cc.Node.extend({ctor:function(){this._super();var a=this,b=new CButton(Resource.UI.ico("special_offer_"+(User.isPayer()?1:0)),null,{b:.07},{b:-.15});b.setPosition(0,55);b.setScale(.95);b.setCbUp(Popup.PopSpecialOffer.show);var c=new cc.Sprite(Resource.UI.ico("timer"));(new CExtNode(c)).stopMouseEvent();var d=new CLabelTTF("00:00:00",16,c.getContentSize().width-25,1);d.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);d.runAction(new cc.RepeatForever(new cc.Sequence([new cc.CallFunc(function(){var b=
User.getOffers().getExpired("special_offer");this.setString(TimeUtils.formatTime(b));0>=b&&a.removeFromParent()},d),new cc.DelayTime(1)])));this.addChild(c);this.addChild(d);this.addChild(b)}});cc.log("DEVELOPMENT - Editor");
var Editor=cc.Node.extend({_wsize:null,_sto:null,_panel:null,_grid:null,_stats:null,ctor:function(){this._super();this._wsize=cc.director.getWinSize();this._sto=Editor.STO;this.setPosition(.5*this._wsize.width,.5*this._wsize.height);this._panel=new Editor.LeftPanel;this._panel.ignoreAnchorPointForPosition(!1);this._panel.setAnchorPoint(1,.5);this._panel.setPosition(.5*this._wsize.width,0);this._panel.onLoadJSON=this.loadJSON.bind(this);this._panel.onSaveJSON=this.saveJSON.bind(this);this._panel.onOpenMenu=
this.openMenu.bind(this);this._panel.onChanged=this.cbxChanged.bind(this);this._panel.onLevelReset=this.levelReset.bind(this);this._panel.onLevelClean=this.levelClean.bind(this);this._panel.onLevelRun=this.levelRun.bind(this);this.addChild(this._panel);this._stats=new Editor.StatsPanel;this._stats.setPosition(.5*-this._wsize.width,.5*-this._wsize.height);this.addChild(this._stats);this._grid=new Editor.Grid;this._grid.setPosition(-100,75);this._grid.onSelect=this.gridSelect.bind(this);this.addChild(this._grid);
this._sto.current&&(this._panel.levelOpen(this._sto.current),this._grid.loadData(this._sto.current.getData()),this._stats.setStats(this._sto.current.getStats()))},gridSelect:function(a){a&&0<a.length&&this._panel.cbxCode(a[0].getCode())},cbxChanged:function(a,b){cc.log(a,": ",b.join()," :",Math.random());this._grid.updateCode(a,b);this._sto.current.setData(this._grid.getCode())},loadJSON:function(){var a=this,b=document.createElement("input");b.type="file";b.accept=".json";b.dispatchEvent(new MouseEvent("click"));
b.multiple=!1;b.addEventListener("change",function(b){if((b=b.target.files)&&1==b.length){var c=new FileReader;c.onload=function(b){b=JSON.parse(b.target.result);if(cc.isArray(b)){for(var c in b)if(isNaN(b[c].id)){alert("invalid level:"+JSON.stringify(b[c]));return}b.sort(function(a,b){return parseInt(a.id)-parseInt(b.id)});a._sto.levels=[];a._sto.current=null;a._grid.clean();a._panel.clean();for(c in b){for(var d=new Editor.Level(b[c]);a._sto.levels.length<d.getId()-1;)a._sto.levels.push(new Editor.Level(a._sto.levels.length+
1));if(a._sto.levels.length>=d.getId()){a._sto.levels=[];alert("duplicate level: "+d.getId());return}d.validate();a._sto.levels.push(d)}alert("loading is complete")}else alert("invalid json")};c.readAsText(b[0])}})},appendJSON:function(){if(null==this._sto.levels)alert("No levels found");else{var a=this,b=document.createElement("input");b.type="file";b.accept=".json";b.dispatchEvent(new MouseEvent("click"));b.multiple=!1;b.addEventListener("change",function(b){if((b=b.target.files)&&1==b.length){var c=
new FileReader;c.onload=function(b){b=JSON.parse(b.target.result);if(cc.isArray(b)){for(var c in b)if(isNaN(b[c].id)){alert("invalid level:"+JSON.stringify(b[c]));return}a._sto.current=null;a._grid.clean();a._panel.clean();b.sort(function(a,b){return parseInt(a.id)-parseInt(b.id)});for(c in b){var d=new Editor.Level(b[c]);d.updateId(a._sto.levels.length+1);d.validate();a._sto.levels.push(d)}alert("done")}else alert("invalid json")};c.readAsText(b[0])}})}},saveJSON:function(){var a=[];for(c in this._sto.levels){var b=
this._sto.levels[c];if(b.hasError()){alert("Correct all errors before saving levels to a file");return}a.push(b.getJSON())}a=new Blob([JSON.stringify(a)],{type:"text/plain"});a=window.URL.createObjectURL(a);var c=document.createElement("a");c.download="lj_levels ("+(new Date).toISOString()+").json";c.href=a;c.dispatchEvent(new MouseEvent("click"));this.saveXML()},saveXML:function(){var a='<?xml version="1.0"?>\n<container>\n'+this._sto.levels.map(function(a){return a.getXML()}).join("")+"</container>";
a=new Blob([a],{type:"text/plain"});a=window.URL.createObjectURL(a);var b=document.createElement("a");b.download="lj_levels ("+(new Date).toISOString()+").xml";b.href=a;b.dispatchEvent(new MouseEvent("click"))},openMenu:function(){if(null!=this._sto.levels){var a=this._sto.current?this._sto.current.getId():1;a=new Editor.LevelMenu(this._sto.levels,a);a.onLoad=this.levelOpen.bind(this);a.onAppend=this.appendJSON.bind(this);a.onSwap=this.levelSwap.bind(this);this.addChild(a,200)}else alert("No levels found")},
levelOpen:function(a){a-1==this._sto.levels.length&&this._sto.levels.push(new Editor.Level(a));this._sto.current=this._sto.levels[a-1];this._panel.levelOpen(this._sto.current);this._grid.loadData(this._sto.current.getData());this._stats.setStats(this._sto.current.getStats())},levelReset:function(){this._sto.current?(this._sto.current.reset(),this._panel.levelOpen(this._sto.current),this._grid.loadData(this._sto.current.getData()),this._stats.setStats(this._sto.current.getStats())):alert("No active level")},
levelClean:function(){this._sto.current?(this._sto.current.clean(),this._panel.levelOpen(this._sto.current),this._grid.loadData(this._sto.current.getData()),this._stats.setStats(this._sto.current.getStats())):alert("No active level")},levelRun:function(){this._sto.current&&!this._sto.current.hasError()?app.loadEditorClient(this._sto.current.getJSON()):alert("The level can not be started")},levelSwap:function(a){var b=a[0];a=a[1];var c=this._sto.levels;if(!(isNaN(b)||isNaN(a)||c.length<b||c.length<
a||b==a)){var d=c[b-1],e=c[a-1];d.updateId(a);e.updateId(b);c[b-1]=e;c[a-1]=d;this._sto.current=null;this._grid.clean();this._panel.clean()}}});Editor.STO=Editor.STO||{};cc.log("DEVELOPMENT - Level");
Editor.Level=cc.Class.extend({_source:null,_current:null,_stats:null,_error:0,_edited:0,ctor:function(a){this._stats=this._source=this._current=null;this._error=0;this._edited=!1;cc.isNumber(a)?(this._current={id:a,ver:"1.0"},this._source=null,this._edited=!0):(a=JSON.stringify(a),this._source=JSON.parse(a),this._current=JSON.parse(a));this.fixIssue();this.validate()},updateId:function(a){this._current.id=a;this._source&&(this._source.id=a)},getId:function(){return this._current.id},getVersion:function(){return this._current.ver||
""},setVersion:function(a){this._current.ver=a||"1.0";this.edited();this.validate()},getMoves:function(){return this._current.m},setMoves:function(a){a=parseInt(a);this._current.m=isNaN(a)||1>a?void 0:String(a);this.edited();this.validate()},getRubies:function(){return this._current.r},setRubies:function(a){a=(a+"").split(",");a.length=3;a[0]=parseInt(a[0]);a[1]=parseInt(a[1]);a[2]=parseInt(a[2]);this._current.r=0<a[0]&&0<a[1]&&0<a[2]?a.join(","):void 0;this.edited();this.validate()},getRainbow:function(){return this._current.rainbow},
setRainbow:function(a){a=parseInt(a);this._current.rainbow=isNaN(a)||1>a?void 0:String(a);this.edited();this.validate()},getColumnBlast:function(){return this._current.columnblast},setColumnBlast:function(a){a=parseInt(a);this._current.columnblast=isNaN(a)||1>a?void 0:String(a);this.edited();this.validate()},getRowBlast:function(){return this._current.rowblast},setRowBlast:function(a){a=parseInt(a);this._current.rowblast=isNaN(a)||1>a?void 0:String(a);this.edited();this.validate()},getCrossBlast:function(){return this._current.crossblast},
setCrossBlast:function(a){a=parseInt(a);this._current.crossblast=isNaN(a)||1>a?void 0:String(a);this.edited();this.validate()},getStone:function(){return this._current.stone},setStone:function(a){a=parseInt(a);this._current.stone=isNaN(a)||1>a?void 0:String(a);this.edited();this.validate()},getButterfly:function(){return this._current.butterfly},setButterfly:function(a){a=(a+"").split(",");a.length=4;a[0]=parseInt(a[0]);a[1]=parseInt(a[1]);a[2]=parseInt(a[2]);a[3]=parseInt(a[3]);this._current.butterfly=
0<a[0]&&0<a[1]&&0<=a[2]&&0<=a[3]?a.join(","):void 0;this.edited();this.validate()},getIceCube:function(){return this._current.icecube},setIceCube:function(a){a=parseInt(a);this._current.icecube=isNaN(a)||1>a?void 0:String(a);this.edited();this.validate()},getCloud:function(){var a=this._current.cloud;if(a)return a.x+","+a.y+","+a.t+","+a.s},setCloud:function(a){a=(a+"").split(",");a.length=4;a[0]=parseInt(a[0]);a[1]=parseInt(a[1]);a[3]=parseInt(a[3]);isNaN(a[0])||isNaN(a[1])||isNaN(a[3])||0>a[3]||
"e"!=a[2]?this._current.cloud=void 0:this._current.cloud={s:String(a[3]),t:String(a[2]),x:String(a[0]),y:String(a[1])};this.edited();this.validate()},getDiamond:function(){return this._current.diamond},setDiamond:function(a){a=(a+"").split(",");a.length=4;a[0]=parseInt(a[0]);a[1]=parseInt(a[1]);a[2]=parseInt(a[2]);a[3]=parseInt(a[3]);this._current.diamond=0<a[0]&&0<a[1]&&0<=a[2]&&0<=a[3]?a.join(","):void 0;this.edited();this.validate()},getData:function(){for(var a=(this._current.data||"0").split(".");64>
a.length;)a.push("0");return a},setData:function(a){this._current.data=a.join(".");this.edited();this.validate()},getSkip:function(){return this._current.skip},setSkip:function(a){this._current.skip=a;this.edited();this.validate()},getRecommended:function(){return this._current.rec||"1:3:4:6:11:13"},getCoins:function(){return this._current.coins},getOrbs:function(){return this._current.orbs},getNRM:function(){return this._current.nrm},getStats:function(){return this._stats||{rubies:0,moves_start:0,
moves_total:0,moves_remain:0,moves_extra:0,moves_spend:0}},setStats:function(a){this._stats={rubies:a.kt.sc0,moves_start:a.kt.mv_i,moves_total:a.kt.mv_t,moves_remain:a.kt.mv_r,moves_extra:a.kt.mv_e,moves_spend:a.kt.mv_d}},reset:function(){if(this._source){var a=JSON.stringify(this._source);this._current=JSON.parse(a);this._stats=null;this._edited=!1;this.fixIssue();this.validate()}else this.clean()},clean:function(){this._current={id:this._current.id,ver:"1.0",m:"50",r:"15,30,60",skip:"f",data:"s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11.s11"};
this._stats=null;this.fixIssue();this.edited();this.validate()},hasError:function(){return 0!=this._error},isEdited:function(){return this._edited},edited:function(){this._edited=!0},validate:function(){this._error=1==(this.validateData()&&this.validatePrams()&&this.validateGoals())?0:1},validateData:function(){var a=this._current.data;a=a?a.split("."):[];if(64>a.length)return!1;a.length=64;for(var b in a){if(0==a[b].length)return!1;var c=(a[b]+"000000").split("");if("0"==c[0])c=["0"].includes(c[1])&&
["0"].includes(c[2])&&["0"].includes(c[3])&&["0"].includes(c[4])&&["0"].includes(c[5])&&["0"].includes(c[6]);else if("s"==c[0])c="1abcdef".split("").includes(c[1])&&"01abcde".split("").includes(c[2])&&["0"].includes(c[3])&&["0","1","2","3","4"].includes(c[4])&&["0"].includes(c[5])&&["0","1","2","3"].includes(c[6]);else if("B"==c[0])c="1abcdef".split("").includes(c[1])&&["0"].includes(c[2])&&"1abdefghij".split("").includes(c[3])&&["0","1","2","3","4"].includes(c[4])&&["0"].includes(c[5])&&["0","1",
"2","3"].includes(c[6]);else if("t"==c[0])c=["0"].includes(c[1])&&["0"].includes(c[2])&&["0"].includes(c[3])&&["0"].includes(c[4])&&["0"].includes(c[5])&&["0","1","2","3"].includes(c[6]);else if("S"==c[0])c=["0"].includes(c[1])&&["0"].includes(c[2])&&["0"].includes(c[3])&&["0"].includes(c[4])&&["0","1","2"].includes(c[5])&&["0","1","2","3"].includes(c[6]);else if("F"==c[0])c="1abcdef".split("").includes(c[1])&&"01abcde".split("").includes(c[2])&&["0"].includes(c[3])&&["0","1","2","3","4"].includes(c[4])&&
["0"].includes(c[5])&&["0","1","2","3"].includes(c[6]);else if("T"==c[0])c=["0"].includes(c[1])&&["0"].includes(c[2])&&["0"].includes(c[3])&&["0"].includes(c[4])&&["0"].includes(c[5])&&["0","1","2","3"].includes(c[6]);else if("P"==c[0])c=["0"].includes(c[1])&&["0"].includes(c[2])&&["0"].includes(c[3])&&["0"].includes(c[4])&&["0"].includes(c[5])&&["0","1","2","3"].includes(c[6]);else if("C"==c[0])c="1abcdef".split("").includes(c[1])&&["0"].includes(c[2])&&["0"].includes(c[3])&&["0","1","2","3","4"].includes(c[4])&&
["0","1"].includes(c[5])&&["0","1","2","3"].includes(c[6]);else if("O"==c[0])c=["*"].includes(c[1])&&["0"].includes(c[2])&&["0"].includes(c[3])&&["0"].includes(c[4])&&["1"].includes(c[5])&&["0"].includes(c[6]);else if("D"==c[0])c=["0"].includes(c[1])&&["0"].includes(c[2])&&["0"].includes(c[3])&&["0"].includes(c[4])&&["1","2"].includes(c[5])&&["0","1","2","3"].includes(c[6]);else if("b"==c[0])c="1abcdef".split("").includes(c[1])&&["0"].includes(c[2])&&["0"].includes(c[3])&&["0"].includes(c[4])&&["0",
"1","2"].includes(c[5])&&["0","1","2","3"].includes(c[6]);else if("I"==c[0])c=["0"].includes(c[1])&&["0"].includes(c[2])&&["0"].includes(c[3])&&["0"].includes(c[4])&&["0"].includes(c[5])&&["0","1","2","3"].includes(c[6]);else if("H"==c[0])c=["0"].includes(c[1])&&["0"].includes(c[2])&&["0"].includes(c[3])&&["0"].includes(c[4])&&["0","1"].includes(c[5])&&["0","1","2","3"].includes(c[6]);else if("R"==c[0])c=["0"].includes(c[1])&&["0"].includes(c[2])&&["0"].includes(c[3])&&["0"].includes(c[4])&&["0"].includes(c[5])&&
["0","1","2","3"].includes(c[6]);else return!1;if(0==c)return!1}for(b in a)if("0"!=a[b].charAt(0))return!0;return!1},validatePrams:function(){if(isNaN(this._current.m)||1>this._current.m)return!1;var a=this._current.r?this._current.r.split(","):[];return isNaN(a[0])||isNaN(a[1])||isNaN(a[2])||parseInt(a[0])>=parseInt(a[1])||parseInt(a[1])>=parseInt(a[2])||this.getRainbow()&&isNaN(this.getRainbow())||this.getColumnBlast()&&isNaN(this.getColumnBlast())||this.getRowBlast()&&isNaN(this.getRowBlast())||
this.getCrossBlast()&&isNaN(this.getCrossBlast())||this.getStone()&&isNaN(this.getStone())||this.getButterfly()&&(a=this.getButterfly().split(","),4!=a.length||isNaN(a[0])||isNaN(a[1])||isNaN(a[2])||isNaN(a[3]))||this.getIceCube()&&isNaN(this.getIceCube())||this.getCloud()&&(a=this.getCloud().split(","),4!=a.length||isNaN(a[0])||isNaN(a[1])||"e"!=a[2]||isNaN(a[3]))||this.getDiamond()&&(a=this.getDiamond().split(","),4!=a.length||isNaN(a[0])||isNaN(a[1])||isNaN(a[2])||isNaN(a[3]))?!1:this.getSkip()&&
2<this.getSkip().length?!1:!0},validateGoals:function(){var a=!1,b=!1,c=!1,d=!1,e=this._current.data;e=e?e.split("."):[];for(var f in e){var g=e[f][0];"t"==g?a=!0:"O"==g?b=!0:"b"==g&&(c=!0);0<e[f][6]&&(d=!0)}f=0+(this.getRainbow()?1:0);f+=this.getColumnBlast()?1:0;f+=this.getRowBlast()?1:0;f+=this.getCrossBlast()?1:0;f+=this.getStone()?1:0;f+=this.getButterfly()?1:0;f+=this.getIceCube()?1:0;f+=this.getDiamond()?1:0;f+=this.getNRM()?1:0;f=f+(a?1:0)+(b?1:0)+(c?1:0);f+=d?1:0;return 0<f&&3>f},fixIssue:function(){if(this._current.data){var a=
this._current.data.split("."),b;for(b in a){var c=a[b].split("");"B"==c[0]&&"0"!=c[2]&&(c[2]="0");a[b]=c.join("")}this._current.data=a.join(".")}this._current.coins||(this._current.coins="10:15:30:2");this._current.orbs||(this._current.orbs="2:5:16:15:7:8:9:10:12:14");this._current.rec||(this._current.rec="1:3:4:6:11:13")},getJSON:function(){return JSON.parse(JSON.stringify(this._current))},getXML:function(){return'<level id="'+this.getId()+'" rec="'+this.getRecommended()+'" coins="'+this.getCoins()+
'" orbs="'+this.getOrbs()+'" ver="'+this.getVersion()+'">\n<m>'+this.getMoves()+"</m>\n"+(this.getNRM()?"<nrm>"+this.getNRM()+"</nrm>\n":"")+"<r>"+this.getRubies()+"</r>\n"+(this.getSkip()?"<ignoreShape>"+this.getSkip()+"</ignoreShape>\n":"")+(this.getDiamond()?"<diamond>"+this.getDiamond()+"</diamond>\n":"")+(this.getCloud()?'<cloud cell="'+this.getCloud().split(",")[0]+":"+(6-parseInt(this.getCloud().split(",")[1]))+'" type="'+this.getCloud().split(",")[2]+'" step="'+this.getCloud().split(",")[3]+
'" />\n':"")+(this.getIceCube()?"<iceCube>"+this.getIceCube()+"</iceCube>\n":"")+(this.getButterfly()?"<butterfly>"+this.getButterfly()+"</butterfly>\n":"")+(this.getRainbow()?"<rainbow>"+this.getRainbow()+"</rainbow>\n":"")+(this.getColumnBlast()?"<columnblast>"+this.getColumnBlast()+"</columnblast>\n":"")+(this.getCrossBlast()?"<crossblast>"+this.getCrossBlast()+"</crossblast>\n":"")+(this.getRowBlast()?"<rowblast>"+this.getRowBlast()+"</rowblast>\n":"")+(this.getStone()?"<stone>"+this.getStone()+
"</stone>\n":"")+'<sub id="0">'+this.getData().join(".")+"</sub>\n</level>\n"}});cc.log("DEVELOPMENT - LevelMenu");
Editor.LevelMenu=cc.LayerColor.extend({_ext:null,_wsize:null,_back:null,_tabs:null,_btns:null,_currId:null,_levels:null,onLoad:null,onSwap:null,onAppend:null,ctor:function(a,b){this._levels=a;this._currId=b||1;this.onLoad=null;this._wsize=cc.director.getWinSize();this._super(new cc.Color(0,0,0,178.5),this._wsize.width,this._wsize.height);this._ext=new CExtNode(this);this._ext.stopMouseEvent();this.ignoreAnchorPointForPosition(!1);this._back=new cc.Scale9Sprite(Resource.EDITOR.img("000"),new cc.Rect(15,
15,5,5));this._back.setContentSize(680,540);this._back.setPosition(.5*this._wsize.width,.5*this._wsize.height);this.addChild(this._back);var c=new CButton(Resource.EDITOR.img("007"),null,{b:.05},{b:-.15});c.setPosition(659,552);c.setCbUp(this.clickClose.bind(this));this._back.addChild(c);var d=new CButton(Resource.EDITOR.img("022"),null,{b:.05},{b:-.15});d.setPosition(c.getPositionX()-31,c.getPositionY());d.setCbUp(this.clickSwap.bind(this));this._back.addChild(d);d=new CButton(Resource.EDITOR.img("021"),
null,{b:.05},{b:-.15});d.setPosition(c.getPositionX()-62,c.getPositionY());d.setCbUp(this.clickAppend.bind(this));this._back.addChild(d);this._tabs=new cc.Node;this._tabs.setPosition(50,this._back.getContentSize().height-25);this._back.addChild(this._tabs);this._btns=new cc.Node;this._btns.setPosition(30,this._back.getContentSize().height-120);this._back.addChild(this._btns);c=new cc.Sprite(Resource.EDITOR.line);c.setScaleX(this._back.getContentSize().width/c.getContentSize().width);c.setPosition(.5*
this._back.getContentSize().width,this._back.getContentSize().height-85);this._back.addChild(c);this.buildTabs();this.buildButton()},buildTabs:function(){var a=this;a._tabs.removeAllChildren();for(var b=function(b,c){var d=0,e;for(e in a._levels){var f=a._levels[e];if(b<=f.getId()&&f.getId()<=c){if(f.hasError())return 2;f.isEdited()&&(d=1)}}return d},c=0;8>c;c++){var d=new CButtonSprite(Resource.EDITOR.img("001"));d.minId=400*c+1;d.maxId=200*(2*c+1);d.setText(d.minId+"-"+d.maxId,16,0);d.setPosition(83*
c,0);d.setCbUp(this.clickTab.bind(this,d.minId,d.maxId));a._tabs.addChild(d);if(d.minId<=this._current&&this._current<=d.maxId){var e=new CButtonSprite(Resource.EDITOR.bt("save"));e.setText(d.minId+"-"+d.maxId,16,0);e.setPosition(d.getPosition().x,d.getPosition().y-1);this._tabs.addChild(e)}e=b(d.minId,d.maxId);0!=e&&(e=new cc.Sprite(Resource.EDITOR.img(2==e?"003":"004")),e.setScale(.9),e.setPosition(d.getPositionX()+32,d.getPositionY()+10),this._tabs.addChild(e))}for(c=0;8>c;c++)d=new CButtonSprite(Resource.EDITOR.img("001")),
d.minId=200*(2*c+1)+1,d.maxId=200*(2*c+2),d.setText(d.minId+"-"+d.maxId,16,0),d.setPosition(83*c,-35),d.setCbUp(this.clickTab.bind(this,d.minId,d.maxId)),this._tabs.addChild(d),d.minId<=this._current&&this._current<=d.maxId&&(e=new CButtonSprite(Resource.EDITOR.bt("save")),e.setText(d.minId+"-"+d.maxId,16,0),e.setPosition(d.getPosition().x,d.getPosition().y-1),this._tabs.addChild(e)),e=b(d.minId,d.maxId),0!=e&&(e=new cc.Sprite(Resource.EDITOR.img(2==e?"003":"004")),e.setPosition(d.getPositionX()+
32,d.getPositionY()+10),this._tabs.addChild(e))},buildButton:function(){this._btns.removeAllChildren();var a=200*Math.floor(this._currId/200)+1,b=0;for(f in this._levels)b=Math.max(b,this._levels[f].getId());for(var c=0;10>c;c++)for(var d=0;20>d;d++){var e=a+20*c+d;if(e==b+1){var f=new CButtonSprite(Resource.EDITOR.img("005"));f.setScale(.85);f.setPosition(d*(f.getContentSize().width*f.getScaleX()-3),-c*f.getContentSize().width*f.getScaleX()*1.2);f.setCbUp(this.clickClose.bind(this,e));this._btns.addChild(f);
return}if(e<=b){var g=this._levels[e-1];if(g.getId()!=e){alert("invalid level order");return}f=new CButtonSprite(Resource.EDITOR.img("002"));f.setText(e,16,0);f.setScale(.85);f.setPosition(d*(f.getContentSize().width*f.getScaleX()-3),-c*f.getContentSize().width*f.getScaleX()*1.2);f.setCbUp(this.clickClose.bind(this,e));this._btns.addChild(f);if(g.hasError()||g.isEdited())e=new cc.Sprite(Resource.EDITOR.img(g.hasError()?"003":"004")),e.setScale(.7),e.setPosition(f.getPositionX()+10,f.getPositionY()+
10),this._btns.addChild(e)}}},clickTab:function(a,b){this._currId=a;this.buildTabs();this.buildButton()},clickClose:function(a){if(void 0!=a&&null!=this.onLoad)this.onLoad(a);this.removeFromParent()},clickAppend:function(){this.onAppend&&this.onAppend();this.removeFromParent()},clickSwap:function(){var a=prompt("Swap levels: x0,x1").split(",");isNaN(a[0])||isNaN(a[1])||(this.onSwap&&this.onSwap(a),this.removeFromParent())}});cc.log("DEVELOPMENT - LeftPanel");
Editor.LeftPanel=cc.LayerColor.extend({onLoadJSON:null,onSaveJSON:null,onOpenMenu:null,onLevelReset:null,onLevelClean:null,onLevelRun:null,onChanged:null,_level:null,_eVersion:null,_eMoves:null,_eRubies:null,_eRowBlast:null,_eColumnBlast:null,_eCrossBlast:null,_eStone:null,_eRainbow:null,_eButterfly:null,_eIceCube:null,_eCloud:null,_eDiamond:null,_cbxJewel:null,_cbxShape:null,_cbxRuby:null,_cbxBonus:null,_cbxLock:null,_cbxState:null,_cbxBack:null,_cShapeA:null,_cShapeB:null,_cShapeC:null,_cShapeD:null,
_cShapeE:null,_cShapeF:null,ctor:function(){this._super(new cc.Color(24,24,24),200,650);this._level=this.onChanged=this.onLevelRun=this.onLevelClean=this.onLevelReset=this.onOpenMenu=this.onSaveJSON=this.onLoadJSON=null;var a=this,b=new CButton(Resource.EDITOR.img("013"),null,{b:.05},{b:-.15});b.setPosition(24,625);b.setCbUp(function(){a.onLoadJSON&&a.onLoadJSON()});var c=new CButton(Resource.EDITOR.img("014"),null,{b:.05},{b:-.15});c.setPosition(b.getPositionX()+35,b.getPositionY());c.setCbUp(function(){a.onOpenMenu&&
a.onOpenMenu()});var d=new CButton(Resource.EDITOR.img("012"),null,{b:.05},{b:-.15});d.setPosition(c.getPositionX()+35,c.getPositionY());d.setCbUp(function(){a.onSaveJSON&&a.onSaveJSON()});var e=new CButton(Resource.EDITOR.img("015"),null,{b:.05},{b:-.15});e.setPosition(d.getPositionX()+35,d.getPositionY());e.setCbUp(function(){a.onLevelReset&&a.onLevelReset()});var f=new CButton(Resource.EDITOR.img("016"),null,{b:.05},{b:-.15});f.setPosition(e.getPositionX()+35,e.getPositionY());f.setCbUp(function(){a.onLevelClean&&
a.onLevelClean()});this.addChild(b);this.addChild(d);this.addChild(c);this.addChild(e);this.addChild(f);b=new cc.Sprite(Resource.EDITOR.line);b.setScaleX(200/b.getContentSize().width);b.setPosition(100,605);this.addChild(b);this._eVersion=new CButtonSprite(Resource.EDITOR.img("008"));this._eVersion.setPosition(145,b.getPositionY()-20);this._eVersion.setCbUp(this.editClick.bind(this,"ver"));b=new CLabelTTF("Version",16,80,4);b.setPosition(this._eVersion.getPositionX()-55,this._eVersion.getPositionY());
b.setAnchorPoint(1,.5);this.addChild(b);this.addChild(this._eVersion);this._eMoves=new CButtonSprite(Resource.EDITOR.img("008"));this._eMoves.setPosition(this._eVersion.getPositionX(),this._eVersion.getPositionY()-25);this._eMoves.setCbUp(this.editClick.bind(this,"moves"));b=new CLabelTTF("Moves",16,80,4);b.setPosition(this._eMoves.getPositionX()-55,this._eMoves.getPositionY());b.setAnchorPoint(1,.5);this.addChild(b);this.addChild(this._eMoves);this._eRubies=new CButtonSprite(Resource.EDITOR.img("008"));
this._eRubies.setPosition(this._eMoves.getPositionX(),this._eMoves.getPositionY()-25);this._eRubies.setCbUp(this.editClick.bind(this,"rubies"));b=new CLabelTTF("Rubies",16,80,4);b.setPosition(this._eRubies.getPositionX()-55,this._eRubies.getPositionY());b.setAnchorPoint(1,.5);this.addChild(b);this.addChild(this._eRubies);b=new cc.Sprite(Resource.EDITOR.line);b.setScaleX(200/b.getContentSize().width);b.setPosition(100,this._eRubies.getPositionY()-18);this.addChild(b);this._cbxJewel=new Editor.ComboBox([{n:"Disable",
data:"0"},{n:"Simple",data:"s"},{n:"Bonus",data:"B"},{n:"Chameleon",data:"C"},{n:"Titanium",data:"T"},{n:"Stone",data:"S"},{n:"Petrifier",data:"P"},{n:"Frozen",data:"F"},{n:"IceCube",data:"I"},{n:"Treasure",data:"t"},{n:"Torch",data:"O"},{n:"Beetle",data:"b"},{n:"Rainbow",data:"R"},{n:"Butterfly",data:"H"},{n:"Diamond",data:"D"}]);this._cbxJewel.setPosition(67,b.getPositionY()-30);this._cbxJewel.name="id_0";this._cbxJewel.onChanged=this.cbxChanged.bind(this);this._cbxJewel.setEnabled(!1);this.addChild(this._cbxJewel);
b=new CLabelTTF("Jewel",16,80,4);b.setPosition(this._cbxJewel.getPositionX()-10,this._cbxJewel.getPositionY()+2);b.setAnchorPoint(1,0);this.addChild(b);this._cbxShape=new Editor.ComboBox([{n:"Disable",data:"0"},{n:"Random",data:"1"},{n:"A",data:"a"},{n:"B",data:"b"},{n:"C",data:"c"},{n:"D",data:"d"},{n:"E",data:"e"},{n:"F",data:"f"}]);this._cbxShape.setPosition(this._cbxJewel.getPositionX(),this._cbxJewel.getPositionY()-26);this._cbxShape.name="id_1";this._cbxShape.onChanged=this.cbxChanged.bind(this);
this._cbxShape.setEnabled(!1);this.addChild(this._cbxShape);b=new CLabelTTF("Shape",16,80,4);b.setPosition(this._cbxShape.getPositionX()-10,this._cbxShape.getPositionY()+2);b.setAnchorPoint(1,0);this.addChild(b);this._cbxRuby=new Editor.ComboBox([{n:"Disable",data:"0"},{n:"Random",data:"1"},{n:"A",data:"a"},{n:"B",data:"b"},{n:"C",data:"c"},{n:"D",data:"d"},{n:"E",data:"e"}]);this._cbxRuby.setPosition(this._cbxShape.getPositionX(),this._cbxShape.getPositionY()-26);this._cbxRuby.name="id_2";this._cbxRuby.onChanged=
this.cbxChanged.bind(this);this._cbxRuby.setEnabled(!1);this.addChild(this._cbxRuby);b=new CLabelTTF("Ruby",16,80,4);b.setPosition(this._cbxRuby.getPositionX()-10,this._cbxRuby.getPositionY()+2);b.setAnchorPoint(1,0);this.addChild(b);this._cbxBonus=new Editor.ComboBox([{n:"Disable",data:"0"},{n:"Random",data:"1"},{n:"Tornado",data:"b"},{n:"Bomb",data:"d"},{n:"Lighting",data:"e"},{n:"RowDestroyer",data:"f"},{n:"ColumnDestroyer",data:"g"},{n:"CrossDestroyer",data:"h"},{n:"FireBlas",data:"i"},{n:"Plus 3",
data:"a"},{n:"Minus 3",data:"j"}]);this._cbxBonus.setPosition(this._cbxRuby.getPositionX(),this._cbxRuby.getPositionY()-26);this._cbxBonus.name="id_3";this._cbxBonus.onChanged=this.cbxChanged.bind(this);this._cbxBonus.setEnabled(!1);this.addChild(this._cbxBonus);b=new CLabelTTF("Bonus",16,80,4);b.setPosition(this._cbxBonus.getPositionX()-10,this._cbxBonus.getPositionY()+2);b.setAnchorPoint(1,0);this.addChild(b);this._cbxLock=new Editor.ComboBox([{n:"0",data:"0"},{n:"1",data:"1"},{n:"2",data:"2"},
{n:"3",data:"3"},{n:"4",data:"4"}]);this._cbxLock.setPosition(this._cbxBonus.getPositionX(),this._cbxBonus.getPositionY()-26);this._cbxLock.name="id_4";this._cbxLock.onChanged=this.cbxChanged.bind(this);this._cbxLock.setEnabled(!1);this.addChild(this._cbxLock);b=new CLabelTTF("Lock",16,80,4);b.setPosition(this._cbxLock.getPositionX()-10,this._cbxLock.getPositionY()+2);b.setAnchorPoint(1,0);this.addChild(b);this._cbxState=new Editor.ComboBox([{n:"0",data:"0"},{n:"1",data:"1"},{n:"2",data:"2"},{n:"3",
data:"3"}]);this._cbxState.setPosition(this._cbxLock.getPositionX(),this._cbxLock.getPositionY()-26);this._cbxState.name="id_5";this._cbxState.onChanged=this.cbxChanged.bind(this);this._cbxState.setEnabled(!1);this.addChild(this._cbxState);b=new CLabelTTF("State",16,80,4);b.setPosition(this._cbxState.getPositionX()-10,this._cbxState.getPositionY()+2);b.setAnchorPoint(1,0);this.addChild(b);this._cbxBack=new Editor.ComboBox([{n:"0",data:"0"},{n:"1",data:"1"},{n:"2",data:"2"},{n:"3",data:"3"}]);this._cbxBack.setPosition(this._cbxState.getPositionX(),
this._cbxState.getPositionY()-26);this._cbxBack.name="id_6";this._cbxBack.onChanged=this.cbxChanged.bind(this);this._cbxBack.setEnabled(!1);this.addChild(this._cbxBack);b=new CLabelTTF("Back",16,80,4);b.setPosition(this._cbxBack.getPositionX()-10,this._cbxBack.getPositionY()+2);b.setAnchorPoint(1,0);this.addChild(b);b=new cc.Sprite(Resource.EDITOR.line);b.setScaleX(200/b.getContentSize().width);b.setPosition(100,this._cbxBack.getPositionY()-10);this.addChild(b);this._eRainbow=new CButtonSprite(Resource.EDITOR.img("008"));
this._eRainbow.setPosition(145,b.getPositionY()-20);this._eRainbow.setCbUp(this.editClick.bind(this,"rainbow"));b=new CLabelTTF("Rainbow",16,80,4);b.setPosition(this._eRainbow.getPositionX()-55,this._eRainbow.getPositionY());b.setAnchorPoint(1,.5);this.addChild(this._eRainbow);this.addChild(b);this._eColumnBlast=new CButtonSprite(Resource.EDITOR.img("008"));this._eColumnBlast.setPosition(this._eRainbow.getPositionX(),this._eRainbow.getPositionY()-25);this._eColumnBlast.setCbUp(this.editClick.bind(this,
"columnblast"));b=new CLabelTTF("Column Blast",16,80,4);b.setPosition(this._eColumnBlast.getPositionX()-55,this._eColumnBlast.getPositionY());b.setAnchorPoint(1,.5);this.addChild(b);this.addChild(this._eColumnBlast);this._eRowBlast=new CButtonSprite(Resource.EDITOR.img("008"));this._eRowBlast.setPosition(this._eColumnBlast.getPositionX(),this._eColumnBlast.getPositionY()-25);this._eRowBlast.setCbUp(this.editClick.bind(this,"rowblast"));b=new CLabelTTF("Row Blast",16,80,4);b.setPosition(this._eRowBlast.getPositionX()-
55,this._eRowBlast.getPositionY());b.setAnchorPoint(1,.5);this.addChild(b);this.addChild(this._eRowBlast);this._eCrossBlast=new CButtonSprite(Resource.EDITOR.img("008"));this._eCrossBlast.setPosition(this._eRowBlast.getPositionX(),this._eRowBlast.getPositionY()-25);this._eCrossBlast.setCbUp(this.editClick.bind(this,"crossblast"));b=new CLabelTTF("Cross Blast",16,80,4);b.setPosition(this._eCrossBlast.getPositionX()-55,this._eCrossBlast.getPositionY());b.setAnchorPoint(1,.5);this.addChild(b);this.addChild(this._eCrossBlast);
this._eStone=new CButtonSprite(Resource.EDITOR.img("008"));this._eStone.setPosition(this._eCrossBlast.getPositionX(),this._eCrossBlast.getPositionY()-25);this._eStone.setCbUp(this.editClick.bind(this,"stone"));b=new CLabelTTF("Stone",16,80,4);b.setPosition(this._eStone.getPositionX()-55,this._eStone.getPositionY());b.setAnchorPoint(1,.5);this.addChild(b);this.addChild(this._eStone);this._eButterfly=new CButtonSprite(Resource.EDITOR.img("008"));this._eButterfly.setPosition(this._eStone.getPositionX(),
this._eStone.getPositionY()-25);this._eButterfly.setCbUp(this.editClick.bind(this,"butterfly"));b=new CLabelTTF("Butterfly",16,80,4);b.setPosition(this._eButterfly.getPositionX()-55,this._eButterfly.getPositionY());b.setAnchorPoint(1,.5);this.addChild(b);this.addChild(this._eButterfly);this._eIceCube=new CButtonSprite(Resource.EDITOR.img("008"));this._eIceCube.setPosition(this._eButterfly.getPositionX(),this._eButterfly.getPositionY()-25);this._eIceCube.setCbUp(this.editClick.bind(this,"icecube"));
b=new CLabelTTF("IceCube",16,80,4);b.setPosition(this._eIceCube.getPositionX()-55,this._eIceCube.getPositionY());b.setAnchorPoint(1,.5);this.addChild(b);this.addChild(this._eIceCube);this._eCloud=new CButtonSprite(Resource.EDITOR.img("008"));this._eCloud.setPosition(this._eIceCube.getPositionX(),this._eIceCube.getPositionY()-25);this._eCloud.setCbUp(this.editClick.bind(this,"cloud"));b=new CLabelTTF("Cloud",16,80,4);b.setPosition(this._eCloud.getPositionX()-55,this._eCloud.getPositionY());b.setAnchorPoint(1,
.5);this.addChild(b);this.addChild(this._eCloud);this._eDiamond=new CButtonSprite(Resource.EDITOR.img("008"));this._eDiamond.setPosition(this._eCloud.getPositionX(),this._eCloud.getPositionY()-25);this._eDiamond.setCbUp(this.editClick.bind(this,"diamond"));b=new CLabelTTF("Diamond",16,80,4);b.setPosition(this._eDiamond.getPositionX()-55,this._eDiamond.getPositionY());b.setAnchorPoint(1,.5);this.addChild(b);this.addChild(this._eDiamond);b=new cc.Sprite(Resource.EDITOR.line);b.setScaleX(200/b.getContentSize().width);
b.setPosition(100,this._eDiamond.getPositionY()-20);this.addChild(b);this._cShapeA=new CButtonSprite(Resource.EDITOR.grid("s_a"));this._cShapeA.setCbUp(this.shapeClick.bind(this,"a"));this._cShapeA.setScale(.5);this._cShapeA.setPosition(20,b.getPositionY()-20);this.addChild(this._cShapeA);this._cShapeB=new CButtonSprite(Resource.EDITOR.grid("s_b"));this._cShapeB.setCbUp(this.shapeClick.bind(this,"b"));this._cShapeB.setScale(.5);this._cShapeB.setPosition(this._cShapeA.getPositionX()+31,this._cShapeA.getPositionY());
this.addChild(this._cShapeB);this._cShapeC=new CButtonSprite(Resource.EDITOR.grid("s_c"));this._cShapeC.setCbUp(this.shapeClick.bind(this,"c"));this._cShapeC.setScale(.5);this._cShapeC.setPosition(this._cShapeB.getPositionX()+31,this._cShapeB.getPositionY());this.addChild(this._cShapeC);this._cShapeD=new CButtonSprite(Resource.EDITOR.grid("s_d"));this._cShapeD.setCbUp(this.shapeClick.bind(this,"d"));this._cShapeD.setScale(.5);this._cShapeD.setPosition(this._cShapeC.getPositionX()+31,this._cShapeC.getPositionY());
this.addChild(this._cShapeD);this._cShapeE=new CButtonSprite(Resource.EDITOR.grid("s_e"));this._cShapeE.setCbUp(this.shapeClick.bind(this,"e"));this._cShapeE.setScale(.5);this._cShapeE.setPosition(this._cShapeD.getPositionX()+31,this._cShapeD.getPositionY());this.addChild(this._cShapeE);this._cShapeF=new CButtonSprite(Resource.EDITOR.grid("s_f"));this._cShapeF.setCbUp(this.shapeClick.bind(this,"f"));this._cShapeF.setScale(.5);this._cShapeF.setPosition(this._cShapeE.getPositionX()+31,this._cShapeE.getPositionY());
this.addChild(this._cShapeF);b=new cc.Sprite(Resource.EDITOR.line);b.setScaleX(200/b.getContentSize().width);b.setPosition(100,this._cShapeF.getPositionY()-20);this.addChild(b);c=new CButton(Resource.EDITOR.img("018"),null,{b:.05},{b:-.15});c.setText("Play",16,4);c.setPosition(45,b.getPositionY()-20);c.setCbUp(function(){a.onLevelRun&&a.onLevelRun()});this.addChild(c)},levelOpen:function(a){this._level=a;this.updateProps();this.cbxReset()},updateProps:function(){var a=this._level;this._eVersion.setText(a.getId()+
"  ["+a.getVersion()+"]",16,4);this._eMoves.setText(a.getMoves(),16,4);this._eRubies.setText(a.getRubies(),16,4);this._eRainbow.setText(a.getRainbow(),16,4);this._eColumnBlast.setText(a.getColumnBlast(),16,4);this._eRowBlast.setText(a.getRowBlast(),16,4);this._eCrossBlast.setText(a.getCrossBlast(),16,4);this._eStone.setText(a.getStone(),16,4);this._eButterfly.setText(a.getButterfly(),16,4);this._eIceCube.setText(a.getIceCube(),16,4);this._eCloud.setText(a.getCloud(),16,4);this._eDiamond.setText(a.getDiamond(),
16,4);this._cShapeA.removeAllChildren();this._cShapeB.removeAllChildren();this._cShapeC.removeAllChildren();this._cShapeD.removeAllChildren();this._cShapeE.removeAllChildren();this._cShapeF.removeAllChildren();var b=a.getSkip()||"";-1!=b.indexOf("a")&&(a=new cc.Sprite(Resource.EDITOR.img("017")),a.setScale(2),a.setPosition(28,26),this._cShapeA.addChild(a));-1!=b.indexOf("b")&&(a=new cc.Sprite(Resource.EDITOR.img("017")),a.setScale(2),a.setPosition(28,26),this._cShapeB.addChild(a));-1!=b.indexOf("c")&&
(a=new cc.Sprite(Resource.EDITOR.img("017")),a.setScale(2),a.setPosition(28,26),this._cShapeC.addChild(a));-1!=b.indexOf("d")&&(a=new cc.Sprite(Resource.EDITOR.img("017")),a.setScale(2),a.setPosition(28,26),this._cShapeD.addChild(a));-1!=b.indexOf("e")&&(a=new cc.Sprite(Resource.EDITOR.img("017")),a.setScale(2),a.setPosition(28,26),this._cShapeE.addChild(a));-1!=b.indexOf("f")&&(a=new cc.Sprite(Resource.EDITOR.img("017")),a.setScale(2),a.setPosition(28,26),this._cShapeF.addChild(a))},editClick:function(a){if(null==
this._level)alert("No active level");else{var b=this._level;switch(a){case "ver":a=prompt("[Level:"+b.getId()+"] Version",b.getVersion());null!=a&&b.setVersion(a);break;case "moves":a="[Level:"+b.getId()+"] Moves";a=prompt(a,b.getMoves());null!=a&&b.setMoves(a);break;case "rubies":a="[Level:"+b.getId()+"] Rubies\nv: x0,x1,x2\n\nx0 - key1 [>0]\nx1 - key2 [>0]\nx2 - key3 [>0]";a=prompt(a,b.getRubies());null!=a&&b.setRubies(a);break;case "rainbow":a="[Level:"+b.getId()+"] Goal - Rainbow\n v: item count";
a=prompt(a,b.getRainbow());null!=a&&b.setRainbow(a);break;case "columnblast":a="[Level:"+b.getId()+"] Goal - Column Blast\n v: item count";a=prompt(a,b.getColumnBlast());null!=a&&b.setColumnBlast(a);break;case "rowblast":a="[Level:"+b.getId()+"] Goal - Row Blast\n v: item count";a=prompt(a,b.getRowBlast());null!=a&&b.setRowBlast(a);break;case "crossblast":a="[Level:"+b.getId()+"] Goal - Cross Blast\n v: item count";a=prompt(a,b.getCrossBlast());null!=a&&b.setCrossBlast(a);break;case "stone":a="[Level:"+
b.getId()+"] Goal - Stone\n v: item count";a=prompt(a,b.getStone());null!=a&&b.setStone(a);break;case "butterfly":a="[Level:"+b.getId()+"] Goal - Butterfly\nv: x0,x1,x2,x3\n\nx0 - item count [>0]\nx1 - item on stage [>0]\nx2 - generate rate [0..100]\nx3 - item state [0,1]";a=prompt(a,b.getButterfly());null!=a&&b.setButterfly(a);break;case "icecube":a="[Level:"+b.getId()+"] Goal - Ice Cube\n v: item count";a=prompt(a,b.getIceCube());null!=a&&b.setIceCube(a);break;case "cloud":a="[Level:"+b.getId()+
"] Goal - Cloud\nv: x0,x1,x2,x3\n\nx0 - tile X\nx1 - tile Y\nx2 - action [e]\nx3 - action step [>=0]";a=prompt(a,b.getCloud());null!=a&&b.setCloud(a);break;case "diamond":a="[Level:"+b.getId()+"] Goal - Diamond\nv: x0,x1,x2,x3\n\nx0 - item count [>0]\nx1 - item on stage [>0]\nx2 - generate rate0 [0..100]\nx3 - generate rate1 [0..100]",a=prompt(a,b.getDiamond()),null!=a&&b.setDiamond(a)}this.updateProps()}},shapeClick:function(a){if(null==this._level)alert("No active level");else{var b=this._level.getSkip()||
"";b=-1==b.indexOf(a)?b+a:b.replace(a,"");this._level.setSkip(b);this.updateProps()}},cbxCode:function(a){null==this._level?alert("Select a level before edit property"):(this._cbxJewel.selectItem(a[0]),this._cbxShape.selectItem(a[1]),this._cbxRuby.selectItem(a[2]),this._cbxBonus.selectItem(a[3]),this._cbxLock.selectItem(a[4]),this._cbxState.selectItem(a[5]),this._cbxBack.selectItem(a[6]),this.cbxConfig())},cbxConfig:function(a){var b=this._cbxJewel.getData()||"0";this._cbxJewel.setEnabled(!0);this._cbxShape.setEnabled(!0);
this._cbxRuby.setEnabled(!0);this._cbxBonus.setEnabled(!0);this._cbxLock.setEnabled(!0);this._cbxState.setEnabled(!0);this._cbxBack.setEnabled(!0);1==a&&(this._cbxShape.selectItem("0"),this._cbxRuby.selectItem("0"),this._cbxBonus.selectItem("0"),this._cbxLock.selectItem("0"),this._cbxState.selectItem("0"),this._cbxBack.selectItem("0"));"0"==b?(this._cbxShape.setEnabled(!1),this._cbxRuby.setEnabled(!1),this._cbxBonus.setEnabled(!1),this._cbxLock.setEnabled(!1),this._cbxState.setEnabled(!1),this._cbxBack.setEnabled(!1)):
"s"==b?(this._cbxBonus.setEnabled(!1),this._cbxState.setEnabled(!1),1==a&&(this._cbxShape.selectItem("1"),this._cbxRuby.selectItem("1"))):"F"==b?(this._cbxBonus.setEnabled(!1),this._cbxState.setEnabled(!1),1==a&&this._cbxShape.selectItem("1")):"B"==b?(this._cbxRuby.setEnabled(!1),this._cbxState.setEnabled(!1),1==a&&(this._cbxShape.selectItem("1"),this._cbxBonus.selectItem("1"))):"S"==b?(this._cbxShape.setEnabled(!1),this._cbxRuby.setEnabled(!1),this._cbxBonus.setEnabled(!1),this._cbxLock.setEnabled(!1)):
"P"==b?(this._cbxShape.setEnabled(!1),this._cbxRuby.setEnabled(!1),this._cbxBonus.setEnabled(!1),this._cbxLock.setEnabled(!1),this._cbxState.setEnabled(!1)):"T"==b?(this._cbxShape.setEnabled(!1),this._cbxRuby.setEnabled(!1),this._cbxBonus.setEnabled(!1),this._cbxLock.setEnabled(!1),this._cbxState.setEnabled(!1)):"t"==b?(this._cbxShape.setEnabled(!1),this._cbxRuby.setEnabled(!1),this._cbxBonus.setEnabled(!1),this._cbxLock.setEnabled(!1),this._cbxState.setEnabled(!1)):"C"==b?(this._cbxRuby.setEnabled(!1),
this._cbxBonus.setEnabled(!1),1==a&&this._cbxShape.selectItem("1")):"O"==b?(this._cbxShape.setEnabled(!1),this._cbxRuby.setEnabled(!1),this._cbxBonus.setEnabled(!1),this._cbxLock.setEnabled(!1),this._cbxState.setEnabled(!1),this._cbxBack.setEnabled(!1),1==a&&this._cbxState.selectItem("1")):"I"==b?(this._cbxShape.setEnabled(!1),this._cbxRuby.setEnabled(!1),this._cbxBonus.setEnabled(!1),this._cbxLock.setEnabled(!1),this._cbxState.setEnabled(!1)):"D"==b?(this._cbxShape.setEnabled(!1),this._cbxRuby.setEnabled(!1),
this._cbxBonus.setEnabled(!1),this._cbxLock.setEnabled(!1),1==a&&this._cbxState.selectItem("1")):"H"==b?(this._cbxShape.setEnabled(!1),this._cbxRuby.setEnabled(!1),this._cbxBonus.setEnabled(!1),this._cbxLock.setEnabled(!1)):"b"==b?(this._cbxRuby.setEnabled(!1),this._cbxBonus.setEnabled(!1),this._cbxLock.setEnabled(!1),1==a&&this._cbxShape.selectItem("1")):"R"==b&&(this._cbxShape.setEnabled(!1),this._cbxRuby.setEnabled(!1),this._cbxBonus.setEnabled(!1),this._cbxLock.setEnabled(!1),this._cbxState.setEnabled(!1))},
cbxChanged:function(a){"id_0"==a.name&&this.cbxConfig(!0);var b=[];b[0]=this._cbxJewel.getData()||"0";b[1]=this._cbxShape.getData()||"0";b[2]=this._cbxRuby.getData()||"0";b[3]=this._cbxBonus.getData()||"0";b[4]=this._cbxLock.getData()||"0";b[5]=this._cbxState.getData()||"0";b[6]=this._cbxBack.getData()||"0";this.onChanged&&this.onChanged(a.name,b)},cbxReset:function(){this._cbxJewel.setEnabled(!1);this._cbxShape.setEnabled(!1);this._cbxRuby.setEnabled(!1);this._cbxBonus.setEnabled(!1);this._cbxLock.setEnabled(!1);
this._cbxState.setEnabled(!1);this._cbxBack.setEnabled(!1);this._cbxJewel.selectItem("0");this._cbxShape.selectItem("0");this._cbxRuby.selectItem("0");this._cbxBonus.selectItem("0");this._cbxLock.selectItem("0");this._cbxState.selectItem("0");this._cbxBack.selectItem("0")},clean:function(){this._eVersion.setText("",16,4);this._eMoves.setText("",16,4);this._eRubies.setText("",16,4);this._eRainbow.setText("",16,4);this._eColumnBlast.setText("",16,4);this._eRowBlast.setText("",16,4);this._eCrossBlast.setText("",
16,4);this._eStone.setText("",16,4);this._eButterfly.setText("",16,4);this._eIceCube.setText("",16,4);this._eCloud.setText("",16,4);this._eDiamond.setText("",16,4);this._cShapeA.removeAllChildren();this._cShapeB.removeAllChildren();this._cShapeC.removeAllChildren();this._cShapeD.removeAllChildren();this._cShapeE.removeAllChildren();this._cShapeF.removeAllChildren();this._level=null;this.cbxReset()}});cc.log("DEVELOPMENT - StatsPanel");
Editor.StatsPanel=cc.LayerColor.extend({ctor:function(){this._super(new cc.Color(24,24,24),558,150)},setStats:function(a){this.removeAllChildren();var b=new CLabelTTF("Moves Start:\nMoves Total:\nMoves Remain:\nMoves Extra:\nMoves Spend:\nRubies:",16,0,4);b.setPosition(10,145);b.setAnchorPoint(0,1);b.setHorizontalAlignment(cc.TEXT_ALIGNMENT_RIGHT);a=new CLabelTTF(cc.formatStr("%s\n%s\n%s\n%s\n%s\n%s",a.moves_start,a.moves_total,a.moves_remain,a.moves_extra,a.moves_spend,a.rubies),16,0,4);a.setPosition(b.getPositionX()+
b.getContentSize().width+10,145);a.setAnchorPoint(0,1);a.setHorizontalAlignment(cc.TEXT_ALIGNMENT_RIGHT);this.addChild(b);this.addChild(a)},clear:function(){this.removeAllChildren()}});cc.log("DEVELOPMENT - Grid");
Editor.Grid=cc.Node.extend({_cells:null,_rect:null,_shift:null,_select:null,_loaded:null,onSelect:null,ctor:function(){this._super();this._cells=[];this._select=[];this._shift=!1;this._rect=new cc.Rect(0,0,512,456);this.setContentSize(this._rect.width,this._rect.height);this.setAnchorPoint(.5,.5);for(var a=this,b=0;8>b;b++)for(var c=0;8>c;c++){var d=new Editor.Grid.Cell(8*c+b);d.setPosition(Editor.Grid.getPointXY(c,7-b));this._cells.push(d);this.addChild(d)}cc.eventManager.addListener({event:cc.EventListener.MOUSE,onMouseDown:this.onMouseDown.bind(this)},
this);"keyboard"in cc.sys.capabilities&&cc.eventManager.addListener({event:cc.EventListener.KEYBOARD,onKeyPressed:function(b,c){a._shift=16==b},onKeyReleased:function(b,c){a._shift=!1}},a)},loadData:function(a){for(var b=0;64>b;b++)this._cells[b].setCode(a[b]),this._cells[b].setSelect(!1);this._select=[];this._shift=!1;this._loaded=!0},updateCode:function(a,b){if(1==this._select.length)this._select[0].setCode(b);else for(var c in this._select){var d=this._select[c];if("id_4"==a){var e=d.getCode();
e[4]=b[4];d.setCode(e)}else"id_6"==a?(e=d.getCode(),e[6]=b[6],d.setCode(e)):d.setCode(b)}},getCode:function(){return this._cells.map(function(a){return a.getCode(!0).join("")})},onMouseDown:function(a){var b=this.convertToNodeSpace(a.getLocation());if(cc.rectContainsPoint(this._rect,b)&&this._loaded){a.stopPropagation();if(!this._shift){this._select=[];for(var c in this._cells)this._cells[c].setSelect(!1)}a=Editor.Grid.getTileId(b);0<=a&&(a=this._cells[a],a.isSelected()?(a.setSelect(!1),a=this._select.indexOf(a),
0<=a&&this._select.splice(a,1)):(a.setSelect(!0),this._select.push(a)),this.onSelect(this._select))}},clean:function(){for(var a=0;64>a;a++)this._cells[a].setCode("0000000"),this._cells[a].setSelect(!1);this._shift=!1;this._select=[];this._loaded=!1}});Editor.Grid.getPointX=function(a){return 64*a};Editor.Grid.getPointY=function(a){return 57*a};Editor.Grid.getPointXY=function(a,b){return new cc.Point(64*a,57*b)};
Editor.Grid.getTileId=function(a){var b=Math.floor(a.x/64);b=0<=b&&7>=b?b:-1;a=Math.floor(a.y/57);a=0<=a&&7>=a?7-a:-1;cc.log("tx:",b,"ty:",a,Math.random());return 0<=b&&0<=a?8*a+b:-1};Editor.Grid.SHAPES="abcdef".split("");Editor.Grid.RUBIES=["a","b","c","d","e"];Editor.Grid.BONUS="abdefghij".split("");
Editor.Grid.Cell=cc.Sprite.extend({_id:null,_center:null,_select:null,_container:null,_code:null,_error:null,getId:function(){return this._id},ctor:function(a){this._super(Resource.EDITOR.grid("back"));this._center=new cc.Point(32,28.5);this._id=a;this._select=null;this._container=new cc.Node;this._error=!1;this._code="0000000".split("");this.setAnchorPoint(0,0);this.addChild(this._container)},setSelect:function(a){a&&null==this._select?(this._select=new cc.Sprite(Resource.EDITOR.grid("select")),
this._select.setPosition(this._center),this.addChild(this._select,1E3)):a||null==this._select||(this._select.removeFromParent(),this._select=null)},isSelected:function(){return null!=this._select},setCode:function(a){this._error=!1;this._container.removeAllChildren();for(this._code=cc.isArray(a)?a:a.split("");7>this._code.length;)this._code.push("0");a=this._code;"s"==a[0]?(a[3]="0",a[5]="0",this._container.addChild(this.getBackground(a)),this._container.addChild(this.getSimpleShape(a)),this._container.addChild(this.getLockShape(a)),
this._container.addChild(this.getRubyShape(a))):"B"==a[0]?(a[2]="0",a[5]="0",this._container.addChild(this.getBackground(a)),this._container.addChild(this.getSimpleShape(a)),this._container.addChild(this.getBonusShape(a)),this._container.addChild(this.getLockShape(a))):"S"==a[0]?(a[1]="0",a[2]="0",a[3]="0",a[4]="0",this._container.addChild(this.getBackground(a)),this._container.addChild(this.getStoneShape(a))):"T"==a[0]?(a[1]="0",a[2]="0",a[3]="0",a[4]="0",a[5]="0",this._container.addChild(this.getBackground(a)),
this._container.addChild(this.getTitaniumShape(a))):"P"==a[0]?(a[1]="0",a[2]="0",a[3]="0",a[4]="0",a[5]="0",this._container.addChild(this.getBackground(a)),this._container.addChild(this.getPetrifierShape(a))):"F"==a[0]?(a[3]="0",a[5]="0",this._container.addChild(this.getBackground(a)),this._container.addChild(this.getSimpleShape(a)),this._container.addChild(this.getFrozenShape(a)),this._container.addChild(this.getLockShape(a)),this._container.addChild(this.getRubyShape(a))):"t"==a[0]?(a[2]="0",a[3]=
"0",a[4]="0",a[5]="0",this._container.addChild(this.getBackground(a)),this._container.addChild(this.getTreasureShape(a))):"O"==a[0]?(a[1]="*",a[2]="0",a[3]="0",a[4]="0",a[5]="1",a[6]="0",this._container.addChild(this.getTourchShape(a))):"I"==a[0]?(a[1]="0",a[2]="0",a[3]="0",a[4]="0",a[5]="0",this._container.addChild(this.getIceCubeShape(a))):"D"==a[0]?(a[1]="0",a[2]="0",a[3]="0",a[4]="0",this._container.addChild(this.getBackground(a)),this._container.addChild(this.getDiamoundShape(a))):"H"==a[0]?
(a[1]="0",a[2]="0",a[3]="0",a[4]="0",this._container.addChild(this.getBackground(a)),this._container.addChild(this.getbutterflyShape(a))):"C"==a[0]?(a[2]="0",a[3]="0",this._container.addChild(this.getBackground(a)),"1"==a[5]?this._container.addChild(this.getSimpleShape(a)):"0"==a[5]?this._container.addChild(this.getTitaniumShape(a)):this._error=!0,this._container.addChild(this.getChameleonShape(a)),this._container.addChild(this.getLockShape(a))):"b"==a[0]?(a[2]="0",a[3]="0",a[4]="0",this._container.addChild(this.getBackground(a)),
this._container.addChild(this.getBeetleShape(a))):"R"==a[0]?(a[1]="0",a[2]="0",a[3]="0",a[4]="0",a[5]="0",this._container.addChild(this.getBackground(a)),this._container.addChild(this.getRainbowShape(a))):(a[0]="0",a[1]="0",a[2]="0",a[3]="0",a[4]="0",a[5]="0",a[6]="0");this._error&&(this._container.removeAllChildren(),this._container.addChild(this.getErrorShape()))},getCode:function(a){for(var b=this._code.slice();a&&1<b.length&&"0"==b[b.length-1];)b.pop();return b},getSimpleShape:function(a){a=a[1];
if("0"==a)this._error=!0,a=new cc.Node;else if("1"==a){a=Editor.Grid.SHAPES[CUtils.random(0,5)];a=new cc.Sprite(Resource.EDITOR.grid("s_"+a));var b=new cc.Sprite(Resource.EDITOR.grid("rnd"));b.setScale(.8);b.setPosition(3,45);a.addChild(b)}else a=new cc.Sprite(Resource.EDITOR.grid("s_"+a));a.setPosition(32,28);return a},getBackground:function(a){a=a[6];"0"==a?a=new cc.Node:(this._error=!(0<a&&4>a),a=new cc.Sprite(Resource.EDITOR.grid("bg_"+(a-1))));a.setPosition(32,28);return a},getRubyShape:function(a){a=
a[2];if("0"==a)a=new cc.Node;else if("1"==a){a=Editor.Grid.RUBIES[CUtils.random(0,4)];a=new cc.Sprite(Resource.EDITOR.grid("r_"+a));var b=new cc.Sprite(Resource.EDITOR.grid("rnd"));b.setScale(.8);b.setPosition(-4,20);a.addChild(b)}else a=new cc.Sprite(Resource.EDITOR.grid("r_"+a));a.setPosition(32,28);return a},getLockShape:function(a){a=a[4];4<a?(this._error=!0,a=new cc.Node):a=0>=a?new cc.Node:new cc.Sprite(Resource.EDITOR.grid("lk_"+(a-1)));a.setPosition(32,28);return a},getBonusShape:function(a){a=
a[3];if("0"==a)this._error=!0,a=new cc.Node;else if("1"==a){a=Editor.Grid.BONUS[CUtils.random(0,Editor.Grid.BONUS.length-1)];a=new cc.Sprite(Resource.EDITOR.grid("b_"+a));var b=new cc.Sprite(Resource.EDITOR.grid("rnd"));b.setScale(.8);b.setPosition(.5*a.getContentSize().width-25,.5*a.getContentSize().height-20);a.addChild(b)}else a=new cc.Sprite(Resource.EDITOR.grid("b_"+a));a.setPosition(32,28);return a},getStoneShape:function(a){a=a[5];2<a?(this._error=!0,a=new cc.Node):a=new cc.Sprite(Resource.EDITOR.grid("stone_"+
a));a.setPosition(32,28);return a},getChameleonShape:function(a){"0"==a[1]&&(this._error=!0);a=new cc.Sprite(Resource.EDITOR.grid("chameleon"));a.setPosition(32,28);return a},getTitaniumShape:function(a){a=new cc.Sprite(Resource.EDITOR.grid("titan"));a.setPosition(32,28);return a},getPetrifierShape:function(a){a=new cc.Sprite(Resource.EDITOR.grid("petrifier"));a.setPosition(32,28);return a},getFrozenShape:function(a){a=new cc.Sprite(Resource.EDITOR.grid("snow"));a.setPosition(32,28);return a},getTreasureShape:function(a){a=
new cc.Sprite(Resource.EDITOR.grid("treasure"));a.setPosition(32,28);return a},getTourchShape:function(a){a=new cc.Sprite(Resource.EDITOR.grid("torch"));a.setPosition(32,28);return a},getIceCubeShape:function(a){a=new cc.Sprite(Resource.EDITOR.grid("icecube"));a.setPosition(32,28);return a},getDiamoundShape:function(a){a=a[5];1!=a&&2!=a?(this._error=!0,a=new cc.Node):a=new cc.Sprite(Resource.EDITOR.grid("diamond_"+a));a.setPosition(32,28);return a},getbutterflyShape:function(a){a=a[5];1!=a&&0!=a?
(this._error=!0,a=new cc.Node):a=new cc.Sprite(Resource.EDITOR.grid("butterfly_"+a));a.setPosition(32,28);return a},getBeetleShape:function(a){var b=a[1];if("0"==b){this._error=!0;var c=new cc.Node}else"1"==b?(b=Editor.Grid.SHAPES[CUtils.random(0,5)],c=new cc.Sprite(Resource.EDITOR.grid("beetle_"+b)),b=new cc.Sprite(Resource.EDITOR.grid("rnd")),b.setScale(.8),b.setPosition(6,45),c.addChild(b,10)):c=new cc.Sprite(Resource.EDITOR.grid("beetle_"+b));b=a[5];if(2<b||this._error)this._error=!0;else if(1==
b||2==b)a=new cc.Sprite(Resource.EDITOR.grid("beetle_"+b)),a.setAnchorPoint(0,0),c.addChild(a);c.setPosition(32,28);return c},getRainbowShape:function(a){a=new cc.Sprite(Resource.EDITOR.grid("rainbow"));a.setPosition(32,28);return a},getErrorShape:function(){var a=new cc.Sprite(Resource.EDITOR.grid("error"));a.setPosition(32,28);return a}});Editor.ComboBox=cc.Node.extend({_back:null,_items:null,_item:null,_menu:null,_label:null,_enabled:null,onChanged:null,ctor:function(a){this._super();this.onChanged=null;this._items=a;this._enabled=!0;this._menu=this._item=null;this._back=new CButton(Resource.EDITOR.img("009"),null,{b:.05},null);this._back.setAnchorPoint(0,0);this._back.setCbUp(this.menuOpen.bind(this));this.addChild(this._back);this._label=new CLabelTTF("",15,80,4);this._label.setAnchorPoint(0,0);this._label.setPosition(10,1);this._label.setHorizontalAlignment(cc.TEXT_ALIGNMENT_LEFT);
this.addChild(this._label)},getData:function(){return this._item?this._item.data:null},selectItem:function(a,b){for(var c in this._items){var d=this._items[c];if(d.data==a){this._item=d;this._label.setString(d.n);b&&this.onChanged&&this.onChanged(this);return}}this._item=null;this._label.setString("")},setEnabled:function(a){this._enabled=a;this._label.setVisible(a)},isEnabled:function(){return this._enabled},menuOpen:function(){if(!(this._menu&&this._menu.parent||!this._enabled)){this._menu=new cc.Node;
var a=this.convertToWorldSpace(new cc.Point(0,0)),b=new cc.Scale9Sprite(Resource.EDITOR.img("010"),new cc.Rect(25,25,5,5));b.setAnchorPoint(0,1);b.setPosition(a.x,a.y+23);b.setContentSize(b.getContentSize().width,22*this._items.length+30);this._menu.addChild(b);a=new CLabelTTF(this._item?this._item.n:"",15,80,4);a.setAnchorPoint(0,0);a.setPosition(10,b.getContentSize().height-22);a.setHorizontalAlignment(cc.TEXT_ALIGNMENT_LEFT);b.addChild(a);a=b.getContentSize().height-24;for(var c=0;c<this._items.length;c++){var d=
new cc.Sprite(Resource.EDITOR.img("011")),e=new CLabelTTF(this._items[c].n,16,110,9);e.setAnchorPoint(0,.5);e.setPosition(10,.5*d.getContentSize().height);e.setHorizontalAlignment(cc.TEXT_ALIGNMENT_LEFT);d.addChild(e);d.setAnchorPoint(0,0);d.setPosition(0,a-22*(c+1));b.addChild(d)}cc.eventManager.addListener({event:cc.EventListener.MOUSE,onMouseDown:this.mouseDown.bind(this)},b);cc.director.getRunningScene().addChild(this._menu)}},mouseDown:function(a){a.stopPropagation();var b=a.getCurrentTarget();
a=b.convertToNodeSpace(a.getLocation());var c=b.getContentSize();b=new cc.Rect(0,0,c.width,c.height);c=c.height-24;cc.rectContainsPoint(b,a)?(a=Math.floor((c-a.y)/22),0<=a&&a<this._items.length?(this.selectItem(this._items[a].data,!0),this.menuClose()):-1==a&&this.menuClose()):this.menuClose()},menuClose:function(){this._menu&&(this._menu.removeFromParent(),this._menu=null)}});var Map=Map||{};Map.EVENT={OPEN_NEXT_LEVEL:"MAP_OPEN_NEXT_LEVEL",UNLOCK_NEXT_CHAPTER:"MAP_UNLOCK_NEXT_CHAPTER",SCROLL_TO_LEVEL:"MAP_SCROLL_TO_LEVEL"};Map=Map||{};
Map.Utils=new (cc.Class.extend({ctor:function(){},getLevel:function(a,b){var c=cc.loader.getRes(Resource.MAP.levels(a));cc.assert(c,"levels not found");cc.assert(c[b-1].id==b,"bad config json");return c[b-1]},getPoster:function(a,b){var c=cc.loader.getRes(Resource.MAP.config(a));c=c?c.post:[];for(var d in c){var e=c[d];if(e.id==b)return e}return null},getLockId:function(a,b){return Math.floor((b-1)/10)+1},getKeys:function(a,b){switch(b-1){case 0:return 0;case 1:return 15;case 2:return 35;case 3:return 75;
default:return 30*(b-1)-10}}}));Map=Map||{};
Map.Default=cc.Layer.extend({_id:0,_ext:null,_countchapter:0,_enablechapter:0,_openchapter:0,_showchapter:0,_nextLevel:0,_segments:null,_context:null,_back:null,_batch:null,_loading:null,_levels:null,_config:null,_touch:null,_obs:null,_avs:null,_touchPoint:null,_touchMove:null,_scroll:null,_speed:0,_score:null,_highScore:null,_treasure:null,ctor:function(a){this._super();this._ext=new CExtNode(this);this._ext.addCustomListener(Map.EVENT.OPEN_NEXT_LEVEL,this.eventHandler.bind(this));this._ext.addCustomListener(Map.EVENT.UNLOCK_NEXT_CHAPTER,this.eventHandler.bind(this));
this._ext.addCustomListener(Map.EVENT.SCROLL_TO_LEVEL,this.eventHandler.bind(this));this._ext.addCustomListener(User.EVENT.SEND_LIFE_REWARD,this.eventHandler.bind(this));cc.log("OPEN MAP ARGS:",JSON.stringify(a));this._id=0;this._scroll=this._touch=!1;this._speed=7;this._obs=[];this._avs=[];this._nextLevel=0;this._levels=cc.loader.getRes(Resource.MAP.levels(this._id));this._config=cc.loader.getRes(Resource.MAP.config(this._id));this._config.obs.sort(function(a,c){return a.id-c.id});cc.assert(this._levels,
"undefined levels");cc.assert(this._config,"undefined config");this._score=User.getScoreById(this._id);this._highScore=User.getHighScoreById(this._id);this._score.getSize()>10*User.getUnlock()&&(User.setUnlock(User.getUnlock()+1),Backend.chapterUnlock(0,User.getUnlock(),"INAPP",function(){}));this._countchapter=app.config.ol(0);this._enablechapter=Math.min(app.config.ol(1),this._countchapter);this._openchapter=Math.min(User.getUnlock(),this._countchapter);this._showchapter=Math.min(6*Math.ceil((User.getUnlock()+
1)/6),this._countchapter);this._treasure=User.getTreasure();this._segments=[];this._context=new cc.Node;this._back=new cc.Node;this._batch=new cc.SpriteBatchNode(Resource.ATLASES.UI0_PNG);this._context.setAnchorPoint(0,0);this._back.setAnchorPoint(0,0);this._batch.setAnchorPoint(0,0);this._context.setContentSize(cc.size(510*Math.floor(this._showchapter/2)+252,1300));this._context.addChild(this._back);this._context.addChild(this._batch);app.config.intro()&&!app.config.introSkip()&&(this._openchapter=
0,app.config.update("intro_skip",1));this.addChild(this._context);this.scheduleUpdate();a.openAnim||void 0!==a.scrollTo?(a.openAnim||this.openNextLevel(!1,!1),a.scrollTo&&this.scrollToLevel(a.scrollTo)):(this.scrollToLevel(this._score.getSize()),this.openNextLevel(!1,!1));cc.eventManager.addListener({event:cc.EventListener.MOUSE,onMouseMove:this.mouseMove.bind(this),onMouseUp:this.mouseUp.bind(this),onMouseDown:this.mouseDown.bind(this)},this)},showLoading:function(a){a&&!this._loading?(this._loading=
new Map.Default.Loading,this._loading.setPosition(70,325),this.addChild(this._loading)):!a&&this._loading&&(this._loading.removeFromParent(),this._loading=null)},scrollToPoint:function(a,b,c){a=this.updateRect(new cc.Point(-a,-b));this._touchPoint=new cc.Point(0,0);this._touchMove=new cc.Point(a.x,a.y);this._scroll=!0;c||(this._context.setPosition(a),this.updateSegment())},scrollToLevel:function(a,b){a=Math.max(1,a);var c=this._config.obs[a-1];cc.assert(c.id==a,"bad config json");this.scrollToPoint(c.x-
380,c.y-325,b)},scrollToLock:function(a,b){a=Math.min(this._countchapter,Math.max(1,a))-1;this.scrollToPoint(2>a?0:510*Math.floor(a/2)+128,0==a%4||0==(a+1)%4?650:0,b)},openNextLevel:function(a,b){var c=this;this._nextLevel=this._score.getSize()+1;if(Math.floor((this._nextLevel-1)/10)>=this._openchapter)this._nextLevel=0,this._openchapter+1>this._enablechapter||(cc.eventManager.pauseTarget(this),this.scrollToLock(this._openchapter+1,a),this.runAction(new cc.Sequence([new cc.DelayTime(1),new cc.CallFunc(function(){cc.eventManager.resumeTarget(this);
Popup.PopChapterUnlock.show()},this)])));else{var d=this._batch.getChildByName("ob"+(this._nextLevel-1)),e=Math.floor((this._nextLevel-1)/20),f=this._segments[e];if(!d&&f){var g=this._config.obs[this._nextLevel-1],h=this._levels[this._nextLevel-1];cc.assert(g.id==this._nextLevel,"bad config json");cc.assert(Number(h.id)==this._nextLevel,"bad level json");var k=[];b&&k.push(new cc.CallFunc(function(){cc.eventManager.pauseTarget(this)},this));a||k.push(new cc.CallFunc(this.updateAvatar.bind(this,e)));
k.push(new cc.DelayTime(.1));for(var m in g.dots){var n=g.dots[m],p=new cc.Sprite(Resource.MAP.dot);p.setPosition(n.x,n.y);this._batch.addChild(p,0);f.dots.push(p);a&&(p.setScale(0),p.setVisible(!1),k.push(new cc.Sequence([new cc.DelayTime(.3),new cc.CallFunc(function(){this.runAction(new cc.Sequence([new cc.Show,new cc.ScaleTo(.1,1)]))},p),new cc.DelayTime(.1)])))}d=new Map.Default.Obelisk(this._nextLevel,h,this._score.getKey(this._nextLevel));d.setPosition(g.x+3,g.y-6);d.setName("ob"+(this._nextLevel-
1));d.setLastOpen(!0);a&&(d.setScale(0),k.push(new cc.Sequence([new cc.DelayTime(.3),new cc.CallFunc(function(){this.runAction(new cc.Sequence([new cc.ScaleTo(.1,1)]))},d)])),k.push(new cc.CallFunc(this.updateAvatar.bind(this,e))),k.push(new cc.DelayTime(.1)));b&&(k.push(new cc.DelayTime(.5)),k.push(new cc.CallFunc(function(){c.clickObelisk(h);cc.eventManager.resumeTarget(this)},this)));this.runAction(new cc.Sequence(k));this._batch.addChild(d,1);this._obs.push(d);f.obs.push(d)}if(f&&d)for(m in f.treasure)e=
f.treasure[m],d.getId()==e.getId()&&d.setVisible(!1);this._obs.forEach(function(a){a.setLastOpen(a==d)});this.scrollToLevel(this._nextLevel,a)}},loadSegment:function(a){var b;if(!(0>a||this._segments[a])){var c=20*a;var d=20*a+20;var e=this._segments[a]={back:null,poster:null,obs:[],dots:[],locks:[],treasure:[],avatar:[]},f=Math.floor(a/3);if(2*a<this._countchapter){null==this._highScore.getData(60*f+1,!1)&&this._highScore.query(60*f+1,60*f+60);e.back=this._back.getChildByTag(f);if(!e.back){var g=
Resource.MAP.segment(f);(b=cc.textureCache.getTextureForKey(g))&&!b.isLoaded()&&cc.textureCache.removeTextureForKey(g);e.back=new cc.Sprite(g);e.back.setAnchorPoint(0,0);e.back.setPositionX(0==f?0:1530*f+242);this._back.addChild(e.back,f,f)}f=this._score.getSize();f+1==this._nextLevel&&f++;f>10*this._openchapter&&(f=10*this._openchapter);for(var h=c;h<d;h++)b=User.getFriendsByLevel(h),0<b.length&&(g=this._config.obs[h],b=new Map.Default.Avatars(h+1,b),null==g&&cc.log("g"),b.setPosition(g.x,g.y),this._batch.addChild(b,
10),e.avatar.push(b));for(h=c;h<Math.min(f,d);h++){g=this._config.obs[h];b=this._levels[h];cc.assert(g.id==h+1,"bad config json");cc.assert(Number(b.id)==h+1,"bad level json");b=new Map.Default.Obelisk(h+1,b,this._score.getKey(h+1));b.setPosition(g.x+3,g.y-6);b.setName("ob"+h);b.setLastOpen(h+1==this._nextLevel);this._batch.addChild(b,1);e.obs.push(b);for(var k in g.dots){var m=g.dots[k];b=new cc.Sprite(Resource.MAP.dot);b.setPosition(m.x,m.y);this._batch.addChild(b,0);e.dots.push(b)}}if(this._treasure.isActive())for(k in b=
this._treasure.getList(),b)if(m=b[k],0==m.s&&CUtils.between(c+1,d,m.l)&&(m.l>f||m.l==f&&m.l==this._nextLevel)&&(g=this._config.obs[m.l-1],h=new Map.Default.Treasure(m.l,m.id),h.setPosition(g.x+10,g.y+10),this._batch.addChild(h,1),e.treasure.push(h),m.l==f))for(n in e.obs)g=e.obs[n],g.getId()==h.getId()&&g.setVisible(!1);2*(a+1)==this._countchapter&&this._score.getSize()==10*this._countchapter&&(c=Map.Utils.getPoster(this._id,a))&&(e.poster=new cc.Sprite(Resource.MAP.poster),e.poster.setPosition(c.x,
c.y),this._batch.addChild(e.poster))}this._obs=[];this._avs=[];for(k in this._segments)this._obs=this._obs.concat(this._segments[k].obs),this._avs=this._avs.concat(this._segments[k].avatar);this.updateAvatar(a);f=0==a?this._config.cloud1:this._config.cloud0;if(2*a>=this._openchapter&&this._openchapter<this._countchapter){var n={id:2*a,clouds:[],node:null};d=0==a?0:510*a+128;c=0==a%2?650:0;for(k in f)b=new cc.Sprite(Resource.MAP.cloud0),b.setPosition(f[k].x+d,f[k].y+c),b.setScaleX(f[k].sx),b.setScaleY(f[k].sy),
b.setRotation(f[k].r),this._batch.addChild(b,1),n.clouds.push(b);n.node=new cc.Sprite(Resource.MAP.empty);n.node.setPosition(d+(0==a?380:255),c+325);this._batch.addChild(n.node,2);n.ico=new cc.Sprite(Resource.MAP.lock);n.ico.setPosition(0,0);n.node.addChild(n.ico,1);n.node.setVisible(0!=a);20*a==this._score.getSize()&&(2*a>=this._enablechapter?(n.cloud=new cc.Sprite(Resource.MAP.cloud2),n.cloud.setPosition(0,-120),n.cloud.runAction(new cc.RepeatForever(new cc.Sequence([new cc.FadeTo(1,200),new cc.FadeTo(1,
255)]))),n.cloud.runAction(new cc.RepeatForever(new cc.Sequence([new cc.ScaleTo(1,1.05),new cc.ScaleTo(1,1)]))),n.node.addChild(n.cloud,0)):(n.ico.runAction(new cc.RepeatForever(new cc.Sequence([new cc.FadeTo(1,200),new cc.FadeTo(1,255)]))),n.arrow=new cc.Sprite(Resource.MAP.arrow),n.arrow.setPosition(0,75),n.arrow.setRotation(90),n.arrow.runAction(new cc.RepeatForever(new cc.Sequence([new cc.MoveTo(.45,0,75),new cc.MoveTo(.55,0,90)]))),n.node.addChild(n.arrow,0),n.cloud=new cc.Sprite(Resource.MAP.cloud1),
n.cloud.setPosition(0,-70),n.cloud.runAction(new cc.RepeatForever(new cc.Sequence([new cc.FadeTo(1,200),new cc.FadeTo(1,255)]))),n.cloud.runAction(new cc.RepeatForever(new cc.Sequence([new cc.ScaleTo(1,1.05),new cc.ScaleTo(1,1)]))),n.node.addChild(n.cloud,0),0==User.getUnlockTimer()&&User.setUnlockTimer(TimeUtils.getTime())));e.locks.push(n)}if(2*a+1>=this._openchapter&&this._openchapter<this._countchapter){n={id:2*a+1,clouds:[],node:null};d=0==a?0:510*a+128;c=0==a%2?0:650;for(k in f)b=new cc.Sprite(Resource.MAP.cloud0),
b.setPosition(f[k].x+d,f[k].y+c),b.setScaleX(f[k].sx),b.setScaleY(f[k].sy),b.setRotation(f[k].r),this._batch.addChild(b,1),n.clouds.push(b);n.node=new cc.Sprite(Resource.MAP.empty);n.node.setPosition(d+(0==a?380:255),c+325);this._batch.addChild(n.node,2);n.ico=new cc.Sprite(Resource.MAP.lock);n.ico.setPosition(0,0);n.node.addChild(n.ico,1);10*(2*a+1)==this._score.getSize()&&(2*a+1>=this._enablechapter?(n.cloud=new cc.Sprite(Resource.MAP.cloud2),n.cloud.setPosition(0,-120),n.cloud.runAction(new cc.RepeatForever(new cc.Sequence([new cc.FadeTo(1,
200),new cc.FadeTo(1,255)]))),n.cloud.runAction(new cc.RepeatForever(new cc.Sequence([new cc.ScaleTo(1,1.05),new cc.ScaleTo(1,1)]))),n.node.addChild(n.cloud,0)):(n.ico.runAction(new cc.RepeatForever(new cc.Sequence([new cc.FadeTo(1,200),new cc.FadeTo(1,255)]))),n.arrow=new cc.Sprite(Resource.MAP.arrow),n.arrow.setPosition(0,75),n.arrow.setRotation(90),n.arrow.runAction(new cc.RepeatForever(new cc.Sequence([new cc.MoveTo(.45,0,75),new cc.MoveTo(.55,0,90)]))),n.node.addChild(n.arrow,0),n.cloud=new cc.Sprite(Resource.MAP.cloud1),
n.cloud.setPosition(0,-70),n.cloud.runAction(new cc.RepeatForever(new cc.Sequence([new cc.FadeTo(1,200),new cc.FadeTo(1,255)]))),n.cloud.runAction(new cc.RepeatForever(new cc.Sequence([new cc.ScaleTo(1,1.05),new cc.ScaleTo(1,1)]))),n.node.addChild(n.cloud,0),0==User.getUnlockTimer()&&User.setUnlockTimer(TimeUtils.getTime())));e.locks.push(n)}}},removeSegment:function(a){if(this._segments[a]){var b=this._segments[a];delete this._segments[a];for(var c in b.obs)b.obs[c].removeFromParent();for(c in b.dots)b.dots[c].removeFromParent();
for(c in b.locks){var d=b.locks[c];d.clouds.forEach(function(a){a.removeFromParent()});d.node.removeFromParent()}for(c in b.treasure)b.treasure[c].removeFromParent();for(c in b.avatar)b.avatar[c].removeFromParent();a=3*Math.floor(a/3);!b.back||this._segments[a]||this._segments[a+1]||this._segments[a+2]||b.back.removeFromParent();b.poster&&b.poster.removeFromParent();this._obs=[];this._avs=[];for(c in this._segments)this._obs=this._obs.concat(this._segments[c].obs),this._avs=this._avs.concat(this._segments[c].avatar)}},
updateSegment:function(){var a=380-this._context.getPositionX()-242;a=Math.floor(a/510);this.loadSegment(a-1);this.loadSegment(a);this.loadSegment(a+1);this.removeSegment(a-2);this.removeSegment(a+2)},updateAvatar:function(a){var b=null,c=this._score.getSize();c+1==this._nextLevel&&c++;c>10*this._openchapter&&(c=10*this._openchapter);if(void 0==a||a==Math.floor((c-1)/20)){for(var d in this._avs)a=this._avs[d],a.getId()!=c?a.removeAvatar(User):b=a;if(b)b.addAvatar(User);else if(b=this._segments[Math.floor((c-
1)/20)])d=this._config.obs[c-1],c=new Map.Default.Avatars(c,[User]),c.setPosition(d.x,d.y),this._batch.addChild(c,10),b.avatar.push(c)}},unlockChapter:function(a){a=Math.min(a,this._countchapter);if(this._openchapter>=a||a>this._openchapter+1||a>this._enablechapter)cc.log("try open invalid chapter");else{User.setUnlock(a);this._openchapter=a;var b=null,c;for(c in this._segments){var d=this._segments[c];for(var e in d.locks)null==b&&d.locks[e].id==a-1&&(b=d.locks[e],delete d.locks[e])}null!=b&&(b.node.removeFromParent(),
b.clouds.forEach(function(a){a.runAction(new cc.Sequence([new cc.FadeTo(1.5,20),new cc.RemoveSelf]))}),d=new Popup.PopChapterUnlocked({id:a}),d.setOnClose(this.openNextLevel.bind(this,!0,!0)),d.show(1.5));if(this._openchapter==this._countchapter)for(c in this._segments){d=this._segments[c];for(var f in d.locks)a=d.locks[f],a.clouds.forEach(function(a){a.runAction(new cc.Sequence([new cc.FadeTo(1.5,20),new cc.RemoveSelf]))}),a.clouds=[]}}},getChapter:function(a){var b=2*Math.floor(Math.max(0,a.x-128)/
510);return b=0==b%4?b+(650<a.y?1:2):b+(650<a.y?2:1)},mouseDown:function(a){AudioEngine.playEffect(Resource.SND.CLICK);this._touchPoint=this._context.convertToNodeSpace(a.getLocation());this._touchMove=a.getLocation();this._touch=!0},mouseUp:function(a){var b=this;if(5>CUtils.distance(a.getLocation(),this._touchMove)&&!this._scroll&&this._touch){var c=this._batch.convertToNodeSpace(a.getLocation());c=this.getChapter(c);for(var d in this._avs)if(this._avs[d].checkClick(a.getLocation())){this._touch=
!1;return}if(c<=this._openchapter)for(d in this._obs){c=this._obs[d];var e=c.convertToNodeSpace(a.getLocation());cc.rectContainsPoint(c.getRect(),e)&&(c.showPortal(!1),this.clickObelisk(c.getData()))}else{var f=this._score.getSize()==10*this._openchapter,g=this._openchapter+1<=this._enablechapter;c-1==this._openchapter&&f&&g?(this.scrollToLock(c,!0),Popup.PopChapterUnlock.show()):g&&(a=new Popup.PopChapterClosed,a.setOnClose(function(){f&&g?(b.scrollToLock(b._openchapter+1,!0),(new Popup.PopChapterUnlock).show()):
b.scrollToLevel(b._score.getSize(),!0)}),a.show())}}this._touch=!1},mouseMove:function(a){if(this._touch)this._touchMove=a.getLocation();else{for(var b in this._obs){var c=this._obs[b],d=c.convertToNodeSpace(a.getLocation());c.showPortal(cc.rectContainsPoint(c.getRect(),d))}for(b in this._avs)this._avs[b].checkHover(a.getLocation())}},update:function(a){if(this._touch||this._scroll){a=this._context.getPosition();var b=Math.round((a.x-this._touchMove.x+this._touchPoint.x)/this._speed),c=Math.round((a.y-
this._touchMove.y+this._touchPoint.y)/this._speed);0==b&&0==c?this._scroll=!1:(this._scroll=!0,a.x-=b,a.y-=c,c=this.updateRect(a),c.x<a.x?(this._touchMove.x=c.x+this._touchPoint.x,this.showLoading(0!=c.x)):0!=b&&this.showLoading(!1),c.x==this._context.getPositionX()&&(this._touchMove.x=c.x+this._touchPoint.x),c.y!=a.y&&(this._touchMove.y=c.y+this._touchPoint.y),this._context.setPosition(c),this.updateSegment())}},updateRect:function(a){var b=this.getContentSize(),c=this._context.getContentSize();
a=new cc.Point(a.x,a.y);0<a.x?a.x=0:a.x<b.width-c.width&&(a.x=b.width-c.width);for(var d=380-a.x-242,e=Math.floor(d/510);0<=e;e--){var f=this._segments[e];if(f)if(0!=f.back.getContentSize().width)d=-f.back.getPositionX();else break;else break}d<a.x&&(a.x=d);0<a.y?a.y=0:a.y<b.height-c.height&&(a.y=b.height-c.height);return a},clickObelisk:function(a){if(this._treasure.hasTreasure(a.id)){var b=this._segments[Math.floor((a.id-1)/20)],c=null,d=null,e;for(e in b.treasure){var f=b.treasure[e];if(f.getId()==
a.id){d=f;break}}for(e in b.obs)if(f=b.obs[e],f.getId()==a.id){c=f;break}c.setVisible(!0);null!=d&&d.isVisible()&&(d.setVisible(!1),Popup.PopChallenge.show({mode:"open",id:d.getType()},0,null,10),Popup.PopChallenge.show({mode:"claim",id:d.getType(),levelId:a.id},0,null,5))}f={};f.level=a;f.mapId=this._id;f.keys=this._score.getKey(a.id);Popup.PopBeginLevel.show(f)},eventHandler:function(a){var b=this,c=a.getEventName();c==Map.EVENT.OPEN_NEXT_LEVEL?(a=a.getUserData()||{},a.levelId==this._score.getSize()&&
(0==Popup.getSize()?b.openNextLevel(!0,!0):cc.director.getScheduler().schedule(function(){0==Popup.getSize()&&(b.openNextLevel(!0,!0),cc.director.getScheduler().unschedule("wait_pop_close",b))},b,.1,cc.REPEAT_FOREVER,0,!1,"wait_pop_close"))):c==Map.EVENT.UNLOCK_NEXT_CHAPTER?10*this._openchapter!==this._score.getSize()?cc.warn("try open invalid chapter id"):(c=this._openchapter+1,a=a.getUserData(),cc.assert(a&&a.type,"undefined unlock type"),Backend.chapterUnlock(0,c,a.type,function(a){a?b.unlockChapter(b._openchapter+
1):Popup.alert(Popup.ALERT.NETWORK)})):c==Map.EVENT.SCROLL_TO_LEVEL?(a=a.getUserData(),a.levelId&&this.scrollToLevel(a.levelId,a.anim)):c==User.EVENT.SEND_LIFE_REWARD&&(a=a.getUserData(),1<a.data.length?app.Scene.getCurrent().addChild(new Map.Default.Notificarion(Lang.getString(Lang.MAP_REWARD_MSG1,a.reward))):app.Scene.getCurrent().addChild(new Map.Default.Notificarion(Lang.getString(Lang.MAP_REWARD_MSG0,a.data[0].getFirstName(),a.reward))))}});
Map.Default.Obelisk=cc.Sprite.extend({_id:0,_data:null,_rect:null,_key0:null,_key1:null,_key2:null,_lb:null,_arrow:null,_portal:null,_lastopen:null,ctor:function(a,b,c){this._super(Resource.MAP.obelisk);this._id=a;this._data=b;this._portal=this._arrow=null;this._lastopen=!1;a=this.getContentSize();this._rect=cc.rect(0,0,a.width,a.height);this._key0=new cc.Sprite(Resource.MAP.sphere);this._key0.setPosition(6,35);this._key0.setVisible(0<c);this._key1=new cc.Sprite(Resource.MAP.sphere);this._key1.setPosition(45,
35);this._key1.setVisible(1<c);this._key2=new cc.Sprite(Resource.MAP.sphere);this._key2.setPosition(25,14);this._key2.setVisible(2<c);this._lb=this.buildNumber(this._id);this._lb.setPosition(26,29);this.addChild(this._key0);this.addChild(this._key1);this.addChild(this._key2);this.addChild(this._lb)},getId:function(){return this._id},getData:function(){return this._data},getRect:function(){return this._rect},setLastOpen:function(a){this._lastopen=a;this.showPortal(a);this.showArrow(a)},buildNumber:function(a){var b=
new cc.Node;a=CUtils.numToArray(a);var c=new cc.Size(6,11),d;for(d in a){var e=new cc.Sprite(Resource.MAP.num(a[d]));e.setAnchorPoint(0,0);e.setPosition(c.width*d,0);b.addChild(e)}b.setContentSize(c.width*a.length,c.height);b.setAnchorPoint(.5,.5);return b},buildPortal:function(){for(var a=[],b=null,c=0;5>c;c++){var d=Resource.MAP.portal(c);a.push(cc.spriteFrameCache.getSpriteFrame(d));0==c&&(b=new cc.Sprite(d))}a=new cc.Animation(a,1/9);b.runAction(new cc.RepeatForever(new cc.Animate(a)));return b},
showArrow:function(a){a&&null==this._arrow?(a=new cc.Point(25,-15),this._arrow=new cc.Sprite(Resource.MAP.arrow),this._arrow.setRotation(270),this._arrow.setPosition(a),this._arrow.runAction(new cc.RepeatForever(new cc.Sequence([new cc.MoveBy(.5,0,-10),new cc.MoveBy(.5,0,10)]))),this.addChild(this._arrow)):a||null==this._arrow||(this._arrow.removeFromParent(),this._arrow=null)},showPortal:function(a){if(a||!this._lastopen)a&&null==this._portal?(this._portal=this.buildPortal(),this._portal.setAnchorPoint(.5,
0),this._portal.setVisible(!1),this._portal.setScaleY(.2),this._portal.setPosition(new cc.Point(26,15)),this._portal.runAction(new cc.Sequence([new cc.DelayTime(.3),new cc.Spawn([new cc.Show,new cc.ScaleTo(.1,1,1),new cc.MoveTo(.1,26,3)])])),this.addChild(this._portal)):a||null==this._portal||(this._portal.runAction(new cc.Sequence([new cc.Spawn([new cc.ScaleTo(.1,1,.1),new cc.MoveTo(.1,26,15)]),new cc.RemoveSelf])),this._portal=null)}});
Map.Default.Loading=cc.Node.extend({ctor:function(){this._super();var a=new cc.Sprite(Resource.UI.img("002"));a.runAction(new cc.RepeatForever(new cc.Sequence([new cc.ScaleTo(1,1),new cc.ScaleTo(1.5,.95)])));this.addChild(a);a=new cc.Sprite(Resource.UI.img("001"));this.addChild(a);a=new cc.Sprite(Resource.UI.img("003"));a.setPosition(1,0);a.runAction(new cc.RepeatForever(new cc.Sequence([new cc.RotateTo(1,180),new cc.RotateTo(1,360)])));this.addChild(a);a=new cc.Sprite(Resource.UI.img("005"));a.runAction(new cc.RepeatForever(new cc.Sequence([new cc.ScaleTo(1,
1),new cc.ScaleTo(1.5,.95)])));this.addChild(a);a=new cc.Sprite(Resource.UI.img("004"));this.addChild(a)}});
Map.Default.Treasure=cc.Sprite.extend({_id:null,_lb:null,ctor:function(a,b){this._super(Resource.MAP.treasure(0==b?"000":1==b?"001":"002"));this._id=a;this._type=b;this._lb=new CLabelTTF("00:00:00",16,150,1);this._lb.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);this._lb.setPosition(64,14);this._lb.runAction(new cc.RepeatForever(new cc.Sequence([new cc.CallFunc(function(){var a=User.getTreasure().getExpired()-TimeUtils.getTime();this.setString(CUtils.getStringTime(a))},
this._lb),new cc.DelayTime(1)])));this.addChild(this._lb)},getId:function(){return this._id},getType:function(){return this._type}});
Map.Default.Avatars=cc.Sprite.extend({_id:null,_expand:!1,_rect:null,ctor:function(a,b){this._super(Resource.MAP.empty);this._id=a;this._expand=!1;this._rect=new cc.Rect(-25,-25,50,50);for(var c=0;c<Math.min(8,b.length);c++){var d=new Map.Default.Avatars.Item(b[c]);this.addChild(d)}this.updateOrder(!0)},addAvatar:function(a){for(var b in this._children)if(this._children[b].getUser()==a)return;7<this.getChildrenCount()&&this._children[0].removeFromParent();this.addChild(new Map.Default.Avatars.Item(a));
this.updateOrder(!0)},removeAvatar:function(a){for(var b in this._children){var c=this._children[b];c.getUser()==a&&c.removeFromParent()}this.updateOrder(!0)},getId:function(){return this._id},getPX:function(a){return parseInt(60*Math.cos(Math.PI/180*-a*45)-2)},getPY:function(a){return parseInt(60*Math.sin(Math.PI/180*-a*45)+5)},expand:function(a){if(this._expand!=a&&(this._expand=!this._expand,!(2>this.getChildrenCount()))){this._expand||this.updateOrder();for(var b in this._children)a=this._children[b],
a.stopActionByTag(1),this._expand?a.runAction(new cc.Sequence(new cc.DelayTime(.3),new cc.MoveTo(.3,a.ep))).setTag(1):a.runAction(new cc.MoveTo(.2,a.cp)).setTag(1)}},updateOrder:function(a){var b=TimeUtils.getTime();this._children.sort(function(a,c){return a.getUser().getGiftTime(b)<c.getUser().getGiftTime(b)});for(var c=0;c<this._children.length;c++){var d=this._children[c];d.cp=new cc.Point(this.getPX(0)-c,this.getPY(0)+c);d.ep=new cc.Point(this.getPX(c),this.getPY(c));d.setLocalZOrder(c);a&&d.setPosition(this._expand?
d.ep:d.cp)}},checkHover:function(a){var b=!1;this._expand?b=cc.rectContainsPoint(this.getBoundingBoxToWorld(),a):0<this._children.length&&(b=cc.rectContainsPoint(this._rect,this._children[0].convertToNodeSpace(a)));this.expand(b)},checkClick:function(a){var b=User.getFriends(),c;for(c in this._children){var d=this._children[c];if(cc.rectContainsPoint(this._rect,d.convertToNodeSpace(a)))return 0==d.getNumberOfRunningActions()&&b.sendGift(d.getUser(),"map_avatar"),!0}return!1}});
Map.Default.Avatars.Item=cc.Node.extend({_user:null,_ext:null,_heart:null,ctor:function(a){this._super();this._user=a;this._ext=new CExtNode(this);this.addChild(new cc.Sprite(Resource.MAP.avatar("back")));this.addChild(new cc.Sprite(Resource.MAP.avatar("front")),1);cc.textureCache.addImage(this._user.getPicture(),function(a){if(a instanceof cc.Texture2D){var b=.5*(a.width-Math.round(1*a.width));b=new cc.rect(b,0,a.width-b,a.height);a=new cc.Sprite(a,b);a.setScale(33/a.getContentSize().width);this.addChild(a)}},
this);0>this._user.getGiftTime()?(this._heart=new cc.Sprite(Resource.MAP.avatar("heart")),this._heart.setPosition(-13,12),this._heart.runAction(new cc.RepeatForever(new cc.Sequence(new cc.MoveTo(.5,this._heart.getPositionX(),this._heart.getPositionY()-1),new cc.MoveTo(.5,this._heart.getPositionX(),this._heart.getPositionY()+1)))),this.addChild(this._heart,2)):this._heart=null;this._ext.addCustomListener(User.EVENT.UPDATE_FRIEND,this.eventHandler.bind(this))},getUser:function(){return this._user},
eventHandler:function(a){var b=a.getEventName();a=a.getUserData();this._heart&&b==User.EVENT.UPDATE_FRIEND&&a.data&&-1!=a.data.indexOf(this._user)&&this._heart.setVisible(0>this._user.getGiftTime())}});
Map.Default.Notificarion=cc.Node.extend({ctor:function(a){this._super();var b=cc.director.getWinSize(),c=new cc.LayerColor(new cc.Color(0,0,0,255),760,100);c.ignoreAnchorPointForPosition(!1);c.setPosition(.5*b.width,.5*b.height);c.setOpacity(100);c.setScale(0);c.runAction(new cc.Spawn(new cc.FadeTo(.2,230),new cc.ScaleTo(.2,1)));this.addChild(c);a=new CLabelTTF(a,36,700,1);a.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);a.setPosition(c.getPosition());a.setScale(0);a.runAction(new cc.ScaleTo(.2,
1));this.addChild(a);this.runAction(new cc.Sequence([new cc.DelayTime(1.8),new cc.RemoveSelf]))}});Map=Map||{};
Map.Adventure=cc.Layer.extend({_id:null,_level:null,_config:null,_score:null,_back:null,_touch:null,_obs:null,ctor:function(a){this._super();this._id=a;this._touch=!1;this._obs=[];this._levels=cc.loader.getRes(Resource.MAP.levels(this._id));this._config=cc.loader.getRes(Resource.MAP.config(this._id));this._config.obs.sort(function(a,b){return a.id-b.id});this._score=User.getScoreById(this._id);this._back=new cc.Sprite(Resource.MAP.back(this._id,0));this._back.setAnchorPoint(0,0);this.addChild(this._back);a=
Math.min(15,this._score.getSize()+1);for(var b=0;b<a;b++){var c=this._config.obs[b],d=this._levels[b];cc.assert(c.id==b+1,"bad config json");cc.assert(Number(d.id)==b+1,"bad level json");d=new Map.Adventure.Obelisk(b+1,d,this._score.getKey(b+1));d.setPosition(c.x+3,c.y-6);d.setName("ob"+b);d.setLastOpen(b+1==a);this.addChild(d);this._obs.push(d)}cc.eventManager.addListener({event:cc.EventListener.MOUSE,onMouseMove:this.mouseMove.bind(this),onMouseUp:this.mouseUp.bind(this),onMouseDown:this.mouseDown.bind(this)},
this)},mouseDown:function(a){AudioEngine.playEffect(Resource.SND.CLICK);this._touch=!0},mouseMove:function(a){if(!this._touch)for(var b in this._obs){var c=this._obs[b],d=c.convertToNodeSpace(a.getLocation());c.showPortal(cc.rectContainsPoint(c.getRect(),d))}},mouseUp:function(a){if(this._touch)for(var b in this._obs){var c=this._obs[b],d=c.convertToNodeSpace(a.getLocation());cc.rectContainsPoint(c.getRect(),d)&&(c.showPortal(!1),this.clickObelisk(c.getData()))}this._touch=!1},clickObelisk:function(a){var b=
{};b.level=a;b.mapId=this._id;b.keys=this._score.getKey(a.id);Popup.PopBeginLevel.show(b)}});
Map.Adventure.Obelisk=cc.Node.extend({_id:0,_data:null,_lastopen:null,_portal:null,_rect:null,ctor:function(a,b,c){this._super();this._id=a;this._data=b;this._lastopen=!1;this._rect=cc.rect(-30,-30,60,70);this.addChild(new cc.Sprite(Resource.MAP.ADV.obelisk),1);a=this.buildNumber(this._id);a.setPosition(0,2);this.addChild(a,1);1==c?(a=new cc.Sprite(Resource.MAP.ADV.sphere),a.setPosition(2,31),this.addChild(a,1)):2==c?(a=new cc.Sprite(Resource.MAP.ADV.sphere),c=new cc.Sprite(Resource.MAP.ADV.sphere),
a.setPosition(-8,31),c.setPosition(16,30),this.addChild(a,1),this.addChild(c,1)):3==c&&(a=new cc.Sprite(Resource.MAP.ADV.sphere),c=new cc.Sprite(Resource.MAP.ADV.sphere),b=new cc.Sprite(Resource.MAP.ADV.sphere),a.setPosition(3,33),c.setPosition(-18,29),b.setPosition(23,27),this.addChild(a,1),this.addChild(c,1),this.addChild(b,1))},getId:function(){return this._id},getData:function(){return this._data},getRect:function(){return this._rect},buildNumber:function(a){var b=new cc.Node;a=CUtils.numToArray(a);
var c=new cc.Size(11,11),d;for(d in a){var e=new cc.Sprite(Resource.MAP.ADV.num(a[d]));e.setAnchorPoint(0,0);e.setScale(.6);e.setPosition(c.width*d,0);b.addChild(e)}b.setContentSize(c.width*a.length,c.height);b.setAnchorPoint(.5,.5);return b},showPortal:function(a){if(a||!this._lastopen)a&&null==this._portal?(this._portal=new cc.Sprite(Resource.MAP.ADV.obelisk_glow),this._portal.setPosition(new cc.Point(2,-1)),this._portal.setScale(.9),this._portal.runAction(new cc.RepeatForever(new cc.Sequence(new cc.ScaleTo(.8,
.9),new cc.ScaleTo(.8,1.1)))),this.addChild(this._portal,0)):a||null==this._portal||(this._portal.runAction(new cc.Sequence([new cc.ScaleTo(.2,.7),new cc.RemoveSelf])),this._portal=null)},setLastOpen:function(a){this._lastopen=a;this.showPortal(a)}});
Map.Adventure.Menu=cc.Node.extend({_wsize:null,_btLT:null,_btRT:null,_pages:null,_page:null,_index:0,ctor:function(a){this._super();this._wsize=cc.director.getWinSize();this.setPosition(.5*this._wsize.width,.5*this._wsize.height);this._index=a;this._btLT=new CButton(Resource.MAP.ADV.arrow,null,{b:.07},{b:-.15});this._btLT.setPosition(-340,0);this._btLT.setCbUp(this.clickLeft.bind(this));this._btRT=new CButton(Resource.MAP.ADV.arrow,null,{b:.07},{b:-.15});this._btRT.setPosition(340,0);this._btRT.setCbUp(this.clickRight.bind(this));
this._btRT.setFlippedX(!0);this.addChild(this._btLT,1);this.addChild(this._btRT,1);this._page=this.buildPage(this._index);this.addChild(this._page)},clickLeft:function(){0<this._index&&this._page&&0==this._page.getNumberOfRunningActions()&&(this._index--,this._page.runAction(new cc.Sequence(new cc.MoveTo(.4,760,0),new cc.RemoveSelf)),this._page=this.buildPage(this._index),this._page.setPosition(-760,0),this._page.runAction(new cc.MoveTo(.4,0,0)),this.addChild(this._page))},clickRight:function(){8>
this._index&&this._page&&0==this._page.getNumberOfRunningActions()&&(this._index++,this._page.runAction(new cc.Sequence(new cc.MoveTo(.4,-760,0),new cc.RemoveSelf)),this._page=this.buildPage(this._index),this._page.setPosition(760,0),this._page.runAction(new cc.MoveTo(.4,0,0)),this.addChild(this._page))},buildPage:function(a){var b=new cc.Sprite(Resource.MAP.ADV.back),c=new cc.Sprite(Resource.MAP.ADV.title(a));c.setPosition(380,550);b.addChild(c);for(c=0;12>c;c++){var d=new Map.Adventure.Item(22+
12*a+c);d.setScale(.95);d.setPosition(c%4*134+180,455-155*Math.floor(c/4));b.addChild(d,c)}return b}});
Map.Adventure.Item=cc.Node.extend({_ext:null,_mapId:null,_ico:null,_win:null,_lb:null,ctor:function(a){this._super();this.setTag(a);this._ext=new CExtNode(this);this._mapId=a;if(a>app.config.ol(2))this.addChild(new cc.Sprite(Resource.MAP.ADV.building(a,"a")));else{this._ext.addCustomListener(User.EVENT.UPDATE_SCORE,this.eventHandler.bind(this));var b=new CButton(Resource.MAP.ADV.building(a,"b"),null,{b:.07},{b:-.15});b.setCbUp(app.loadMap.bind(this,a));this.addChild(b);a=User.getScoreById(this._mapId);
a.isReady()||a.restGetData();this._win=new cc.Sprite(Resource.MAP.ADV.complete);this._win.setPosition(0,-68);this._win.setVisible(a.isReady()&&15<=a.getSize());this.addChild(this._win);this._ico=new cc.Sprite(Resource.MAP.ADV.sphere);this._ico.setPosition(-22,-75);this._ico.setScale(.9);this._ico.setVisible(a.isReady());this.addChild(this._ico);this._lb=new CLabelTTF(cc.formatStr("%s / %s",a.getKeys(),45),16,0,2);this._lb.setAlignment(cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);this._lb.setAnchorPoint(0,
.5);this._lb.setPosition(-9,-75);this._lb.setVisible(a.isReady());this.addChild(this._lb)}},eventHandler:function(a){var b=a.getEventName();a=a.getUserData()||{};b==User.EVENT.UPDATE_SCORE&&a.getMapId()==this._mapId&&(this._lb.setString(cc.formatStr("%s / %s",a.getKeys(),45)),this._win.setVisible(15<=a.getSize()),this._ico.setVisible(!0),this._lb.setVisible(!0))}});cc.log("DEVELOPMENT - MapEditor");
var MapEditor=cc.Node.extend({_touchMode:0,_touchX:0,_touchY:0,_select:null,_deltaX:0,_deltaY:0,_container:null,_guide:null,_lock:null,_posts:null,_parts:0,_obs:[],_post:[],ctor:function(a){var b;this._super();this._parts=a;this._container=new cc.Node;this._container.setScale(.6);this.addChild(this._container);this._lock=new cc.Sprite(Resource.MAP.lock);this._lock.setScale(.3);this._lock.setPosition(740,620);this.addChild(this._lock);a=cc.size(1530*this._parts+252,1300);for(b=100;b<this._parts;b++){var c=
new cc.Sprite(Resource.MAP.segment(b));c.setTag(501);c.setAnchorPoint(0,0);c.setPosition(0==b?0:1783+1540*(b-1)-10*b,0);this._container.addChild(c)}this._guide=new cc.Node;this._container.addChild(this._guide);c=new cc.LayerColor(new cc.Color(255,0,0,255),a.width,2);c.setPosition(0,.5*a.height);this._guide.addChild(c);for(b=636;b<a.width;)c=new cc.LayerColor(new cc.Color(255,0,0,255),2,1300),c.setPosition(b,0),this._guide.addChild(c),c=new cc.LayerColor(new cc.Color(255,0,0,255),2,1300),c.setPosition(b+
124,0),this._guide.addChild(c),b+=510;var d=cc.loader.getRes(Resource.MAP.config(0)),e=60*this._parts,f;for(f in d.obs){var g=d.obs[f];if(g.id<=e){var h=new Map.Default.Obelisk(g.id,null,3);h.setPosition(g.x+3,g.y-6);h.dots=[];h.setVisible(6200<g.id);this._obs.push(h);this._container.addChild(h);for(var k in g.dots)c=new cc.Sprite(Resource.MAP.dot),c.setPosition(g.dots[k].x,g.dots[k].y),c.setVisible(h.isVisible()),b=new cc.Sprite(Resource.MAP.num(Number(k))),b.setColor(new cc.Color(255,0,0,255)),
c.addChild(b),h.dots.push(c),this._container.addChild(c)}}this._posts=new cc.Node;this._container.addChild(this._posts);for(f in d.post)g=d.post[f],c=new cc.Sprite(Resource.MAP.poster),c.setPosition(g.x,g.y),c.id=g.id,b=this.buildNumber(g.id),b.setPosition(30,80),c.addChild(b),this._post.push(c),this._posts.addChild(c);this._container.setPosition(750-a.width*this._container.getScale(),0);cc.eventManager.addListener({event:cc.EventListener.KEYBOARD,onKeyPressed:this.onKeyPress.bind(this),onKeyReleased:function(a,
b){}},this);cc.eventManager.addListener({event:cc.EventListener.MOUSE,onMouseMove:this.mouseMove.bind(this),onMouseUp:this.mouseUp.bind(this),onMouseDown:this.mouseDown.bind(this),onMouseScroll:this.mouseScroll.bind(this)},this)},onKeyPress:function(a){107==a?this._container.setScale(this._container.getScale()+.01):109==a?this._container.setScale(this._container.getScale()-.01):112==a?this._guide.setVisible(!this._guide.isVisible()):113==a?this._lock.setVisible(!this._lock.isVisible()):114==a?this._posts.setVisible(!this._posts.isVisible()):
115==a?this.save():116==a?this.addObelisck():117==a?this.addDot():118==a?this.addPost():86==a?this.validate():87==a&&null!=this._select?this._select.setPositionY(this._select.getPositionY()+1):83==a&&null!=this._select?this._select.setPositionY(this._select.getPositionY()-1):65==a&&null!=this._select?this._select.setPositionX(this._select.getPositionX()-1):68==a&&null!=this._select&&this._select.setPositionX(this._select.getPositionX()+1);cc.log(a)},mouseDown:function(a){this._touchMode=0;if(this._select){if(cc.isArray(this._select.dots))for(b in this._select.dots)this._select.dots[b].setBlendFunc(cc.BLEND_SRC,
cc.BLEND_DST);this._select.setBlendFunc(cc.BLEND_SRC,cc.BLEND_DST);this._select=null}if(!this._lock.isVisible()){for(var b in this._obs){var c=this._obs[b],d;for(d in c.dots){var e=c.dots[d];var f=e.convertToNodeSpace(a.getLocation());cc.rectContainsPoint(new cc.Rect(0,0,e.getContentSize().width,e.getContentSize().height),f)&&(f=this._container.convertToNodeSpace(a.getLocation()),this._deltaX=e.getPositionX()-f.x,this._deltaY=e.getPositionY()-f.y,this._select=e,this._select.setBlendFunc(cc.ZERO,cc.ONE_MINUS_SRC_COLOR),
this._touchMode=3)}if(null==this._select&&(f=c.convertToNodeSpace(a.getLocation()),cc.rectContainsPoint(c.getRect(),f)))for(b in this._select=c,this._select.setBlendFunc(cc.ZERO,cc.ONE_MINUS_SRC_COLOR),this._touchMode=2,f=this._container.convertToNodeSpace(a.getLocation()),this._deltaX=c.getPositionX()-f.x,this._deltaY=c.getPositionY()-f.y,this._select.dots)this._select.dots[b].setBlendFunc(cc.ZERO,cc.ONE_MINUS_SRC_COLOR);if(null!=this._select)break}if(null==this._select)for(b in this._post)c=this._post[b],
f=c.convertToNodeSpace(a.getLocation()),cc.rectContainsPoint(new cc.Rect(0,0,c.getContentSize().width,c.getContentSize().height),f)&&(this._select=c,this._select.setBlendFunc(cc.ZERO,cc.ONE_MINUS_SRC_COLOR),this._touchMode=4)}null==this._select&&(this._touchMode=1,this._touchX=this._container.getPositionX()-a.getLocationX(),this._touchY=this._container.getPositionY()-a.getLocationY())},mouseUp:function(a){this._touchMode=0},mouseMove:function(a){1==this._touchMode?this._container.setPosition(this._touchX+
a.getLocationX(),this._touchY+a.getLocationY()):0<this._touchMode&&null!=this._select&&(a=this._container.convertToNodeSpace(a.getLocation()),this._select.setPosition(Math.round(a.x)+this._deltaX,Math.round(a.y)+this._deltaY))},mouseScroll:function(a){var b=this._container.convertToNodeSpace(new cc.Point(380,325));a=this._container.getScale()+.03*(0<a.getScrollY()?1:-1);this._container.setScale(Math.max(a,.1));b=this._container.convertToWorldSpace(b);this._container.setPositionX(this._container.getPositionX()+
380-b.x);this._container.setPositionY(this._container.getPositionY()+325-b.y)},addObelisck:function(){if(!this._lock.isVisible()){var a=this._container.convertToNodeSpace(new cc.Point(380,325)),b=new Map.Default.Obelisk(this._obs.length+1,null,3);b.setPosition(Math.round(a.x),Math.round(a.y));b.dots=[];this._obs.push(b);this._container.addChild(b)}},addDot:function(){if(!this._lock.isVisible())if(null!=this._select&&this._select.dots){var a=new cc.Sprite(Resource.MAP.dot);a.setPosition(this._select.getPositionX()+
20,this._select.getPositionY());var b=new cc.Sprite(Resource.MAP.num(this._select.dots.length));b.setColor(new cc.Color(255,0,0,255));a.addChild(b);this._select.dots.push(a);this._container.addChild(a)}else alert("select obelisk")},addPost:function(){if(!this._lock.isVisible()&&this._posts.isVisible()){var a=this._container.convertToNodeSpace(new cc.Point(380,325)),b=new cc.Sprite(Resource.MAP.poster);b.setPosition(Math.round(a.x),Math.round(a.y));b.id=this._post.length;a=this.buildNumber(b.id);a.setPosition(30,
80);b.addChild(a);this._post.push(b);this._posts.addChild(b)}},validate:function(){for(var a in this._container.getChildren()){var b=this._container.getChildren()[a],c=b.getContentSize();501==b.getTag()&&(cc.assert(1783==c.width||1540==c.width,JSON.stringify(c)),cc.assert(1300==c.height,JSON.stringify(c)))}cc.log("Validation success")},save:function(){var a=cc.loader.getRes(Resource.MAP.config(0));a.obs=[];for(var b in this._obs){var c=this._obs[b];a.obs.push({id:c.getId(),x:Math.floor(c.getPositionX()-
3),y:Math.floor(c.getPositionY()+6),dots:c.dots.map(function(a){return{x:Math.floor(a.getPositionX()),y:Math.floor(a.getPositionY())}})})}a.post=[];for(b in this._post)c=this._post[b],a.post.push({id:c.id,x:Math.floor(c.getPositionX()),y:Math.floor(c.getPositionY())});c=new Blob([JSON.stringify(a)],{type:"text/plain"});c=window.URL.createObjectURL(c);a=document.createElement("a");a.download="map_0_config_"+(new Date).getTime()+".json";a.href=c;a.dispatchEvent(new MouseEvent("click"))},buildNumber:function(a){var b=
new cc.Node;a=CUtils.numToArray(a);var c=new cc.Size(6,11),d;for(d in a){var e=new cc.Sprite(Resource.MAP.num(a[d]));e.setAnchorPoint(0,0);e.setPosition(c.width*d,0);b.addChild(e)}b.setContentSize(c.width*a.length,c.height);b.setAnchorPoint(.5,.5);return b}});cc.log("DEVELOPMENT - MapAdvEditor");
var MapAdvEditor=cc.Node.extend({_container:null,_mapId:null,_obs:[],_touchMode:0,_touchX:0,_touchY:0,_select:null,ctor:function(a){this._super();this._mapId=a;this._container=new cc.Sprite("map/bg_"+this._mapId+"_0.jpg");this._container.setAnchorPoint(0,0);a=cc.loader.getRes(Resource.MAP.config(this._mapId));for(var b in a.obs){var c=a.obs[b];if(15>=c.id){var d=new Map.Default.Obelisk(c.id,null,3);d.setPosition(c.x+3,c.y-6);d.dots=[];this._obs.push(d);this._container.addChild(d)}}this.addChild(this._container);cc.eventManager.addListener({event:cc.EventListener.MOUSE,
onMouseMove:this.mouseMove.bind(this),onMouseUp:this.mouseUp.bind(this),onMouseDown:this.mouseDown.bind(this)},this);cc.eventManager.addListener({event:cc.EventListener.KEYBOARD,onKeyPressed:this.onKeyPress.bind(this),onKeyReleased:function(a,b){}},this)},onKeyPress:function(a){107!=a&&109!=a&&112!=a&&113!=a&&114!=a&&(115==a?this.save():116!=a&&117!=a&&118!=a&&(87==a&&null!=this._select?this._select.setPositionY(this._select.getPositionY()+1):83==a&&null!=this._select?this._select.setPositionY(this._select.getPositionY()-
1):65==a&&null!=this._select?this._select.setPositionX(this._select.getPositionX()-1):68==a&&null!=this._select&&this._select.setPositionX(this._select.getPositionX()+1)))},mouseDown:function(a){this._touchMode=0;this._select&&(this._select.setBlendFunc(cc.BLEND_SRC,cc.BLEND_DST),this._select=null);for(var b in this._obs){var c=this._obs[b],d=c.convertToNodeSpace(a.getLocation());cc.rectContainsPoint(c.getRect(),d)&&(this._select=c,this._select.setBlendFunc(cc.ZERO,cc.ONE_MINUS_SRC_COLOR),this._touchMode=
2);if(null!=this._select)break}},mouseUp:function(a){this._touchMode=0},mouseMove:function(a){1!=this._touchMode&&0<this._touchMode&&null!=this._select&&(a=this._container.convertToNodeSpace(a.getLocation()),this._select.setPosition(Math.round(a.x),Math.round(a.y)))},save:function(){var a=cc.loader.getRes(Resource.MAP.config(this._mapId));a.obs=[];for(var b in this._obs){var c=this._obs[b];a.obs.push({id:c.getId(),x:c.getPositionX()-3,y:c.getPositionY()+6})}a=new Blob([JSON.stringify(a)],{type:"text/plain"});
a=window.URL.createObjectURL(a);b=document.createElement("a");b.download="map_"+this._mapId+"_config_"+(new Date).getTime()+".json";b.href=a;b.dispatchEvent(new MouseEvent("click"))}});Map=Map||{};
Map.Challenge=cc.Layer.extend({_id:null,_type:0,_lastLevel:0,_levels:null,ctor:function(a){this._super();this._id=a;this._type=User.getChallenge().getType();this._lastLevel=User.getChallenge().getLevel();this._levels=cc.loader.getRes(Resource.MAP.levels(this._id));var b=this;a=new cc.Sprite(Resource.WEEKLY_CHALLENGE.back(this._type));a.setAnchorPoint(0,0);this.addChild(a);var c=new cc.Sprite(Resource.WEEKLY_CHALLENGE.img("map/lotos"));c.setPosition(400,477);this.addChild(c);a=[{x:352,y:103},{x:447,
y:152},{x:354,y:203},{x:437,y:252},{x:363,y:309}];for(var d=0;5>d;d++){var e=.4*d+.3,f=new cc.Sprite(Resource.WEEKLY_CHALLENGE.img("map/butterfly_shadow"));f.setPosition(a[d].x+1,a[d].y-48);this.addChild(f);f=new cc.Sprite(Resource.WEEKLY_CHALLENGE.img("map/butterfly"));f.setPosition(a[d].x+1,a[d].y-4);this.addChild(f,1);var g=new cc.Sprite(Resource.WEEKLY_CHALLENGE.img("num/"+(d+1)));g.setScale(.65);g.setPosition(47,0);f.addChild(g);d<this._lastLevel&&(f=new cc.Sprite(Resource.WEEKLY_CHALLENGE.img("map/lotos_anim",
d)),f.setOpacity(0),f.setPosition(c.getPosition()),f.runAction(new cc.Sequence([new cc.DelayTime(e),(new cc.FadeIn(.5)).easing(cc.easeOut(.2))])),this.addChild(f),f=new cc.Sprite(Resource.WEEKLY_CHALLENGE.img("map/butterfly",d)),f.setPosition(a[d]),f.setOpacity(0),f.runAction(new cc.Sequence([new cc.DelayTime(e),(new cc.FadeIn(.5)).easing(cc.easeOut(.2))])),this.addChild(f,1))}if(5<=this._lastLevel)cc.loader.load("particle/weekly_challenge_map.plist",function(a,d){if(!a){var e=new cc.ParticleSystem("particle/weekly_challenge_map.plist");
e.setPosition(c.getPosition());e.stopSystem();e.runAction(new cc.Sequence([new cc.DelayTime(1.5),new cc.CallFunc(function(){e.resetSystem()})]));b.addChild(e,100)}});else{a=a[this._lastLevel];var h=new CButton(Resource.WEEKLY_CHALLENGE.img("map/butterfly_glow"),null,null,null);h.setOpacity(0);h.setPosition(a.x-.5,a.y-6);h.setScale(1.2);h.runAction(new cc.Sequence([new cc.DelayTime(.4*this._lastLevel+.4),new cc.FadeIn(.5),new cc.CallFunc(function(){h.runAction(new cc.RepeatForever(new cc.Sequence([new cc.ScaleTo(1,
1.3),new cc.ScaleTo(1,1.2)])))})]));h.setCbUp(function(){var a={};a.level=b._levels[b._lastLevel];a.mapId=b._id;a.type=b._type;a.viewmode="challenge";Popup.PopBeginLevel.show(a)});this.addChild(h,0)}}});var Client=cc.Node.extend({_ext:null,_state:0,_grid:null,_batch:null,_mapId:0,_levelId:0,_level:null,_goal:null,_ruby:null,_girl:null,_spell:null,_info:null,_buyMode:0,_exitOn:!1,_time:0,_movesTotal:0,_movesRemained:0,_movesExtra:0,_editor:!1,ctor:function(a,b,c){cc.assert(b);this._super();this._ext=new CExtNode(this);this._editor=c;this._info=new Client.Info;this._buyMode=this._levelId=this._state=0;this._exitOn=!1;this._mapId=a;this._level=b;this._levelId=Number(b.id);this._time=TimeUtils.getTime();
this._movesExtra=this._movesRemained=this._movesTotal=0;1E3>a&&User.getScoreById(a).getSize()>=Number(b.id)&&(b.guide=null);null!=b.guide&&(a=cc.formatStr("guide_%s_%s",a,b.id),LocalStorage.getValue(a)?b.guide=null:LocalStorage.setValue(a,!0));this.init()},init:function(){this._state=Client.STATE.INIT;this._batch=new cc.Sprite;this._goal=new Client.GoalPanel;this._goal.setPosition(80,435);this._ruby=new Client.RubyPanel(this._level);this._ruby.setPosition(728,338);this._spell=new Client.SpellPanel(User.getOrbs(1));
this._spell.setPosition(250,45);this._girl=new cc.Sprite(Resource.CLIENT.ui("girl"));this._girl.setPosition(88,146);this._grid=new Client.Grid(this._mapId,this._level);this._batch.addChild(this._spell);this._batch.addChild(this._grid.getBackground());this._batch.addChild(this._goal);this._batch.addChild(this._girl);this._batch.addChild(this._ruby);this._batch.addChild(this._grid);this._batch.setVisible(!1);this.addChild(this._batch);this.scheduleUpdate();this._ext.addCustomListener(Client.EVENT.PLAY_NOMOVES,
this.eventHandler.bind(this));this._ext.addCustomListener(Client.EVENT.PLAY_NOMATCH,this.eventHandler.bind(this));this._ext.addCustomListener(Client.EVENT.PLAY_RESHUFFLE,this.eventHandler.bind(this));this._ext.addCustomListener(Client.EVENT.PLAY_FINISH,this.eventHandler.bind(this));this._ext.addCustomListener(app.Events.PRESS_EXIT,this.eventHandler.bind(this));this._ext.addCustomListener(Backend.EVENT.PURCHASE_SUCCESS,this.eventHandler.bind(this));app.config.qqq()&&this.qqq()},initUI:function(){var a=
this._grid,b=this._grid.getBackground(),c=this._goal,d=this._ruby,e=this._girl,f=this._spell;c.setPositionX(-80);d.setPositionX(800);e.setPositionX(-150);f.setPositionY(-150);b.setOpacity(0);a.setOpacity(0);c.runAction(new cc.Sequence([new cc.DelayTime(.5),(new cc.MoveTo(.7,80,c.getPositionY())).easing(cc.easeSineOut())]));d.runAction(new cc.Sequence([new cc.DelayTime(.5),(new cc.MoveTo(.7,728,d.getPositionY())).easing(cc.easeSineOut())]));e.runAction(new cc.Sequence([new cc.DelayTime(.5),(new cc.MoveTo(1,
88,e.getPositionY())).easing(cc.easeSineOut())]));b.runAction(new cc.Sequence([new cc.DelayTime(.5),new cc.DelayTime(.5),(new cc.FadeTo(.3,255)).easing(cc.easeSineOut())]));a.runAction(new cc.Sequence([new cc.DelayTime(.5),new cc.DelayTime(.6),(new cc.FadeTo(.4,255)).easing(cc.easeSineOut()),new cc.CallFunc(function(){this._state=Client.STATE.PLAYING},this)]));f.runAction(new cc.Sequence([new cc.DelayTime(.5),(new cc.MoveTo(.7,f.getPositionX(),45)).easing(cc.easeSineOut())]));this._batch.setVisible(!0);
this._state=Client.STATE.PAUSE},update:function(a){switch(this._state){case Client.STATE.INIT:this.initUI();break;case Client.STATE.PLAYING:this._grid.update();break;case Client.STATE.PLAY_FINISH:if(this._grid.destroyGrid())if(a=this._grid.getGoal(),this._movesTotal=Math.max(this._movesTotal,a.getTotalMoves()),this._movesRemained=Math.max(this._movesRemained,a.getTotalMoves()-a.getSpendMoves()),(a.getTotalMoves()>a.getSpendMoves()||1>this._ruby.getSphere()&&app.config.oneSphere())&&this._ruby.isEmptyDump()){var b=
new cc.EventCustom(Client.EVENT.UPDATE_RUBY);b.setUserData({k:JRuby.getRandom(),x:80,y:520});cc.eventManager.dispatchEvent(b);a.updateTotalMoves(-1,!0);AudioEngine.playEffect(Resource.SND.CL_MOVES_REM,!0)}else this._ruby.isReady()&&(this._state=Client.STATE.PAUSE,0==this._ruby.getSphere()&&(5<this._levelId||0!=this._mapId)?this.exit(Client.STATUS.NO_SPHERE):this.exit(Client.STATUS.WIN))}},pause:function(a){a&&this._state==Client.STATE.PLAYING?this._state=Client.STATE.PAUSE:a||this._state!=Client.STATE.PAUSE||
(this._state=Client.STATE.PLAYING)},eventHandler:function(a){var b=a.getEventName();a=a.getUserData()||{};var c=this._grid.getGoal();b==Client.EVENT.PLAY_NOMOVES?this.buyMoves():b==Client.EVENT.PLAY_FINISH?(this._state=Client.STATE.PLAY_FINISH,this._goal.setExtMoves(!1)):b==Client.EVENT.PLAY_NOMATCH?this.exit(Client.STATUS.NO_MATCH):b==Client.EVENT.PLAY_RESHUFFLE?this.addChild(new Client.StatusPanel(Lang.getString(Lang.CL_AUTORESHUFFLE),null),100):b==app.Events.PRESS_EXIT?this.exit(Client.STATUS.PRESS_EXIT):
b==Backend.EVENT.PURCHASE_SUCCESS&&a.prodId==Products.IDS.PR_MOVES_5&&(c.updateTotalMoves(5,!0),this._movesExtra+=5,AudioEngine.playEffect(Resource.SND.CL_MOVES_ADD,!0))},buyMoves:function(){var a=this,b=this._grid.getGoal(),c=function(c){b.hasMoves()?(a._state=Client.STATE.PLAYING,1==c&&(a._buyMode++,a._info.ego_update(1),a._goal.setExtMoves(!1),a.ktEvent())):(a.ktEvent(),a.exit(Client.STATUS.NO_MOVES))};6>this._levelId&&0==this._mapId&&(this._buyMode=-1);this._state=Client.STATE.PAUSE;1==this._editor?
(b.updateTotalMoves(5,!0),this._movesExtra+=5,c(!0)):0<=this._buyMode?app.openBuyMoves(this._buyMode,b.hasMoves(),c):c(!1)},exit:function(a){if(!this._exitOn){this._exitOn=!0;this._state=Client.STATE.PAUSE;var b=this._grid.getGoal(),c={};c.mapId=this._mapId;c.levelId=this._levelId;c.level=this._level;c.time=TimeUtils.getTime()-this._time;c.score=this._ruby.getRuby();c.keys=this._ruby.getSphere();c.coins=this._ruby.getRuby();c.moves=this._movesRemained;c.status=a;c.kt={};c.kt.background0=b.getGoalBackground();
c.kt.background1=b.getDoneBackground();c.kt.treasure0=b.getGoalTreasure();c.kt.treasure1=b.getDoneTreasure();c.kt.torch0=b.getGoalTorch();c.kt.torch1=b.getDoneTorch();c.kt.diamond0=b.getGoalDiamond();c.kt.diamond1=b.getDoneDiamond();c.kt.beetle0=b.getGoalBeetle();c.kt.beetle1=b.getDoneBeetle();c.kt.rainbow0=b.getGoalRainbow();c.kt.rainbow1=b.getDoneRainbow();c.kt.rowblast0=b.getGoalRowBlast();c.kt.rowblast1=b.getDoneRowBlast();c.kt.columnblast0=b.getGoalColumnBlast();c.kt.columnblast1=b.getDoneColumnBlast();
c.kt.crossblast0=b.getGoalCrossBlast();c.kt.crossblast1=b.getDoneCrossBlast();c.kt.stone0=b.getGoalStone();c.kt.stone1=b.getDoneStone();c.kt.t=TimeUtils.getTime()-this._time;c.kt.sc0=this._ruby.getRuby();c.kt.sc1=this._ruby.getRuby(1);c.kt.mv_t=Math.max(this._movesTotal,b.getTotalMoves());c.kt.mv_r=Math.max(this._movesRemained,b.getTotalMoves()-b.getSpendMoves());c.kt.mv_e=this._movesExtra;c.kt.mv_i=Number(this._level.m);c.kt.mv_d=this._grid.getInfo().mv_d();c.kt.ego=this._info.ego();c.kt.auto_match=
this._grid.getInfo().auto_match();c.kt.it_bought=this._grid.getInfo().it_bought();c.kt.it_used=this._grid.getInfo().it_used();b="";a==Client.STATUS.NO_MATCH?b=Lang.getString(Lang.CL_EXIT_NOMATCH):a==Client.STATUS.NO_MOVES?b=Lang.getString(Lang.CL_EXIT_NOMOVES):a==Client.STATUS.NO_SPHERE?b=Lang.getString(0==this._mapId?Lang.CL_EXIT_NOSPHERE:Lang.CL_EXIT_NOSTARS):a==Client.STATUS.PRESS_EXIT?b=Lang.getString(Lang.CL_EXIT_LEAVE):a==Client.STATUS.WIN&&(b=Lang.getString(Lang.CL_EXIT_WIN));this.addChild(new Client.StatusPanel(b,
function(){}),100);this.runAction(new cc.Sequence(new cc.DelayTime(1.8),new cc.CallFunc(this._editor?app.exitEditorClient.bind(this,c):app.exitClient.bind(this,c)),new cc.CallFunc(function(){cc.game.canvas.style.cursor="auto"})));cc.log("client exit call");AudioEngine.playEffect(Resource.SND.CL_END_LEVEL,!0)}},qqq:function(){var a=this;"keyboard"in cc.sys.capabilities&&cc.eventManager.addListener({event:cc.EventListener.KEYBOARD,onKeyPressed:function(b,c){switch(b){case 84:a._state=Client.STATE.PLAY_FINISH;
break;case 65:a._grid.getGoal().updateTotalMoves(1,!0);break;case 90:a._grid.getGoal().updateTotalMoves(-1,!0);break;case 49:cc.eventManager.dispatchCustomEvent(Client.EVENT.SPELL_ACTIVE,{type:JSpell.HAMMER});break;case 50:cc.eventManager.dispatchCustomEvent(Client.EVENT.SPELL_ACTIVE,{type:JSpell.COLOR_BLAST});break;case 51:cc.eventManager.dispatchCustomEvent(Client.EVENT.SPELL_ACTIVE,{type:JSpell.HAND});break;case 52:cc.eventManager.dispatchCustomEvent(Client.EVENT.SPELL_ACTIVE,{type:JSpell.UNLOCK});
break;case 53:cc.eventManager.dispatchCustomEvent(Client.EVENT.SPELL_ACTIVE,{type:JSpell.SUPER_BOMB});break;case 54:cc.eventManager.dispatchCustomEvent(Client.EVENT.SPELL_ACTIVE,{type:JSpell.RESHUFFLE});break;case 69:var d=a._grid.getSelect(0);d&&d.execJAction(!1,{type:3});break;case 81:if(d=a._grid.getSelect(0))d.updateCode(0,JType.BONUS),d.updateCode(2,"0"),d.updateCode(3,JBonus.getNext(d.getCode(3))),d.updateUI(!0)}}},this)},ktEvent:function(){if(!this._editor){var a=this._grid.getGoal(),b=KApi.setJSData(KApi.EVENT.LEVEL_CUSTOM,
{});b.st1="level_end";b.data.level=this._levelId;b.data.level_max=User.getScoreById(this._mapId).getSize();b.data.level_name=this._mapId+"v"+this._levelId+"v"+(this._level.ver||"0");b.data.level_uuid=this._level.uuid||0;b.data.map_id=this._mapId;b.data.result=String(this._ruby.getSphere());b.data.fail_reason="no_moves";b.data.type_ego="0";b.data.finalized=1;b.data.time_given=0;b.data.time_made=0;b.data.duration=TimeUtils.getTime()-this._time;b.data.user_score=this._ruby.getRuby();b.data.target_score=
this._ruby.getRuby(1);b.data.moves_given=Number(this._level.m);b.data.moves_made=this._grid.getInfo().mv_d();b.data.number_of_ego_shown=this._info.ego();b.data.target1=a.getGoalBackground();b.data.target1_made=a.getDoneBackground();b.data.target2=a.getGoalTreasure();b.data.target2_made=a.getDoneTreasure();b.data.target3=a.getGoalTorch();b.data.target3_made=a.getDoneTorch();b.data.target4=a.getGoalDiamond();b.data.target4_made=a.getDoneDiamond();b.data.target5=a.getGoalBeetle();b.data.target5_made=
a.getDoneBeetle();b.data.target6=a.getGoalRainbow();b.data.target6_made=a.getDoneRainbow();b.data.target7=a.getGoalRowBlast();b.data.target7_made=a.getDoneRowBlast();b.data.target8=a.getGoalColumnBlast();b.data.target8_made=a.getDoneColumnBlast();b.data.target9=a.getGoalCrossBlast();b.data.target9_made=a.getDoneCrossBlast();b.data.target10=a.getGoalStone();b.data.target10_made=a.getDoneStone();KApi.event(KApi.EVENT.LEVEL_CUSTOM,b)}}});Client.STATE={PAUSE:0,INIT:1,PLAYING:2,PLAY_FINISH:3};
Client.STATUS={NO_MOVES:"no_moves",NO_MATCH:"no_matches",NO_SPHERE:"no_sphere",PRESS_EXIT:"press_exit",WIN:"win"};
Client.EVENT={UPDATE_GOAL:"CLIENT_UPDATE_GOAL",UPDATE_RUBY:"CLIENT_UPDATE_RUBY",UPDATE_CLOUD:"CLIENT_UPDATE_CLOUD",UPDATE_SPELL:"CLIENT_UPDATE_SPELL",PLAY_FINISH:"CLIENT_PLAY_FINISH",PLAY_NOMOVES:"CLIENT_PLAY_NOMOVES",PLAY_NOMATCH:"CLIENT_PLAY_NOMATCH",PLAY_RESHUFFLE:"CLIENT_PLAY_RESHUFFLE",FLY_BEETLE:"CLIENT_FLY_BEETLE",FLY_BUTTERFLY:"CLIENT_FLY_BUTTERFLY",FLY_RAINBOW:"CLIENT_FLY_RAINBOW",SPELL_BOUGHT:"CLIENT_SPELL_BOUGHT",SPELL_ACTIVE:"CLIENT_SPELL_ACTIVE",SPELL_USED:"CLIENT_SPELL_USED",SPELL_CANCEL:"CLIENT_SPELL_CANCEL",
GUIDE_CLOSED:"CLIENT_CLOSE_GUIDE"};var JType={SIMPLE:"s",BONUS:"B",STONE:"S",TITANIUM:"T",PETRIFIER:"P",ICECUBE:"I",FROZEN:"F",FROG:"f",TREASURE:"t",CHAMELEON:"C",TORCH:"O",BEETLE:"b",DIAMOND:"D",BUTTERFLY:"H",RAINBOW:"R",ENIGMA:"E",MIRROR:"M",MAGICBALL:"m",PEARL:"p",SHELL:"h",MAGNET:"g",FREEZE:"z"};var JState=new (cc.Class.extend({NONE:-1,EMPTY:0,LOCKED:1,TRANSFORM:2,MATCHED:3,MATCH_ON:4,MATCH_OFF:5,MOVE:6,EXPLODE:7,CROSSDESTROYER:8,TORNADO:9,TORNADOLOCK:10,LIGHTING:11,BONUS:12,BONUSLOCK:13,FIREBLAST:14,BOMB:15,SWAP:16,RAINBOW:17,FROG:18,FREEZE:19}));var JSpell=new (cc.Class.extend({HAMMER:1001,HAND:1002,UNLOCK:1003,SUPER_BOMB:1004,COLOR_BLAST:1005,RESHUFFLE:1006}));JSpell.fromProdId=function(a){if(a==Products.IDS.OR_HAMMER)return JSpell.HAMMER;if(a==Products.IDS.OR_HAND)return JSpell.HAND;if(a==Products.IDS.OR_UNLOCK)return JSpell.UNLOCK;if(a==Products.IDS.OR_SUPER_BOMB)return JSpell.SUPER_BOMB;if(a==Products.IDS.OR_COLOR_BLASTER)return JSpell.COLOR_BLAST;cc.assert(!1,"unknown spell type:"+a)};
JSpell.getOPT=function(a){if(a==JSpell.HAMMER)return 7;if(a==JSpell.HAND)return 16;if(a==JSpell.UNLOCK)return 5;if(a==JSpell.SUPER_BOMB)return 12;if(a==JSpell.COLOR_BLAST)return 9;cc.assert(!1,"unknown spell type:"+prodId)};var JShape=new (cc.Class.extend({A:"a",B:"b",C:"c",D:"d",E:"e",F:"f",ASTERISK:"*",STONE:"Stone",TREASURE:"Treasure",_all:null,_allowed:null,ctor:function(){this._allowed=this._all=[this.A,this.B,this.C,this.D,this.E,this.F]},config:function(a){this._allowed=this._all.filter(function(b){return-1==a.indexOf(b)})},isAllowed:function(a){return-1!=this._allowed.indexOf(a)||"*"==a},getRandom:function(a){var b=null;b=void 0===a?this._allowed:a instanceof Array?this._allowed.filter(function(b){return-1==
a.indexOf(b)}):this._allowed.filter(function(b){return a!=b});return b[Math.round(Math.random()*(b.length-1))]}}));var JRuby=new (cc.Class.extend({A:"a",B:"b",C:"c",D:"d",E:"e",CH:"ch",_all:null,ctor:function(){this._all=[this.A,this.B,this.C,this.D,this.E]},getRandom:function(a){var b=null;b=void 0===a?this._all:a instanceof Array?this._all.filter(function(b){return-1==a.indexOf(b)}):this._all.filter(function(b){return a!=b});return b[Math.round(Math.random()*(b.length-1))]}}));var JBonus=new (cc.Class.extend({A:"a",B:"b",D:"d",E:"e",F:"f",G:"g",H:"h",J:"j",I:"i",_all:null,ctor:function(){this._all=[this.A,this.B,this.D,this.E,this.F,this.G,this.H,this.J,this.I]},getRandom:function(a){var b=null;b=void 0===a?this._all:a instanceof Array?this._all.filter(function(b){return-1==a.indexOf(b)}):this._all.filter(function(b){return a!=b});return b[Math.round(Math.random()*(b.length-1))]},getNext:function(a){for(var b=0;b<this._all.length-2;b++)if(a==this._all[b])return this._all[b+
1];return this._all[0]}}));var JSwap={NOBONUS:0,FG:1,FGD:2,FGE:3,FGH:4,FGI:5,DH:6,DE:7,DI:8,EH:9,EI:10,HI:11,HH:12,DEFAULT:13};var JRelation={allowMatch:function(a,b,c,d){c=c||[];c.push(JState.MATCH_ON,JState.SWAP,JState.LOCKED);d&&10>Math.abs(a.getCell().getCenter().y-a.getPositionY())&&c.push(JState.MOVE);d=a.getCode();b=b.getCode();return!JRelation.isMatch3(a)||JRelation.isLocked(a,c)?!1:d[0]==JType.DIAMOND||b[0]==JType.DIAMOND?d[0]==b[0]&&d[5]==b[5]:d[0]==JType.PEARL||b[0]==JType.PEARL?d[0]==b[0]:d[1]==b[1]},allowDestroyLastRow:function(a,b){b=b||[];b.push(JState.MATCH_ON);var c=a.getCode();return(c[0]==JType.TITANIUM||
c[0]==JType.TREASURE||c[0]==JType.CHAMELEON&&"1"==c[5]||c[0]==JType.BONUS&&c[3]==JBonus.A||c[0]==JType.BONUS&&c[3]==JBonus.J)&&!JRelation.isLocked(a,b)},allowActionCrossDestroyer:function(a,b){b=b||[];b.push(JState.MATCH_ON,JState.MOVE);var c=a.getCode();return!(c[0]==JType.TORCH||c[0]==JType.BEETLE||c[0]==JType.DIAMOND||c[0]==JType.RAINBOW||JRelation.isLocked(a,b))},allowActionExplode:function(a,b){b=b||[];b.push(JState.MOVE,JState.TORNADOLOCK,JState.LOCKED,JState.MATCH_ON);return!JRelation.isLocked(a,
b)},allowActionMove:function(a,b){b=b||[];b.push(JState.LIGHTING,JState.EXPLODE,JState.MATCH_ON,JState.BONUS);return JRelation.isMovable(a)&&!JRelation.isLocked(a,b)},allowActionSwap:function(a,b,c){return JRelation.isNearJewels(a,b)&&!JRelation.isLocked(a,c)&&!JRelation.isLocked(b,c)},allowSelect:function(a,b){return a.hasCell()&&a.hasUI()&&JRelation.isSelectable(a)&&!JRelation.isLocked(a,b)},allowActionTornado:function(a,b){b=b||[];b.push(JState.MOVE,JState.MATCH_ON);var c=a.getCode();return!(c[0]==
JType.TORCH||c[0]==JType.DIAMOND||c[0]==JType.BUTTERFLY||c[0]==JType.ENIGMA||c[0]==JType.MAGICBALL||c[0]==JType.MAGNET||c[0]==JType.FREEZE||c[0]==JType.ICECUBE||c[0]==JType.RAINBOW||JRelation.isLocked(a,b))},allowActionBomb:function(a,b){b=b||[];b.push(JState.MOVE,JState.MATCH_ON,JState.TORNADOLOCK);var c=a.getCode();return!(c[0]==JType.TORCH||c[0]==JType.BEETLE&&"0"==c[5]||c[0]==JType.DIAMOND||c[0]==JType.RAINBOW||JRelation.isLocked(a,b))},allowActionLighting:function(a,b){b=b||[];b.push(JState.MOVE,
JState.MATCH_ON);var c=a.getCode();return!(c[0]==JType.TORCH||c[0]==JType.BEETLE||c[0]==JType.DIAMOND||c[0]==JType.MAGNET||c[0]==JType.FREEZE||c[0]==JType.ENIGMA||c[0]==JType.RAINBOW||JRelation.isLocked(a,b))},allowActionFireBlast:function(a,b){b=b||[];b.push(JState.MOVE,JState.MATCH_ON,JState.TORNADOLOCK);var c=a.getCode();return!(c[0]==JType.DIAMOND||c[0]==JType.TORCH||c[0]==JType.BEETLE||c[0]==JType.FROG||c[0]==JType.MAGNET||c[0]==JType.FREEZE||c[0]==JType.SHELL||c[0]==JType.ICECUBE||c[0]==JType.MAGICBALL||
c[0]==JType.PEARL||c[0]==JType.RAINBOW||c[0]==JType.ENIGMA||c[0]==JType.BUTTERFLY||JRelation.isLocked(a,b))},allowActionRainbow:function(a,b){b=b||[];b.push(JState.RAINBOW,JState.TORNADOLOCK,JState.LOCKED,JState.MATCH_ON);return!JRelation.isLocked(a,b)},isApllyIceCube:function(a){if(!a)return!1;if(a.isEmpty())return!0;a=a.getJewel();var b=a.getCode();return!(JRelation.isLocked(a,[])||a.isLocked()||b[0]==JType.ICECUBE||b[0]==JType.STONE||b[0]==JType.FROG||b[0]==JType.MAGNET||b[0]==JType.FREEZE||b[0]==
JType.SHELL||b[0]==JType.MIRROR||b[0]==JType.ENIGMA||b[0]==JType.MAGICBALL||b[0]==JType.BUTTERFLY||b[0]==JType.TREASURE||b[0]==JType.TITANIUM||b[0]==JType.BEETLE||b[0]==JType.PETRIFIER||b[0]==JType.RAINBOW||b[0]==JType.TORCH)},isApplySpellHammer:function(a){var b=a.getCode();return(b[0]==JType.SIMPLE||b[0]==JType.STONE||b[0]==JType.FROG||b[0]==JType.FROG||b[0]==JType.MIRROR||b[0]==JType.FROZEN||b[0]==JType.ICECUBE||b[0]==JType.ENIGMA||b[0]==JType.PEARL||b[0]==JType.SHELL||b[0]==JType.MAGICBALL||b[0]==
JType.BUTTERFLY||b[0]==JType.PETRIFIER||b[0]==JType.BONUS||b[0]==JType.CHAMELEON&&"0"==b[5]||b[0]==JType.BEETLE&&"0"!=b[5])&&!a.isLocked()&&a.execJAction(!0,null)},isApplySpellHand:function(a){a=a.getCode();return!(a[0]==JType.TORCH||a[0]==JType.MAGNET||a[0]==JType.FREEZE||a[0]==JType.RAINBOW)},isApplySpellBomb:function(a){var b=a.getCode();return(b[0]==JType.SIMPLE||b[0]==JType.STONE||b[0]==JType.MIRROR||b[0]==JType.FROG||b[0]==JType.FROZEN||b[0]==JType.PETRIFIER||b[0]==JType.ICECUBE||b[0]==JType.ENIGMA||
b[0]==JType.PEARL||b[0]==JType.SHELL||b[0]==JType.BUTTERFLY||b[0]==JType.MAGICBALL||b[0]==JType.BONUS||b[0]==JType.CHAMELEON&&"0"==b[5]||b[0]==JType.BEETLE&&"0"!=b[5])&&JRelation.allowActionBomb(a,[JState.LOCKED])},isApplySpellUnlock:function(a,b){return 0<a.getLocks()},isExplodeNear:function(a,b,c){if(!a||!b)return!1;a=a.getCode();b=b.getCode();return a[0]==JType.STONE||a[0]==JType.TORCH||a[0]==JType.BEETLE||a[0]==JType.BUTTERFLY||a[0]==JType.ENIGMA||a[0]==JType.FROG||a[0]==JType.RAINBOW||a[0]==
JType.ICECUBE||(a[0]==JType.PEARL||a[0]==JType.DIAMOND||a[0]==JType.MAGICBALL||a[0]==JType.PETRIFIER)&&b[0]==JType.RAINBOW?!1:c&&(b[0]==JType.ICECUBE||b[0]==JType.ENIGMA||b[0]==JType.MAGICBALL||b[0]==JType.SHELL)||b[0]==JType.STONE||b[0]==JType.BEETLE&&"0"!=b[5]||b[0]==JType.RAINBOW||b[0]==JType.TORCH&&(a[0]==JType.SIMPLE||a[0]==JType.BONUS||a[0]==JType.FROZEN||a[0]==JType.CHAMELEON&&"1"==a[5])&&(b[1]==JShape.ASTERISK||a[0]==JType.CHAMELEON&&"1"==a[5]||a[1]==b[1])?!0:!1},isBreakBackground:function(a){a=
a.getCode();return!(a[0]==JType.STONE||a[0]==JType.ICECUBE||a[0]==JType.RAINBOW||a[0]==JType.ENIGMA||a[0]==JType.SHELL||a[0]==JType.BUTTERFLY)},isApplyLock:function(a){a=a.getCode();return a[0]==JType.SIMPLE||a[0]==JType.FROZEN||a[0]==JType.BONUS||a[0]==JType.CHAMELEON&&"0"==a[5]},isApplyFireBlast:function(a,b,c){a=a.getCode();return!(a[1]!=b||a[0]==JType.STONE||a[0]==JType.MIRROR||a[0]==JType.FROG||a[0]==JType.TREASURE||a[0]==JType.DIAMOND||a[0]==JType.PETRIFIER||a[0]==JType.MAGNET||a[0]==JType.FREEZE||
a[0]==JType.ICECUBE||a[0]==JType.ENIGMA||a[0]==JType.MAGICBALL||a[0]==JType.PEARL||a[0]==JType.SHELL||a[0]==JType.BUTTERFLY||a[0]==JType.RAINBOW||a[0]==JType.TITANIUM||a[0]==JType.CHAMELEON&&"1"==a[5]||a[0]==JType.BEETLE&&"0"==a[5])},isApplyLighting:function(a,b){var c=a.getCode();return!(c[0]==JType.BEETLE&&"0"==c[5]||c[0]==JType.RAINBOW||c[0]==JType.DIAMOND)},isApplyFrog:function(a,b){var c=a.getCode();b=b||[];return(c[0]==JType.SIMPLE||c[0]==JType.BONUS)&&!JRelation.isLocked(a,b)},isApplyMagnet:function(a,
b){var c=a.getCode();b=b||[];return c[0]==JType.TREASURE&&!JRelation.isLocked(a,b)},isApplyShell:function(a,b){var c=a.getCode();b=b||[];b.push(JState.MOVE);return c[0]==JType.SIMPLE&&!JRelation.isLocked(a,b)},isApplyBomb:function(a,b){var c=a.getCode();return!(c[0]==JType.BEETLE&&"0"==c[5]||c[0]==JType.RAINBOW||c[0]==JType.FREEZE||c[0]==JType.DIAMOND)},isApplyTornado:function(a,b){b=b||[];b.push(JState.MOVE,JState.MATCH_ON,JState.EXPLODE,JState.TRANSFORM);var c=a.getCode();return c[0]!=JType.PETRIFIER&&
c[0]!=JType.TORCH&&c[0]!=JType.ICECUBE&&c[0]!=JType.STONE&&c[0]!=JType.MIRROR&&c[0]!=JType.MAGNET&&c[0]!=JType.FREEZE&&c[0]!=JType.BEETLE&&c[0]!=JType.ENIGMA&&c[0]!=JType.MAGICBALL&&c[0]!=JType.RAINBOW&&c[0]!=JType.DIAMOND&&c[0]!=JType.TITANIUM&&!(c[0]==JType.CHAMELEON&&"1"==c[5])&&!JRelation.isLocked(a,b)},isApplyCrossDestroyer:function(a,b){var c=a.getCode();return!(c[0]==JType.TORCH||c[0]==JType.DIAMOND||c[0]==JType.MAGNET||c[0]==JType.FREEZE||c[0]==JType.RAINBOW||c[0]==JType.BEETLE&&"0"==c[5])},
isApplyCloud:function(a,b,c){var d=a.getCode();c=c||[];switch(b){case "a":case "b":case "c":case "d":return d[0]!=JType.STONE&&d[0]!=JType.MIRROR&&d[0]!=JType.TITANIUM&&d[0]!=JType.CHAMELEON&&d[0]!=JType.ENIGMA&&d[0]!=JType.MAGICBALL&&d[0]!=JType.FROG&&d[0]!=JType.MAGNET&&d[0]!=JType.FREEZE&&d[0]!=JType.SHELL&&d[0]!=JType.FROZEN&&d[0]!=JType.PETRIFIER&&d[0]!=JType.TREASURE&&d[0]!=JType.RAINBOW&&d[0]!=JType.TORCH&&d[0]!=JType.DIAMOND&&d[0]!=JType.BEETLE&&d[0]!=JType.BUTTERFLY&&!JRelation.isLocked(a,
c);case "e":return c.push(JState.MOVE,JState.TORNADOLOCK,JState.LOCKED,JState.MATCH_ON),!(d[0]==JType.BEETLE&&"0"==d[5])&&d[0]!=JType.RAINBOW&&d[0]!=JType.TORCH&&d[0]!=JType.DIAMOND&&d[0]!=JType.MAGNET&&d[0]!=JType.FREEZE&&d[0]!=JType.FROG&&!JRelation.isLocked(a,c)}return!1},isApplyReshuffle:function(a,b){var c=a.getCode();return c[0]==JType.SIMPLE||c[0]==JType.FROZEN||c[0]==JType.BONUS||c[0]==JType.CHAMELEON&&"0"==c[5]},isMovable:function(a){a=a.getCode();return!(a[0]==JType.TORCH||a[0]==JType.ENIGMA||
a[0]==JType.MAGNET||a[0]==JType.FREEZE||a[0]==JType.SHELL||a[0]==JType.MAGICBALL||a[0]==JType.ICECUBE||a[0]==JType.RAINBOW)},isSelectable:function(a){var b=a.getCode();return!a.isLocked()&&(b[0]==JType.SIMPLE||b[0]==JType.TREASURE||b[0]==JType.BONUS||b[0]==JType.DIAMOND||b[0]==JType.PEARL||b[0]==JType.BUTTERFLY||b[0]==JType.CHAMELEON&&"0"==b[5]||b[0]==JType.BEETLE&&"0"==b[5])},isNearJewels:function(a,b){var c=null==a.getCell()?null:a.getCell().getTile(),d=null==b.getCell()?null:b.getCell().getTile();
return null!=c&&null!=d&&(c.x==d.x&&1==Math.abs(c.y-d.y)||c.y==d.y&&1==Math.abs(c.x-d.x))},isMatch3:function(a){a=a.getCode();return!(a[0]==JType.STONE||a[0]==JType.MIRROR||a[0]==JType.MAGNET||a[0]==JType.FREEZE||a[0]==JType.FROG||a[0]==JType.TORCH||a[0]==JType.TREASURE||a[0]==JType.PETRIFIER||a[0]==JType.ICECUBE||a[0]==JType.BUTTERFLY||a[0]==JType.RAINBOW||a[0]==JType.ENIGMA||a[0]==JType.SHELL||a[0]==JType.MAGICBALL||a[0]==JType.TITANIUM||a[0]==JType.CHAMELEON&&"1"==a[5]||a[0]==JType.BEETLE&&"0"!=
a[5])},isLocked:function(a,b){var c=a.getStates().slice();if(b instanceof Array)for(var d=0;d<b.length;d++)c[b[d]]=0;return-1!=c.indexOf(1)}};var JLogic={_bonuses:{combo4:[{bonus:"f",patterns:"1111000000000000000000000 1110000100000000000000000 1110010000000000000000000 0010011100000000000000000 1000011100000000000000000 0100011100000000000000000 1110001000000000000000000 1100001100000000000000000 0110011000000000000000000".split(" ")},{bonus:"g",patterns:"1000010000100001000000000 1000010000110000000000000 0100001000110000000000000 1100010000100000000000000 1100001000010000000000000 1000011000100000000000000 0100011000010000000000000 1000011000010000000000000 0100011000100000000000000".split(" ")}],
combo5:[{bonus:"e",patterns:"1111100000000000000000000 1000010000100001000010000 0001011110000000000000000 1000011110000000000000000 1111000010000000000000000 1111010000000000000000000 1100010000100001000000000 1100001000010000100000000 1000010000100001100000000 0100001000010001100000000 1100001110000000000000000 1110000110000000000000000 0111011000000000000000000 0011011100000000000000000 0100001000110001000000000 0100011000100001000000000 1000010000110000100000000 1000011000010000100000000 1111001000000000000000000 1111000100000000000000000 0100011110000000000000000 0010011110000000000000000 1000011000100001000000000 0100011000010000100000000 1000010000110001000000000 0100001000110000100000000".split(" ")},
{bonus:"h",patterns:"0010000100111000000000000 1000010000111000000000000 1110010000100000000000000 1110000100001000000000000 0100001000111000000000000 1000011100100000000000000 1110001000010000000000000 0010011100001000000000000 1010011100000000000000000 1100010000110000000000000 1110010100000000000000000 1100001000110000000000000".split(" ")}],combo6:[{bonus:"d",patterns:"0010000100111100000000000 0100001000111100000000000 1000010000111001000000000 1000011100100001000000000 1111001000010000000000000 1111000100001000000000000 0010011100001000010000000 0010000100111000010000000 0010011111000000000000000 1111100100000000000000000 1000010000110001000010000 0100001000110000100001000".split(" ")}],
combo7:[{bonus:"i",patterns:["0010000100111110000000000","1000010000111001000010000","1111100100001000000000000","0010000100111000010000100"]}]},_match3:[{t:{x:0,y:0},m:[{x:2,y:0},{x:3,y:0}],d:[{x:1,y:0}],s:{w:4,h:1}},{t:{x:3,y:0},m:[{x:0,y:0},{x:1,y:0}],d:[{x:2,y:0}],s:{w:4,h:1}},{t:{x:0,y:0},m:[{x:0,y:2},{x:0,y:3}],d:[{x:0,y:1}],s:{w:1,h:4}},{t:{x:0,y:3},m:[{x:0,y:0},{x:0,y:1}],d:[{x:0,y:2}],s:{w:1,h:4}},{t:{x:0,y:0},m:[{x:1,y:1},{x:2,y:1}],d:[{x:1,y:0}],s:{w:3,h:2}},{t:{x:0,y:0},m:[{x:1,y:1},{x:2,
y:1}],d:[{x:0,y:1}],s:{w:3,h:2}},{t:{x:1,y:0},m:[{x:0,y:1},{x:0,y:2}],d:[{x:0,y:0}],s:{w:2,h:3}},{t:{x:1,y:0},m:[{x:0,y:1},{x:0,y:2}],d:[{x:1,y:1}],s:{w:2,h:3}},{t:{x:2,y:1},m:[{x:0,y:0},{x:1,y:0}],d:[{x:2,y:0}],s:{w:3,h:2}},{t:{x:2,y:1},m:[{x:0,y:0},{x:1,y:0}],d:[{x:1,y:1}],s:{w:3,h:2}},{t:{x:0,y:2},m:[{x:1,y:0},{x:1,y:1}],d:[{x:0,y:1}],s:{w:2,h:3}},{t:{x:0,y:2},m:[{x:1,y:0},{x:1,y:1}],d:[{x:1,y:2}],s:{w:2,h:3}},{t:{x:2,y:0},m:[{x:0,y:1},{x:1,y:1}],d:[{x:1,y:0}],s:{w:3,h:2}},{t:{x:2,y:0},m:[{x:0,
y:1},{x:1,y:1}],d:[{x:2,y:1}],s:{w:3,h:2}},{t:{x:1,y:2},m:[{x:0,y:0},{x:0,y:1}],d:[{x:1,y:1}],s:{w:2,h:3}},{t:{x:1,y:2},m:[{x:0,y:0},{x:0,y:1}],d:[{x:0,y:2}],s:{w:2,h:3}},{t:{x:0,y:1},m:[{x:1,y:0},{x:2,y:0}],d:[{x:0,y:0}],s:{w:3,h:2}},{t:{x:0,y:1},m:[{x:1,y:0},{x:2,y:0}],d:[{x:1,y:1}],s:{w:3,h:2}},{t:{x:0,y:0},m:[{x:1,y:1},{x:1,y:2}],d:[{x:1,y:0}],s:{w:2,h:3}},{t:{x:0,y:0},m:[{x:1,y:1},{x:1,y:2}],d:[{x:0,y:1}],s:{w:2,h:3}},{t:{x:0,y:1},m:[{x:1,y:0},{x:2,y:1}],d:[{x:1,y:1}],s:{w:3,h:2}},{t:{x:1,y:0},
m:[{x:0,y:1},{x:2,y:1}],d:[{x:1,y:1}],s:{w:3,h:2}},{t:{x:2,y:1},m:[{x:1,y:0},{x:0,y:1}],d:[{x:1,y:1}],s:{w:3,h:2}},{t:{x:0,y:0},m:[{x:1,y:1},{x:0,y:2}],d:[{x:0,y:1}],s:{w:2,h:3}},{t:{x:1,y:1},m:[{x:0,y:0},{x:0,y:2}],d:[{x:0,y:1}],s:{w:2,h:3}},{t:{x:0,y:2},m:[{x:0,y:0},{x:1,y:1}],d:[{x:0,y:1}],s:{w:2,h:3}},{t:{x:0,y:0},m:[{x:2,y:0},{x:1,y:1}],d:[{x:1,y:0}],s:{w:3,h:2}},{t:{x:1,y:1},m:[{x:0,y:0},{x:2,y:0}],d:[{x:1,y:0}],s:{w:3,h:2}},{t:{x:2,y:0},m:[{x:0,y:0},{x:1,y:1}],d:[{x:1,y:0}],s:{w:3,h:2}},{t:{x:1,
y:2},m:[{x:1,y:0},{x:0,y:1}],d:[{x:1,y:1}],s:{w:2,h:3}},{t:{x:0,y:1},m:[{x:1,y:0},{x:1,y:2}],d:[{x:1,y:1}],s:{w:2,h:3}},{t:{x:1,y:0},m:[{x:0,y:1},{x:1,y:2}],d:[{x:1,y:1}],s:{w:2,h:3}},{t:{x:2,y:0},m:[{x:0,y:0},{x:0,y:1}],d:[{x:1,y:0}],s:{w:3,h:2}},{t:{x:1,y:2},m:[{x:0,y:0},{x:1,y:0}],d:[{x:1,y:1}],s:{w:2,h:3}},{t:{x:0,y:1},m:[{x:2,y:0},{x:2,y:1}],d:[{x:1,y:1}],s:{w:3,h:2}},{t:{x:0,y:0},m:[{x:0,y:2},{x:1,y:2}],d:[{x:0,y:1}],s:{w:2,h:3}},{t:{x:2,y:1},m:[{x:0,y:0},{x:0,y:1}],d:[{x:1,y:1}],s:{w:3,h:2}},
{t:{x:0,y:2},m:[{x:0,y:0},{x:1,y:0}],d:[{x:0,y:1}],s:{w:2,h:3}},{t:{x:0,y:0},m:[{x:2,y:0},{x:2,y:1}],d:[{x:1,y:0}],s:{w:3,h:2}},{t:{x:1,y:0},m:[{x:0,y:2},{x:1,y:2}],d:[{x:1,y:1}],s:{w:2,h:3}}],findMatch:function(a,b,c){var d=[];JRelation.isMatch3(b)&&JLogic.recursiveFindMatch(a,b,d);d.forEach(function(a){a.setState(JState.MATCHED,!1)});return c?{matches:d,bonus:JLogic.findBonus(a,d)}:{matches:d,bonus:null}},recursiveFindMatch:function(a,b,c){b.setState(JState.MATCH_ON,!1);b.setState(JState.MATCHED,
!0);c.push(b);var d=b.getCell().getTile(),e=a.getJewel(d.x-1,d.y);null!=e&&JRelation.allowMatch(e,b)&&JLogic.recursiveFindMatch(a,e,c);e=a.getJewel(d.x+1,d.y);null!=e&&JRelation.allowMatch(e,b)&&JLogic.recursiveFindMatch(a,e,c);e=a.getJewel(d.x,d.y-1);null!=e&&JRelation.allowMatch(e,b)&&JLogic.recursiveFindMatch(a,e,c);e=a.getJewel(d.x,d.y+1);null!=e&&JRelation.allowMatch(e,b,null,!0)&&JLogic.recursiveFindMatch(a,e,c)},findBonus:function(a,b){if(3>=b.length)return null;if(0==a.getMapId())switch(a.getLastLevelId()){case 0:return null;
case 1:if(4<b.length)return null;case 2:if(5<b.length)return null;case 3:if(7<b.length)return null}for(var c=b[0].getCell().getTileX(),d=b[0].getCell().getTileX(),e=b[0].getCell().getTileY(),f=b[0].getCell().getTileY(),g=0;g<b.length;g++){if(b[g].getCode()[0]!=JType.SIMPLE||b[g].isLocked())return null;c=Math.min(c,b[g].getCell().getTileX());d=Math.max(d,b[g].getCell().getTileX());e=Math.min(e,b[g].getCell().getTileY());f=Math.max(f,b[g].getCell().getTileY())}d="0000000000000000000000000".split("");
for(g=0;g<b.length;g++)d[5*(b[g].getCell().getTileY()-e)+b[g].getCell().getTileX()-c]=1;d=d.join("");c=this._bonuses["combo"+b.length];if(null==c||void 0==c)return null;for(g=0;g<c.length;g++)for(e=0;e<c[g].patterns.length;e++)if(d==c[g].patterns[e])return c[g].bonus;return 5==b.length?"e":6==b.length?"d":7<=b.length?"i":null},swapBonus:function(a,b){if(!a.isJType(JType.BONUS)||!b.isJType(JType.BONUS))return JSwap.NOBONUS;var c=a.getCode()[3],d=b.getCode()[3];return c!=JBonus.F&&c!=JBonus.G||d!=JBonus.F&&
d!=JBonus.G?c==JBonus.D&&(d==JBonus.F||d==JBonus.G)||d==JBonus.D&&(c==JBonus.F||c==JBonus.G)?JSwap.FGD:c==JBonus.E&&(d==JBonus.F||d==JBonus.G)||d==JBonus.E&&(c==JBonus.F||c==JBonus.G)?JSwap.FGE:c==JBonus.H&&(d==JBonus.F||d==JBonus.G)||d==JBonus.H&&(c==JBonus.F||c==JBonus.G)?JSwap.FGH:c==JBonus.I&&(d==JBonus.F||d==JBonus.G)||d==JBonus.I&&(c==JBonus.F||c==JBonus.G)?JSwap.FGI:c==JBonus.D&&d==JBonus.H||c==JBonus.H&&d==JBonus.D?JSwap.DH:c==JBonus.D&&d==JBonus.E||c==JBonus.E&&d==JBonus.D?JSwap.DE:c==JBonus.D&&
d==JBonus.I||c==JBonus.I&&d==JBonus.D?JSwap.DI:c==JBonus.E&&d==JBonus.H||c==JBonus.H&&d==JBonus.E?JSwap.EH:c==JBonus.E&&d==JBonus.I||c==JBonus.I&&d==JBonus.E?JSwap.EI:c==JBonus.I&&d==JBonus.H||c==JBonus.H&&d==JBonus.I?JSwap.HI:c==JBonus.H&&d==JBonus.H?JSwap.HH:JSwap.DEFAULT:JSwap.FG},hasMatch:function(a){for(var b=0;8>b;b++)for(var c=0;8>c;c++){var d=a.getJewel(b,c);if(null!=d&&2<JLogic.findMatch(a,d,!1).matches.length)return!0}return!1},canMatch2:function(a,b){for(var c=[],d,e,f=0;8>f;f++)for(var g=
0;8>g;g++){var h=a.getJewel(f,g);null==h||!h.isJType(JType.BONUS)||h.isLocked()||JLogic.hasCode(h,b)||(d={x:h.getCell().getTileX(),y:h.getCell().getTileY()},e=a.getJewel(f-1,g),null==e||e.isLocked()||JLogic.hasCode(h,b)||JLogic.swapBonus(h,e)==JSwap.NOBONUS||(e={x:e.getCell().getTileX(),y:e.getCell().getTileY()},JLogic.swapExist(d,e,c)||c.push({s:d,d:e})),e=a.getJewel(f+1,g),null==e||e.isLocked()||JLogic.hasCode(h,b)||JLogic.swapBonus(h,e)==JSwap.NOBONUS||(e={x:e.getCell().getTileX(),y:e.getCell().getTileY()},
JLogic.swapExist(d,e,c)||c.push({s:d,d:e})),e=a.getJewel(f,g-1),null==e||e.isLocked()||JLogic.hasCode(h,b)||JLogic.swapBonus(h,e)==JSwap.NOBONUS||(e={x:e.getCell().getTileX(),y:e.getCell().getTileY()},JLogic.swapExist(d,e,c)||c.push({s:d,d:e})),e=a.getJewel(f,g+1),null==e||e.isLocked()||JLogic.hasCode(h,b)||JLogic.swapBonus(h,e)==JSwap.NOBONUS||(e={x:e.getCell().getTileX(),y:e.getCell().getTileY()},JLogic.swapExist(d,e,c)||c.push({s:d,d:e})))}return c},canMatch3:function(a,b){for(var c=[],d=JLogic.getMatchMask(a,
b),e=0;e<d.length;e++)for(var f=0;f<d[e].length;f++)for(var g=0;g<this._match3.length;g++){var h=this._match3[g];if(e+h.s.w<=d.length&&f+h.s.h<=d[e].length){var k=d[e+h.t.x][f+h.t.y];if(null!=k&&"XXX"!=k){for(var m=!0,n=!0,p=0;p<h.m.length;p++)if(k!=d[e+h.m[p].x][f+h.m[p].y]){m=!1;break}if(m)for(p=0;p<h.d.length;p++)if(k==d[e+h.d[p].x][f+h.d[p].y]||null==d[e+h.d[p].x][f+h.d[p].y]){n=!1;break}k={x:h.t.x+e,y:h.t.y+f};if(m&&n&&JLogic.isSelectable(a,k))for(p=0;p<h.d.length;p++)m={x:h.d[p].x+e,y:h.d[p].y+
f},!JLogic.swapExist(k,m,c)&&JLogic.isSelectable(a,m)&&c.push({s:k,d:m})}}}return c},isSelectable:function(a,b){var c=a.getJewel(b.x,b.y);return null!=c&&JRelation.isSelectable(c)},hasCode:function(a,b){return 0<=a.getCode().join("").search(b)},swapExist:function(a,b,c){for(var d=0;d<c.length;d++)if(c[d].s.x==a.x&&c[d].s.y==a.y&&c[d].d.x==b.x&&c[d].d.y==b.y)return!0;return!1},shuffleShape:function(a,b,c){for(var d,e=0;8>e;e++)for(var f=0;8>f;f++)d=a.getJewel(e,f),null!=d&&JRelation.isApplyReshuffle(d)&&
d.updateCode(1,JShape.getRandom(d.getCode(1)));for(;;){var g=!0;for(e=0;8>e;e++)for(f=0;8>f;f++)d=a.getJewel(e,f),null!=d&&(d=JLogic.findMatch(a,d,!1).matches,2<d.length&&(g=!1,d.forEach(function(a){a.updateCode(1,JShape.getRandom(a.getCode(1)))})));if(g)break}if(0<JLogic.canMatch2(a,"^B..j").length||0<JLogic.canMatch3(a,"^B..j").length){if(c)for(e=0;8>e;e++)for(f=0;8>f;f++)d=a.getJewel(e,f),null!=d&&d.updateUI();return!0}return 0<b?JLogic.shuffleShape(a,b-1,c):!1},getMatchMask:function(a,b){for(var c=
[],d=0;8>d;d++){c[d]=[];for(var e=0;8>e;e++){var f=a.getJewel(d,e);f&&!JLogic.hasCode(f,b)&&JRelation.isMatch3(f)?f.isJType(JType.DIAMOND)?c[d][e]=f.getCode(0)+f.getCode(5):f.isJType(JType.PEARL)?c[d][e]=f.getCode(0):c[d][e]=f.getCode(1):c[d][e]=f&&JRelation.isSelectable(f)?"XXX":null}}return c},shuffleArray:function(a){for(var b=[],c=[],d,e=0;e<a.length;e++)b.push(e);for(e=0;e<a.length;e++){do d=Math.round(Math.random()*(b.length-1));while(b[d]==e&&1<b.length);c[b[d]]=a[e];b.splice(d,1)}return c},
getRainbowState:function(a,b){switch(a){case "a":return(1^b)&b;case "b":return(2^b)&b;case "c":return(4^b)&b;case "d":return(8^b)&b;case "e":return(16^b)&b;case "f":return(32^b)&b}return b}};var JAction=cc.Class.extend({_type:0,_controller:null,_complete:!1,_removed:!1,ctor:function(a){cc.assert(a);this._type=a;this._removed=this._complete=!1},getType:function(){return this._type},setController:function(a){this._controller=a},update:function(){},remove:function(){this._complete=this._removed=!0;this._controller&&(this._controller.remJAction(this),this._controller=null)}});JAction.NONE=0;JAction.MOVE=1;JAction.EXPLODE=2;JAction.CROSSDESTROYER=3;JAction.TORNADO=4;JAction.LIGHTING=5;
JAction.BONUS=6;JAction.FIREBLAST=7;JAction.BOMB=8;JAction.SWAP=9;JAction.RAINBOW=10;JAction.FROG=11;JAction.MAGNET=12;JAction.S_RESHUFFLE=13;JAction.S_HAMMER=14;JAction.S_HAND=15;JAction.S_COLOR_BLAST=16;JAction.S_UNLOCK=17;JAction.S_SUPER_BOMB=18;var JActionBase=JAction.extend({_jstate:0,_grid:null,_args:null,_target:null,ctor:function(a,b,c,d){this._super(a);cc.assert(b);this._jstate=c;this._target=b;this._grid=b.getCell().getGrid();this._args=d||{};this._args.hasOwnProperty("swap")||(this._args.swap=!1);this._target.setState(this._jstate,!0)},update:function(){},remove:function(){this._removed||(this._super(),this._target.setState(this._jstate,!1),this._grid=this._args=this._target=null)}});JAction.Bonus=JActionBase.extend({_list:null,_tick:0,ctor:function(a,b,c){this._super(JAction.BONUS,a,JState.BONUS);this._grid.setStableGrid(!1);this._target.setLocalZOrder(1);this._tick=15;this._list=b.filter(function(b){b.setState(JState.SWAP,!1);null!=b.getSwapRef()&&b.getSwapRef().setState(JState.SWAP,!1);return b!=a?(b.setLocalZOrder(0),b.setState(JState.BONUSLOCK,!0),!0):!1});b=a.getCode();"0"!=b[2]&&this._grid.addRuby(b[2],this._target.getPosition());var d=[];d[0]=JType.BONUS;d[1]=b[1];d[2]=
"0";d[3]=c;d[4]=b[4];d[5]="0";d[6]="0";this._target.setCode(d);c==JBonus.F?this._grid.getGoal().doneRowBlast(1,!0):c==JBonus.H?this._grid.getGoal().doneCrossBlast(1,!0):c==JBonus.G&&this._grid.getGoal().doneColumnBlast(1,!0)},update:function(){this._super();if(0<this._tick)for(c=0;c<this._list.length;c++){7==this._tick&&this._list[c]!=this._target&&this._list[c].getCell().remJewel();var a=this._target.getPosition(),b=this._list[c].getPosition();b.x-=(b.x-a.x)/this._tick;b.y-=(b.y-a.y)/this._tick;
this._list[c].setPosition(b)}else{for(var c=0;c<this._list.length;c++)"0"!=this._list[c].getCode(2)&&this._grid.addRuby(this._list[c].getCode(2),this._list[c].getPosition()),this._list[c].setState(JState.BONUSLOCK,!1),this._list[c].removeFromParent();this.remove()}this._tick--},remove:function(){this._target.setState(JState.MATCH_ON,!0);this._super()}});JAction.Bomb=JActionBase.extend({_tick:0,_state:0,_cpos:null,ctor:function(a,b){this._super(JAction.BOMB,a,JState.BOMB,b);this._args.hasOwnProperty("dx")||(this._args.dx=0);this._args.hasOwnProperty("dy")||(this._args.dy=0);this._args.hasOwnProperty("showExp")||(this._args.showExp=!1);this._state=this._tick=0;this._cpos=a.getCell().getTile();this._target.setLocalZOrder(100);this._target.runJAction(new JAction.Explode(this._target,{expType:"fire",scale:4,rotation:this.random(1,360),showExp:this._args.showExp}));
AudioEngine.playEffect(Resource.SND.CL_BOMB,!0)},random:function(a,b){return Math.round(Math.random()*(b-a))+a},explode:function(a){if(null!=a&&a.isEnabled()){var b=a.getJewel();null!=b&&JRelation.isApplyBomb(b)?(b.setLocalZOrder(0),b.execJAction(!1,{expType:"fire",rotation:this.random(1,360)})):a.breakBackground()}},update:function(){this._super();this._tick--;if(!(0<this._tick))if(0==this._state)this.explode(this._grid.getCell(this._cpos.x-1,this._cpos.y-1)),this.explode(this._grid.getCell(this._cpos.x-
1,this._cpos.y)),this.explode(this._grid.getCell(this._cpos.x-1,this._cpos.y+1)),this.explode(this._grid.getCell(this._cpos.x+1,this._cpos.y-1)),this.explode(this._grid.getCell(this._cpos.x+1,this._cpos.y)),this.explode(this._grid.getCell(this._cpos.x+1,this._cpos.y+1)),this.explode(this._grid.getCell(this._cpos.x,this._cpos.y+1)),this.explode(this._grid.getCell(this._cpos.x,this._cpos.y-1)),0!=this._args.dx||0!=this._args.dy?(0!=this._args.dx&&(this.explode(this._grid.getCell(this._cpos.x+this._args.dx,
this._cpos.y-1)),this.explode(this._grid.getCell(this._cpos.x+this._args.dx,this._cpos.y)),this.explode(this._grid.getCell(this._cpos.x+this._args.dx,this._cpos.y+1))),0!=this._args.dy&&(this.explode(this._grid.getCell(this._cpos.x+1,this._cpos.y+this._args.dy)),this.explode(this._grid.getCell(this._cpos.x,this._cpos.y+this._args.dy)),this.explode(this._grid.getCell(this._cpos.x-1,this._cpos.y+this._args.dy))),0!=this._args.dx&&0!=this._args.dy&&this.explode(this._grid.getCell(this._cpos.x+this._args.dx,
this._cpos.y+this._args.dy)),this.remove()):0==this._grid.getPowerAction()?this.remove():(this._tick=6,this._state=1);else if(1==this._state){var a=4>this._cpos.x?2:-2;this.explode(this._grid.getCell(this._cpos.x+a,this._cpos.y-1));this.explode(this._grid.getCell(this._cpos.x+a,this._cpos.y));this.explode(this._grid.getCell(this._cpos.x+a,this._cpos.y+1));if(2==this._grid.getPowerAction()){var b=4>this._cpos.y?2:-2;this.explode(this._grid.getCell(this._cpos.x+1,this._cpos.y+b));this.explode(this._grid.getCell(this._cpos.x,
this._cpos.y+b));this.explode(this._grid.getCell(this._cpos.x-1,this._cpos.y+b));this.explode(this._grid.getCell(this._cpos.x+a,this._cpos.y+b))}this.remove()}}});JAction.Diamond=JActionBase.extend({_list:null,_tick:15,ctor:function(a,b){this._super(JAction.BONUS,a,JState.BONUS);this._grid.setStableGrid(!1);this._target.setLocalZOrder(1);this._tick=15;this._list=b.filter(function(b){b.setState(JState.SWAP,!1);null!=b.getSwapRef()&&b.getSwapRef().setState(JState.SWAP,!1);return b!=a?(b.setLocalZOrder(0),b.setState(JState.BONUSLOCK,!0),!0):!1})},update:function(){this._super();if(0<this._tick)for(c=0;c<this._list.length;c++){7==this._tick&&this._list[c]!=this._target&&
this._list[c].getCell().remJewel();var a=this._target.getPosition(),b=this._list[c].getPosition();b.x-=(b.x-a.x)/this._tick;b.y-=(b.y-a.y)/this._tick;this._list[c].setPosition(b)}else{a=this._target.getUState();0<a&&this._target.setUState(a-1);for(var c=0;c<this._list.length;c++)"0"!=this._list[c].getCode(2)&&this._grid.addRuby(this._list[c].getCode(2),this._list[c].getPosition()),this._list[c].setState(JState.BONUSLOCK,!1),this._list[c].removeFromParent();this.remove()}this._tick--},remove:function(){var a=
this._target;0==a.getUState()?(a.setState(JState.BONUSLOCK,!0),a.runAction(new cc.Sequence(new cc.DelayTime(.5),new cc.CallFunc(function(){a.runJAction(new JAction.Explode(a))})))):a.setState(JState.MATCH_ON,!0);this._super()}});JAction.Rainbow=JActionBase.extend({ctor:function(a,b){this._super(JAction.EXPLODE,a,JState.EXPLODE,b);this._grid.setStableGrid(!1);this._args.hasOwnProperty("scale")||(this._args.scale=1);this._args.hasOwnProperty("rotation")||(this._args.rotation=0);this._args.hasOwnProperty("showExp")||(this._args.showExp=!1);this._args.hasOwnProperty("swap")||(this._args.swap=!1);if(!this._args.hasOwnProperty("expType")){var c=a.getCode();this._args.expType="0"!=c[1]&&"*"!=c[1]?c[1]:"a"}this._cell=a.getCell();
this.initExplosion()},initExplosion:function(){for(var a=this._args.expType,b=[],c=0;9>c;c++){var d=Resource.CLIENT.jewel_explode(a,c);b.push(cc.spriteFrameCache.getSpriteFrame(d))}a=new cc.Animation(b.slice(0,b.length-3),.028);c=new cc.Animation(b.slice(b.length-2),.028);b=new cc.Sprite(b[0]);b.setScale(this._args.scale);b.setRotation(this._args.rotation);d=[];d.push(new cc.Animate(a));d.push(new cc.CallFunc(this.k0,this));d.push(new cc.Animate(c));d.push(new cc.CallFunc(this.k1,this));d.push(new cc.RemoveSelf);
b.runAction(new cc.Sequence(d));this._target.addChild(b)},k0:function(){var a=this._target.getUState(),b=JLogic.getRainbowState(this._args.expType,a);this._target.setUState(b);0==a||0!=b&&1!=b&&2!=b&&4!=b&&8!=b&&16!=b&&32!=b||(this._target.removeFromParent(),this._target.getCell().remJewel(),this._grid.getGoal().isDoneRainbow()||(a=this._target.getPosition(),a=this._grid.convertToWorldSpace(a),b=new cc.EventCustom(Client.EVENT.FLY_RAINBOW),b.setUserData({k:"",p:a}),cc.eventManager.dispatchEvent(b)),
this._grid.getGoal().doneRainbow(1,!0),this.remove())},k1:function(){this.remove()}});JAction.Lighting=JActionBase.extend({_strike:0,_goal:null,_light:null,_targetExploded:!1,ctor:function(a,b){this._super(JAction.LIGHTING,a,JState.LIGHTING,b);this._strike=5+2*this._grid.getPowerAction();this._light=new cc.Sprite(Resource.CLIENT.jewel_explode("lighting",0));this._light.setAnchorPoint(.5,0);this._light.setLocalZOrder(100);this._grid.addChild(this._light);this._targetExploded=!1},findGoal:function(){for(var a=[],b=0;8>b;b++)for(var c=0;8>c;c++){var d=this._grid.getJewel(b,c);null!=d&&
JRelation.isApplyLighting(d)&&d.execJAction(!0,null)&&a.push(d)}return 0==a.length?null:a[CUtils.random(0,a.length-1)]},k0:function(){this._goal&&this._goal.execJAction(!1);0!=this._strike||this._targetExploded||(this._targetExploded=!0,this._target.runJAction(new JAction.Explode(this._target,{expType:"fire",rotation:CUtils.random(1,360),swap:this._args.swap})))},k1:function(){this._goal=null},update:function(){if(null==this._goal&&0<this._strike&&(this._goal=this.findGoal(),this._strike--,null!=
this._goal)){var a=[];a.push(new cc.FadeIn);a.push(new cc.DelayTime(.08));a.push(new cc.FlipX(!0));a.push(new cc.DelayTime(.08));a.push(new cc.FlipY(!0));a.push(new cc.DelayTime(.08));a.push(new cc.FlipX(!1));a.push(new cc.DelayTime(.08));a.push(new cc.FlipY(!1));a.push(new cc.CallFunc(this.k0.bind(this)));a.push(new cc.DelayTime(.08));a.push(new cc.FadeTo(.1,0));a.push(new cc.CallFunc(this.k1.bind(this)));this._light.runAction(new cc.Sequence(a));AudioEngine.playEffect(Resource.SND.CL_LIGHTNING,
!0)}if(null!=this._goal){a=this._target.getPosition();var b=this._goal.getPosition(),c=Math.sqrt(Math.pow(a.x-b.x,2)+Math.pow(a.y-b.y,2));this._light.setVisible(!0);this._light.setPosition(a);this._light.setScaleY(c/this._light.getContentSize().height);this._light.setRotation(90-CUtils.getAngle(a,b,!1))}else this._light.setVisible(!1);0==this._strike&&null==this._goal&&(this._targetExploded||(this._targetExploded=!0,this._target.runJAction(new JAction.Explode(this._target,{expType:"fire",rotation:CUtils.random(1,
360),swap:this._args.swap}))),this._light.removeFromParent(),this.remove())}});JAction.FireBlast=JActionBase.extend({_items:null,_boules:null,_speed:0,ctor:function(a,b){this._super(JAction.FIREBLAST,a,JState.FIREBLAST,b);this._speed=9;this._items=[];this._boules=[];for(var c=this._target.getCode(1),d=[],e=0;3>e;e++){var f=Resource.CLIENT.jewel_explode("fireblast",e);d.push(cc.spriteFrameCache.getSpriteFrame(f))}f=new cc.Animation(d,.03);var g=this._target.getCell().getCenter();for(e=0;8>e;e++)for(var h=0;8>h;h++){var k=this._grid.getJewel(e,h);if(null!=k&&k!=this._target&&
JRelation.isApplyFireBlast(k,c)){this._items.push(k);var m=new cc.Sprite(d[0]);m.setAnchorPoint(.2,.5);m.setLocalZOrder(100);m.setPosition(g);m.runAction(new cc.RepeatForever(new cc.Animate(f)));m.setRotation(180-CUtils.getAngle(g,k.getPosition(),!1));this._grid.addChild(m);this._boules.push(m)}}this._target.runJAction(new JAction.Explode(this._target,{expType:"fire",rotation:this.random(1,360),swap:this._args.swap}));AudioEngine.playEffect(Resource.SND.CL_COLOR_BLAST,!0)},random:function(a,b){return Math.round(Math.random()*
(b-a))+a},getAngle:function(a,b){var c=Math.atan2(b.y-a.y,b.x-a.x);0>c?c=2*Math.PI+c:c>=2*Math.PI&&(c-=2*Math.PI);return c},update:function(){for(var a=this._items.length-1;0<=a;a--){var b=this._items[a],c=this._boules[a],d=b.getPosition(),e=c.getPosition(),f=this.getAngle(e,d),g=e.x+this._speed*Math.cos(f);f=e.y+this._speed*Math.sin(f);c.setPositionX(e.x!=d.x&&(e.x>d.x&&d.x>g||e.x<d.x&&d.x<g)?d.x:g);c.setPositionY(e.y!=d.y&&(e.y>d.y&&d.y>f||e.y<d.y&&d.y<f)?d.y:f);c.getPositionY()==d.y&&c.getPositionX()==
d.x?(b.execJAction(!1,{expType:"fire",rotation:this.random(1,360)}),c.removeFromParent(),this._boules.splice(a,1),this._items.splice(a,1)):c.setRotation(180-CUtils.getAngle(c.getPosition(),d,!1))}0==this._items.length&&this.remove()}});JAction.Tornado=JActionBase.extend({_items:null,_center:null,_cpos:null,_state:0,_tx:0,_ty:0,_angle:0,_angle_rot:20,_angle_min:10,_angle_max:20,ctor:function(a){this._super(JAction.TORNADO,a,JState.TORNADO);this._items=[];this._center=[];this._angle=this._ty=this._tx=this._state=0;this._angle_rot=20;this._angle_min=10;this._angle_max=20;this.init();null!=a.getSwapRef()&&a.setSwapRef(null);a.setLocalZOrder(1E3);a.runJAction(new JAction.Explode(a));a=[];for(var b=0;11>b;b++){var c=Resource.CLIENT.jewel_explode("tornado",
b);a.push(cc.spriteFrameCache.getSpriteFrame(c))}b=new cc.Sprite(a[0]);b.setLocalZOrder(100);b.setScale(0==this._grid.getPowerAction()?3:4);b.setPosition(this._cpos);a=new cc.Animation(a,.03);b.runAction(new cc.Sequence(new cc.Animate(a),new cc.RemoveSelf));this._grid.addChild(b)},init:function(){var a=this._target.getCell();this._state=0;this._cpos=new cc.Point(a.getCenter().x,a.getCenter().y);this._tx=a.getTileX();this._ty=a.getTileY();a=8>this._tx?1:-1;var b=8>this._ty?1:-1;switch(this._grid.getPowerAction()){case 1:case 2:this._cpos.x+=
a*Client.Grid.getCHSize().width,this._cpos.y+=b*Client.Grid.getCHSize().height,a*=2,b*=2,this.add(this._grid.getJewel(this._tx+a,this._ty-1)),this.add(this._grid.getJewel(this._tx+a,this._ty)),this.add(this._grid.getJewel(this._tx+a,this._ty+1)),this.add(this._grid.getJewel(this._tx-1,this._ty+b)),this.add(this._grid.getJewel(this._tx,this._ty+b)),this.add(this._grid.getJewel(this._tx+1,this._ty+b)),this.add(this._grid.getJewel(this._tx+a,this._ty+b));case 0:this.add(this._grid.getJewel(this._tx+
1,this._ty-1)),this.add(this._grid.getJewel(this._tx,this._ty-1)),this.add(this._grid.getJewel(this._tx-1,this._ty-1)),this.add(this._grid.getJewel(this._tx+1,this._ty+1)),this.add(this._grid.getJewel(this._tx,this._ty+1)),this.add(this._grid.getJewel(this._tx-1,this._ty+1)),this.add(this._grid.getJewel(this._tx-1,this._ty)),this.add(this._grid.getJewel(this._tx+1,this._ty))}for(b=0;b<this._items.length;b++){var c=this._items[b].getPosition();a=this._cpos.x>c.x?.5*(this._cpos.x-c.x)+c.x:.5*(c.x-this._cpos.x)+
this._cpos.x;c=this._cpos.y>c.y?.5*(this._cpos.y-c.y)+c.y:.5*(c.y-this._cpos.y)+this._cpos.y;this._center.push({cx:a,cy:c})}AudioEngine.playEffect(Resource.SND.CL_TORNADO,!0)},add:function(a){a&&JRelation.isApplyTornado(a)&&a!=this._target.getSwapRef()&&(a.setState(JState.TORNADOLOCK,!0),this._items.push(a))},rotate:function(a,b,c,d,e){var f=Math.PI/180*e;e=Math.cos(f);f=Math.sin(f);return{x:e*(c-a)+f*(d-b)+a,y:e*(d-b)-f*(c-a)+b}},update:function(){if(0==this._state){this._angle+=this._angle_rot;
180<=this._angle&&(this._angle_rot=this._angle_rot-this._angle-180,this._state=1);for(var a=0;a<this._items.length;a++){var b=this._items[a].getPosition();b=this.rotate(this._center[a].cx,this._center[a].cy,b.x,b.y,-this._angle_rot);this._items[a].setPosition(b)}this._angle_rot=this._angle_rot-.005>this._angle_min?this._angle_rot-.005:this._angle_min}else if(1==this._state){this._center=[];this._items=this._items.filter(function(a){return null!=a.parent&&null!=a.getCell()});var c=JLogic.shuffleArray(this._items);
for(a=0;a<this._items.length;a++){if(this._items[a]!=c[a]){b=this._items[a].getCell();var d=c[a].getCell();b.remJewel();d.remJewel();b.addJewel(c[a]);d.addJewel(this._items[a]);c[a].setPosition(c[a].getCell().getCenter())}this._items[a].setPosition(this._items[a].getCell().getCenter())}for(a=b=c=0;a<this._items.length;a++)b=this._items[a].getPosition(),c=this._cpos.x>b.x?.5*(this._cpos.x-b.x)+b.x:.5*(b.x-this._cpos.x)+this._cpos.x,b=this._cpos.y>b.y?.5*(this._cpos.y-b.y)+b.y:.5*(b.y-this._cpos.y)+
this._cpos.y,this._center.push({cx:c,cy:b}),this._items[a].setPosition(this._cpos);this._angle=0;this._state=2}else if(2==this._state){this._angle+=this._angle_rot;180<=this._angle&&(this._angle_rot=this._angle_rot-this._angle-180,this._state=3);cc.log(this._target.getCode(1)+" "+this._angle);for(a=0;a<this._items.length;a++)b=this._items[a].getPosition(),b=this.rotate(this._center[a].cx,this._center[a].cy,b.x,b.y,-this._angle_rot),this._items[a].setPosition(b);this._angle_rot=this._angle_rot+.005>
this._angle_max?this._angle_rot+.005:this._angle_max}else if(3==this._state){cc.log("clean");for(a=0;a<this._items.length;a++)c=this._items[a].getCell(),null!=c&&this._items[a].setPosition(c.getCenter()),this._items[a].setState(JState.TORNADOLOCK,!1),this._items[a].setState(JState.MATCH_ON,!0);this.remove()}}});JAction.Swap=JActionBase.extend({_arg0:null,_arg1:null,_state:0,_smoves:0,ctor:function(a,b){this._arg0=a;this._arg1=b;this._arg0.setSwapRef(this._arg1);this._arg1.setSwapRef(this._arg0);this._super(JAction.SWAP,this._arg0,JState.SWAP);this._arg1.setState(JState.SWAP,!0);this._arg0.setState(JState.MATCH_OFF,!0);this._arg1.setState(JState.MATCH_OFF,!0);this._smoves=1;this._state=0;this.doSwap(this._arg0,this._arg1)},doSwap:function(a,b){var c=a.getCell(),d=b.getCell();c.remJewel();d.remJewel();c.addJewel(b);
d.addJewel(a);a.runJAction(new JAction.Move(a));b.runJAction(new JAction.Move(b));0==this._state?AudioEngine.playEffect(Resource.SND.CL_SWAP_ITEM):AudioEngine.playEffect(Resource.SND.CL_SWAP_ITEM_BACK)},update:function(){this._super();if(0==this._state)if(!this._arg0.isState(JState.SWAP)||!this._arg1.isState(JState.SWAP))this.remove();else{if(!this._arg0.isState(JState.MOVE)&&!this._arg1.isState(JState.MOVE))switch(JLogic.swapBonus(this._arg0,this._arg1)){case JSwap.FG:this._arg0.setState(JState.MATCH_OFF,
!1);this._arg1.setState(JState.MATCH_OFF,!1);this._arg0.setState(JState.SWAP,!1);this._arg1.setState(JState.SWAP,!1);this.swapBonus1(this._arg0,this._arg1);this.remove();break;case JSwap.FGD:this._arg0.setState(JState.MATCH_OFF,!1);this._arg1.setState(JState.MATCH_OFF,!1);this._arg0.setState(JState.SWAP,!1);this._arg1.setState(JState.SWAP,!1);this.swapBonus2(this._arg0,this._arg1);this.remove();break;case JSwap.FGH:this._arg0.setState(JState.MATCH_OFF,!1);this._arg1.setState(JState.MATCH_OFF,!1);
this._arg0.setState(JState.SWAP,!1);this._arg1.setState(JState.SWAP,!1);this.swapBonus4(this._arg0,this._arg1);this.remove();break;case JSwap.DH:this._arg0.setState(JState.MATCH_OFF,!1);this._arg1.setState(JState.MATCH_OFF,!1);this._arg0.setState(JState.SWAP,!1);this._arg1.setState(JState.SWAP,!1);this.swapBonus6(this._arg0,this._arg1);this.remove();break;case JSwap.DE:case JSwap.DI:this._arg0.setState(JState.MATCH_OFF,!1);this._arg1.setState(JState.MATCH_OFF,!1);this._arg0.setState(JState.SWAP,!1);
this._arg1.setState(JState.SWAP,!1);this.swapBonus78(this._arg0,this._arg1);this.remove();break;case JSwap.HH:this._arg0.setState(JState.MATCH_OFF,!1);this._arg1.setState(JState.MATCH_OFF,!1);this._arg0.setState(JState.SWAP,!1);this._arg1.setState(JState.SWAP,!1);this._arg0.execJAction(!1,{type:3,swap:!0});this._arg1.execJAction(!1,{swap:!0});this.remove();break;case JSwap.DEFAULT:case JSwap.HI:case JSwap.EI:case JSwap.EH:case JSwap.FGI:case JSwap.FGE:this._arg0.setState(JState.MATCH_OFF,!1);this._arg1.setState(JState.MATCH_OFF,
!1);this._arg0.setState(JState.SWAP,!1);this._arg1.setState(JState.SWAP,!1);this._arg0.execJAction(!1,{swap:!0});this._arg1.execJAction(!1,{swap:!0});this.remove();break;default:this._arg0.setState(JState.MATCH_OFF,!1),this._arg1.setState(JState.MATCH_OFF,!1),this._arg0.setState(JState.MATCH_ON,!0),this._arg1.setState(JState.MATCH_ON,!0),this._state=1}}else 1==this._state?this._arg0.isState(JState.SWAP)&&this._arg1.isState(JState.SWAP)?this._arg0.isState(JState.MATCH_ON)||JRelation.isLocked(this._arg0,
[JState.SWAP])||this._arg1.isState(JState.MATCH_ON)||JRelation.isLocked(this._arg1,[JState.SWAP])||(this.doSwap(this._arg0,this._arg1),this._state=2):this.remove():2==this._state&&(this._arg0.isState(JState.SWAP)&&this._arg1.isState(JState.SWAP)?this._arg0.isState(JState.MOVE)||this._arg1.isState(JState.MOVE)||(this._arg0.setState(JState.MATCH_ON,!0),this._arg1.setState(JState.MATCH_ON,!0),this._smoves=0,this.remove()):(this._smoves=0,this.remove()))},remove:function(){if(1>=this._state&&this._grid.getCloud()){var a=
this._grid.getCloud();if(this._arg1.hasCell()){var b=this._arg1.getCell().getTile();a.goTo(b.x,b.y,!0);a.exec()}else this._arg0.hasCell()&&(b=this._arg0.getCell().getTile(),a.goTo(b.x,b.y,!0),a.exec())}0<this._smoves&&(this._grid.setInfectSwap(!0),this._grid.setInfectMagnet(this._grid.getInfectMagnet()+1));this._grid.getInfo().mv_d(this._smoves);this._grid.getGoal().updateSpendMoves(this._smoves,!0);this._super();this._arg0.setSwapRef(null);this._arg1.setSwapRef(null);this._arg0.setState(JState.SWAP,
!1);this._arg1.setState(JState.SWAP,!1);this._arg0.setState(JState.MATCH_OFF,!1);this._arg1.setState(JState.MATCH_OFF,!1)},swapBonus1:function(a,b){var c={dx:0,dy:0,swap:!0},d=a.getCode(),e=b.getCode(),f=a.getCell().getTile(),g=b.getCell().getTile();d[3]==JBonus.F&&e[3]==JBonus.F&&f.y==g.y?c.dy=4>f.y?1:-1:d[3]==JBonus.G&&e[3]==JBonus.G&&f.x==g.x&&(c.dx=4>f.x?1:-1);a.execJAction(!1,{dx:0,dy:0,swap:!0});b.execJAction(!1,c)},swapBonus2:function(a,b){var c={dx:0,dy:0,arrow:!1,expType:"fire",expTypeOverride:!0,
swap:!0};a.getCode(3)==JBonus.D?a.updateCode(3,b.getCode(3)):b.updateCode(3,a.getCode(3));var d=a.getCode(),e=b.getCode(),f=a.getCell().getTile(),g=b.getCell().getTile();d[3]==JBonus.F&&e[3]==JBonus.F&&f.y==g.y?c.dy=4>f.y?1:-1:d[3]==JBonus.G&&e[3]==JBonus.G&&f.x==g.x&&(c.dx=4>f.x?1:-1);a.execJAction(!1,c);b.execJAction(!1,{dx:0,dy:0,arrow:!1,expType:"fire",expTypeOverride:!0,swap:!0})},swapBonus4:function(a,b){var c={dx:0,dy:0,swap:!0},d=a.getCode(),e=b.getCode(),f=a.getCell().getTile(),g=b.getCell().getTile();
d[3]!=JBonus.F&&e[3]!=JBonus.F||f.y!=g.y?d[3]!=JBonus.G&&e[3]!=JBonus.G||f.x!=g.x||(c.dx=4>f.x?1:-1):c.dy=4>f.y?1:-1;a.execJAction(!1,{dx:0,dy:0,swap:!0});b.execJAction(!1,c)},swapBonus6:function(a,b){var c={dx:0,dy:0,arrow:!1,expType:"fire",expTypeOverride:!0,swap:!0};a.updateCode(3,JBonus.H);b.updateCode(3,JBonus.H);var d=a.getCell().getTile(),e=b.getCell().getTile();d.y==e.y?c.dy=4>d.y?1:-1:d.x==e.x&&(c.dx=4>d.x?1:-1);a.execJAction(!1,c);b.execJAction(!1,{dx:0,dy:0,arrow:!1,expType:"fire",expTypeOverride:!0,
swap:!0})},swapBonus78:function(a,b){var c={dx:0,dy:0,swap:!0};if(a.getCode(3)==JBonus.D){var d=a;var e=b}else d=b,e=a;d=d.getCell().getTile();e=e.getCell().getTile();d.x==e.x?c.dy=d.y>e.y?-2:2:c.dx=d.x>e.x?-2:2;a.execJAction(!1,c);b.execJAction(!1,{swap:!0})}});JAction.Frog=JActionBase.extend({_target0:null,_target1:null,_tongue:null,ctor:function(a,b){this._super(JAction.FROG,a,JState.FROG,b);this._target0=a;this._target0.setLocalZOrder(100);this._target1=this.findTarget();this._target1.setState(JState.FROG,!0);var c=this,d=CUtils.getAngle(this._target0.getPosition(),this._target1.getPosition(),!0);this._tongue=new cc.Scale9Sprite(Resource.CLIENT.jewel_infect("frog",1),new cc.Rect(5,38,5,2));this._tongue.setAnchorPoint(.5,0);this._tongue.setPosition(this._target0.getPosition());
this._tongue.setRotation(this._target0.getRotation());this._tongue.step=0;this._tongue.dist=CUtils.distance(this._target0.getPosition(),this._target1.getPosition());this._tongue.jump=.001*this._tongue.dist;var e=this._tongue.getContentSize(),f=new cc.Sprite(Resource.CLIENT.jewel_infect("frog",0));f.setPosition(.5*e.width-2,0);this._tongue.setContentSize(e.width,0);this._tongue.addChild(f);e=[];e.push(new cc.RotateTo(.2,d));e.push(new cc.Repeat(new cc.Sequence([new cc.DelayTime(this._tongue.jump/100),
new cc.CallFunc(function(){var a=this.getContentSize();this.step=Math.min(100,this.step+1);this.setContentSize(a.width,this.dist/100*this.step);this.setVisible(!0)},this._tongue)]),100));e.push(new cc.CallFunc(function(){AudioEngine.playEffect(Resource.SND.CL_TAKE_RUBY);this.setOpacity(150)},this._target0));e.push(new cc.Spawn([new cc.MoveTo(this._tongue.jump,this._target1.getPosition()),new cc.Repeat(new cc.Sequence([new cc.DelayTime(this._tongue.jump/200),new cc.CallFunc(function(){var a=CUtils.distance(this.getPosition(),
c._target1.getPosition()),b=this.getContentSize();this.setContentSize(b.width,a)},this._tongue)]),200)]));e.push(new cc.CallFunc(function(){var a=c._target0.getCell(),b=c._target1.getCell();a.remJewel();b.remJewel();a.addJewel(c._target1);b.addJewel(c._target0);c._target0.setPosition(b.getCenter());c._target1.setPosition(a.getCenter());c._target0.setOpacity(255);c.remove()}));e.push(new cc.RemoveSelf);this._target0.runAction(new cc.RotateTo(.2,d));this._tongue.runAction(new cc.Sequence(e));this._grid.addChild(this._tongue,
500)},findTarget:function(){for(var a=[],b=[],c=0;8>c;c++)for(var d=0;8>d;d++){var e=this._grid.getJewel(c,d);null!=e&&e!=this._target&&JRelation.isApplyFrog(e)&&(e.isJType(JType.SIMPLE)?a.push(e):b.push(e))}return 0<b.length?b[CUtils.random(0,b.length-1)]:a[CUtils.random(0,a.length-1)]},update:function(){},remove:function(){this._target1.setState(JState.FROG,!1);this._target1.setState(JState.MATCH_ON,!0);this._super()}});JAction.Magnet=JActionBase.extend({ctor:function(a,b){this._super(JAction.MAGNET,a,JState.NONE,b)},doSwap:function(a,b){var c=a.getCell(),d=b.getCell();c.remJewel();d.remJewel();c.addJewel(b);d.addJewel(a);a.runJAction(new JAction.Move(a));b.runJAction(new JAction.Move(b))},update:function(){var a=this._target.getCell().getTile(),b=.5<Math.random()?1:-1,c=this._grid.getJewel(a.x,a.y+1),d=this._grid.getJewel(a.x-b,a.y+1);a=this._grid.getJewel(a.x+b,a.y+1);c&&JRelation.isMovable(c)&&!c.isJType(JType.TREASURE)?
this.doSwap(this._target,c):d&&JRelation.isMovable(d)&&!d.isJType(JType.TREASURE)?this.doSwap(this._target,d):a&&JRelation.isMovable(a)&&!a.isJType(JType.TREASURE)&&this.doSwap(this._target,a);this.remove()},remove:function(){this._super()}});JAction.Move=JActionBase.extend({JUMP_TAG:59,_accel:0,_speed:0,_speedMax:0,_jump:!1,ctor:function(a,b,c,d,e){this._super(JAction.MOVE,a,JState.MOVE);this._accel=void 0===c?.7:c;this._speed=void 0===d?3:d;this._speedMax=void 0===e?6:e;this._jump=b;a.stopActionByTag(this.JUMP_TAG)},update:function(){this._super();this._speed=Math.min(this._speed+this._accel,this._speedMax);var a=this._target.getCell().getCenter(),b=this._target.getPosition();Math.abs(b.x-a.x)<this._speed&&Math.abs(b.y-a.y)<this._speed&&
(this._complete=!JRelation.allowActionMove(this._target,[JState.MOVE])||!this._target.getCell().dropJewel());this._complete?(this._target.setPosition(a),this._jump&&(this._target.runAction(new cc.Sequence([new cc.MoveTo(.1,a.x,a.y-2),new cc.MoveTo(.1,a.x,a.y+.5),new cc.MoveTo(.05,a.x,a.y)])).setTag(this.JUMP_TAG),this._target.runAction(new cc.Sequence([new cc.ScaleTo(.1,1,.97),new cc.ScaleTo(.1,1,1)]))),this.remove()):(a.x!=b.x&&(Math.abs(a.x-b.x)<Math.abs(this._speed)?this._target.setPositionX(a.x):
b.x<a.x?this._target.setPositionX(b.x+this._speed):this._target.setPositionX(b.x-this._speed)),a.y!=b.y&&(Math.abs(a.y-b.y)<Math.abs(this._speed)?this._target.setPositionY(a.y):b.y<a.y?this._target.setPositionY(b.y+this._speed):this._target.setPositionY(b.y-this._speed)))},remove:function(){this._target.isState(JState.SWAP)||this._target.setState(JState.MATCH_ON,!0);this._super()}});JAction.Explode=JActionBase.extend({_cell:null,_removeJewel:!0,_flyOn:!1,ctor:function(a,b){this._super(JAction.EXPLODE,a,JState.EXPLODE,b);this._grid.setStableGrid(!1);this._removeJewel=!0;this._flyOn=!1;this._args.hasOwnProperty("scale")||(this._args.scale=1);this._args.hasOwnProperty("rotation")||(this._args.rotation=0);this._args.hasOwnProperty("showExp")||(this._args.showExp=!1);this._args.hasOwnProperty("swap")||(this._args.swap=!1);if(!this._args.hasOwnProperty("expType")){var c=a.getCode();
this._args.expType="0"!=c[1]&&"*"!=c[1]?c[1]:"a"}this._target.isLocked()?(this._target.setLocks(this._target.getLocks()-1),this._removeJewel=!1):0<this._target.getUState()?(c=this._target.getUState()-1,this._target.setUState(c),this._removeJewel=!1,this._target.isJType(JType.TORCH)&&0==c?this._grid.getGoal().doneTorch(1,!0):this._target.isJType(JType.MAGICBALL)&&this._grid.setInfectMagicBall(!1)):this._target.isJType(JType.STONE)&&0==this._target.getUState()?this._grid.getGoal().doneStone(1,!0):this._target.isJType(JType.BEETLE)&&
0==this._target.getUState()?(this._flyOn=!this._grid.getGoal().isDoneBeetle(),this._grid.getGoal().doneBeetle(1,!0)):this._target.isJType(JType.DIAMOND)&&0==this._target.getUState()?this._grid.getGoal().doneDiamond(1,!0):this._target.isJType(JType.MIRROR)&&0==this._target.getUState()?this._grid.getGoal().doneMirror(1,!0):this._target.isJType(JType.FROG)&&0==this._target.getUState()?(AudioEngine.playEffect(Resource.SND.CL_HAMMER,!0),this._grid.getGoal().doneFrog(1,!0)):this._target.isJType(JType.BUTTERFLY)?
(this._args.expType="a",0==this._target.getUState()&&(this._flyOn=!this._grid.getGoal().isDoneButterfly(),this._grid.getGoal().doneButterfly(1,!0))):this._target.isJType(JType.ICECUBE)?(this._grid.setInfectIceCube(!1),this._grid.getGoal().doneIceCube(1,!0),this._args.expType="a"):this._target.isJType(JType.BONUS)?this._target.getCode(3)==JBonus.A?(this._grid.getGoal().updateTotalMoves(3,!0),AudioEngine.playEffect(Resource.SND.CL_MOVES_ADD,!0)):this._target.getCode(3)==JBonus.J&&(this._grid.getGoal().updateTotalMoves(-3,
!0),AudioEngine.playEffect(Resource.SND.CL_MOVES_REM,!0)):this._target.isJType(JType.MAGICBALL)?(this._grid.setInfectMagicBall(!1),this._grid.getGoal().doneMagicBall(1,!0),AudioEngine.playEffect(Resource.SND.CL_TAKE_RUBY)):this._target.isJType(JType.PEARL)&&(this._grid.getGoal().donePearl(1,!0),this._args.expType="a");this._cell=a.getCell();this.initExplosion()},initExplosion:function(){for(var a=this._args.expType,b=[],c=0;9>c;c++){var d=Resource.CLIENT.jewel_explode(a,c);b.push(cc.spriteFrameCache.getSpriteFrame(d))}a=
new cc.Animation(b.slice(0,b.length-3),.028);c=new cc.Animation(b.slice(b.length-2),.028);b=new cc.Sprite(b[0]);b.setScale(this._args.scale);b.setRotation(this._args.rotation);d=[];this._removeJewel?this._target.isJType(JType.ICECUBE)?(b.setVisible(!1),d.push(new cc.CallFunc(this.icecubeExp,this)),d.push(new cc.Animate(a)),d.push(new cc.CallFunc(this.k0,this)),d.push(new cc.Animate(c)),d.push(new cc.CallFunc(this.k1,this))):this._target.isJType(JType.MIRROR)?(b.setVisible(!1),d.push(new cc.CallFunc(this.mirrorExp,
this)),d.push(new cc.Animate(a)),d.push(new cc.CallFunc(this.k0,this)),d.push(new cc.Animate(c)),d.push(new cc.CallFunc(this.k1,this))):this._target.isJType(JType.BEETLE)?(b.setVisible(!1),d.push(new cc.CallFunc(this.beetleFly,this)),d.push(new cc.Animate(a)),d.push(new cc.CallFunc(this.k0,this)),d.push(new cc.Animate(c)),d.push(new cc.CallFunc(this.k1,this))):this._target.isJType(JType.BUTTERFLY)?(b.setVisible(!0),d.push(new cc.CallFunc(this.butterflyFly,this)),d.push(new cc.Animate(a)),d.push(new cc.CallFunc(this.k0,
this)),d.push(new cc.Animate(c)),d.push(new cc.CallFunc(this.k1,this))):this._target.isJType(JType.ENIGMA)?(d.push(new cc.Animate(a)),d.push(new cc.CallFunc(this.enigmaExp.bind(this,0),this)),d.push(new cc.Animate(c)),d.push(new cc.CallFunc(this.k2,this))):this._target.isJType(JType.SHELL)?(b.setVisible(!1),d.push(new cc.Animate(a)),d.push(new cc.CallFunc(this.shellExp.bind(this),this)),d.push(new cc.Animate(c)),d.push(new cc.DelayTime(.5)),d.push(new cc.CallFunc(this.k2,this))):(d.push(new cc.Animate(a)),
d.push(new cc.CallFunc(this.k0,this)),d.push(new cc.Animate(c)),d.push(new cc.CallFunc(this.k1,this))):(this._target.isJType(JType.BEETLE)?(b.setVisible(!1),d.push(new cc.CallFunc(this.beetleExp,this))):this._target.isJType(JType.MAGICBALL)&&AudioEngine.playEffect(Resource.SND.CL_HAMMER,!0),d.push(new cc.Animate(a)),this._target.isJType(JType.ENIGMA)&&d.push(new cc.CallFunc(this.enigmaExp.bind(this,1),this)),d.push(new cc.Animate(c)),d.push(new cc.CallFunc(this.k2,this)));d.push(new cc.RemoveSelf);
b.runAction(new cc.Sequence(d));this._target.addChild(b)},explodeNear:function(){var a=this._cell.getTile(),b=this._target.getCode(),c={expType:this._args.expType};b={expType:"0"!=b[1]&&"*"!=b[1]?b[1]:this._args.expType};var d=this._grid.getJewel(a.x,a.y-1);JRelation.isExplodeNear(this._target,d,this._args.swap)&&d.execJAction(!1,d.isJType(JType.RAINBOW)?b:c);d=this._grid.getJewel(a.x,a.y+1);JRelation.isExplodeNear(this._target,d,this._args.swap)&&d.execJAction(!1,d.isJType(JType.RAINBOW)?b:c);d=
this._grid.getJewel(a.x-1,a.y);JRelation.isExplodeNear(this._target,d,this._args.swap)&&d.execJAction(!1,d.isJType(JType.RAINBOW)?b:c);d=this._grid.getJewel(a.x+1,a.y);JRelation.isExplodeNear(this._target,d,this._args.swap)&&d.execJAction(!1,d.isJType(JType.RAINBOW)?b:c)},k0:function(){this.explodeNear();JRelation.isBreakBackground(this._target)&&this._cell&&this._cell.breakBackground();0!=this._target.getCode(2)&&this._grid.addRuby(this._target.getCode(2),this._target.getPosition());this._target.getCell()&&
this._target.getCell().remJewel();this._target.remUI()},k1:function(){this._target.removeFromParent();this.remove()},k2:function(){this._target.setState(JState.MATCH_ON,!0);this.remove()},beetleFly:function(){if(this._flyOn){var a=this._target.getPosition();a=this._grid.convertToWorldSpace(a);var b=new cc.EventCustom(Client.EVENT.FLY_BEETLE);b.setUserData({k:this._target.getCode(1),p:a});cc.eventManager.dispatchEvent(b)}},beetleExp:function(){var a=this._target.getPosition(),b=new cc.Sprite(Resource.CLIENT.jewel_explode("beetle",
0)),c=new cc.Sprite(Resource.CLIENT.jewel_explode("beetle",1)),d=new cc.Sprite(Resource.CLIENT.jewel_explode("beetle",2));this._grid.addChild(b,100);this._grid.addChild(c,100);this._grid.addChild(d,100);0<this._target.getUState()?(b.setPosition(a.x-20,a.y+20),c.setPosition(a.x,a.y+30),d.setPosition(a.x+20,a.y+20),b.runAction(new cc.Sequence(new cc.Spawn(new cc.MoveTo(.2,a.x-30,a.y+40),new cc.FadeTo(.2,150)),new cc.RemoveSelf)),c.runAction(new cc.Sequence(new cc.Spawn(new cc.MoveTo(.2,a.x,a.y+50),
new cc.FadeTo(.2,150)),new cc.RemoveSelf)),d.runAction(new cc.Sequence(new cc.Spawn(new cc.MoveTo(.2,a.x+30,a.y+40),new cc.FadeTo(.2,150)),new cc.RemoveSelf))):(b.setPosition(a.x-20,a.y-20),c.setPosition(a.x,a.y-30),d.setPosition(a.x+20,a.y-20),b.setFlippedY(!0),c.setFlippedY(!0),d.setFlippedY(!0),b.runAction(new cc.Sequence(new cc.Spawn(new cc.MoveTo(.2,a.x-30,a.y-40),new cc.FadeTo(.2,150)),new cc.RemoveSelf)),c.runAction(new cc.Sequence(new cc.Spawn(new cc.MoveTo(.2,a.x,a.y-50),new cc.FadeTo(.2,
150)),new cc.RemoveSelf)),d.runAction(new cc.Sequence(new cc.Spawn(new cc.MoveTo(.2,a.x+30,a.y-40),new cc.FadeTo(.2,150)),new cc.RemoveSelf)))},butterflyFly:function(){if(this._flyOn){var a=this._target.getPosition();a=this._grid.convertToWorldSpace(a);var b=new cc.EventCustom(Client.EVENT.FLY_BUTTERFLY);b.setUserData({k:"",p:a});cc.eventManager.dispatchEvent(b)}},icecubeExp:function(){var a=this._target.getPosition(),b=new cc.Sprite(Resource.CLIENT.jewel_explode("icecube",0)),c=new cc.Sprite(Resource.CLIENT.jewel_explode("icecube",
1)),d=new cc.Sprite(Resource.CLIENT.jewel_explode("icecube",2)),e=new cc.Sprite(Resource.CLIENT.jewel_explode("icecube",3)),f=new cc.Sprite(Resource.CLIENT.jewel_explode("icecube",4)),g=new cc.Sprite(Resource.CLIENT.jewel_explode("icecube",5));b.setPosition(a.x-16,a.y+17);c.setPosition(a.x+6,a.y-3);d.setPosition(a.x+16,a.y+12);e.setPosition(a.x-22,a.y-7);f.setPosition(a.x-14,a.y-22);g.setPosition(a.x+19,a.y-20);b.runAction(new cc.Sequence([new cc.Spawn(new cc.MoveTo(.1,a.x-20,a.y+14),new cc.RotateTo(.1,
-11)),new cc.Spawn([new cc.MoveTo(.1,a.x-16,a.y-50),new cc.RotateTo(.1,-65),new cc.FadeTo(.1,100),new cc.ScaleTo(.1,.8)]),new cc.RemoveSelf]));c.runAction(new cc.Sequence([new cc.Spawn(new cc.MoveTo(.1,a.x+7,a.y-3),new cc.RotateTo(.1,-5)),new cc.Spawn([new cc.MoveTo(.1,a.x+6,a.y-60),new cc.RotateTo(.1,-24),new cc.FadeTo(.1,100),new cc.ScaleTo(.1,.5)]),new cc.RemoveSelf]));d.runAction(new cc.Sequence([new cc.Spawn(new cc.MoveTo(.1,a.x+22,a.y+8),new cc.RotateTo(.1,14)),new cc.Spawn([new cc.MoveTo(.1,
a.x+28,a.y-55),new cc.RotateTo(.1,-23),new cc.FadeTo(.1,100),new cc.ScaleTo(.1,.5)]),new cc.RemoveSelf]));e.runAction(new cc.Sequence([new cc.Spawn(new cc.MoveTo(.1,a.x-27,a.y-16),new cc.RotateTo(.1,-8)),new cc.Spawn([new cc.MoveTo(.1,a.x-28,a.y-76),new cc.RotateTo(.1,-53),new cc.FadeTo(.1,100),new cc.ScaleTo(.1,.7)]),new cc.RemoveSelf]));f.runAction(new cc.Sequence([new cc.Spawn(new cc.MoveTo(.1,a.x-17,a.y-36),new cc.RotateTo(.1,-14)),new cc.Spawn([new cc.MoveTo(.1,a.x-17,a.y-60),new cc.RotateTo(.1,
-24),new cc.FadeTo(.1,100),new cc.ScaleTo(.1,.6)]),new cc.RemoveSelf]));g.runAction(new cc.Sequence([new cc.Spawn(new cc.MoveTo(.1,a.x+22,a.y-35),new cc.RotateTo(.1,21)),new cc.Spawn([new cc.MoveTo(.1,a.x+20,a.y-65),new cc.RotateTo(.1,-46),new cc.FadeTo(.1,100),new cc.ScaleTo(.1,.7)]),new cc.RemoveSelf]));this._grid.addChild(b,100);this._grid.addChild(c,100);this._grid.addChild(d,100);this._grid.addChild(e,100);this._grid.addChild(f,100);this._grid.addChild(g,100)},enigmaExp:function(a){if(0==a){this._target.infect();
var b=this._target.getPosition();var c=new cc.Sprite(Resource.CLIENT.jewel_explode("enigma",0));var d=new cc.Sprite(Resource.CLIENT.jewel_explode("enigma",1));var e=new cc.Sprite(Resource.CLIENT.jewel_explode("enigma",2));var f=new cc.Sprite(Resource.CLIENT.jewel_explode("enigma",3));a=new cc.Sprite(Resource.CLIENT.jewel_explode("enigma",4));c.setPosition(b);d.setPosition(b.x-14,b.y+12);e.setPosition(b.x+11,b.y+12);f.setPosition(b.x-14,b.y-14);a.setPosition(b.x+14,b.y-14);c.runAction(new cc.Sequence([new cc.DelayTime(.1),
new cc.Spawn([new cc.FadeTo(.2,100),new cc.ScaleTo(.1,1.5)]),new cc.RemoveSelf]));d.runAction(new cc.Sequence([new cc.MoveTo(.2,b.x-20,b.y+18),new cc.Spawn([new cc.MoveTo(.1,b.x-25,b.y+24),new cc.FadeTo(.1,100),new cc.ScaleTo(.1,.7)]),new cc.RemoveSelf]));e.runAction(new cc.Sequence([new cc.MoveTo(.2,b.x+15,b.y+16),new cc.Spawn([new cc.MoveTo(.1,b.x+18,b.y+24),new cc.FadeTo(.1,100),new cc.ScaleTo(.1,.7)]),new cc.RemoveSelf]));f.runAction(new cc.Sequence([new cc.MoveTo(.2,b.x-20,b.y-18),new cc.Spawn([new cc.MoveTo(.1,
b.x-25,b.y-24),new cc.FadeTo(.1,100),new cc.ScaleTo(.1,.7)]),new cc.RemoveSelf]));a.runAction(new cc.Sequence([new cc.MoveTo(.2,b.x+18,b.y-18),new cc.Spawn([new cc.MoveTo(.1,b.x+22,b.y-24),new cc.FadeTo(.1,100),new cc.ScaleTo(.1,.7)]),new cc.RemoveSelf]));this._grid.addChild(c,100);this._grid.addChild(d,100);this._grid.addChild(e,100);this._grid.addChild(f,100);this._grid.addChild(a,100)}else{b=this._target.getPosition();d=new cc.Sprite(Resource.CLIENT.jewel_explode("enigma",6));e=new cc.Sprite(Resource.CLIENT.jewel_explode("enigma",
7));f=new cc.Sprite(Resource.CLIENT.jewel_explode("enigma",8));a=new cc.Sprite(Resource.CLIENT.jewel_explode("enigma",9));c=new cc.Sprite(Resource.CLIENT.jewel_explode("enigma",5));var g=new cc.Sprite(Resource.CLIENT.jewel_explode("enigma",5)),h=new cc.Sprite(Resource.CLIENT.jewel_explode("enigma",5)),k=new cc.Sprite(Resource.CLIENT.jewel_explode("enigma",5));d.setPosition(b.x-14,b.y+12);e.setPosition(b.x+11,b.y+12);f.setPosition(b.x-14,b.y-14);a.setPosition(b.x+14,b.y-14);c.setPosition(b.x-20,b.y);
g.setPosition(b.x+20,b.y);h.setRotation(-90);h.setPosition(b.x,b.y-18);k.setRotation(90);k.setPosition(b.x,b.y+18);d.runAction(new cc.Sequence([new cc.MoveTo(.2,b.x-20,b.y+18),new cc.Spawn([new cc.MoveTo(.1,b.x-25,b.y+24),new cc.FadeTo(.1,100),new cc.ScaleTo(.1,.7)]),new cc.RemoveSelf]));e.runAction(new cc.Sequence([new cc.MoveTo(.2,b.x+15,b.y+16),new cc.Spawn([new cc.MoveTo(.1,b.x+18,b.y+24),new cc.FadeTo(.1,100),new cc.ScaleTo(.1,.7)]),new cc.RemoveSelf]));f.runAction(new cc.Sequence([new cc.MoveTo(.2,
b.x-20,b.y-18),new cc.Spawn([new cc.MoveTo(.1,b.x-25,b.y-24),new cc.FadeTo(.1,100),new cc.ScaleTo(.1,.7)]),new cc.RemoveSelf]));a.runAction(new cc.Sequence([new cc.MoveTo(.2,b.x+18,b.y-18),new cc.Spawn([new cc.MoveTo(.1,b.x+22,b.y-24),new cc.FadeTo(.1,100),new cc.ScaleTo(.1,.7)]),new cc.RemoveSelf]));c.runAction(new cc.Sequence([new cc.MoveTo(.2,b.x-23,b.y),new cc.Spawn([new cc.MoveTo(.1,b.x-26,b.y),new cc.FadeTo(.1,100),new cc.ScaleTo(.1,.7)]),new cc.RemoveSelf]));g.runAction(new cc.Sequence([new cc.MoveTo(.2,
b.x+23,b.y),new cc.Spawn([new cc.MoveTo(.1,b.x+26,b.y),new cc.FadeTo(.1,100),new cc.ScaleTo(.1,.7)]),new cc.RemoveSelf]));h.runAction(new cc.Sequence([new cc.MoveTo(.2,b.x,b.y+21),new cc.Spawn([new cc.MoveTo(.1,b.x,b.y+24),new cc.FadeTo(.1,100),new cc.ScaleTo(.1,.7)]),new cc.RemoveSelf]));k.runAction(new cc.Sequence([new cc.MoveTo(.2,b.x,b.y-21),new cc.Spawn([new cc.MoveTo(.1,b.x,b.y-24),new cc.FadeTo(.1,100),new cc.ScaleTo(.1,.7)]),new cc.RemoveSelf]));this._grid.addChild(d,100);this._grid.addChild(e,
100);this._grid.addChild(f,100);this._grid.addChild(a,100);this._grid.addChild(c,100);this._grid.addChild(g,100);this._grid.addChild(h,100);this._grid.addChild(k,100)}AudioEngine.playEffect(Resource.SND.CL_HAMMER,!0)},shellExp:function(){this._target.infect()},mirrorExp:function(){var a=this._target.getPosition();this._target.setVisible(!1);var b=new cc.Sprite(Resource.CLIENT.jewel_explode("mirror",0)),c=new cc.Sprite(Resource.CLIENT.jewel_explode("mirror",1)),d=new cc.Sprite(Resource.CLIENT.jewel_explode("mirror",
2)),e=new cc.Sprite(Resource.CLIENT.jewel_explode("mirror",3)),f=new cc.Sprite(Resource.CLIENT.jewel_explode("mirror",4)),g=new cc.Sprite(Resource.CLIENT.jewel_explode("mirror",5)),h=new cc.Sprite(Resource.CLIENT.jewel_explode("mirror",6));b.setPosition(a.x,a.y-12);c.setPosition(a.x+11,a.y-11);d.setPosition(a.x+12,a.y);e.setPosition(a.x+11,a.y+11);f.setPosition(a.x+3,a.y+16);g.setPosition(a.x-13,a.y-7);h.setPosition(a.x-12,a.y+12);b.runAction(new cc.Sequence([new cc.MoveTo(.2,a.x,a.y-15),new cc.Spawn([new cc.MoveTo(.1,
a.x,a.y-18),new cc.FadeTo(.1,100),new cc.ScaleTo(.1,.7)]),new cc.RemoveSelf]));c.runAction(new cc.Sequence([new cc.MoveTo(.2,a.x+14,a.y-14),new cc.Spawn([new cc.MoveTo(.1,a.x+17,a.y-17),new cc.FadeTo(.1,100),new cc.ScaleTo(.1,.7)]),new cc.RemoveSelf]));d.runAction(new cc.Sequence([new cc.MoveTo(.2,a.x+15,a.y),new cc.Spawn([new cc.MoveTo(.1,a.x+18,a.y),new cc.FadeTo(.1,100),new cc.ScaleTo(.1,.7)]),new cc.RemoveSelf]));e.runAction(new cc.Sequence([new cc.MoveTo(.2,a.x+14,a.y+14),new cc.Spawn([new cc.MoveTo(.1,
a.x+17,a.y+17),new cc.FadeTo(.1,100),new cc.ScaleTo(.1,.7)]),new cc.RemoveSelf]));f.runAction(new cc.Sequence([new cc.MoveTo(.2,a.x+3,a.y+19),new cc.Spawn([new cc.MoveTo(.1,a.x+3,a.y+22),new cc.FadeTo(.1,100),new cc.ScaleTo(.1,.7)]),new cc.RemoveSelf]));g.runAction(new cc.Sequence([new cc.MoveTo(.2,a.x-16,a.y-10),new cc.Spawn([new cc.MoveTo(.1,a.x-19,a.y-13),new cc.FadeTo(.1,100),new cc.ScaleTo(.1,.7)]),new cc.RemoveSelf]));h.runAction(new cc.Sequence([new cc.MoveTo(.2,a.x-15,a.y+15),new cc.Spawn([new cc.MoveTo(.1,
a.x-18,a.y+18),new cc.FadeTo(.1,100),new cc.ScaleTo(.1,.7)]),new cc.RemoveSelf]));this._grid.addChild(b,100);this._grid.addChild(c,100);this._grid.addChild(d,100);this._grid.addChild(e,100);this._grid.addChild(f,100);this._grid.addChild(g,100);this._grid.addChild(h,100)},shellFindTarget:function(){for(var a=[],b=0;8>b;b++)for(var c=0;8>c;c++)this._grid.getJewel(b,c);return 0<a.length?a[CUtils.random(0,a.length-1)]:null}});JAction.CrossDestroyer=JActionBase.extend({_sx:0,_sy:0,_speed:0,_arrowRight:null,_arrowLeft:null,_arrowUp:null,_arrowDown:null,_arrowURight:null,_arrowDRight:null,_arrowULeft:null,_arrowDLeft:null,ctor:function(a,b,c){this._super(JAction.CROSSDESTROYER,a,JState.CROSSDESTROYER,c);this._args.hasOwnProperty("type")&&(b=this._args.type);this._args.hasOwnProperty("arrow")||(this._args.arrow=!0);this._args.hasOwnProperty("dx")||(this._args.dx=0);this._args.hasOwnProperty("dy")||(this._args.dy=0);this._args.swap=
!1;this._sx=a.getCell().getCenter().x;this._sy=a.getCell().getCenter().y;this._speed=15;this._arrowDLeft=this._arrowULeft=this._arrowDRight=this._arrowURight=this._arrowDown=this._arrowUp=this._arrowLeft=this._arrowRight=null;if(0!=this._args.dx||0!=this._args.dy)c=Client.Grid.getCSize(),this._sx+=c.width*this._args.dx,this._sy+=c.height*this._args.dy,this._args.dx=0,this._args.dy=0;a.runJAction(new JAction.Explode(a,this._args));0==b?(this._arrowRight=this.createArrow(0,this._args.arrow),this._arrowLeft=
this.createArrow(180,this._args.arrow),AudioEngine.playEffect(Resource.SND.CL_LINE_BLAST,!0)):1==b?(this._arrowUp=this.createArrow(-90,this._args.arrow),this._arrowDown=this.createArrow(90,this._args.arrow),AudioEngine.playEffect(Resource.SND.CL_LINE_BLAST,!0)):2==b?(this._arrowRight=this.createArrow(0,this._args.arrow),this._arrowLeft=this.createArrow(180,this._args.arrow),this._arrowUp=this.createArrow(-90,this._args.arrow),this._arrowDown=this.createArrow(90,this._args.arrow),AudioEngine.playEffect(Resource.SND.CL_CROSS_BLAST,
!0)):3==b?(this._arrowURight=this.createArrow(-45,this._args.arrow),this._arrowULeft=this.createArrow(-135,this._args.arrow),this._arrowDLeft=this.createArrow(135,this._args.arrow),this._arrowDRight=this.createArrow(45,this._args.arrow),AudioEngine.playEffect(Resource.SND.CL_CROSS_BLAST,!0)):cc.assert(!1)},createArrow:function(a,b){for(var c=[],d=0;8>d;d++){var e=Resource.CLIENT.jewel_explode("cross",d);c.push(cc.spriteFrameCache.getSpriteFrame(e))}d=new cc.Sprite(c[0]);d.setPosition(this._sx,this._sy);
d.tx=Client.Grid.getTileX(this._sx);d.ty=Client.Grid.getTileY(this._sy);d.trg=this._target;d.minX=Client.Grid.getPointX(d.tx);d.minY=Client.Grid.getPointY(d.ty);d.maxX=d.minX+Client.Grid.getCSize().width;d.maxY=d.minY+Client.Grid.getCSize().height;b&&(d.setRotation(a),d.setAnchorPoint(.9,.5),c=new cc.Animation(c,.028),d.runAction(new cc.RepeatForever(new cc.Animate(c))),d.setLocalZOrder(1E3),this._grid.addChild(d));return d},updateArrowRight:function(){if(null==this._arrowRight)return!0;var a=this._arrowRight.getPosition();
a.x+=this._speed;this._arrowRight.setPosition(a);var b=Client.Grid.getTileX(a.x);-1==b&&-1==Client.Grid.getTileX(a.x-this._arrowRight.getContentSize().width)?(this._arrowRight.removeFromParent(),this._arrowRight=null):b!=this._arrowRight.tx&&(this._arrowRight.tx=b,a=this._grid.getJewel(this._arrowRight.tx-1,this._arrowRight.ty),null!=a&&a!=this._arrowRight.trg&&JRelation.isApplyCrossDestroyer(a)&&25>Math.abs(a.getCell().getCenter().y-a.getPositionY())&&a.execJAction(!1,this._args),(a=this._grid.getCell(this._arrowRight.tx,
this._arrowRight.ty))&&a.isEnabled()?(b=a.getJewel(),this._arrowRight.trg=b,null!=b&&JRelation.isApplyCrossDestroyer(b)?b.execJAction(!1,this._args):a.breakBackground()):this._arrowRight.trg=null);return!1},updateArrowLeft:function(){if(null==this._arrowLeft)return!0;var a=this._arrowLeft.getPosition();a.x-=this._speed;this._arrowLeft.setPosition(a);var b=Client.Grid.getTileX(a.x);-1==b&&-1==Client.Grid.getTileX(a.x+this._arrowLeft.getContentSize().width)?(this._arrowLeft.removeFromParent(),this._arrowLeft=
null):b!=this._arrowLeft.tx&&(this._arrowLeft.tx=b,a=this._grid.getJewel(this._arrowLeft.tx+1,this._arrowLeft.ty),null!=a&&a!=this._arrowLeft.trg&&JRelation.isApplyCrossDestroyer(a)&&25>Math.abs(a.getCell().getCenter().y-a.getPositionY())&&a.execJAction(!1,this._args),(a=this._grid.getCell(this._arrowLeft.tx,this._arrowLeft.ty))&&a.isEnabled()?(b=a.getJewel(),this._arrowLeft.trg=b,null!=b&&JRelation.isApplyCrossDestroyer(b)?b.execJAction(!1,this._args):a.breakBackground()):this._arrowLeft.trg=null);
return!1},updateArrowDown:function(){if(null==this._arrowDown)return!0;var a=this._arrowDown.getPosition();a.y-=this._speed;this._arrowDown.setPosition(a);var b=Client.Grid.getTileY(a.y);-1==b&&-1==Client.Grid.getTileY(a.y+this._arrowDown.getContentSize().width)?(this._arrowDown.removeFromParent(),this._arrowDown=null):b!=this._arrowDown.ty&&(this._arrowDown.ty=b,a=this._grid.getJewel(this._arrowDown.tx,this._arrowDown.ty+1),null!=a&&a!=this._arrowDown.trg&&JRelation.isApplyCrossDestroyer(a)&&a.execJAction(!1,
this._args),(a=this._grid.getCell(this._arrowDown.tx,this._arrowDown.ty))&&a.isEnabled()?(b=a.getJewel(),this._arrowDown.trg=b,null!=b&&JRelation.isApplyCrossDestroyer(b)?b.execJAction(!1,this._args):a.breakBackground()):this._arrowDown.trg=null);return!1},updateArrowUp:function(){if(null==this._arrowUp)return!0;var a=this._arrowUp.getPosition();a.y+=this._speed;this._arrowUp.setPosition(a);var b=Client.Grid.getTileY(a.y);-1==b&&-1==Client.Grid.getTileY(a.y-this._arrowUp.getContentSize().width)?(this._arrowUp.removeFromParent(),
this._arrowUp=null):b!=this._arrowUp.ty&&(this._arrowUp.ty=b,a=this._grid.getJewel(this._arrowUp.tx,this._arrowUp.ty-1),null!=a&&a!=this._arrowUp.trg&&JRelation.isApplyCrossDestroyer(a)&&a.execJAction(!1,this._args),(a=this._grid.getCell(this._arrowUp.tx,this._arrowUp.ty))&&a.isEnabled()?(b=a.getJewel(),this._arrowUp.trg=b,null!=b&&JRelation.isApplyCrossDestroyer(b)?b.execJAction(!1,this._args):a.breakBackground()):this._arrowUp.trg=null);return!1},updateArrowURight:function(){if(null==this._arrowURight)return!0;
var a=this._arrowURight,b=a.getPosition();b.x+=this._speed;b.y+=this._speed*Client.Grid.getRHW();a.setPosition(b);var c=Client.Grid.getTileX(b.x);-1==Client.Grid.getTileY(b.y)&&-1==Client.Grid.getTileY(b.y-a.getContentSize().height)||-1==c&&-1==Client.Grid.getTileX(b.x-a.getContentSize().width)?(this._arrowURight.removeFromParent(),this._arrowURight=null):a.minX<b.x&&a.maxX>b.x&&a.minY<b.y&&a.maxY>b.y&&((b=this._grid.getCell(a.tx,a.ty))&&b.isEnabled()&&((c=b.getJewel())&&JRelation.isApplyCrossDestroyer(c)?
c.execJAction(!1,this._args):b.breakBackground()),a.tx++,a.ty++,a.minX=Client.Grid.getPointX(a.tx),a.minY=Client.Grid.getPointY(a.ty),a.maxX=a.minX+Client.Grid.getCSize().width,a.maxY=a.minY+Client.Grid.getCSize().height);return!1},updateArrowULeft:function(){if(null==this._arrowULeft)return!0;var a=this._arrowULeft,b=a.getPosition();b.x-=this._speed;b.y+=this._speed*Client.Grid.getRHW();a.setPosition(b);var c=Client.Grid.getTileX(b.x);-1==Client.Grid.getTileY(b.y)&&-1==Client.Grid.getTileY(b.y-a.getContentSize().width)||
-1==c&&-1==Client.Grid.getTileX(b.x+a.getContentSize().width)?(this._arrowULeft.removeFromParent(),this._arrowULeft=null):a.minX<b.x&&a.maxX>b.x&&a.minY<b.y&&a.maxY>b.y&&((b=this._grid.getCell(a.tx,a.ty))&&b.isEnabled()&&((c=b.getJewel())&&JRelation.isApplyCrossDestroyer(c)?c.execJAction(!1,this._args):b.breakBackground()),a.tx--,a.ty++,a.minX=Client.Grid.getPointX(a.tx),a.minY=Client.Grid.getPointY(a.ty),a.maxX=a.minX+Client.Grid.getCSize().width,a.maxY=a.minY+Client.Grid.getCSize().height);return!1},
updateArrowDRight:function(){if(null==this._arrowDRight)return!0;var a=this._arrowDRight,b=a.getPosition();b.x+=this._speed;b.y-=this._speed*Client.Grid.getRHW();a.setPosition(b);var c=Client.Grid.getTileX(b.x);-1==Client.Grid.getTileY(b.y)&&-1==Client.Grid.getTileY(b.y+a.getContentSize().width)||-1==c&&-1==Client.Grid.getTileX(b.x-a.getContentSize().width)?(this._arrowDRight.removeFromParent(),this._arrowDRight=null):a.minX<b.x&&a.maxX>b.x&&a.minY<b.y&&a.maxY>b.y&&((b=this._grid.getCell(a.tx,a.ty))&&
b.isEnabled()&&((c=b.getJewel())&&JRelation.isApplyCrossDestroyer(c)?c.execJAction(!1,this._args):b.breakBackground()),a.tx++,a.ty--,a.minX=Client.Grid.getPointX(a.tx),a.minY=Client.Grid.getPointY(a.ty),a.maxX=a.minX+Client.Grid.getCSize().width,a.maxY=a.minY+Client.Grid.getCSize().height);return!1},updateArrowDLeft:function(){if(null==this._arrowDLeft)return!0;var a=this._arrowDLeft,b=a.getPosition();b.x-=this._speed;b.y-=this._speed*Client.Grid.getRHW();a.setPosition(b);var c=Client.Grid.getTileX(b.x);
-1==Client.Grid.getTileY(b.y)&&-1==Client.Grid.getTileY(b.y+a.getContentSize().width)||-1==c&&-1==Client.Grid.getTileX(b.x+a.getContentSize().width)?(this._arrowDLeft.removeFromParent(),this._arrowDLeft=null):a.minX<b.x&&a.maxX>b.x&&a.minY<b.y&&a.maxY>b.y&&((b=this._grid.getCell(a.tx,a.ty))&&b.isEnabled()&&((c=b.getJewel())&&JRelation.isApplyCrossDestroyer(c)?c.execJAction(!1,this._args):b.breakBackground()),a.tx--,a.ty--,a.minX=Client.Grid.getPointX(a.tx),a.minY=Client.Grid.getPointY(a.ty),a.maxX=
a.minX+Client.Grid.getCSize().width,a.maxY=a.minY+Client.Grid.getCSize().height);return!1},update:function(){this._complete=this.updateArrowRight();this._complete=this.updateArrowLeft()&&this._complete;this._complete=this.updateArrowDown()&&this._complete;this._complete=this.updateArrowUp()&&this._complete;this._complete=this.updateArrowURight()&&this._complete;this._complete=this.updateArrowDRight()&&this._complete;this._complete=this.updateArrowULeft()&&this._complete;(this._complete=this.updateArrowDLeft()&&
this._complete)&&this.remove()}});var JController=cc.Class.extend({_actions:null,ctor:function(){this._actions=[]},addJAction:function(a){a.setController(this);this._actions.push(a)},remJAction:function(a){this._actions=this._actions.filter(function(b){return b==a?(a.setController(null),!1):!0})},hasJAction:function(a){a=a instanceof JAction?a.getType():a;for(var b=0;b<this._actions.length;b++)if(this._actions[b].getType()==a)return!0;return!1},update:function(){this._actions.forEach(function(a,b,c){a.update()})},count:function(){return this._actions.length},
removeAll:function(){this._actions.clean()}});var JSActionBase=JAction.extend({_grid:null,_args:null,_target:null,_cursor:null,_exec:!1,_spell:null,ctor:function(a,b,c,d){this._super(a);cc.assert(c);cc.assert(b);this._spell=b;this._grid=c;this._args=d||{};this._exec=!1;this._cursor=null;this.loadCursor()},mouseDown:function(a){return!0},mouseMove:function(a){if(this._cursor){var b=Client.Grid.getTile(a),c=this._grid.getJewel(b.x,b.y);c=c&&this.execAllowed(c);this._cursor.setVisible(!0);this._cursor.setPosition(a);this._cursor.setBrightness(c?
0:-.2);this._cursor.setContrast(c?0:-.4);cc.game.canvas.style.cursor=Client.Grid.validTile(b)?"none":"auto"}},exec:function(a){this._target=a;this._grid.runJAction(this);return!0},execAllowed:function(a){return!0},loadCursor:function(){this._cursor=null;cc.game.canvas.style.cursor="auto"},update:function(){},remove:function(){this._removed||(this._super(),this._cursor&&(this._cursor.removeFromParent(),this._cursor=null,cc.game.canvas.style.cursor="auto"),this._exec?(cc.eventManager.dispatchCustomEvent(Client.EVENT.SPELL_USED,
{type:this._spell}),this._grid.getInfo().it_used(JSpell.getOPT(this._spell)-1)):cc.eventManager.dispatchCustomEvent(Client.EVENT.SPELL_CANCEL,{type:this._spell}),this._target=null,this._grid.activeSpell(null),this._args=this._grid=null)}});JAction.SReshuffle=JSActionBase.extend({_centerX:0,_ticks:0,_speed:20,_list:null,_frames:null,ctor:function(a,b){this._super(JAction.S_RESHUFFLE,JSpell.RESHUFFLE,a,b);this._frames=[];this._list=[];this._ticks=this._centerX=0;this._speed=20},exec:function(a){if(!this._super(a))return!1;a=Client.Grid.getPointX(this._grid.getColMaxId());var b=Client.Grid.getPointX(this._grid.getColMinId());this._centerX=.5*(a-b)+b+Client.Grid.getCHSize().width;for(b=0;6>b;b++)a=Resource.CLIENT.jewel_efect("0",b),this._frames.push(cc.spriteFrameCache.getSpriteFrame(a));
for(b=5;0<=b;b--)a=Resource.CLIENT.jewel_efect("0",b),this._frames.push(cc.spriteFrameCache.getSpriteFrame(a));AudioEngine.playEffect(Resource.SND.CL_RESHUFFLE,!0);return!0},update:function(){this._ticks++;1==this._ticks&&JLogic.shuffleShape(this._grid,50,!1);if(0==this._ticks%2){var a=Math.round(.5*this._ticks)+this._grid.getRowMinId()-1;if(a<=this._grid.getRowMaxId()){for(var b=[],c=[],d=0;8>d;d++){var e=this._grid.getJewel(d,a);e&&(b.push(e),c.push((this._centerX-e.getPositionX())/this._speed))}0<
b.length&&this._list.push({items:b,steps:c,state:0,ticks:this._speed})}}for(a=0;a<this._list.length;)if(3==this._list[a].state){if(this._list.splice(a,1),0==this._list.length){this.remove();break}}else this.shuffleAnim(this._list[a]),a++},shuffleAnim:function(a){if(0==a.state){for(var b=0;b<a.items.length;b++){var c=a.items[b];c.setPositionX(c.getPositionX()+a.steps[b])}1==a.ticks&&(c=new cc.Sprite(this._frames[0]),c.runAction(new cc.Sequence(new cc.Animate(new cc.Animation(this._frames,.02)),new cc.RemoveSelf)),
c.setScale(1.5),c.setPosition(this._centerX+10,a.items[0].getPositionY()),this._grid.addChild(c,100));a.ticks--;0==a.ticks&&(a.state=1)}else if(1==a.state){for(b=0;b<a.items.length;b++)a.items[b].updateUI(!1);a.state=2;a.ticks=this._speed}else if(2==a.state){for(b=0;b<a.items.length;b++)c=a.items[b],1==a.ticks?c.setPositionX(c.getCell().getCenter().x):c.setPositionX(c.getPositionX()-a.steps[b]);a.ticks--;0==a.ticks&&(a.state=3)}},remove:function(){this._removed||(this._grid.updatePower(.05),this._super())}});JAction.SHammer=JSActionBase.extend({_centerX:0,_ticks:0,_speed:20,_list:null,_frames:null,ctor:function(a,b){this._super(JAction.S_HAMMER,JSpell.HAMMER,a,b);this._frames=[];this._list=[];this._speed=20;this._centerX=this._ticks=0},mouseDown:function(a){a=Client.Grid.getTile(a);a=this._grid.getJewel(a.x,a.y);if(this._exec)return!0;a&&this.execAllowed(a)?this.exec(a):this.remove();return!0},exec:function(a){if(!this._super(a))return!1;this._target.execJAction(!1,null);this._exec=!0;AudioEngine.playEffect(Resource.SND.CL_HAMMER,
!0);return!0},execAllowed:function(a){return JRelation.isApplySpellHammer(a)},loadCursor:function(){this._super();this._cursor=new CSprite(Resource.CLIENT.cursor("hammer"));this._cursor.setVisible(!1);this._grid.addChild(this._cursor,1E3);cc.game.canvas.style.cursor="auto"},update:function(){this.remove()}});JAction.SHand=JSActionBase.extend({_select0:null,_select1:null,ctor:function(a,b){this._super(JAction.S_HAND,JSpell.HAND,a,b);this._select1=this._select0=null},mouseDown:function(a){a=Client.Grid.getTile(a);a=this._grid.getJewel(a.x,a.y);if(this._exec)return!0;if(!a)return this.remove(),!0;if(a==this._select0)return!0;a&&this.execAllowed(a)&&(this._select0?(this._select1=a,this._select1.setSelect(!0),this.exec(a)):(this._select0=a,this._select0.setSelect(!0)));return!0},exec:function(a){if(!this._super(a))return!1;
a=this._select0.getCell();var b=this._select1.getCell();a.remJewel();b.remJewel();a.addJewel(this._select1);b.addJewel(this._select0);this._select0.runJAction(new JAction.Move(this._select0));this._select1.runJAction(new JAction.Move(this._select1));this._exec=!0;AudioEngine.playEffect(Resource.SND.CL_SWAP_ITEM);return!0},execAllowed:function(a){return JRelation.isApplySpellHand(a)?null==this._select0||JRelation.isNearJewels(this._select0,a):!1},loadCursor:function(){this._super();this._cursor=new CSprite(Resource.CLIENT.cursor("hand"));
this._cursor.setVisible(!1);this._grid.addChild(this._cursor,1E3);cc.game.canvas.style.cursor="auto"},update:function(){this.remove()},remove:function(){this._removed||(this._super(),this._select0&&(this._select0.setSelect(!1),this._select0=null),this._select1&&(this._select1.setSelect(!1),this._select1=null))}});JAction.SColorBlast=JSActionBase.extend({ctor:function(a,b){this._super(JAction.S_COLOR_BLAST,JSpell.COLOR_BLAST,a,b)},mouseDown:function(a){a=Client.Grid.getTile(a);a=this._grid.getJewel(a.x,a.y);if(this._exec)return!0;a&&this.execAllowed(a)?this.exec(a):this.remove();return!0},exec:function(a){if(!this._super(a))return!1;this._target.runJAction(new JAction.FireBlast(this._target));return this._exec=!0},execAllowed:function(a){return JRelation.isApplyFireBlast(a,a.getCode(1))&&JRelation.allowActionFireBlast(a)},
loadCursor:function(){this._super();this._cursor=new CSprite(Resource.CLIENT.cursor("color_blast"));this._cursor.setVisible(!1);this._grid.addChild(this._cursor,1E3);cc.game.canvas.style.cursor="auto"},update:function(){this.remove()}});JAction.SUnlock=JSActionBase.extend({ctor:function(a,b){this._super(JAction.S_UNLOCK,JSpell.UNLOCK,a,b)},mouseDown:function(a){a=Client.Grid.getTile(a);a=this._grid.getJewel(a.x,a.y);if(this._exec)return!0;a&&this.execAllowed(a)?this.exec(a):this.remove();return!0},exec:function(a){if(!this._super(a))return!1;this._target.setLocks(0);return this._exec=!0},execAllowed:function(a){return JRelation.isApplySpellUnlock(a)},loadCursor:function(){this._super();this._cursor=new CSprite(Resource.CLIENT.cursor("unlock"));
this._cursor.setVisible(!1);this._grid.addChild(this._cursor,1E3);cc.game.canvas.style.cursor="auto"},update:function(){this.remove()}});JAction.SSuperBomb=JSActionBase.extend({ctor:function(a,b){this._super(JAction.S_SUPER_BOMB,JSpell.SUPER_BOMB,a,b)},mouseDown:function(a){a=Client.Grid.getTile(a);a=this._grid.getJewel(a.x,a.y);if(this._exec)return!0;a&&this.execAllowed(a)?this.exec(a):this.remove();return!0},exec:function(a){if(!this._super(a))return!1;this._target.runJAction(new JAction.Bomb(this._target,{showExp:!0}));this._exec=!0;a=[];for(var b=0;9>b;b++){var c=Resource.CLIENT.jewel_explode("fire",b);a.push(cc.spriteFrameCache.getSpriteFrame(c))}b=
new cc.Sprite(a[0]);b.setScale(4);c=[];c.push(new cc.Animate(new cc.Animation(a.slice(0,a.length-3),.028)));c.push(new cc.Animate(new cc.Animation(a.slice(a.length-2),.028)));c.push(new cc.RemoveSelf);b.runAction(new cc.Sequence(c));b.setPosition(this._target.getPosition());this._grid.addChild(b,101);return!0},execAllowed:function(a){return JRelation.isApplySpellBomb(a)},loadCursor:function(){this._super();this._cursor=new CSprite(Resource.CLIENT.cursor("bomb"));this._cursor.setVisible(!1);this._grid.addChild(this._cursor,
1E3);cc.game.canvas.style.cursor="auto"},update:function(){this.remove()}});Client.Grid=cc.Sprite.extend({_ext:null,_background:null,_guide:null,_guides:null,_mapId:0,_lastLevelId:0,_level:null,_power:0,_powerAction:0,_rubyCount:null,_csize:null,_goal:null,_info:null,_suggestion:null,_cloud:null,_controller:null,_saves:null,_saveOn:!1,_table:null,_state:0,_stableTick:0,_stableState:!1,_stableGrid:!0,_destroy:0,_activeSpell:null,_tasks:null,_updateOn:!1,_reshuffleOn:!0,_highlightOn:!1,_touchOn:!1,_touchPoint:null,_touchRect:null,_magnetOn:!1,_infectSwap:!1,_infectIceCube:!0,
_infectMagicBall:!1,_infectMagnet:0,_countButterfly:0,_confButterfly:null,_countDiamond:0,_confDiamond:null,_countMirror:0,_confMirror:null,_select0:null,_select1:null,_shapes:null,_rowMinId:0,_rowMaxId:0,_colMinId:0,_colMaxId:0,_normcodes:!0,getHighlightOn:function(){return this._highlightOn},getLevelId:function(){return this._level.id},getLastLevelId:function(){return this._lastLevelId},getMapId:function(){return this._mapId},getPower:function(){return this._power},getPowerAction:function(){return this._powerAction},
getInfo:function(){return this._info},getBackground:function(){return this._background},getRowMinId:function(){return this._rowMinId},getRowMaxId:function(){return this._rowMaxId},getColMinId:function(){return this._colMinId},getColMaxId:function(){return this._colMaxId},isStableState:function(){return this._stableState},getCloud:function(){return this._cloud},getSelect:function(a){return 1==a?this._select1:this._select0},ctor:function(a,b){this._super(Resource.CLIENT.empty);this.setCascadeOpacityEnabled(!0);
this._ext=new CExtNode(this);this._ext.addCustomListener(Client.EVENT.SPELL_ACTIVE,this.eventHandler.bind(this));this._ext.addCustomListener(Client.EVENT.SPELL_BOUGHT,this.eventHandler.bind(this));this._ext.addCustomListener(Client.EVENT.GUIDE_CLOSED,this.eventHandler.bind(this));this._ext.addCustomListener(User.EVENT.UPDATE_ORB,this.eventHandler.bind(this));this._mapId=a;this._lastLevelId=0==User.getFbId()?30:User.getScoreById(a).getSize();this._level=b;this._guide=null;this._guides=b.guide?b.guide.slice().sort(function(a,
b){return a.id>b.id}):null;this._reshuffleOn=!0;this._highlightOn=!1;this._powerAction=this._power=0;this._cloud=this._suggestion=null;this._stableTick=this._state=0;this._stableState=this._saveOn=!1;this._stableGrid=!0;this._countButterfly=this._destroy=0;this._confButterfly=[0,0,0,0];this._countDiamond=0;this._confDiamond=[0,0,0,0];this._countMirror=0;this._confMirror=[0,0,0,0];if(b.butterfly){var c=b.butterfly.split(",");this._confButterfly[0]=Number(c[0]);this._confButterfly[1]=Number(c[1]);this._confButterfly[2]=
Number(c[2]);this._confButterfly[3]=Number(c[3])}b.diamond&&(c=b.diamond.split(","),this._confDiamond[0]=Number(c[0]),this._confDiamond[1]=Number(c[1]),this._confDiamond[2]=Number(c[2]),this._confDiamond[3]=Number(c[3]));b.mirror&&(c=b.mirror.split(","),this._confMirror[0]=Number(c[0]),this._confMirror[1]=Number(c[1]),this._confMirror[2]=Number(c[2]),this._confMirror[3]=Number(c[3]));JShape.config(b.skip||"");this.initVars();this.initGrid(b.data);this.buildBackground();b.cloud&&(this._cloud=new Client.Cloud(this,
b.cloud),this.addChild(this._cloud,Number.MAX_VALUE-1));cc.eventManager.addListener({event:cc.EventListener.MOUSE,onMouseMove:this.onMouseMove.bind(this),onMouseUp:this.onMouseUp.bind(this),onMouseDown:this.onMouseDown.bind(this)},this)},initVars:function(){this._power=0;this._rubyCount=new CValue;this._goal=new Client.Goal(this._level);this._info=new Client.GridInfo;this._controller=new JController;this._saves=[];this._tasks=[];this._shapes="12345678".split("");this._updateOn=!0;this._magnetOn=!1;
this._csize=Client.Grid.getCSize();this._table=[[],[],[],[],[],[],[],[]]},initGrid:function(a){a=a.split(".");for(var b=this._colMinId=this._rowMinId=7;0<=b;b--)for(var c=0;8>c;c++){var d=a[8*c+b];"0"!=d?(this._rowMinId=Math.min(7-c,this._rowMinId),this._rowMaxId=Math.max(7-c,this._rowMaxId),this._colMinId=Math.min(b,this._colMinId),this._colMaxId=Math.max(b,this._colMaxId),d=(d+"00000000").substr(0,8),d[0]==JType.MAGNET&&(this._magnetOn=!0),this._table[b][7-c]=new Client.GridCell(this,d.split(""),
b,7-c)):this._table[b][7-c]=null}this._touchRect=new cc.Rect(this._colMinId*this._csize.width,this._rowMinId*this._csize.height,(this._colMaxId+1-this._colMinId)*this._csize.width,(this._rowMaxId+1-this._rowMinId)*this._csize.height);a=new cc.Point(178,110);7-this._colMaxId>this._colMinId?a.x+=.5*this._csize.width:7-this._colMaxId<this._colMinId&&(a.x-=.5*this._csize.width);7-this._rowMaxId>this._rowMinId?a.y+=.5*this._csize.height:7-this._rowMaxId<this._rowMinId&&(a.y-=.5*this._csize.height);this.setPosition(a);
this._normcodes&&JLogic.hasMatch(this)&&JLogic.shuffleShape(this,100,!0);a=User.getOrbs();for(var e in a)this.activeOrb(a[e])},update:function(){var a,b;if(this._updateOn){var c=!0,d=null;this.showGuide();this._controller.update();this._controller.hasJAction(JAction.S_RESHUFFLE)||this.updatePower(-3.75E-4);for(b=this._countMirror=this._countButterfly=this._countDiamond=0;8>b;b++)for(a=0;8>a;a++)if(this._table[a][b]){var e=this._table[a][b];e.checkMatch();e.isEmpty()||(e=e.getJewel(),e.isJType(JType.DIAMOND)&&
"0"!=e.getCode(5)?this._countDiamond++:e.isJType(JType.BUTTERFLY)?this._countButterfly++:e.isJType(JType.MIRROR)?this._countMirror++:e.isJType(JType.ENIGMA)&&null!=(d=e.getCodeEnigma())&&(d[0]==JType.DIAMOND&&"0"!=d[5]?this._countDiamond++:d[0]==JType.BUTTERFLY?this._countButterfly++:d[5]==JType.MIRROR&&this._countMirror++))}for(b=0;8>b;b++)for(a=0;8>a;a++)this._table[a][b]&&(c=this._table[a][b].update(b==this._rowMinId)&&c);this._cloud&&this._cloud.update();this.executeTasks();c||(this._reshuffleOn=
!0);if(c&&0==this._controller.count()){this._stableTick++;this._stableState=!0;if(20<this._stableTick)if(this._stableGrid){this.updateState();switch(this._state){case Client.Grid.STATE.PLAY_FINISH:cc.eventManager.dispatchCustomEvent(Client.EVENT.PLAY_FINISH);return;case Client.Grid.STATE.PLAY_NOMOVES:cc.eventManager.dispatchCustomEvent(Client.EVENT.PLAY_NOMOVES);return}this._saveOn&&(this.saveGame(),this._saveOn=!1)}else{if(this._infectSwap){c=[];d=[];var f=[],g=[],h=[];for(b=0;8>b;b++)for(a=0;8>
a;a++)(e=(e=this.getCell(b,a))?e.getJewel():null)&&e.isJType(JType.FREEZE)&&e.infect();for(b=0;8>b;b++)for(a=0;8>a;a++)(e=this.getJewel(b,a))&&(e.isJType(JType.CHAMELEON)?e.infect():e.isJType(JType.PETRIFIER)?d.push(e):e.isJType(JType.FROZEN)?c.push(e):e.isJType(JType.ICECUBE)?f.push(e):e.isJType(JType.FROG)?g.push(e):e.isJType(JType.MAGICBALL)&&h.push(e));for(;0<c.length&&(b=CUtils.random(0,c.length-1),!c[b].infect());)c.splice(b,1);for(;0<d.length&&(b=CUtils.random(0,d.length-1),!d[b].infect());)d.splice(b,
1);for(;0<g.length&&(b=CUtils.random(0,g.length-1),!g[b].infect());)g.splice(b,1);for(;this._infectMagicBall&&0<h.length;)b=CUtils.random(0,h.length-1),h[b].infect(),h.splice(b,1);for(;this._infectIceCube&&0<f.length&&(b=CUtils.random(0,f.length-1),!f[b].infect());)f.splice(b,1);if(this._magnetOn&&2<this._infectMagnet)for(b=this._infectMagnet=0;8>b;b++)for(a=0;8>a;a++)(e=this.getJewel(b,a))&&JRelation.isApplyMagnet(e)&&e.runJAction(new JAction.Magnet(e))}this._infectMagicBall=this._infectIceCube=
!0;this._infectSwap=!1;this._stableGrid=!0}if(!(this._suggestion||this._guide||50!=this._stableTick&&120!=this._stableTick)){c=JLogic.canMatch2(this,"^B..j");for(b=c.length-1;0<=b;b--)e=c[b],a=this.getCell(e.s.x,e.s.y),e=this.getCell(e.d.x,e.d.y),a&&a.isEnabled()&&a.isActive()&&e&&e.isEnabled()&&e.isActive()||c.splice(b,1);if(0==c.length)for(c=JLogic.canMatch3(this,"^B..j"),b=c.length-1;0<=b;b--)e=c[b],a=this.getCell(e.s.x,e.s.y),e=this.getCell(e.d.x,e.d.y),a&&a.isEnabled()&&a.isActive()&&e&&e.isEnabled()&&
e.isActive()||c.splice(b,1);if(50==this._stableTick&&0==c.length)this._reshuffleOn?(this._reshuffleOn=!1,this.activeSpell(JSpell.RESHUFFLE),cc.eventManager.dispatchEvent(new cc.EventCustom(Client.EVENT.PLAY_RESHUFFLE))):cc.eventManager.dispatchEvent(new cc.EventCustom(Client.EVENT.PLAY_NOMATCH));else if(120==this._stableTick&&0<c.length){for(b=a=0;b<c.length;b++)Math.max(c[b].s.y,c[b].d.y)<Math.max(c[a].s.y,c[a].d.y)?a=b:Math.max(c[b].s.y,c[b].d.y)==Math.max(c[a].s.y,c[a].d.y)&&c[b].d.y<c[a].d.y&&
(a=b);this.showSuggestion(c[a].s,c[a].d)}}}else this._stableTick=0,this._saveOn=!0,this._stableState=!1,null==this._guide&&this.hideSuggestion()}},updateState:function(){this._goal.isCompleted()?this._state=Client.Grid.STATE.PLAY_FINISH:this._goal.hasMoves()?this._state=Client.Grid.STATE.PLAYING:this._state=Client.Grid.STATE.PLAY_NOMOVES},addRuby:function(a,b){b=this.convertToWorldSpace(b);var c=new cc.EventCustom(Client.EVENT.UPDATE_RUBY);c.setUserData({k:a,x:b.x,y:b.y});cc.eventManager.dispatchEvent(c)},
selectJewel:function(a){null!=a&&this._select0!=a&&JRelation.allowSelect(a)&&a.getCell().isActive()&&(null!=this._select0&&this._select0.setSelect(!1),this.updateState(),this._state==Client.Grid.STATE.PLAYING&&(null!=this._select0&&this._select0.hasCell()&&this._select0.hasUI()?(this._select1=this._select0,this._select0=null):this._select1=null,this._select0=a,null!=this._select1&&JRelation.allowActionSwap(this._select0,this._select1)?(this._select0.runJAction(new JAction.Swap(this._select0,this._select1)),
this._select1=this._select0=null):this._select0.setSelect(!0),this.hideSuggestion()))},onMouseDown:function(a){AudioEngine.playEffect(Resource.SND.CLICK);var b=this.convertToNodeSpace(a.getLocation());if((!this._activeSpell||!this._activeSpell.mouseDown(b))&&cc.rectContainsPoint(this._touchRect,b))if(a.stopPropagation(),this._stableTick=0,this._activeSpell||0!=this._tasks.length&&!this._guide)this._select0&&(this._select0.setSelect(!1),this._select0=null),this._select1&&(this._select1.setSelect(!1),
this._select1=null),this._touchOn=!1,this.hideSuggestion();else if(a=this.getJewel(Client.Grid.getTileX(b.x),Client.Grid.getTileY(b.y)))this._touchOn=!0,this._touchPoint=b,this.selectJewel(a)},onMouseUp:function(a){this._touchOn=!1},onMouseMove:function(a){var b=this.convertToNodeSpace(a.getLocation());this._activeSpell&&this._activeSpell.mouseMove(b);if(cc.rectContainsPoint(this._touchRect,b)&&(a.stopPropagation(),this._touchOn&&null!=this._select0&&(5<Math.abs(this._touchPoint.x-b.x)||5<Math.abs(this._touchPoint.y-
b.y))))if(JRelation.allowSelect(this._select0)){a=this._select0.getCell().getTileX();var c=this._select0.getCell().getTileY();Math.abs(this._touchPoint.x-b.x)>Math.abs(this._touchPoint.y-b.y)?a+=this._touchPoint.x>b.x?-1:1:c+=this._touchPoint.y>b.y?-1:1;this.selectJewel(this.getJewel(a,c))}else this._select0.setSelect(!1),this._select0=null},buildBackground:function(){this._background=new cc.Sprite(Resource.CLIENT.empty);this._background.setCascadeOpacityEnabled(!0);for(var a=0;8>a;a++)for(var b=
0;8>b;b++){var c=this.getCell(a,b);if(null!=c){var d=new cc.Sprite(Resource.CLIENT.grid(0));d.setPosition(c.getCenter());this._background.addChild(d,0);null==this.getCell(a,b+1)&&(d=new cc.Sprite(Resource.CLIENT.grid(1)),d.setAnchorPoint(0,0),d.setPositionX(c.getPosition().x),d.setPositionY(c.getPosition().y+this._csize.height),this._background.addChild(d,1));null==this.getCell(a,b-1)&&(d=new cc.Sprite(Resource.CLIENT.grid(1)),d.setAnchorPoint(0,0),d.setScaleY(-1),d.setPosition(c.getPosition()),this._background.addChild(d,
1));null==this.getCell(a-1,b)&&(d=new cc.Sprite(Resource.CLIENT.grid(1)),d.setAnchorPoint(0,0),d.setScaleX(this._csize.height/d.getContentSize().width),d.rotation=-90,d.setPosition(c.getPosition()),this._background.addChild(d,1));null==this.getCell(a+1,b)&&(d=new cc.Sprite(Resource.CLIENT.grid(1)),d.setAnchorPoint(1,0),d.setScaleX(this._csize.height/d.getContentSize().width),d.rotation=90,d.setPositionY(c.getPosition().y),d.setPositionX(c.getPosition().x+this._csize.width),this._background.addChild(d,
1));null==this.getCell(a,b-1)&&null==this.getCell(a-1,b)&&(d=new cc.Sprite(Resource.CLIENT.grid(2)),d.setAnchorPoint(0,1),d.rotation=90,d.setPositionX(c.getPosition().x+3),d.setPositionY(c.getPosition().y+3),this._background.addChild(d,2));null==this.getCell(a,b-1)&&null==this.getCell(a+1,b)&&(d=new cc.Sprite(Resource.CLIENT.grid(2)),d.setAnchorPoint(0,1),d.rotation=0,d.setPositionX(c.getPosition().x-3+this._csize.width),d.setPositionY(c.getPosition().y+3),this._background.addChild(d,2));null==this.getCell(a,
b+1)&&null==this.getCell(a+1,b)&&(d=new cc.Sprite(Resource.CLIENT.grid(2)),d.setAnchorPoint(0,1),d.rotation=270,d.setPositionX(c.getPosition().x-3+this._csize.width),d.setPositionY(c.getPosition().y-3+this._csize.height),this._background.addChild(d,2));null==this.getCell(a,b+1)&&null==this.getCell(a-1,b)&&(d=new cc.Sprite(Resource.CLIENT.grid(2)),d.setAnchorPoint(0,1),d.rotation=180,d.setPositionX(c.getPosition().x+3),d.setPositionY(c.getPosition().y-3+this._csize.height),this._background.addChild(d,
2));null!=this.getCell(a,b-1)&&null!=this.getCell(a-1,b)&&null==this.getCell(a-1,b-1)&&(d=new cc.Sprite(Resource.CLIENT.grid(3)),d.setAnchorPoint(0,1),d.rotation=90,d.setPosition(c.getPosition()),this._background.addChild(d,2));null!=this.getCell(a,b-1)&&null!=this.getCell(a+1,b)&&null==this.getCell(a+1,b-1)&&(d=new cc.Sprite(Resource.CLIENT.grid(3)),d.setAnchorPoint(0,1),d.rotation=0,d.setPositionX(c.getPosition().x+this._csize.width),d.setPositionY(c.getPosition().y),this._background.addChild(d,
2));null!=this.getCell(a,b+1)&&null!=this.getCell(a-1,b)&&null==this.getCell(a-1,b+1)&&(d=new cc.Sprite(Resource.CLIENT.grid(3)),d.setAnchorPoint(0,1),d.rotation=180,d.setPositionX(c.getPosition().x),d.setPositionY(c.getPosition().y+this._csize.height),this._background.addChild(d,2));null!=this.getCell(a,b+1)&&null!=this.getCell(a+1,b)&&null==this.getCell(a+1,b+1)&&(d=new cc.Sprite(Resource.CLIENT.grid(3)),d.setAnchorPoint(0,1),d.rotation=-90,d.setPositionX(c.getPosition().x+this._csize.width),d.setPositionY(c.getPosition().y+
this._csize.height),this._background.addChild(d,2))}}this._background.setPosition(this.getPosition())},getCell:function(a,b){return 0>a||8<=a||0>b||8<=b?null:this._table[a][b]},getJewel:function(a,b){var c=this.getCell(a,b);return c&&c.isEnabled()?c.getJewel():null},isState:function(a){return this._state==a},getJShape:function(a){var b=this._shapes.slice(Math.max(0,a-1),Math.min(7,a+1)+1);this._shapes[a]=JShape.getRandom(b);return this._shapes[a]},getNewCode:function(a){var b=Math.round(100*Math.random()),
c=null,d=this._goal;d.getGoalButterfly()-d.getDoneButterfly()>this._countButterfly&&this._confButterfly[1]>this._countButterfly&&b<this._confButterfly[2]&&(c=[JType.BUTTERFLY,"0","0","0","0",this._confButterfly[3]+""],this._countButterfly++);null==c&&d.getGoalMirror()-d.getDoneMirror()>this._countMirror&&this._confMirror[1]>this._countMirror&&b<this._confMirror[2]&&(c=[JType.MIRROR,"0","0","0","0",this._confMirror[3]+""],this._countMirror++);null==c&&0<d.getGoalDiamond()&&b<(this._countDiamond>this._confDiamond[1]?
this._confDiamond[2]:this._confDiamond[3])&&(c=[JType.DIAMOND,"0","0","0","0","2"],this._countDiamond++);null==c&&(c=[JType.SIMPLE,"1","0","0","0","0","0"],c[1]=this.getJShape(a),c[2]=this.isPowerOn()?"1":"0");return c},isPowerOn:function(){return Math.random()<this._power/5},setPower:function(a){this._power=Math.min(1,Math.max(0,a));this.rubyHighlight(.95<=a);this._powerAction=.66<this._power?2:.33<this._power?1:0},updatePower:function(a){this.setPower(this._power+a)},setStableGrid:function(a){this._stableGrid=
a},getGoal:function(){return this._goal},destroyGrid:function(){var a;var b=!0;this._cloud&&this._cloud.update();for(var c=0;8>c;c++)for(var d=0;8>d;d++)if(a=this._table[d][c])a.isEmpty()||a.getJewel().setState(JState.MATCH_ON,!1),b=a.update(c==this._rowMinId)&&b;if(!b)return!1;switch(this._destroy){case 0:this._destroy=1;this._state=Client.Grid.STATE.PLAY_FINISH;this.setPower(0);this.hideSuggestion();this._activeSpell&&(this._activeSpell.remove(),this._activeSpell=null);c=new cc.EventCustom(Client.EVENT.UPDATE_SPELL);
c.setUserData({enable:!1,list:null});cc.eventManager.dispatchEvent(c);break;case 1:this._cloud&&(this._cloud.runAction(new cc.Sequence([new cc.FadeTo(1,50),new cc.RemoveSelf])),this._cloud=null);var e=[];for(c=0;8>c;c++)for(d=0;8>d;d++)(b=this.getJewel(c,d))&&b.isJType(JType.BONUS)&&(a=b.getCode(),a[3]!=JBonus.A&&a[3]!=JBonus.J||b.updateCode(0,JType.SIMPLE),e.push(b));0==e.length?this._destroy=2:(b=e[CUtils.random(0,e.length-1)],b.setLocks(0),b.execJAction(!1,null));break;case 2:for(c=0;8>c;c++)for(d=
0;8>d;d++)if(a=this.getCell(c,d))if(a.breakBackground(10),b=a.getJewel())b.setLocks(0),a=b.getCode(),a[0]==JType.FREEZE&&b.isState(JState.FREEZE)&&b.infect(),a[0]!=JType.SHELL&&a[0]!=JType.RAINBOW&&a[0]!=JType.MAGNET&&a[0]!=JType.DIAMOND&&a[0]!=JType.TITANIUM&&a[0]!=JType.FROG&&a[0]!=JType.ENIGMA&&a[0]!=JType.MIRROR&&a[0]!=JType.CHAMELEON||b.updateCode(0,JType.SIMPLE),a[0]!=JType.TORCH&&b.setUState(0),b.execJAction(!1,null);this._destroy=3;break;case 3:for(c=0;8>c;c++)for(d=0;8>d;d++)if(b=this.getJewel(c,
d))if(a=b.getCode(),(a[0]!=JType.TORCH||0!=b.getUState())&&a[0]!=JType.TREASURE)return a[0]==JType.DIAMOND&&b.setUState(0),JRelation.isLocked(b,[JState.FREEZE])||(a[0]==JType.FREEZE?b.runJAction(new JAction.Explode(b,null)):b.execJAction(!1,null)),!1;return!0}return!1},showSuggestion:function(a,b){this.hideSuggestion();var c=new cc.Point(Client.Grid.getPointX(a.x),Client.Grid.getPointY(a.y)),d=new cc.Point(Client.Grid.getPointX(b.x),Client.Grid.getPointY(b.y)),e=Client.Grid.getCHSize();this._suggestion=
new Client.Suggestion(this);this._suggestion.setPosition(.5*(c.x+d.x)+e.width,.5*(c.y+d.y)+e.height);this._suggestion.setRotation(a.x==b.x?0:90);this.addChild(this._suggestion,200)},hideSuggestion:function(){this._suggestion&&(this._suggestion.removeFromParent(),this._suggestion=null)},showGuide:function(){null==this._guide&&null!=this._guides&&0==Popup.getSize()&&(0<this._guides.length?Number(this._guides[0].spend)==this._goal.getSpendMoves()&&(this.hideSuggestion(),this._guide=new Client.Guide(this,
this._guides[0]),this._guide.show(),this._guides.splice(0,1)):this._guides=null)},runJAction:function(a){this._controller.addJAction(a)},activeSpell:function(a){this._activeSpell&&(this._activeSpell.remove(),this._activeSpell=null);switch(a){case JSpell.RESHUFFLE:this._activeSpell=new JAction.SReshuffle(this);this._activeSpell.exec();break;case JSpell.HAMMER:this._activeSpell=new JAction.SHammer(this);break;case JSpell.HAND:this._activeSpell=new JAction.SHand(this);break;case JSpell.COLOR_BLAST:this._activeSpell=
new JAction.SColorBlast(this);break;case JSpell.UNLOCK:this._activeSpell=new JAction.SUnlock(this);break;case JSpell.SUPER_BOMB:this._activeSpell=new JAction.SSuperBomb(this)}this._activeSpell&&(this._select0&&(this._select0.setSelect(!1),this._select0=null),this._select1&&(this._select1.setSelect(!1),this._select1=null))},activeOrb:function(a){if(a.isBought())switch(a.getId()){case Products.IDS.OR_TORNADO:this._tasks.push({key:"add_extra",stable:!0,data:"B10b000".split("")});this._tasks.push({key:"add_extra",
stable:!0,data:"B10b000".split("")});break;case Products.IDS.OR_LIGHTNING:this._tasks.push({key:"add_extra",stable:!0,data:"B10e000".split("")});this._tasks.push({key:"add_extra",stable:!0,data:"B10e000".split("")});break;case Products.IDS.OR_CROSS_BLAST:this._tasks.push({key:"add_extra",stable:!0,data:"B10h000".split("")});this._tasks.push({key:"add_extra",stable:!0,data:"B10h000".split("")});break;case Products.IDS.OR_BOMB:this._tasks.push({key:"add_extra",stable:!0,data:"B10d000".split("")});this._tasks.push({key:"add_extra",
stable:!0,data:"B10d000".split("")});break;case Products.IDS.OR_FIRE_BLAST:this._tasks.push({key:"add_extra",stable:!0,data:"B10i000".split("")}),this._tasks.push({key:"add_extra",stable:!0,data:"B10i000".split("")})}},boughtOrb:function(a){if(a.isBought())switch(a.getId()){case Products.IDS.OR_HAMMER:this._info.it_bought(6);break;case Products.IDS.OR_HAND:this._info.it_bought(15);break;case Products.IDS.OR_UNLOCK:this._info.it_bought(4);break;case Products.IDS.OR_SUPER_BOMB:this._info.it_bought(11);
break;case Products.IDS.OR_COLOR_BLASTER:this._info.it_bought(8)}},activeCell:function(a,b){if(void 0==b){b=[];for(var c=0;8>c;c++)for(var d=0;8>d;d++)b.push({x:c,y:d})}for(var e in b)c=b[e],(c=this.getCell(c.x,c.y))&&c.setActive(a)},executeTasks:function(){if(!(0<Popup.getSize()||this._guide))for(var a=this._tasks.length-1;0<=a;a--){var b=this._tasks[a];if(!b.stable||b.stable&&this._stableState){isNaN(b.attempt)&&(b.attempt=3);switch(b.key){case "add_extra":b.attempt=this.addExtra(b.data)?0:b.attempt-
1;break;default:cc.log("unknown task key",b.key),b.attempt=0}0>=b.attempt&&this._tasks.splice(a,1)}}},addExtra:function(a){for(var b,c=[],d=0;8>d;d++)for(var e=0;8>e;e++)(b=this.getJewel(d,e))&&b.isJType(JType.SIMPLE)&&!b.isLocked()&&!JRelation.isLocked(b)&&c.push(b);if(0==c.length)return!1;b=c[CUtils.random(0,c.length-1)];b.updateCode(0,a[0]);b.updateCode(2,a[2]);b.updateCode(3,a[3]);b.updateCode(4,a[4]);b.updateCode(5,a[5]);b.updateUI(!0);b.addInitEfect();return!0},rubyHighlight:function(a){if(this._highlightOn!=
a){this._highlightOn=a;for(var b=0;8>b;b++)for(var c=0;8>c;c++){var d=this.getJewel(b,c);d&&d.rubyHighlight(a)}}},eventHandler:function(a){var b=a.getEventName();a=a.getUserData()||{};b==Client.EVENT.SPELL_ACTIVE&&void 0!=a.type?this._activeSpell?cc.eventManager.dispatchCustomEvent(Client.EVENT.SPELL_CANCEL,{type:a.type}):this.activeSpell(a.type):b==User.EVENT.UPDATE_ORB&&"bought"==a.action&&a.orb?(this.activeOrb(a.orb),this.boughtOrb(a.orb)):b==Client.EVENT.GUIDE_CLOSED&&a==this._guide&&(this._guide=
null)},saveGame:function(){},setInfectSwap:function(a){this._infectSwap=a},setInfectIceCube:function(a){this._infectIceCube=a},setInfectMagicBall:function(a){this._infectMagicBall=a},setInfectMagnet:function(a){this._infectMagnet=a},getInfectMagnet:function(){return this._infectMagnet}});Client.Grid.STATE={PLAYING:0,PLAY_FINISH:1,PLAY_NOMOVES:2};Client.Grid.getCSize=function(){Client.Grid._csize||(Client.Grid._csize=new cc.Size(64,57));return Client.Grid._csize};
Client.Grid.getRWH=function(){if(!Client.Grid._RWH){var a=Client.Grid.getCSize();Client.Grid._RWH=a.width/a.height}return Client.Grid._RWH};Client.Grid.getRHW=function(){if(!Client.Grid._RHW){var a=Client.Grid.getCSize();Client.Grid._RHW=a.height/a.width}return Client.Grid._RHW};Client.Grid.getCHSize=function(){Client.Grid._chsize||(Client.Grid._chsize=new cc.Size(32,28));return Client.Grid._chsize};
Client.Grid.getTileX=function(a){a=Math.floor(a/Client.Grid.getCSize().width);return 0<=a&&7>=a?a:-1};Client.Grid.getTileY=function(a){a=Math.floor(a/Client.Grid.getCSize().height);return 0<=a&&7>=a?a:-1};Client.Grid.getTile=function(a){return new cc.Point(Client.Grid.getTileX(a.x),Client.Grid.getTileY(a.y))};Client.Grid.validTile=function(a){return!(0>a.x||8<=a.x||0>a.y||8<=a.y)};Client.Grid.getPointX=function(a){return a*Client.Grid.getCSize().width};Client.Grid.getPointY=function(a){return a*Client.Grid.getCSize().height};
Client.Grid.getPoint=function(a){return new cc.Point(Client.Grid.getPointX(a.x),Client.Grid.getPointY(a.y))};Client.GridCell=cc.Class.extend({_size:null,_grid:null,_tile:null,_position:null,_center:null,_controller:null,_jewel:null,_active:!0,_enabled:!0,_background:null,ctor:function(a,b,c,d){this._size=Client.Grid.getCSize();this._grid=a;this._tile=new cc.Point(c,d);this._position=new cc.Point(c*this._size.width,d*this._size.height);this._center=new cc.Point(this._position.x+Math.round(.5*this._size.width),this._position.y+Math.round(.5*this._size.height));this._jewel=null;this._controller=new JController;
"0"!=b[6]&&(this._background=new Client.Jewel.Background(b),this._background.setPosition(this._center),this._background.setLocalZOrder(-1),this._grid.addChild(this._background));"1"!=b[0]&&(a=null,"0"!=b[7]&&(c=Number(b[7])-1,a=b.slice(0,7),b=[JType.ENIGMA,"0","0","0","0",String(c),"0"]),this._jewel=new Client.Jewel(b,this,a),this._grid.addChild(this._jewel))},checkMatch:function(){var a=this._jewel;if(a&&this.isEnabled()&&a.isState(JState.MATCH_ON)&&!a.isState(JState.TRANSFORM))if(JRelation.allowMatch(a,
a)){var b=!0;var c=!1;a=JLogic.findMatch(this._grid,a,!0);var d=a.matches.length;if(2<d){this._grid.updatePower(.012*d);if(null!=a.bonus){c=null;for(d=0;d<a.matches.length;d++)if(a.matches[d].isState(JState.SWAP)){b=!1;c=a.matches[d];break}null==c&&(c=a.matches[Math.round(Math.random()*(a.matches.length-1))]);c.runJAction(new JAction.Bonus(c,a.matches,a.bonus));this._grid.getInfo().ct_bonus(1)}else if(a.matches[0].isJType(JType.DIAMOND)){c=null;for(d=0;d<a.matches.length;d++)if(a.matches[d].isState(JState.SWAP)){b=
!1;c=a.matches[d];break}null==c&&(c=a.matches[Math.round(Math.random()*(a.matches.length-1))]);c.runJAction(new JAction.Diamond(c,a.matches))}else{for(d=0;d<a.matches.length;d++)if(null!=a.matches[d].getSwapRef()){b=!1;c=!0;break}for(d=0;d<a.matches.length;d++)a.matches[d].setState(JState.SWAP,!1),null!=a.matches[d].getSwapRef()&&a.matches[d].getSwapRef().setState(JState.SWAP,!1),a.matches[d].execJAction(!1,{swap:c})}b&&this._grid.getInfo().auto_match(1)}}else a.setState(JState.MATCH_ON,!1)},update:function(a){var b=
this._jewel,c=!0;if(null==b)this.fillCell();else if(a&&JRelation.allowDestroyLastRow(b)){if(b.isJType(JType.TREASURE))for(this._grid.getGoal().doneTreasure(1,!0),a=3+3*b.getCode(5),c=0;c<a;c++)this._grid.addRuby(JRuby.getRandom(),b.getPosition());b.removeFromParent();this.remJewel();c=!1}else b.getController().update();this._controller.update();return c=c&&0==this._controller.count()&&(null==b||0==b.getController().count()&&!b.isState(JState.TRANSFORM))},breakBackground:function(a){a=a||1;null!=this._background&&
(a=this._background.getState()-a,0<a?this._background.setState(a):(this._background.removeFromParent(),this._background=null,this._grid.getGoal().doneBackground(1,!0)),AudioEngine.playEffect(Resource.SND.CL_HAMMER,!0))},getController:function(){return this._controller},fillCell:function(){if(null!=this._grid.getCell(this._tile.x,this._tile.y+1)||null!=this._grid.getCell(this._tile.x+1,this._tile.y+1)||null!=this._grid.getCell(this._tile.x-1,this._tile.y+1)||this._grid.isState(Client.Grid.STATE.PLAY_FINISH)){var a=
this._grid.getCell(this._tile.x,this._tile.y+1);if(null==a||!a.tryDropJewel(!0)){var b=.5<Math.random()?1:-1;a=this._grid.getCell(this._tile.x+b,this._tile.y+1);null!=a&&a.tryDropJewel(!0)||(a=this._grid.getCell(this._tile.x-b,this._tile.y+1),null!=a&&a.tryDropJewel(!0))}}else this.newJewel(),this.tryDropJewel(!1)},newJewel:function(){cc.assert(null==this._jewel);var a=this._grid.getNewCode(this._tile.x);this._jewel=new Client.Jewel(a,this);this._jewel.setPositionY(this._jewel.getPositionY()+2*this._size.height);
this._jewel.rubyHighlight(this._grid.getHighlightOn());this._grid.addChild(this._jewel);a=Client.GridCell._soundId||0;AudioEngine.playEffect(Resource.SND.CL_NEW_ITEM(a));Client.GridCell._soundId=9<a+1?0:a+1},addJewel:function(a){cc.assert(null==this._jewel);this._jewel=a;this._jewel.setCell(this)},remJewel:function(){null!=this._jewel&&(this._jewel.setCell(null),this._jewel=null)},tryDropJewel:function(a){var b=this._jewel;if(this.isEnabled()&&null!=b&&JRelation.allowActionMove(b)){if(a&&!this.dropJewel())return!1;
b.runJAction(new JAction.Move(b,!0));return!0}return!1},dropJewel:function(){if(0>=this._tile.y)return!1;var a=this._jewel,b=this._grid.getCell(this._tile.x,this._tile.y-1);if(null!=b&&b.isEnabled()&&b.isEmpty())return this.remJewel(),b.addJewel(a),!0;b=.5<Math.random()?1:-1;var c=this._grid.getCell(this._tile.x-b,this._tile.y-1),d=this._grid.getCell(this._tile.x-b,this._tile.y);if(c&&c.isEmpty()&&c.isEnabled()&&(!d||d.isEnabled()&&(d.isEmpty()||!JRelation.isMovable(d.getJewel())||30<Math.abs(d.getCenter().y-
d.getJewel().getPosition().y))))return d&&!d.isEmpty()&&a.setLocalZOrder(d.getJewel().getLocalZOrder()+1),this.remJewel(),c.addJewel(a),!0;c=this._grid.getCell(this._tile.x+b,this._tile.y-1);d=this._grid.getCell(this._tile.x+b,this._tile.y);return c&&c.isEmpty()&&c.isEnabled()&&(!d||d.isEnabled()&&(d.isEmpty()||!JRelation.isMovable(d.getJewel())||30<Math.abs(d.getCenter().y-d.getJewel().getPosition().y)))?(d&&!d.isEmpty()&&a.setLocalZOrder(d.getJewel().getLocalZOrder()+1),this.remJewel(),c.addJewel(a),
!0):!1},getJewel:function(){return this._jewel},isEmpty:function(){return null==this._jewel},getGrid:function(){return this._grid},getTile:function(){return this._tile},getTileX:function(){return this._tile.x},getTileY:function(){return this._tile.y},getPosition:function(){return this._position},getCenter:function(){return this._center},setActive:function(a){this._active=a},isActive:function(){return this._active},setEnabled:function(a){this._enabled=a},isEnabled:function(){return this._enabled}});Client.GridInfo=cc.Class.extend({_mv_d:null,_auto_match:null,_ct_bonus:null,_it_bought:null,_it_used:null,ctor:function(){this._ct_bonus=this._auto_match=this._mv_d=0;this._it_bought=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];this._it_used=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},mv_d:function(a){isNaN(a)||(this._mv_d+=a);return this._mv_d},auto_match:function(a){isNaN(a)||(this._auto_match+=a);return this._auto_match},ct_bonus:function(a){isNaN(a)||(this._ct_bonus+=a);return this._ct_bonus},it_bought:function(a){!isNaN(a)&&
a<this._it_bought.length&&this._it_bought[a]++;return this._it_bought.slice()},it_used:function(a){!isNaN(a)&&a<this._it_used.length&&this._it_used[a]++;return this._it_used.slice()}});Client.Cloud=cc.Sprite.extend({_tx:null,_ty:null,_px:null,_py:null,_action:null,_stepAction:null,_stepCurrent:null,_speed:null,_speedMax:null,_speedMin:null,_accel:null,_tasks:null,_grid:null,_self:null,ctor:function(a,b){b.t=b.t||"e";this._super(Resource.CLIENT.jewel_cloud(b.t+"_0"));this._grid=a;this._action=String(b.t);this._stepAction=Number(b.s);this._stepCurrent=0;this._ty=this._tx=-1;this._py=this._px=0;this._tasks=[];this._accel=.5;this._speed=2;this._speedMax=4;this._speedMin=2;this.goTo(Number(b.x),
Number(b.y),!1)},goTo:function(a,b,c){var d;(d=this._grid.getCell(this._tx,this._ty))&&d.setActive(!0);(d=this._grid.getCell(this._tx+1,this._ty))&&d.setActive(!0);(d=this._grid.getCell(this._tx+1,this._ty+1))&&d.setActive(!0);(d=this._grid.getCell(this._tx,this._ty+1))&&d.setActive(!0);c?(this._tx<a-1?this._tx++:this._tx>a&&this._tx--,this._ty<b-1?this._ty++:this._ty>b&&this._ty--,this._px=Client.Grid.getPointX(this._tx+1),this._py=Client.Grid.getPointY(this._ty+1)):(this._tx=a,this._ty=b,this._px=
Client.Grid.getPointX(a+1),this._py=Client.Grid.getPointY(b+1),this.setPosition(this._px,this._py));(d=this._grid.getCell(this._tx,this._ty))&&d.setActive(!1);(d=this._grid.getCell(this._tx+1,this._ty))&&d.setActive(!1);(d=this._grid.getCell(this._tx+1,this._ty+1))&&d.setActive(!1);(d=this._grid.getCell(this._tx,this._ty+1))&&d.setActive(!1);this._speed=this._speedMin},exec:function(){this._stepCurrent++;this._stepCurrent==this._stepAction&&(this._stepCurrent=0,this._tasks.push({key:this._action,
target:this.findTarget(this._action)}))},findTarget:function(a){for(var b=[],c=0;8>c;c++)for(var d=0;8>d;d++){var e=this._grid.getJewel(c,d);e&&JRelation.isApplyCloud(e,a)&&("e"==a&&e.execJAction(!0,null)?b.push(e):"e"!=a&&b.push(e))}if(0==b.length)return null;a=3*Client.Grid.getCSize().height;for(c=0;100>c;c++)if(d=b[CUtils.random(0,b.length-1)],d.hasCell()&&CUtils.distance(d.getCell().getCenter(),this.getPosition())>a)return d;return null},update:function(){this._super();this._speed=Math.min(this._speed+
this._accel,this._speedMax);var a=this.getPosition();if(a.x!==this._px||a.y!==this._py)a.x=Math.abs(a.x-this._px)<Math.abs(this._speed)?this._px:a.x<this._px?a.x+this._speed:a.x-this._speed,a.y=Math.abs(a.y-this._py)<Math.abs(this._speed)?this._py:a.y<this._py?a.y+(this._speed-Client.Grid.getRHW()/this._speed):a.y-(this._speed-Client.Grid.getRHW()/this._speed),this.setPosition(a);if(0<this._tasks.length)for(a=this._tasks.length-1;0<=a;a--){var b=this._tasks[a];if(b.target){if(!b.anim){b.anim=new cc.Sprite(Resource.CLIENT.jewel_explode("lighting",
0));b.anim.setAnchorPoint(.5,0);this._grid.addChild(b.anim,this.getLocalZOrder()-1);var c=[];c.push(new cc.CallFunc(function(){var a=[cc.spriteFrameCache.getSpriteFrame(Resource.CLIENT.jewel_cloud(b.key+"_1")),cc.spriteFrameCache.getSpriteFrame(Resource.CLIENT.jewel_cloud(b.key+"_0"))];a=new cc.Animation(a,.028,7);this.runAction(new cc.Animate(a))},this));c.push(new cc.FadeIn);c.push(new cc.DelayTime(.08));c.push(new cc.FlipX(!0));c.push(new cc.DelayTime(.08));c.push(new cc.FlipY(!0));c.push(new cc.DelayTime(.08));
c.push(new cc.FlipX(!1));c.push(new cc.DelayTime(.08));c.push(new cc.FlipY(!1));c.push(new cc.CallFunc(function(){if("a"==b.key)this.updateCode(0,JType.STONE),this.updateCode(1,"0"),this.updateCode(2,"0"),this.updateCode(3,"0"),this.updateCode(4,"0"),this.updateCode(5,"0"),this.updateUI(!0);else if("b"==b.key){var a=this.getCode(1);this.updateCode(0,JType.CHAMELEON);this.updateCode(1,JShape.isAllowed(a)?a:JShape.getRandom());this.updateCode(2,"0");this.updateCode(3,"0");this.updateCode(4,"0");this.updateCode(5,
"0");this.updateUI(!0,.2)}else"c"==b.key?(this.updateCode(0,JType.TITANIUM),this.updateCode(1,"0"),this.updateCode(2,"0"),this.updateCode(3,"0"),this.updateCode(4,"0"),this.updateCode(5,"0"),this.updateUI(!0,.2)):"d"==b.key?(a=this.getCode(1),this.updateCode(0,JType.FROZEN),this.updateCode(1,JShape.isAllowed(a)?a:JShape.getRandom()),this.updateCode(2,"0"),this.updateCode(3,"0"),this.updateCode(4,"0"),this.updateCode(5,"0"),this.updateUI(!0,.2)):this.execJAction(!1)},b.target));c.push(new cc.DelayTime(.08));
c.push(new cc.FadeTo(.1,0));c.push(new cc.CallFunc(function(){this.target=null},b));c.push(new cc.RemoveSelf);b.anim.runAction(new cc.Sequence(c))}c=this.getPosition();var d=b.target.getPosition(),e=Math.sqrt(Math.pow(c.x-d.x,2)+Math.pow(c.y-d.y,2));b.anim.setPosition(c);b.anim.setScaleY(e/b.anim.getContentSize().height);b.anim.setRotation(90-CUtils.getAngle(c,d,!1))}else this._tasks.splice(a,1)}}});Client.Goal=cc.Class.extend({_totalMoves:null,_spendMoves:null,_goalMoves:null,_goalBackground:null,_doneBackground:null,_goalTreasure:null,_doneTreasure:null,_goalTorch:null,_doneTorch:null,_goalBeetle:null,_doneBeetle:null,_goalDiamond:null,_doneDiamond:null,_goalIceCube:null,_doneIceCube:null,_goalButterfly:null,_doneButterfly:null,_goalRainbow:null,_doneRainbow:null,_goalRowBlast:null,_doneRowBlast:null,_goalColumnBlast:null,_doneColumnBlast:null,_goalCrossBlast:null,_doneCrossBlast:null,_goalStone:null,
_doneStone:null,_goalMirror:null,_doneMirror:null,_goalFrog:null,_doneFrog:null,_goalMagicBall:null,_doneMagicBall:null,_goalPearl:null,_donePearl:null,ctor:function(a){this._totalMoves=new CValue(a.m);this._spendMoves=new CValue(0);this._goalMoves=new CValue(a.nrm);this._goalBackground=new CValue(0);this._doneBackground=new CValue(0);this._goalTreasure=new CValue(0);this._doneTreasure=new CValue(0);this._goalTorch=new CValue(0);this._doneTorch=new CValue(0);this._goalBeetle=new CValue(0);this._doneBeetle=
new CValue(0);this._goalDiamond=new CValue(a.diamond?Number(a.diamond.split(",")[0]):0);this._doneDiamond=new CValue(0);this._goalIceCube=new CValue(a.icecube);this._doneIceCube=new CValue(0);this._goalButterfly=new CValue(a.butterfly?Number(a.butterfly.split(",")[0]):0);this._doneButterfly=new CValue(0);this._goalRainbow=new CValue(a.rainbow);this._doneRainbow=new CValue(0);this._goalRowBlast=new CValue(a.rowblast);this._doneRowBlast=new CValue(0);this._goalColumnBlast=new CValue(a.columnblast);
this._doneColumnBlast=new CValue(0);this._goalCrossBlast=new CValue(a.crossblast);this._doneCrossBlast=new CValue(0);this._goalStone=new CValue(a.stone);this._doneStone=new CValue(0);this._goalMirror=new CValue(a.mirror?Number(a.mirror.split(",")[0]):0);this._doneMirror=new CValue(0);this._goalFrog=new CValue(a.frog);this._doneFrog=new CValue(0);this._goalMagicBall=new CValue(0);this._doneMagicBall=new CValue(0);this._goalPearl=new CValue(a.pearl);this._donePearl=new CValue(0);a=a.data.split(".").slice(0,
64);for(var b=0;b<a.length;b++){var c=(a[b]+"000000").substr(0,7).split("");c[0]==JType.BEETLE?this._goalBeetle.addValue(1):c[0]==JType.TORCH?this._goalTorch.addValue(1):c[0]==JType.TREASURE?this._goalTreasure.addValue(1):c[0]==JType.MAGICBALL&&this._goalMagicBall.addValue(1);"0"!=c[6]&&this._goalBackground.addValue(1)}this.update()},update:function(){cc.eventManager.dispatchCustomEvent(Client.EVENT.UPDATE_GOAL,this)},hasMoves:function(){return this._totalMoves.getValue()>this._spendMoves.getValue()},
isCompleted:function(){return this._goalMoves.getValue()<=this._spendMoves.getValue()&&this._goalBackground.getValue()<=this._doneBackground.getValue()&&this._goalTreasure.getValue()<=this._doneTreasure.getValue()&&this._goalTorch.getValue()<=this._doneTorch.getValue()&&this._goalBeetle.getValue()<=this._doneBeetle.getValue()&&this._goalDiamond.getValue()<=this._doneDiamond.getValue()&&this._goalIceCube.getValue()<=this._doneIceCube.getValue()&&this._goalButterfly.getValue()<=this._doneButterfly.getValue()&&
this._goalRainbow.getValue()<=this._doneRainbow.getValue()&&this._goalRowBlast.getValue()<=this._doneRowBlast.getValue()&&this._goalColumnBlast.getValue()<=this._doneColumnBlast.getValue()&&this._goalCrossBlast.getValue()<=this._doneCrossBlast.getValue()&&this._goalStone.getValue()<=this._doneStone.getValue()&&this._goalFrog.getValue()<=this._doneFrog.getValue()&&this._goalMirror.getValue()<=this._doneMirror.getValue()&&this._goalMagicBall.getValue()<=this._doneMagicBall.getValue()&&this._goalPearl.getValue()<=
this._donePearl.getValue()},getTotalMoves:function(){return this._totalMoves.getValue()},getSpendMoves:function(){return this._spendMoves.getValue()},getCurrentMoves:function(){return this._totalMoves.getValue()-this._spendMoves.getValue()},updateSpendMoves:function(a,b){this._spendMoves.setValue(Math.min(this._totalMoves.getValue(),this._spendMoves.getValue()+a));1==b&&0!=a&&this.update()},updateTotalMoves:function(a,b){this._totalMoves.setValue(Math.max(this._spendMoves.getValue(),this._totalMoves.getValue()+
a));1==b&&0!=a&&this.update()},getDoneMoves:function(){return this._spendMoves.getValue()},getGoalMoves:function(){return this._goalMoves.getValue()},getDoneBackground:function(){return this._doneBackground.getValue()},getGoalBackground:function(){return this._goalBackground.getValue()},doneBackground:function(a,b){this._doneBackground.addValue(a||1);1==b&&0!=this._goalBackground.getValue()&&this.update()},getDoneTreasure:function(){return this._doneTreasure.getValue()},getGoalTreasure:function(){return this._goalTreasure.getValue()},
doneTreasure:function(a,b){this._doneTreasure.addValue(a||1);1==b&&0!=this._goalTreasure.getValue()&&this.update()},getDoneTorch:function(){return this._doneTorch.getValue()},getGoalTorch:function(){return this._goalTorch.getValue()},doneTorch:function(a,b){this._doneTorch.addValue(a||1);1==b&&0!=this._goalTorch.getValue()&&this.update()},getDoneBeetle:function(){return this._doneBeetle.getValue()},getGoalBeetle:function(){return this._goalBeetle.getValue()},doneBeetle:function(a,b){this._doneBeetle.addValue(a||
1);1==b&&0!=this._goalBeetle.getValue()&&this.update()},isDoneBeetle:function(){return this._goalBeetle.getValue()<=this._doneBeetle.getValue()},getDoneRowBlast:function(){return this._doneRowBlast.getValue()},getGoalRowBlast:function(){return this._goalRowBlast.getValue()},doneRowBlast:function(a,b){this._doneRowBlast.addValue(a||1);1==b&&0!=this._goalRowBlast.getValue()&&this.update()},getDoneColumnBlast:function(){return this._doneColumnBlast.getValue()},getGoalColumnBlast:function(){return this._goalColumnBlast.getValue()},
doneColumnBlast:function(a,b){this._doneColumnBlast.addValue(a||1);1==b&&0!=this._goalColumnBlast.getValue()&&this.update()},getDoneCrossBlast:function(){return this._doneCrossBlast.getValue()},getGoalCrossBlast:function(){return this._goalCrossBlast.getValue()},doneCrossBlast:function(a,b){this._doneCrossBlast.addValue(a||1);1==b&&0!=this._goalCrossBlast.getValue()&&this.update()},getDoneStone:function(){return this._doneStone.getValue()},getGoalStone:function(){return this._goalStone.getValue()},
doneStone:function(a,b){this._doneStone.addValue(a||1);1==b&&0!=this._goalStone.getValue()&&this.update()},getDoneButterfly:function(){return this._doneButterfly.getValue()},getGoalButterfly:function(){return this._goalButterfly.getValue()},doneButterfly:function(a,b){this._doneButterfly.addValue(a||1);1==b&&0!=this._goalButterfly.getValue()&&this.update()},isDoneButterfly:function(){return this._goalButterfly.getValue()<=this._doneButterfly.getValue()},getDoneDiamond:function(){return this._doneDiamond.getValue()},
getGoalDiamond:function(){return this._goalDiamond.getValue()},doneDiamond:function(a,b){this._doneDiamond.addValue(a||1);1==b&&0!=this._goalDiamond.getValue()&&this.update()},getDoneRainbow:function(){return this._doneRainbow.getValue()},getGoalRainbow:function(){return this._goalRainbow.getValue()},doneRainbow:function(a,b){this._doneRainbow.addValue(a||1);1==b&&0!=this._goalRainbow.getValue()&&this.update()},isDoneRainbow:function(){return this._goalRainbow.getValue()<=this._doneRainbow.getValue()},
getDoneIceCube:function(){return this._doneIceCube.getValue()},getGoalIceCube:function(){return this._goalIceCube.getValue()},doneIceCube:function(a,b){this._doneIceCube.addValue(a||1);1==b&&0!=this._goalIceCube.getValue()&&this.update()},getDoneMirror:function(){return this._doneMirror.getValue()},getGoalMirror:function(){return this._goalMirror.getValue()},doneMirror:function(a,b){this._doneMirror.addValue(a||1);1==b&&0!=this._goalMirror.getValue()&&this.update()},isDoneMirror:function(){return this._goalMirror.getValue()<=
this._doneMirror.getValue()},getDoneFrog:function(){return this._doneFrog.getValue()},getGoalFrog:function(){return this._goalFrog.getValue()},doneFrog:function(a,b){this._doneFrog.addValue(a||1);1==b&&0!=this._goalFrog.getValue()&&this.update()},isDoneFrog:function(){return this._goalFrog.getValue()<=this._doneFrog.getValue()},getDoneMagicBall:function(){return this._doneMagicBall.getValue()},getGoalMagicBall:function(){return this._goalMagicBall.getValue()},doneMagicBall:function(a,b){this._doneMagicBall.addValue(a||
1);1==b&&0!=this._goalMagicBall.getValue()&&this.update()},isDoneMagicBall:function(){return this._goalMagicBall.getValue()<=this._doneMagicBall.getValue()},getDonePearl:function(){return this._donePearl.getValue()},getGoalPearl:function(){return this._goalPearl.getValue()},donePearl:function(a,b){this._donePearl.addValue(a||1);1==b&&0!=this._goalPearl.getValue()&&this.update()},isDonePearl:function(){return this._goalPearl.getValue()<=this._donePearl.getValue()},save:function(){var a={};a.totalMoves=
this._totalMoves.getValue();a.spendMoves=this._spendMoves.getValue();a.goalMoves=this._goalMoves.getValue();a.goalBackground=this._goalBackground.getValue();a.doneBackground=this._doneBackground.getValue();a.doneTreasure=this._goalTreasure.getValue();a.doneTreasure=this._doneTreasure.getValue();a.doneTorch=this._goalTorch.getValue();a.doneTorch=this._doneTorch.getValue();a.goalBeetle=this._goalBeetle.getValue();a.doneBeetle=this._doneBeetle.getValue();a.goalDiamond=this._goalDiamond.getValue();a.doneDiamond=
this._doneDiamond.getValue();a.goalIceCube=this._goalIceCube.getValue();a.doneIceCube=this._doneIceCube.getValue();a.goalButterfly=this._goalButterfly.getValue();a.doneButterfly=this._doneButterfly.getValue();a.goalRainbow=this._goalRainbow.getValue();a.doneRainbow=this._doneRainbow.getValue();a.goalRowBlast=this._goalRowBlast.getValue();a.doneRowBlast=this._doneRowBlast.getValue();a.goalColumnBlast=this._goalColumnBlast.getValue();a.doneColumnBlast=this._doneColumnBlast.getValue();a.goalCrossBlast=
this._goalCrossBlast.getValue();a.doneCrossBlast=this._doneCrossBlast.getValue();a.goalStone=this._goalStone.getValue();a.doneStone=this._doneStone.getValue();a.goalMirror=this._goalMirror.getValue();a.doneMirror=this._doneMirror.getValue();a.goalFrog=this._goalFrog.getValue();a.doneFrog=this._doneFrog.getValue();return a},load:function(a){this._totalMoves.setValue(a.totalMoves);this._spendMoves.setValue(a.spendMoves);this._goalMoves.setValue(a.goalMoves);this._goalBackground.setValue(a.goalBackground);
this._doneBackground.setValue(a.doneBackground);this._goalTreasure.setValue(a.doneTreasure);this._doneTreasure.setValue(a.doneTreasure);this._goalTorch.setValue(a.doneTorch);this._doneTorch.setValue(a.doneTorch);this._goalBeetle.setValue(a.goalBeetle);this._doneBeetle.setValue(a.doneBeetle);this._goalDiamond.setValue(a.goalDiamond);this._doneDiamond.setValue(a.doneDiamond);this._goalIceCube.setValue(a.goalIceCube);this._doneIceCube.setValue(a.doneIceCube);this._goalButterfly.setValue(a.goalButterfly);
this._doneButterfly.setValue(a.doneButterfly);this._goalRainbow.setValue(a.goalRainbow);this._doneRainbow.setValue(a.doneRainbow);this._goalRowBlast.setValue(a.goalRowBlast);this._doneRowBlast.setValue(a.doneRowBlast);this._goalColumnBlast.setValue(a.goalColumnBlast);this._doneColumnBlast.setValue(a.doneColumnBlast);this._goalCrossBlast.setValue(a.goalCrossBlast);this._doneCrossBlast.setValue(a.doneCrossBlast);this._goalStone.setValue(a.goalStone);this._doneStone.setValue(a.doneStone);this._goalMirror.setValue(a.goalMirror);
this._doneMirror.setValue(a.doneMirror);this._goalFrog.setValue(a.goalFrog);this._doneFrog.setValue(a.doneFrog)}});Client.Guide=cc.Node.extend({_ext:null,_grid:null,_data:null,ctor:function(a,b){this._super();this._grid=a;this._data=b;this._ext=new CExtNode(this);this._ext.addCustomListener(Client.EVENT.UPDATE_GOAL,this.eventHandler.bind(this));this.setCascadeOpacityEnabled(!0);var c=new cc.Sprite,d=new cc.ClippingNode(c);d.setCascadeOpacityEnabled(!0);d.setInverted(!0);d.addChild(new cc.LayerColor(new cc.Color(0,0,0,224.4)));this.addChild(d);a.activeCell(!1);if(b.cell){d=b.cell.split(",").map(function(a){a=a.split(":");
return{x:Number(a[0])||0,y:Number(a[1])||0}});var e=a.getPosition(),f=Client.Grid.getCSize(),g=new cc.Color(0,0,0,255);for(m in d){var h=d[m],k=new cc.LayerColor(g,f.width,f.height);k.setPosition(Client.Grid.getPointX(h.x)+e.x,Client.Grid.getPointY(h.y)+e.y);c.addChild(k)}}if(b.lb){c=b.lb.split(",");e=c[1].split(":");c=c[0];var m=Number(e[0])||0;d=Number(e[1])||0;f=Number(e[2])||0;e=new cc.Node;e.addChild(new cc.Sprite(Resource.CLIENT.ui("avatar")));e.setPosition(m,d);c=new CLabelTTF(Lang.getString(Lang.CL_TUTORIAL(c)),
22,f,1);c.setAlignment(cc.TEXT_ALIGNMENT_LEFT,cc.VERTICAL_TEXT_ALIGNMENT_CENTER);c.setAnchorPoint(0,.5);c.setPosition(55,0);e.addChild(c);this.addChild(e)}1==b.skip&&(c=new CButtonSprite(Resource.CLIENT.ui("skip_normal"),Resource.CLIENT.ui("skip_hover"),Resource.CLIENT.ui("skip_hover")),c.setPosition(690,50),c.setCbUp(this.close.bind(this)),this.addChild(c));b.close&&this.runAction(new cc.Sequence(new cc.DelayTime(Number(b.close)),new cc.RemoveSelf));b.hint&&(c=b.hint.split(",").map(function(a){a=
a.split(":");return{x:Number(a[0])||0,y:Number(a[1])||0}}),a.activeCell(!0,c),this.runAction(new cc.Sequence(new cc.DelayTime(1),new cc.CallFunc(a.showSuggestion.bind(a,c[0],c[1])))));cc.eventManager.addListener({event:cc.EventListener.MOUSE,onMouseMove:this.mouseEvent.bind(this),onMouseDown:this.mouseEvent.bind(this)},this)},mouseEvent:function(a){var b=this._grid.convertToNodeSpace(a.getLocation());b=Client.Grid.getTile(b);(b=this._grid.getCell(b.x,b.y))&&b.isEnabled()&&b.isActive()||a.stopPropagation()},
show:function(){app.Scene.getCurrent().addChild(this);this.setOpacity(0);this.runAction(new cc.FadeTo(.2,255))},close:function(){this.removeFromParent()},removeFromParent:function(){this._super();this._grid.activeCell(!0);cc.eventManager.dispatchCustomEvent(Client.EVENT.GUIDE_CLOSED,this)},eventHandler:function(a){a.getEventName()==Client.EVENT.UPDATE_GOAL&&Number(this._data.spend)<this._grid.getGoal().getSpendMoves()&&this.removeFromParent()}});Client.Info=cc.Class.extend({_ego:null,ctor:function(){this._ego=0},ego:function(){return this._ego},ego_update:function(a){this._ego+=Number(a)}});Client.Jewel=cc.Node.extend({_code:null,_enigma:null,_state:null,_cell:null,_controller:null,_ui:null,_swapRef:null,_locks:0,ctor:function(a,b,c){this._super();this._controller=new JController;this._code=this.fixCode(a);this._enigma=c?this.fixCode(c):null;this._state=[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];this._locks=0;this.setCell(b);this.setPosition(b.getCenter());this.updateUI();this.setLocks(this._code[4]);this.setCascadeOpacityEnabled(!0)},runJAction:function(a){this.setSelect(!1);switch(a.getType()){case JAction.SWAP:case JAction.BOMB:case JAction.FIREBLAST:case JAction.LIGHTING:case JAction.TORNADO:case JAction.CROSSDESTROYER:case JAction.EXPLODE:case JAction.RAINBOW:case JAction.MAGNET:case JAction.FROG:return this._cell.getController().addJAction(a),
!0;case JAction.BONUS:case JAction.MOVE:return this._controller.addJAction(a),!0;default:cc.assert(!1,"runJAction")}return!1},execJAction:function(a,b){switch(this._code[0]){case JType.MAGNET:case JType.FREEZE:case JType.TITANIUM:case JType.TREASURE:break;case JType.RAINBOW:if(JRelation.allowActionRainbow(this)){var c=this.getUState();if(b&&b.hasOwnProperty("expType")&&JLogic.getRainbowState(b.expType,c)!=c)return a||this.runJAction(new JAction.Rainbow(this,b)),!0}break;case JType.DIAMOND:case JType.CHAMELEON:case JType.TORCH:if(this._code[0]==
JType.TORCH&&"0"==this._code[5])break;if(this._code[0]==JType.CHAMELEON&&"1"==this._code[5])break;if(this._code[0]==JType.DIAMOND&&"1"==this._code[5])break;case JType.ICECUBE:case JType.BUTTERFLY:case JType.BEETLE:case JType.PETRIFIER:case JType.STONE:case JType.MIRROR:case JType.FROG:case JType.ENIGMA:case JType.SHELL:case JType.PEARL:case JType.MAGICBALL:case JType.FROZEN:case JType.SIMPLE:if(JRelation.allowActionExplode(this))return a||this.runJAction(new JAction.Explode(this,b)),!0;break;case JType.BONUS:if(this.isLocked()){if(JRelation.allowActionExplode(this))return a||
this.runJAction(new JAction.Explode(this,b)),!0;break}else switch(this._code[3]){case JBonus.A:return JRelation.allowActionExplode(this)?(a||this.runJAction(new JAction.Explode(this,b)),!0):!1;case JBonus.B:return JRelation.allowActionTornado(this)?(a||this.runJAction(new JAction.Tornado(this)),!0):!1;case JBonus.D:return JRelation.allowActionBomb(this)?(a||this.runJAction(new JAction.Bomb(this),b),!0):!1;case JBonus.E:return JRelation.allowActionLighting(this)?(a||this.runJAction(new JAction.Lighting(this,
b)),!0):!1;case JBonus.F:return JRelation.allowActionCrossDestroyer(this)?(a||this.runJAction(new JAction.CrossDestroyer(this,0,b)),!0):!1;case JBonus.G:return JRelation.allowActionCrossDestroyer(this)?(a||this.runJAction(new JAction.CrossDestroyer(this,1,b)),!0):!1;case JBonus.H:return JRelation.allowActionCrossDestroyer(this)?(a||this.runJAction(new JAction.CrossDestroyer(this,2,b)),!0):!1;case JBonus.J:return JRelation.allowActionExplode(this)?(a||this.runJAction(new JAction.Explode(this,b)),!0):
!1;case JBonus.I:return JRelation.allowActionFireBlast(this)?(a||this.runJAction(new JAction.FireBlast(this,b)),!0):!1;default:cc.assert(!1,"bad code[%s]",this._code[3])}default:cc.assert(!1,"bad code[%s]",this._code[0])}return!1},setSelect:function(a){this._ui&&this._ui.setSelect(a)},setLocks:function(a){this._code[4]=a;a=JRelation.isApplyLock(this)?a:0;null!=this._ui&&(this._ui.getLocks()>a&&this._cell&&AudioEngine.playEffect(Resource.SND.CL_OPEN_LOCK),this._ui.setLocks(a));this.setState(JState.LOCKED,
0!=a)},getLocks:function(){return null==this._ui?0:this._ui.getLocks()},isLocked:function(){return 0!=this.getLocks()},setUState:function(a){this._ui&&this._ui.setState(a);this._code[5]=a},getUState:function(){return this._ui?this._ui.getState():0},isState:function(a){cc.assert(a);return 1==this._state[a]},setState:function(a,b){cc.assert(void 0!=a&&void 0!=b);a!=JState.NONE&&(this._state[a]=1==b?1:0)},getStates:function(){return this._state},getController:function(){return this._controller},setCell:function(a){this._cell=
a;this.setState(JState.EMPTY,null==a)},getCell:function(){return this._cell},hasCell:function(){return null!=this._cell},setSwapRef:function(a){this._swapRef=a},getSwapRef:function(){return this._swapRef},getCodeEnigma:function(){return this._enigma},getCode:function(a){return void 0===a?this._code:this._code[a]},setCode:function(a){cc.assert(7==a.length);this._code=a;this.updateUI()},updateCode:function(a,b){this._code[a]=b},fixCode:function(a){"1"!=a[1]&&JShape.isAllowed(a[1])||(a[1]=JShape.getRandom());
"1"==a[2]&&(a[2]=JRuby.getRandom());"1"==a[3]&&(a[3]=JBonus.getRandom());a[0]==JType.RAINBOW&&"0"==a[5]&&(a[5]=63);return a},isJType:function(a){cc.assert(a);return this._code[0]==a},buildUI:function(a){switch(a[0]){case JType.SIMPLE:return new Client.Jewel.Simple(a);case JType.BONUS:return new Client.Jewel.Bonus(a);case JType.TITANIUM:return new Client.Jewel.Titanium(a);case JType.TREASURE:return new Client.Jewel.Treasure(a);case JType.STONE:return new Client.Jewel.Stone(a);case JType.TORCH:return new Client.Jewel.Torch(a);
case JType.FROZEN:return new Client.Jewel.Frozen(a);case JType.PETRIFIER:return new Client.Jewel.Petrifier(a);case JType.BEETLE:return new Client.Jewel.Beetle(a);case JType.BUTTERFLY:return new Client.Jewel.Butterfly(a);case JType.DIAMOND:return new Client.Jewel.Diamond(a);case JType.RAINBOW:return new Client.Jewel.Rainbow(a);case JType.ICECUBE:return new Client.Jewel.IceCube(a);case JType.CHAMELEON:return new Client.Jewel.Chameleon(a);case JType.ENIGMA:return new Client.Jewel.Enigma(a);case JType.MIRROR:return new Client.Jewel.Mirror(a);
case JType.FROG:return new Client.Jewel.Frog(a);case JType.MAGICBALL:return new Client.Jewel.MagicBall(a);case JType.PEARL:return new Client.Jewel.Pearl(a);case JType.SHELL:return new Client.Jewel.Shell(a);case JType.MAGNET:return new Client.Jewel.Magnet(a);case JType.FREEZE:return new Client.Jewel.Freeze(a)}cc.assert(!1)},hasUI:function(){return null!=this._ui},remUI:function(){null!=this._ui&&(this._ui.removeFromParent(),this._ui=null)},updateUI:function(a,b){b=b||.1;if(1==a){var c=this,d=c._ui;
c._ui=c.buildUI(c._code);c._ui.setOpacity(0);c.addChild(c._ui);c.setLocks(c._code[4]);null!=d&&d.runAction(new cc.Sequence(new cc.FadeTo(b,50),new cc.RemoveSelf));c._ui.runAction(new cc.Sequence([new cc.CallFunc(function(){c.setState(JState.TRANSFORM,!0)}),new cc.FadeTo(b+.1,255),new cc.DelayTime(.2),new cc.CallFunc(function(){c.setState(JState.TRANSFORM,!1);c.setState(JState.MATCH_ON,!0)})]))}else this._ui&&this._ui.removeFromParent(),this._ui=this.buildUI(this._code),this.addChild(this._ui),this.setLocks(this._code[4]),
this.setState(JState.TRANSFORM,!1),this.setState(JState.MATCH_ON,!0)},infect:function(){var a;var b=this._code;var c=this._cell.getGrid();var d=this._cell.getTile(),e=[];var f=a=null;if(b[0]==JType.FROZEN||b[0]==JType.PETRIFIER){(f=c.getJewel(d.x-1,d.y-1))&&f.isJType(JType.SIMPLE)&&e.push(f);(f=c.getJewel(d.x-1,d.y+1))&&f.isJType(JType.SIMPLE)&&e.push(f);(f=c.getJewel(d.x-1,d.y))&&f.isJType(JType.SIMPLE)&&e.push(f);(f=c.getJewel(d.x+1,d.y-1))&&f.isJType(JType.SIMPLE)&&e.push(f);(f=c.getJewel(d.x+
1,d.y+1))&&f.isJType(JType.SIMPLE)&&e.push(f);(f=c.getJewel(d.x+1,d.y))&&f.isJType(JType.SIMPLE)&&e.push(f);(f=c.getJewel(d.x,d.y-1))&&f.isJType(JType.SIMPLE)&&e.push(f);(f=c.getJewel(d.x,d.y+1))&&f.isJType(JType.SIMPLE)&&e.push(f);b[0]==JType.PETRIFIER&&(e=e.filter(function(a){return 0==a.getLocks()}));if(0==e.length)return!1;f=e[CUtils.random(0,e.length-1)];this.setLocalZOrder(f.getLocalZOrder()+1);if(b[0]==JType.FROZEN){c=[];for(b=0;10>b;b++){var g=Resource.CLIENT.jewel_infect("frozen",b);c.push(cc.spriteFrameCache.getSpriteFrame(g))}a=
new cc.Sprite(c[0]);a.setAnchorPoint(.81,.18);a.setRotation(135-CUtils.getAngle(this.getPosition(),f.getPosition(),!1));a.runAction(new cc.Sequence(new cc.Animate(new cc.Animation(c,.03)),new cc.RemoveSelf));this.addChild(a);f.updateCode(0,JType.FROZEN);f.updateUI(!0);AudioEngine.playEffect(Resource.SND.CL_FROZEN)}else if(b[0]==JType.PETRIFIER){c=[];for(b=0;12>b;b++)g=Resource.CLIENT.jewel_infect("petrifier",b),c.push(cc.spriteFrameCache.getSpriteFrame(g));a=new cc.Sprite(c[0]);a.setAnchorPoint(.34,
.5);a.setRotation(-CUtils.getAngle(this.getPosition(),f.getPosition(),!1));a.runAction(new cc.Sequence(new cc.Animate(new cc.Animation(c,.035)),new cc.RemoveSelf));a.runAction(new cc.Sequence(new cc.DelayTime(.15),new cc.CallFunc(f.updateUI,f,!0)));this.addChild(a);f.updateCode(0,JType.STONE);f.updateCode(2,"0");f.updateCode(3,"0");f.updateCode(5,f.getCode(4));f.updateCode(4,"0");AudioEngine.playEffect(Resource.SND.CL_PETRIFIER)}return!0}if(b[0]==JType.ICECUBE){(f=c.getCell(d.x,d.y-1))&&f.isEnabled()&&
JRelation.isApllyIceCube(f)&&e.push(f);(f=c.getCell(d.x,d.y+1))&&f.isEnabled()&&JRelation.isApllyIceCube(f)&&e.push(f);(f=c.getCell(d.x+1,d.y))&&f.isEnabled()&&JRelation.isApllyIceCube(f)&&e.push(f);(f=c.getCell(d.x-1,d.y))&&f.isEnabled()&&JRelation.isApllyIceCube(f)&&e.push(f);if(0==e.length)return!1;f=e[CUtils.random(0,e.length-1)];c=f.getTile();a=new Client.Jewel.IceCubeInfect(d.x==c.x?d.y>c.y?3:2:d.x>c.x?1:0);a.setLocalZOrder(1E3);a.setPosition(f.getCenter());a.runAction(new cc.Sequence(new cc.DelayTime(.4),
new cc.RemoveSelf));f.getGrid().addChild(a);(c=f.getJewel())?(this.setLocalZOrder(c.getLocalZOrder()+1),c.updateCode(0,JType.ICECUBE),c.updateCode(2,"0"),c.updateCode(3,"0"),c.updateCode(4,"0"),c.updateCode(5,"0"),c.setLocalZOrder(0),c.runAction(new cc.Sequence(new cc.FadeOut(.28),new cc.CallFunc(c.updateUI,c),new cc.FadeIn(0)))):(c=new Client.Jewel(b,f),c.setLocalZOrder(0),c.setOpacity(0),c.runAction(new cc.Sequence(new cc.DelayTime(.4),new cc.FadeIn(0))),f.addJewel(c),f.getGrid().addChild(c));return!0}if(b[0]==
JType.CHAMELEON){if("0"==b[5]&&this.isLocked())return;this.updateCode(5,"0"==b[5]?"1":"0");this.updateUI(!0,.2)}else{if(b[0]==JType.ENIGMA){if(!this._enigma)return!1;this._code=this._enigma;this._enigma=null;this.updateUI(!0,.1);return!0}if(b[0]==JType.SHELL){b=this._code;this._code=this.fixCode("p0000000".split(""));c=[];for(b=0;8>b;b++)g=Resource.CLIENT.jewel_infect("shell",b),c.push(cc.spriteFrameCache.getSpriteFrame(g));a=new cc.Sprite(c[0]);a.runAction(new cc.Sequence(new cc.CallFunc(this.setState.bind(this,
JState.TRANSFORM,1),this),new cc.Animate(new cc.Animation(c,.055)),new cc.CallFunc(this.updateUI.bind(this,!1,0),this),new cc.CallFunc(this.setState.bind(this,JState.TRANSFORM,0),this),new cc.CallFunc(function(){for(var a=[],b=this._cell.getGrid(),c=0;8>c;c++)for(var d=0;8>d;d++){var e=b.getJewel(c,d);null!=e&&e!=this&&JRelation.isApplyShell(e)&&a.push(e)}0<a.length&&(a=a[CUtils.random(0,a.length-1)],a.updateCode(0,JType.SHELL),a.updateUI(!0))},this),new cc.RemoveSelf));this.addChild(a);return!0}if(b[0]==
JType.FROG)return this.runJAction(new JAction.Frog(this)),!0;if(b[0]==JType.MAGICBALL&&2>this.getUState())this.setUState(this.getUState()+1);else if(b[0]==JType.FREEZE){f=this._cell.getTile();d=a=f.x;var h=e=f.y;c=this._cell.getGrid();var k=this.getCode(5);b=[this._cell];var m=null;if(0==k||2==k){for(;m=c.getCell(a-1,f.y);)--a,b.push(m);for(;m=c.getCell(d+1,f.y);)d+=1,b.push(m)}if(1==k||2==k){for(;m=c.getCell(f.x,e-1);)--e,b.push(m);for(;m=c.getCell(f.x,h+1);)h+=1,b.push(m)}if(this.isState(JState.FREEZE))for(g in this._ui.unfreeze(),
b){if(b[g].setEnabled(!0),f=b[g].getJewel())f.setState(JState.FREEZE,!1),f.setState(JState.MATCH_ON,!0)}else{this._ui.freeze(f.x-Math.max(0,a),Math.min(7,d)-f.x,Math.min(7,h)-f.y,f.y-Math.max(0,e));for(g in b)if(b[g].setEnabled(!1),f=b[g].getJewel())f.setLocalZOrder(0),f.setState(JState.FREEZE,!0);this.setLocalZOrder(64)}}}return!1},addInitEfect:function(){for(var a=[],b=0;9>b;b++){var c=Resource.CLIENT.jewel_efect("1",b);a.push(cc.spriteFrameCache.getSpriteFrame(c))}b=new cc.Sprite(a[0]);b.runAction(new cc.Sequence(new cc.Animate(new cc.Animation(a,
.055)),new cc.RemoveSelf));b.setPosition(0,0);this.addChild(b,10)},rubyHighlight:function(a){this._ui&&this.isJType(JType.SIMPLE)&&0!=this._code[2]&&this._ui.rubyHighlight(a)}});Client.Jewel.JBase=cc.Node.extend({_code:null,_shape:null,_ruby:null,_rubyAnim:null,_locks:null,_background:null,_select:null,_state:0,ctor:function(a){this._super();this._code=a;this._state=0;this.setCascadeOpacityEnabled(!0)},build:function(){},getCode:function(){return this._code},setLocks:function(a){if(0<a){if(a<this.getLocks()){for(var b=[],c=0;6>c;c++){var d=Resource.CLIENT.jewel_efect("0",c);b.push(cc.spriteFrameCache.getSpriteFrame(d))}c=new cc.Sprite(b[0]);c.runAction(new cc.Sequence(new cc.Animate(new cc.Animation(b,
.028)),new cc.RemoveSelf));c.setScale(1.7);c.setPosition(15,0);this.addChild(c,100)}null!=this._locks?(this._locks.setSpriteFrame(Resource.CLIENT.jewel_lock(a-1)),this._locks.setTag(a)):(this._locks=new cc.Sprite(Resource.CLIENT.jewel_lock(a-1)),this._locks.setLocalZOrder(10),this._locks.setTag(a),this.addChild(this._locks))}else null!=this._locks&&(this._locks.removeFromParent(),this._locks=null)},getLocks:function(){return null==this._locks?0:this._locks.getTag()},setShape:function(a){null!=a&&
"0"!=a?null!=this._shape?this._shape.setSpriteFrame(Resource.CLIENT.jewel_simple(a)):(this._shape=new cc.Sprite(Resource.CLIENT.jewel_simple(a)),this._shape.setLocalZOrder(0),this.addChild(this._shape)):null!=this._shape&&(this._shape.removeFromParent(),this._shape=null)},setRuby:function(a){null!=a&&"0"!=a?null!=this._ruby?this._ruby.setSpriteFrame(Resource.CLIENT.jewel_ruby(a)):(this._ruby=new cc.Sprite(Resource.CLIENT.jewel_ruby(a)),this._ruby.setLocalZOrder(2),this.addChild(this._ruby)):null!=
this._ruby&&(this._ruby.removeFromParent(),this._ruby=null,this._rubyAnim&&(this._rubyAnim.removeFromParent(),this._rubyAnim=null))},rubyHighlight:function(a){if(!this._rubyAnim&&a){a=[];for(var b=0;10>b;b++){var c=Resource.CLIENT.jewel_efect("2",b);a.push(cc.spriteFrameCache.getSpriteFrame(c))}this._rubyAnim=new cc.Sprite(a[0]);this._rubyAnim.runAction(new cc.RepeatForever(new cc.Animate(new cc.Animation(a,.055))));this._rubyAnim.setPosition(0,0);this._rubyAnim.setScale(.7);this.addChild(this._rubyAnim,
2)}else this._rubyAnim&&!a&&(this._rubyAnim.removeFromParent(),this._rubyAnim=null)},setBackground:function(a){0<a?null!=this._background?this._background.setSpriteFrame(Resource.CLIENT.jewel_background(a-1)):(this._background=new CSprite(Resource.CLIENT.jewel_background(a-1)),this._background.setLocalZOrder(0),this._background.runAction(new cc.RepeatForever(new cc.Sequence(new cc.ActionTween(1,"brightness",0,.15),new cc.ActionTween(1,"brightness",.15,0)))),this.addChild(this._background)):null!=
this._background&&(this._background.removeFromParent(),this._background=null)},hasRuby:function(){return null!=this._ruby},setSelect:function(a){a&&null==this._select?(this._select=new cc.Sprite(Resource.CLIENT.jewel_select),this._select.setLocalZOrder(0),this.addChild(this._select)):a||null==this._select||(this._select.removeFromParent(),this._select=null)},isSelect:function(){return null!=this._select},setState:function(a){this._state=a},getState:function(){return this._state}});Client.Jewel.Background=Client.Jewel.JBase.extend({ctor:function(a){this._super(a);this.build()},build:function(){this._super();this.setState(this._code[6])},setState:function(a){this._super(a);this.setBackground(a)}});Client.Jewel.Beetle=Client.Jewel.JBase.extend({_ice:null,ctor:function(a){this._super(a);this.build()},build:function(){this._super();this.setShape(this._code[1]);this.setState(this._code[5]);this.setRuby(null);this.setLocks(0)},setShape:function(a){null!=this._shape?this._shape.setSpriteFrame(Resource.CLIENT.jewel_beetle(a)):(this.addChild(new cc.Sprite(Resource.CLIENT.jewel_beetle("0"))),this._shape=new cc.Sprite(Resource.CLIENT.jewel_beetle(a)),this._shape.setLocalZOrder(0),this.addChild(this._shape))},
setState:function(a){this._super(a=Math.min(2,a));0<a?null!=this._ice?this._ice.setSpriteFrame(Resource.CLIENT.jewel_beetle(a)):(this._ice=new cc.Sprite(Resource.CLIENT.jewel_beetle(a)),this._ice.setLocalZOrder(2),this.addChild(this._ice)):null!=this._ice&&(this._ice.removeFromParent(),this._ice=null)}});Client.Jewel.BeetleFly=cc.Sprite.extend({ctor:function(a){this._super(Resource.CLIENT.jewel_beetle(a));var b=new cc.Sprite(Resource.CLIENT.jewel_beetle(4));b.setPosition(.48*this.getContentSize().width,.37*this.getContentSize().height);this.addChild(b);b=new cc.Sprite(Resource.CLIENT.jewel_beetle(3));b.setAnchorPoint(.86,.9);b.setRotation(-22);b.setPosition(.39*this.getContentSize().width,.45*this.getContentSize().height);b.runAction(new cc.RepeatForever(new cc.Sequence(new cc.RotateTo(.1,0),new cc.RotateTo(.1,
b.getRotation()))));this.addChild(b);b=new cc.Sprite(Resource.CLIENT.jewel_beetle(3));b.setFlippedX(!0);b.setAnchorPoint(.14,.9);b.setRotation(22);b.setPosition(.58*this.getContentSize().width,.45*this.getContentSize().height);b.runAction(new cc.RepeatForever(new cc.Sequence(new cc.RotateTo(.1,0),new cc.RotateTo(.1,b.getRotation()))));this.addChild(b);b=new cc.Sprite(Resource.CLIENT.jewel_beetle(3));b.setAnchorPoint(.87,.92);b.setRotation(-20);b.setScale(.9);b.setPosition(.36*this.getContentSize().width,
.5*this.getContentSize().height);b.runAction(new cc.RepeatForever(new cc.Sequence(new cc.RotateTo(.1,0),new cc.RotateTo(.1,b.getRotation()))));this.addChild(b);b=new cc.Sprite(Resource.CLIENT.jewel_beetle(3));b.setFlippedX(!0);b.setAnchorPoint(.13,.92);b.setRotation(20);b.setScale(.9);b.setPosition(.6*this.getContentSize().width,.5*this.getContentSize().height);b.runAction(new cc.RepeatForever(new cc.Sequence(new cc.RotateTo(.1,0),new cc.RotateTo(.1,b.getRotation()))));this.addChild(b);b=new cc.Sprite(Resource.CLIENT.jewel_beetle("wing_"+
a));b.setAnchorPoint(.9,.95);b.setRotation(-32);b.setPosition(.4*this.getContentSize().width,.59*this.getContentSize().height);b.runAction(new cc.RotateTo(.1,0));this.addChild(b);a=new cc.Sprite(Resource.CLIENT.jewel_beetle("wing_"+a));a.setAnchorPoint(.1,.95);a.setFlippedX(!0);a.setRotation(32);a.setPosition(.55*this.getContentSize().width,.59*this.getContentSize().height);a.runAction(new cc.RotateTo(.1,0));this.addChild(a)}});Client.Jewel.Bonus=Client.Jewel.JBase.extend({_bonus:null,ctor:function(a){this._super(a);this.build()},build:function(){this._super();this.setShape(this._code[1]);this.setRuby(null);this.setBonus(this._code[3]);this.setLocks(this._code[4]);for(var a=[],b=0;6>b;b++){var c=Resource.CLIENT.jewel_efect("0",b);a.push(cc.spriteFrameCache.getSpriteFrame(c))}for(b=5;0<=b;b--)c=Resource.CLIENT.jewel_efect("0",b),a.push(cc.spriteFrameCache.getSpriteFrame(c));c=new cc.Sprite(a[0]);c.runAction(new cc.Sequence(new cc.Animate(new cc.Animation(a,
.028)),new cc.RemoveSelf));c.setScale(2.5);c.setPosition(15,0);this.addChild(c,100)},setBonus:function(a){cc.assert(void 0!=a);null!=this._bonus?this._bonus.setSpriteFrame(Resource.CLIENT.jewel_bonus(a)):(this._bonus=new cc.Sprite(Resource.CLIENT.jewel_bonus(a)),this._bonus.setPosition(-.5,0),this._bonus.setLocalZOrder(3),this.addChild(this._bonus))}});Client.Jewel.Butterfly=Client.Jewel.JBase.extend({ctor:function(a){this._super(a);this.build()},build:function(){this._super();this.setState(this._code[5]);this.setRuby(null);this.setLocks(0)},setShape:function(a){null!=this._shape?this._shape.setSpriteFrame(Resource.CLIENT.jewel_butterfly(a)):(this._shape=new cc.Sprite(Resource.CLIENT.jewel_butterfly(a)),this._shape.setLocalZOrder(0),this.addChild(this._shape))},setState:function(a){this._super(Math.min(1,a));this.setShape(this.getState())}});Client.Jewel.ButterflyFly=cc.Sprite.extend({ctor:function(){this._super(Resource.CLIENT.jewel_butterfly(0));this.runAction(new cc.RepeatForever(new cc.Sequence((new cc.ScaleTo(.17,.3,1)).easing(cc.easeSineOut()),(new cc.ScaleTo(.15,1,1)).easing(cc.easeSineIn()))))}});Client.Jewel.Chameleon=Client.Jewel.JBase.extend({_blick:null,ctor:function(a){this._super(a);this.build()},build:function(){this._super();"0"==this._code[5]?(this.setShape(this._code[1]),this.setRuby(JRuby.CH)):(this.setShape(null),this.setRuby(null));this.setLocks(0)},setShape:function(a){null!=a?(this._super(a),null==this._blick&&(this._blick=new cc.Sprite(Resource.CLIENT.jewel_chameleon),this._blick.setLocalZOrder(1),this._blick.setRotation(CUtils.random(90,270)),this._blick.runAction(new cc.RepeatForever(new cc.Sequence(new cc.FadeOut(1.2),
new cc.FadeTo(1.4,240))))),this._blick.removeFromParent(),this.addChild(this._blick)):null!=this._shape?this._shape.setSpriteFrame(Resource.CLIENT.jewel_titan):(this._shape=new cc.Sprite(Resource.CLIENT.jewel_titan),this._shape.setLocalZOrder(0),this.addChild(this._shape))}});Client.Jewel.Diamond=Client.Jewel.JBase.extend({ctor:function(a){this._super(a);this.build()},build:function(){this._super();this.setState(this._code[5]);this.setRuby(null);this.setLocks(0)},setShape:function(a){null!=this._shape?this._shape.setSpriteFrame(Resource.CLIENT.jewel_diamond(a)):(this._shape=new cc.Sprite(Resource.CLIENT.jewel_diamond(a)),this._shape.setLocalZOrder(0),this.addChild(this._shape))},setState:function(a){this._super(Math.min(2,a));this.setShape(this.getState())}});Client.Jewel.Frozen=Client.Jewel.JBase.extend({_show:null,ctor:function(a){this._super(a);this.build()},build:function(){this._super();this.setShape(this._code[1]);this.setRuby(this._code[2]);this.setLocks(this._code[4]);this._show=new cc.Sprite(Resource.CLIENT.jewel_snow);this._show.setLocalZOrder(3);this.addChild(this._show)}});Client.Jewel.IceCube=Client.Jewel.JBase.extend({ctor:function(a){this._super(a);this.build()},build:function(){this._super();this.setShape(null);this.setRuby(null);this.setLocks(0)},setShape:function(a){null!=this._shape?this._shape.setSpriteFrame(Resource.CLIENT.jewel_icecube):(this._shape=new cc.Sprite(Resource.CLIENT.jewel_icecube),this._shape.setLocalZOrder(0),this.addChild(this._shape))}});Client.Jewel.IceCubeInfect=cc.Node.extend({_size:null,_mask:null,_stencil:null,_icon:null,_anim:null,ctor:function(a){this._super();this._size=Client.Grid.getCSize();this._stencil=new cc.Sprite(Resource.CLIENT.jewel_icecube);this._icon=new cc.Sprite(Resource.CLIENT.jewel_icecube);this._mask=new cc.ClippingNode(this._stencil);this._mask.addChild(this._icon);for(var b=[],c=0;12>c;c++){var d=Resource.CLIENT.jewel_infect("icecube",c);b.push(cc.spriteFrameCache.getSpriteFrame(d))}this._anim=new cc.Sprite(b[0]);
this._anim.runAction(new cc.Sequence(new cc.Animate(new cc.Animation(b,.03)),new cc.RemoveSelf));this.setContentSize(this._size);this.setAnchorPoint(.5,.5);this.addChild(this._mask);this.addChild(this._anim);0==a?(this._stencil.setAnchorPoint(0,0),this._stencil.setScaleX(0),this._icon.setAnchorPoint(0,0),this._anim.setPosition(.5*this._size.width,.5*this._size.height),this.runAction(new cc.ActionTween(.3,"scaleX",0,1))):1==a?(this._stencil.setAnchorPoint(0,0),this._stencil.setScaleX(0),this._icon.setAnchorPoint(1,
1),this._icon.setRotation(180),this._anim.setPosition(.5*this._size.width,.5*this._size.height),this.runAction(new cc.ActionTween(.3,"scaleX",0,1)),this.setRotation(180)):2==a?(this._stencil.setAnchorPoint(0,0),this._stencil.setScaleY(0),this._icon.setAnchorPoint(0,0),this._anim.setPosition(.5*this._size.width,.5*this._size.height),this._anim.setRotation(-90),this.runAction(new cc.ActionTween(.32,"scaleY",0,1))):(this._stencil.setAnchorPoint(0,0),this._stencil.setScaleY(0),this._icon.setAnchorPoint(1,
1),this._icon.setRotation(180),this._anim.setPosition(.5*this._size.width,.5*this._size.height),this._anim.setRotation(-90),this.runAction(new cc.ActionTween(.32,"scaleY",0,1)),this.setRotation(180))},updateTweenAction:function(a,b){"scaleX"==b?(this._stencil.setScaleX(a),this._mask.visit()):"scaleY"==b&&(this._stencil.setScaleY(a),this._mask.visit())}});Client.Jewel.Petrifier=Client.Jewel.JBase.extend({_anim:null,ctor:function(a){this._super(a);this.build()},build:function(){this._super();this.setShape(null)},setShape:function(a){null==this._shape&&(this._shape=new cc.Sprite(Resource.CLIENT.jewel_petrifier(0)),this.addChild(this._shape),this._anim=new cc.Sprite(Resource.CLIENT.jewel_petrifier(1)),this._anim.runAction(new cc.RepeatForever(new cc.Sequence(new cc.RotateTo(1,-180),new cc.RotateTo(1,-360)))),this.addChild(this._anim))}});Client.Jewel.Rainbow=Client.Jewel.JBase.extend({_node:null,ctor:function(a){this._super(a);this.build()},build:function(){this._super();this._node=new cc.Node;this.setShape(null);this.setState(this._code[5]);this.setRuby(null);this.setLocks(0)},setShape:function(a){this._state||(this._shape=new cc.Sprite(Resource.CLIENT.jewel_rainbow(0)),this._shape.setLocalZOrder(0),this.addChild(this._shape),this.addChild(this._node),this.addChild(new cc.Sprite(Resource.CLIENT.jewel_rainbow(1))))},setState:function(a){this._super(a);
var b=[],c=[];0!=(a&1)||this._node.getChildByName("a")||c.push("a");0!=(a&2)||this._node.getChildByName("b")||c.push("b");0!=(a&4)||this._node.getChildByName("c")||c.push("c");0!=(a&8)||this._node.getChildByName("d")||c.push("d");0!=(a&16)||this._node.getChildByName("e")||c.push("e");0!=(a&32)||this._node.getChildByName("f")||c.push("f");for(a=0;5>a;a++)this._node.getChildByTag(a)||b.push(a);for(a=0;a<c.length&&0!=b.length;a++){var d=b.splice(CUtils.random(0,b.length-1),1)[0],e=new cc.Sprite(Resource.CLIENT.jewel_rainbow(c[a]));
e.setName(c[a]);e.setTag(d);0==d?e.setPosition(0,11):1==d?(e.setPosition(14,1),e.setRotation(79)):2==d?(e.setPosition(9,-14),e.setRotation(141)):3==d?(e.setPosition(-8,-15),e.setRotation(226)):4==d&&(e.setPosition(-13,1),e.setRotation(284));this._node.addChild(e)}}});Client.Jewel.Stone=Client.Jewel.JBase.extend({ctor:function(a){this._super(a);this.build()},build:function(){this._super();this.setState(this._code[5]);this.setRuby(null);this.setLocks(0)},setShape:function(a){null!=this._shape?this._shape.setSpriteFrame(Resource.CLIENT.jewel_stone(a)):(this._shape=new cc.Sprite(Resource.CLIENT.jewel_stone(a)),this._shape.setLocalZOrder(0),this.addChild(this._shape))},setState:function(a){this._super(Math.min(2,a));this.setShape(this.getState())}});Client.Jewel.Titanium=Client.Jewel.JBase.extend({ctor:function(a){this._super(a);this.build()},build:function(){this._super();this.setShape("titan");this.setRuby(null);this.setLocks(0)},setShape:function(a){null!=a&&"0"!=a?null!=this._shape?this._shape.setSpriteFrame(Resource.CLIENT.jewel_titan):(this._shape=new cc.Sprite(Resource.CLIENT.jewel_titan),this._shape.setLocalZOrder(0),this.addChild(this._shape)):null!=this._shape&&(this._shape.removeFromParent(),this._shape=null)}});Client.Jewel.Torch=Client.Jewel.JBase.extend({_fire:null,ctor:function(a){this._super(a);this.build()},build:function(){this._super();this.setShape(null);this.setRuby(null);this.setLocks(0);this.setState(this._code[5])},setShape:function(a){null!=this._shape?this._shape.setSpriteFrame(Resource.CLIENT.jewel_torch):(this._shape=new cc.Sprite(Resource.CLIENT.jewel_torch),this._shape.setLocalZOrder(0),this.addChild(this._shape))},setState:function(a){this._super(a=Math.min(1,a));0!=a||this._fire?0!=a&&
this._fire&&(this._fire.removeFromParent(),this._fire=null):(this._fire=this.buildFire(),this.addChild(this._fire,1))},buildFire:function(){for(var a=new cc.Node,b=[],c=0;6>c;c++){var d=Resource.CLIENT.jewel_fire("torch",c);b.push(cc.spriteFrameCache.getSpriteFrame(d))}c=new cc.Sprite(b[0]);c.setScale(.6);d=new cc.Sprite(b[1]);d.setPosition(-1,17);d.runAction(new cc.RepeatForever(new cc.Animate(new cc.Animation(b.slice(1),.06))));a.addChild(c);a.addChild(d);return a}});Client.Jewel.Treasure=Client.Jewel.JBase.extend({ctor:function(a){this._super(a);this.build()},build:function(){this._super();this.setShape(this._code[5]);this.setRuby(null);this.setLocks(0)},setShape:function(a){null!=this._shape?this._shape.setSpriteFrame(Resource.CLIENT.jewel_treasure(a)):(this._shape=new cc.Sprite(Resource.CLIENT.jewel_treasure(a)),this._shape.setLocalZOrder(0),this.addChild(this._shape))}});Client.Jewel.Simple=Client.Jewel.JBase.extend({ctor:function(a){this._super(a);this.build()},build:function(){this._super();this.setShape(this._code[1]);this.setRuby(this._code[2]);this.setLocks(this._code[4])}});Client.Jewel.Enigma=Client.Jewel.JBase.extend({ctor:function(a){this._super(a);this.build()},build:function(){this._super();this.setState(this._code[5]);this.setRuby(null);this.setLocks(0)},setShape:function(a){null!=this._shape?this._shape.setSpriteFrame(Resource.CLIENT.jewel_enigma(a)):(this._shape=new cc.Sprite(Resource.CLIENT.jewel_enigma(a)),this._shape.setLocalZOrder(0),this.addChild(this._shape))},setState:function(a){this._super(Math.min(2,a));this.setShape(this.getState())}});Client.Jewel.Mirror=Client.Jewel.JBase.extend({ctor:function(a){this._super(a);this.build()},build:function(){this._super();this.setState(this._code[5]);this.setRuby(null);this.setLocks(0)},setShape:function(a){null!=this._shape?this._shape.setSpriteFrame(Resource.CLIENT.jewel_mirror(a)):(this._shape=new cc.Sprite(Resource.CLIENT.jewel_mirror(a)),this._shape.setLocalZOrder(0),this.addChild(this._shape))},setState:function(a){this._super(Math.min(1,a));this.setShape(this.getState())}});Client.Jewel.MagicBall=Client.Jewel.JBase.extend({ctor:function(a){this._super(a);this.build()},build:function(){this._super();this.setState(this._code[5]);this.setRuby(null);this.setLocks(0)},setShape:function(a){null!=this._shape?this._shape.setSpriteFrame(Resource.CLIENT.jewel_magicball(a)):(this._shape=new cc.Sprite(Resource.CLIENT.jewel_magicball(a)),this._shape.setLocalZOrder(0),this.addChild(this._shape))},setState:function(a){this._super(Math.min(2,a));this.setShape(this.getState())}});Client.Jewel.Frog=Client.Jewel.JBase.extend({ctor:function(a){this._super(a);this.build()},build:function(){this._super();this.setShape(null);this.setRuby(null);this.setLocks(0)},setShape:function(a){null!=this._shape?this._shape.setSpriteFrame(Resource.CLIENT.jewel_frog):(this._shape=new cc.Sprite(Resource.CLIENT.jewel_frog),this._shape.setLocalZOrder(0),this.addChild(this._shape))}});Client.Jewel.Pearl=Client.Jewel.JBase.extend({ctor:function(a){this._super(a);this.build()},build:function(){this._super();this.setShape(null);this.setRuby(null);this.setLocks(0)},setShape:function(a){null!=this._shape?this._shape.setSpriteFrame(Resource.CLIENT.jewel_pearl):(this._shape=new cc.Sprite(Resource.CLIENT.jewel_pearl),this._shape.setLocalZOrder(0),this.addChild(this._shape))}});Client.Jewel.Shell=Client.Jewel.JBase.extend({ctor:function(a){this._super(a);this.build()},build:function(){this._super();this.setShape(null);this.setRuby(null);this.setLocks(0)},setShape:function(a){null!=this._shape?this._shape.setSpriteFrame(Resource.CLIENT.jewel_shell):(this._shape=new cc.Sprite(Resource.CLIENT.jewel_shell),this._shape.setLocalZOrder(0),this.addChild(this._shape))}});Client.Jewel.Magnet=Client.Jewel.JBase.extend({ctor:function(a){this._super(a);this.build()},build:function(){this._super();this.setShape(null);this.setRuby(null);this.setLocks(0)},setShape:function(a){null!=this._shape?this._shape.setSpriteFrame(Resource.CLIENT.jewel_magnet(0)):(this._shape=new cc.Sprite(Resource.CLIENT.jewel_magnet(0)),this._shape.setLocalZOrder(0),new cc.Sprite(Resource.CLIENT.jewel_magnet(1)),this.addChild(this._shape))}});Client.Jewel.Freeze=Client.Jewel.JBase.extend({_left:[],_right:[],_top:[],_bottom:[],ctor:function(a){this._super(a);this.build()},build:function(){this._super();this.setShape(null);this.setRuby(null);this.setLocks(0)},setShape:function(a){this._shape||(this._shape=new cc.Sprite(Resource.CLIENT.jewel_freeze(0)),this._shape.setCascadeOpacityEnabled(!0),this._shape.setLocalZOrder(1),this.addChild(this._shape),a=new cc.Sprite(Resource.CLIENT.jewel_freeze(2)),a.setPosition(32,10),a.setName("bottom"),
this._shape.addChild(a),a=new cc.Sprite(Resource.CLIENT.jewel_freeze(2)),a.setPosition(32,48),a.setName("top"),a.setRotation(180),this._shape.addChild(a),a=new cc.Sprite(Resource.CLIENT.jewel_freeze(2)),a.setPosition(12,28.5),a.setName("left"),a.setRotation(90),this._shape.addChild(a),a=new cc.Sprite(Resource.CLIENT.jewel_freeze(2)),a.setPosition(51,28.5),a.setName("right"),a.setRotation(-90),this._shape.addChild(a),a=new cc.Sprite(Resource.CLIENT.jewel_freeze(1)),a.setPosition(32,28.5),this._shape.addChild(a))},
freeze:function(a,b,c,d){if(0<a){var e={x:.92,y:1.145};var f=new cc.Sprite(Resource.CLIENT.jewel_infect("freeze",0));f.setAnchorPoint(.5,1);f.setPosition(-16,0);f.setScale(e.x,e.y);f.setRotation(90);this.addChild(f,0);this._left.push(f);var g=2*a-1;for(var h=0;h<=g;h++)f=this._left[this._left.length-1],a=new cc.Sprite(Resource.CLIENT.jewel_infect("freeze",h==g?2:1)),a.runAction(new cc.Sequence([new cc.DelayTime(.03*h),new cc.FadeIn(.07)])),a.setOpacity(0),a.setAnchorPoint(.5,1),a.setPosition(f.getPositionX()-
(f.getContentSize().height-9)*e.y,0),a.setScale(e.x,e.y),a.setRotation(90),this.addChild(a),this._left.push(a);(e=this._shape.getChildByName("left"))&&e.runAction(new cc.MoveTo(.2,7,28.5))}if(0<b){e={x:.92,y:1.145};f=new cc.Sprite(Resource.CLIENT.jewel_infect("freeze",0));f.setAnchorPoint(.5,1);f.setPosition(15,0);f.setScale(e.x,e.y);f.setRotation(-90);this.addChild(f,0);this._right.push(f);g=2*b-1;for(h=0;h<=g;h++)f=this._right[this._right.length-1],a=new cc.Sprite(Resource.CLIENT.jewel_infect("freeze",
h==g?2:1)),a.runAction(new cc.Sequence([new cc.DelayTime(.03*h),new cc.FadeIn(.07)])),a.setOpacity(0),a.setAnchorPoint(.5,1),a.setPosition(f.getPositionX()+(f.getContentSize().height-9)*e.y,0),a.setScale(e.x,e.y),a.setRotation(-90),this.addChild(a),this._right.push(a);(e=this._shape.getChildByName("right"))&&e.runAction(new cc.MoveTo(.2,56,28.5))}if(0<c){e={x:1,y:1.017};f=new cc.Sprite(Resource.CLIENT.jewel_infect("freeze",0));f.setAnchorPoint(.5,1);f.setPosition(0,14);f.setScale(e.x,e.y);f.setRotation(180);
this.addChild(f,0);this._top.push(f);g=2*c-1;for(h=0;h<=g;h++)f=this._top[this._top.length-1],a=new cc.Sprite(Resource.CLIENT.jewel_infect("freeze",h==g?2:1)),a.runAction(new cc.Sequence([new cc.DelayTime(.03*h),new cc.FadeIn(.07)])),a.setOpacity(0),a.setAnchorPoint(.5,1),a.setPosition(0,f.getPositionY()+(f.getContentSize().height-9)*e.y),a.setScale(e.x,e.y),a.setRotation(180),this.addChild(a),this._top.push(a);(e=this._shape.getChildByName("top"))&&e.runAction(new cc.MoveTo(.2,32,52))}if(0<d){e=
{x:1,y:1.017};f=new cc.Sprite(Resource.CLIENT.jewel_infect("freeze",0));f.setAnchorPoint(.5,1);f.setPosition(0,-14);f.setScale(e.x,e.y);f.setRotation(0);this.addChild(f,0);this._bottom.push(f);g=2*d-1;for(h=0;h<=g;h++)f=this._bottom[this._bottom.length-1],a=new cc.Sprite(Resource.CLIENT.jewel_infect("freeze",h==g?2:1)),a.runAction(new cc.Sequence([new cc.DelayTime(.03*h),new cc.FadeIn(.07)])),a.setOpacity(0),a.setAnchorPoint(.5,1),a.setPosition(0,f.getPositionY()-(f.getContentSize().height-9)*e.y),
a.setScale(e.x,e.y),a.setRotation(0),this.addChild(a),this._bottom.push(a);(e=this._shape.getChildByName("bottom"))&&e.runAction(new cc.MoveTo(.2,32,5))}},unfreeze:function(){this._left.reverse();this._right.reverse();this._top.reverse();this._bottom.reverse();for(var a=0;a<this._left.length;a++){var b=this._left[a];b.runAction(new cc.Sequence([new cc.DelayTime(.03*a),new cc.FadeOut(.07),new cc.RemoveSelf]))}for(a=0;a<this._right.length;a++)b=this._right[a],b.runAction(new cc.Sequence([new cc.DelayTime(.03*
a),new cc.FadeOut(.07),new cc.RemoveSelf]));for(a=0;a<this._top.length;a++)b=this._top[a],b.runAction(new cc.Sequence([new cc.DelayTime(.03*a),new cc.FadeOut(.07),new cc.RemoveSelf]));for(a=0;a<this._bottom.length;a++)b=this._bottom[a],b.runAction(new cc.Sequence([new cc.DelayTime(.03*a),new cc.FadeOut(.07),new cc.RemoveSelf]));(b=this._shape.getChildByName("top"))&&b.runAction(new cc.MoveTo(.2,32,48));(b=this._shape.getChildByName("bottom"))&&b.runAction(new cc.MoveTo(.2,32,10));(b=this._shape.getChildByName("left"))&&
b.runAction(new cc.MoveTo(.2,12,28.5));(b=this._shape.getChildByName("right"))&&b.runAction(new cc.MoveTo(.2,51,28.5));this._left=[];this._right=[];this._top=[];this._bottom=[]}});Client.GoalPanel=cc.Sprite.extend({_ext:null,_moves:null,_movesdone:null,_background:null,_treasure:null,_torch:null,_beetle:null,_diamond:null,_icecube:null,_butterfly:null,_rainbow:null,_rowblast:null,_columnBlast:null,_crossBlast:null,_stone:null,_frog:null,_mirror:null,_magicball:null,_pearl:null,_btMoves:null,_extMoves:null,ctor:function(){this._super(Resource.CLIENT.goal_back);this._ext=new CExtNode(this);this._btMoves=null;this._extMoves=!0;this._moves=new Client.GoalPanel.Moves(115);this._moves.setPosition(82,
240);this._movesdone=new Client.GoalPanel.MovesDone(115);this._background=new Client.GoalPanel.Background(115);this._treasure=new Client.GoalPanel.Treasure(115);this._torch=new Client.GoalPanel.Torch(115);this._beetle=new Client.GoalPanel.Beetle(115);this._diamond=new Client.GoalPanel.Diamond(115);this._icecube=new Client.GoalPanel.IceCube(115);this._butterfly=new Client.GoalPanel.Butterfly(115);this._rainbow=new Client.GoalPanel.Rainbow(115);this._rowblast=new Client.GoalPanel.RowBlast(115);this._columnBlast=
new Client.GoalPanel.ColumnBlast(115);this._crossBlast=new Client.GoalPanel.CrossBlast(115);this._stone=new Client.GoalPanel.Stone(115);this._frog=new Client.GoalPanel.Frog(115);this._mirror=new Client.GoalPanel.Mirror(115);this._magicball=new Client.GoalPanel.MagicBall(115);this._pearl=new Client.GoalPanel.Pearl(115);this.addChild(this._moves);this.addChild(this._movesdone);this.addChild(this._background);this.addChild(this._treasure);this.addChild(this._torch);this.addChild(this._beetle);this.addChild(this._diamond);
this.addChild(this._icecube);this.addChild(this._butterfly);this.addChild(this._rainbow);this.addChild(this._rowblast);this.addChild(this._columnBlast);this.addChild(this._crossBlast);this.addChild(this._stone);this.addChild(this._frog);this.addChild(this._mirror);this.addChild(this._magicball);this.addChild(this._pearl);this._ext.addCustomListener(Client.EVENT.UPDATE_GOAL,this.eventHandler.bind(this));this._ext.addCustomListener(Client.EVENT.FLY_BEETLE,this.eventHandler.bind(this));this._ext.addCustomListener(Client.EVENT.FLY_BUTTERFLY,
this.eventHandler.bind(this));this._ext.addCustomListener(Client.EVENT.FLY_RAINBOW,this.eventHandler.bind(this))},eventHandler:function(a){if(a.getEventName()==Client.EVENT.UPDATE_GOAL)a=a.getUserData(),this._moves.update(a.getTotalMoves()-a.getSpendMoves()),this._movesdone.update(a.getGoalMoves(),a.getSpendMoves()),this._background.update(a.getGoalBackground(),a.getDoneBackground()),this._treasure.update(a.getGoalTreasure(),a.getDoneTreasure()),this._torch.update(a.getGoalTorch(),a.getDoneTorch()),
this._beetle.update(a.getGoalBeetle(),a.getDoneBeetle()),this._diamond.update(a.getGoalDiamond(),a.getDoneDiamond()),this._icecube.update(a.getGoalIceCube(),a.getDoneIceCube()),this._butterfly.update(a.getGoalButterfly(),a.getDoneButterfly()),this._rainbow.update(a.getGoalRainbow(),a.getDoneRainbow()),this._rowblast.update(a.getGoalRowBlast(),a.getDoneRowBlast()),this._columnBlast.update(a.getGoalColumnBlast(),a.getDoneColumnBlast()),this._crossBlast.update(a.getGoalCrossBlast(),a.getDoneCrossBlast()),
this._stone.update(a.getGoalStone(),a.getDoneStone()),this._frog.update(a.getGoalFrog(),a.getDoneFrog()),this._mirror.update(a.getGoalMirror(),a.getDoneMirror()),this._magicball.update(a.getGoalMagicBall(),a.getDoneMagicBall()),this._pearl.update(a.getGoalPearl(),a.getDonePearl()),this._movesdone.setPosition(80,150),this._background.setPosition(80,this._movesdone.getPositionY()-(this._movesdone.isVisible()?this._movesdone.getContentSize().height:0)),this._treasure.setPosition(80,this._background.getPositionY()-
(this._background.isVisible()?this._background.getContentSize().height:0)),this._torch.setPosition(80,this._treasure.getPositionY()-(this._treasure.isVisible()?this._treasure.getContentSize().height:0)),this._beetle.setPosition(80,this._torch.getPositionY()-(this._torch.isVisible()?this._torch.getContentSize().height:0)),this._diamond.setPosition(80,this._beetle.getPositionY()-(this._beetle.isVisible()?this._beetle.getContentSize().height:0)),this._icecube.setPosition(80,this._diamond.getPositionY()-
(this._diamond.isVisible()?this._diamond.getContentSize().height:0)),this._butterfly.setPosition(80,this._icecube.getPositionY()-(this._icecube.isVisible()?this._icecube.getContentSize().height:0)),this._rainbow.setPosition(80,this._butterfly.getPositionY()-(this._butterfly.isVisible()?this._butterfly.getContentSize().height:0)),this._rowblast.setPosition(80,this._rainbow.getPositionY()-(this._rainbow.isVisible()?this._rainbow.getContentSize().height:0)),this._columnBlast.setPosition(80,this._rowblast.getPositionY()-
(this._rowblast.isVisible()?this._rowblast.getContentSize().height:0)),this._crossBlast.setPosition(80,this._columnBlast.getPositionY()-(this._columnBlast.isVisible()?this._columnBlast.getContentSize().height:0)),this._stone.setPosition(80,this._crossBlast.getPositionY()-(this._crossBlast.isVisible()?this._crossBlast.getContentSize().height:0)),this._frog.setPosition(80,this._stone.getPositionY()-(this._stone.isVisible()?this._stone.getContentSize().height:0)),this._mirror.setPosition(80,this._frog.getPositionY()-
(this._frog.isVisible()?this._frog.getContentSize().height:0)),this._magicball.setPosition(80,this._mirror.getPositionY()-(this._mirror.isVisible()?this._mirror.getContentSize().height:0)),this._pearl.setPosition(80,this._magicball.getPositionY()-(this._magicball.isVisible()?this._magicball.getContentSize().height:0)),this._extMoves&=0==a.getGoalMoves(),this.checkBtMoves(a.getTotalMoves()-a.getSpendMoves());else if(a.getEventName()==Client.EVENT.FLY_BEETLE){a=a.getUserData();var b=new Client.Jewel.BeetleFly(a.k);
var c=app.Scene.getCurrent();b.setPosition(a.p);c.addChild(b);c=this.convertToWorldSpace(this._beetle.getPosition());c.x-=23;c.y+=20;b.runAction(new cc.Sequence([new cc.RotateTo(.01,CUtils.getAngle(a.p,c,!0)),new cc.MoveTo(CUtils.distance(a.p,c)/300,c),new cc.RotateTo(.1,0),new cc.ScaleTo(.1,.8),new cc.RemoveSelf]))}else a.getEventName()==Client.EVENT.FLY_BUTTERFLY?(a=a.getUserData(),b=new Client.Jewel.ButterflyFly(a.k),c=app.Scene.getCurrent(),b.setPosition(a.p),c.addChild(b),c=this.convertToWorldSpace(this._butterfly.getPosition()),
c.x-=23,c.y+=20,b.runAction(new cc.Sequence([new cc.RotateTo(.01,CUtils.getAngle(a.p,c,!0)),new cc.MoveTo(CUtils.distance(a.p,c)/300,c),new cc.ScaleTo(.1,.8),new cc.RemoveSelf]))):a.getEventName()==Client.EVENT.FLY_RAINBOW&&this._rainbow.isVisible()&&(a=a.getUserData(),c=app.Scene.getCurrent(),b=new cc.Sprite(Resource.CLIENT.jewel_rainbow(2)),b.setPosition(a.p),c.addChild(b),c=this.convertToWorldSpace(this._rainbow.getPosition()),c.x-=23,c.y+=20,b.runAction(new cc.Sequence([new cc.RotateTo(.01,CUtils.getAngle(a.p,
c,!0)),new cc.MoveTo(CUtils.distance(a.p,c)/500,c),new cc.ScaleTo(.1,.8),new cc.RemoveSelf])))},setExtMoves:function(a){this._extMoves=a;!this._extMoves&&this._btMoves&&(this._btMoves.removeFromParent(),this._btMoves=null)},checkBtMoves:function(a){(a=6>a&&this._extMoves)&&!this._btMoves?(this._btMoves=new CButtonSprite(Resource.CLIENT.ui("add_moves")),this._btMoves.setPosition(15,320),this._btMoves.runAction(new cc.JumpTo(.5,148,290,5,1)),this._btMoves.runAction(new cc.RepeatForever(new cc.Sequence([new cc.MoveBy(.2,
0,3),new cc.MoveBy(.2,0,-3),new cc.MoveBy(.2,0,3),new cc.MoveBy(.2,0,-3),new cc.DelayTime(.5)]))),this._btMoves.setCbUp(function(){cc.eventManager.dispatchCustomEvent(Client.EVENT.PLAY_NOMOVES)}),this.addChild(this._btMoves)):!a&&this._btMoves&&(this._btMoves.removeFromParent(),this._btMoves=null)}});
Client.GoalPanel.Moves=cc.Node.extend({_lb:null,_num:null,ctor:function(a){this._super();this._lb=new cc.LabelTTF(Lang.getString(Lang.CL_GOAL_MOVES),Lang.F_GNUOLANE,24,new cc.Size(a,0),cc.TEXT_ALIGNMENT_CENTER);this._lb.setPosition(0,28);this._num=this.buildNumber(0);this.addChild(this._lb);this.addChild(this._num)},update:function(a){this.buildNumber(Math.max(0,a),this._num)},buildNumber:function(a,b){b=b||new cc.Node;b.removeAllChildren();var c=CUtils.numToArray(a),d=0;0==c.length&&c.push(0);for(var e in c){var f=
new cc.Sprite(Resource.CLIENT.goal_num(c[e]));f.setAnchorPoint(0,0);f.setPosition(d,0);d+=f.getContentSize().width;b.addChild(f)}b.setContentSize(0,0);c=b.getBoundingBoxToWorld();b.setContentSize(c.width,c.height);b.setAnchorPoint(.5,.5);return b}});
Client.GoalPanel.MovesDone=cc.Node.extend({_lb:null,_ico0:null,_ico1:null,_ico2:null,_num:null,ctor:function(a){this._super();this.setContentSize(a,60);this.setAnchorPoint(.5,0);this._lb=new cc.LabelTTF(Lang.getString(Lang.CL_GOAL_MOVESDONE),Lang.F_GNUOLANE,16,null,cc.TEXT_ALIGNMENT_CENTER);this._lb.setAnchorPoint(.5,1);this._lb.setPosition(.5*this.getContentSize().width,this.getContentSize().height);this._lb.getContentSize().width>a&&this._lb.setScale(a/this._lb.getContentSize().width);this._ico0=
new cc.Sprite(Resource.CLIENT.goal_icon("arrow"));this._ico0.setScale(.7);this._ico0.setPosition(.3*a,16);this._ico0.setRotation(90);this._ico0.runAction(new cc.RepeatForever(new cc.Sequence(new cc.MoveBy(.5,3,0),new cc.MoveBy(.5,-3,0))));this._ico2=new cc.Sprite(Resource.CLIENT.goal_icon("arrow"));this._ico2.setFlippedY(!0);this._ico2.setScale(.7);this._ico2.setRotation(90);this._ico2.setPosition(.3*a,31);this._ico2.runAction(new cc.RepeatForever(new cc.Sequence(new cc.MoveBy(.5,-3,0),new cc.MoveBy(.5,
3,0))));this._ico1=new cc.Sprite(Resource.CLIENT.goal_done);this._ico1.setPosition(.75*a,22);this._ico1.setScale(.8);this._num=this.buildNumber(0);this._num.setPosition(.75*a,22);this.addChild(this._ico0);this.addChild(this._ico2);this.addChild(this._ico1);this.addChild(this._lb);this.addChild(this._num)},update:function(a,b){this.setVisible(0!=a);this._ico1.setVisible(a<=b);this._num.setVisible(!this._ico1.isVisible());this.buildNumber(Math.max(0,a-b),this._num)},buildNumber:function(a,b){b=b||new cc.Node;
b.removeAllChildren();var c=CUtils.numToArray(a),d=0;0==c.length&&c.push(0);for(var e in c){var f=new cc.Sprite(Resource.CLIENT.goal_num(c[e]));f.setAnchorPoint(0,0);f.setPosition(d,0);d+=f.getContentSize().width;b.addChild(f)}b.setContentSize(0,0);c=b.getBoundingBoxToWorld();b.setContentSize(c.width,c.height);b.setAnchorPoint(.5,.5);b.setScale(.9);return b}});
Client.GoalPanel.Background=cc.Node.extend({_lb:null,_ico0:null,_ico1:null,_num:null,ctor:function(a){this._super();this.setContentSize(a,60);this.setAnchorPoint(.5,0);this._lb=new cc.LabelTTF(Lang.getString(Lang.CL_GOAL_BACKGROUND),Lang.F_GNUOLANE,16,null,cc.TEXT_ALIGNMENT_CENTER);this._lb.setAnchorPoint(.5,1);this._lb.setPosition(.5*this.getContentSize().width,this.getContentSize().height);this._lb.getContentSize().width>a&&this._lb.setScale(a/this._lb.getContentSize().width);this._ico0=new cc.Sprite(Resource.CLIENT.goal_icon("background"));
this._ico0.setScale(.9);this._ico0.setPosition(.3*a,23);this._ico1=new cc.Sprite(Resource.CLIENT.goal_done);this._ico1.setPosition(.75*a,22);this._ico1.setScale(.8);this._num=this.buildNumber(0);this._num.setPosition(.75*a,22);this.addChild(this._ico0);this.addChild(this._ico1);this.addChild(this._lb);this.addChild(this._num)},update:function(a,b){this.setVisible(0!=a);this._ico1.setVisible(a<=b);this._num.setVisible(!this._ico1.isVisible());this.buildNumber(Math.max(0,a-b),this._num)},buildNumber:function(a,
b){b=b||new cc.Node;b.removeAllChildren();var c=CUtils.numToArray(a),d=0;0==c.length&&c.push(0);for(var e in c){var f=new cc.Sprite(Resource.CLIENT.goal_num(c[e]));f.setAnchorPoint(0,0);f.setPosition(d,0);d+=f.getContentSize().width;b.addChild(f)}b.setContentSize(0,0);c=b.getBoundingBoxToWorld();b.setContentSize(c.width,c.height);b.setAnchorPoint(.5,.5);b.setScale(.9);return b}});
Client.GoalPanel.Treasure=cc.Node.extend({_lb:null,_ico0:null,_ico1:null,_num:null,ctor:function(a){this._super();this.setContentSize(a,60);this.setAnchorPoint(.5,0);this._lb=new cc.LabelTTF(Lang.getString(Lang.CL_GOAL_TREASURE),Lang.F_GNUOLANE,16,null,cc.TEXT_ALIGNMENT_CENTER);this._lb.setAnchorPoint(.5,1);this._lb.setPosition(.5*this.getContentSize().width,this.getContentSize().height);this._lb.getContentSize().width>a&&this._lb.setScale(a/this._lb.getContentSize().width);this._ico0=new cc.Sprite(Resource.CLIENT.goal_icon("treasure"));
this._ico0.setPosition(.3*a,23);this._ico1=new cc.Sprite(Resource.CLIENT.goal_done);this._ico1.setPosition(.75*a,22);this._ico1.setScale(.8);this._num=this.buildNumber(0);this._num.setPosition(.75*a,22);this.addChild(this._ico0);this.addChild(this._ico1);this.addChild(this._lb);this.addChild(this._num)},update:function(a,b){this.setVisible(0!=a);this._ico1.setVisible(a<=b);this._num.setVisible(!this._ico1.isVisible());this.buildNumber(Math.max(0,a-b),this._num)},buildNumber:function(a,b){b=b||new cc.Node;
b.removeAllChildren();var c=CUtils.numToArray(a),d=0;0==c.length&&c.push(0);for(var e in c){var f=new cc.Sprite(Resource.CLIENT.goal_num(c[e]));f.setAnchorPoint(0,0);f.setPosition(d,0);d+=f.getContentSize().width;b.addChild(f)}b.setContentSize(0,0);c=b.getBoundingBoxToWorld();b.setContentSize(c.width,c.height);b.setAnchorPoint(.5,.5);b.setScale(.9);return b}});
Client.GoalPanel.Torch=cc.Node.extend({_lb:null,_ico0:null,_ico1:null,_num:null,ctor:function(a){this._super();this.setContentSize(a,62);this.setAnchorPoint(.5,0);this._lb=new cc.LabelTTF(Lang.getString(Lang.CL_GOAL_TORCH),Lang.F_GNUOLANE,16,null,cc.TEXT_ALIGNMENT_CENTER);this._lb.setAnchorPoint(.5,1);this._lb.setPosition(.5*this.getContentSize().width,this.getContentSize().height);this._lb.getContentSize().width>a&&this._lb.setScale(a/this._lb.getContentSize().width);this._ico0=new cc.Sprite(Resource.CLIENT.goal_icon("torch"));
this._ico0.setPosition(.31*a,24);this._ico1=new cc.Sprite(Resource.CLIENT.goal_done);this._ico1.setPosition(.75*a,22);this._ico1.setScale(.8);this._num=this.buildNumber(0);this._num.setPosition(.75*a,17);this.addChild(this._ico0);this.addChild(this._ico1);this.addChild(this._lb);this.addChild(this._num)},update:function(a,b){this.setVisible(0!=a);this._ico1.setVisible(a<=b);this._num.setVisible(!this._ico1.isVisible());this.buildNumber(Math.max(0,a-b),this._num)},buildNumber:function(a,b){b=b||new cc.Node;
b.removeAllChildren();var c=CUtils.numToArray(a),d=0;0==c.length&&c.push(0);for(var e in c){var f=new cc.Sprite(Resource.CLIENT.goal_num(c[e]));f.setAnchorPoint(0,0);f.setPosition(d,0);d+=f.getContentSize().width;b.addChild(f)}b.setContentSize(0,0);c=b.getBoundingBoxToWorld();b.setContentSize(c.width,c.height);b.setAnchorPoint(.5,.5);b.setScale(.9);return b}});
Client.GoalPanel.Beetle=cc.Node.extend({_lb:null,_ico0:null,_ico1:null,_num:null,ctor:function(a){this._super();this.setContentSize(a,60);this.setAnchorPoint(.5,0);this._lb=new cc.LabelTTF(Lang.getString(Lang.CL_GOAL_BEETLE),Lang.F_GNUOLANE,16,null,cc.TEXT_ALIGNMENT_CENTER);this._lb.setAnchorPoint(.5,1);this._lb.setPosition(.5*this.getContentSize().width,this.getContentSize().height);this._lb.getContentSize().width>a&&this._lb.setScale(a/this._lb.getContentSize().width);this._ico0=new cc.Sprite(Resource.CLIENT.goal_icon("beetle"));
this._ico0.setScale(.9);this._ico0.setPosition(.3*a,22);this._ico1=new cc.Sprite(Resource.CLIENT.goal_done);this._ico1.setPosition(.75*a,24);this._ico1.setScale(.8);this._num=this.buildNumber(0);this._num.setPosition(.75*a,20);this.addChild(this._ico0);this.addChild(this._ico1);this.addChild(this._lb);this.addChild(this._num)},update:function(a,b){this.setVisible(0!=a);this._ico1.setVisible(a<=b);this._num.setVisible(!this._ico1.isVisible());this.buildNumber(Math.max(0,a-b),this._num)},buildNumber:function(a,
b){b=b||new cc.Node;b.removeAllChildren();var c=CUtils.numToArray(a),d=0;0==c.length&&c.push(0);for(var e in c){var f=new cc.Sprite(Resource.CLIENT.goal_num(c[e]));f.setAnchorPoint(0,0);f.setPosition(d,0);d+=f.getContentSize().width;b.addChild(f)}b.setContentSize(0,0);c=b.getBoundingBoxToWorld();b.setContentSize(c.width,c.height);b.setAnchorPoint(.5,.5);b.setScale(.9);return b}});
Client.GoalPanel.Diamond=cc.Node.extend({_lb:null,_ico0:null,_ico1:null,_num:null,ctor:function(a){this._super();this.setContentSize(a,60);this.setAnchorPoint(.5,0);this._lb=new cc.LabelTTF(Lang.getString(Lang.CL_GOAL_DIAMOND),Lang.F_GNUOLANE,16,null,cc.TEXT_ALIGNMENT_CENTER);this._lb.setAnchorPoint(.5,1);this._lb.setPosition(.5*this.getContentSize().width,this.getContentSize().height);this._lb.getContentSize().width>a&&this._lb.setScale(a/this._lb.getContentSize().width);this._ico0=new cc.Sprite(Resource.CLIENT.goal_icon("diamond"));
this._ico0.setScale(.9);this._ico0.setPosition(.29*a,24);this._ico1=new cc.Sprite(Resource.CLIENT.goal_done);this._ico1.setPosition(.75*a,24);this._ico1.setScale(.8);this._num=this.buildNumber(0);this._num.setPosition(.75*a,20);this.addChild(this._ico0);this.addChild(this._ico1);this.addChild(this._lb);this.addChild(this._num)},update:function(a,b){this.setVisible(0!=a);this._ico1.setVisible(a<=b);this._num.setVisible(!this._ico1.isVisible());this.buildNumber(Math.max(0,a-b),this._num)},buildNumber:function(a,
b){b=b||new cc.Node;b.removeAllChildren();var c=CUtils.numToArray(a),d=0;0==c.length&&c.push(0);for(var e in c){var f=new cc.Sprite(Resource.CLIENT.goal_num(c[e]));f.setAnchorPoint(0,0);f.setPosition(d,0);d+=f.getContentSize().width;b.addChild(f)}b.setContentSize(0,0);c=b.getBoundingBoxToWorld();b.setContentSize(c.width,c.height);b.setAnchorPoint(.5,.5);b.setScale(.9);return b}});
Client.GoalPanel.IceCube=cc.Node.extend({_lb:null,_ico0:null,_ico1:null,_num:null,ctor:function(a){this._super();this.setContentSize(a,60);this.setAnchorPoint(.5,0);this._lb=new cc.LabelTTF(Lang.getString(Lang.CL_GOAL_ICECUBE),Lang.F_GNUOLANE,16,null,cc.TEXT_ALIGNMENT_CENTER);this._lb.setAnchorPoint(.5,1);this._lb.setPosition(.5*this.getContentSize().width,this.getContentSize().height);this._lb.getContentSize().width>a&&this._lb.setScale(a/this._lb.getContentSize().width);this._ico0=new cc.Sprite(Resource.CLIENT.goal_icon("icecube"));
this._ico0.setScale(.9);this._ico0.setPosition(.3*a,22);this._ico1=new cc.Sprite(Resource.CLIENT.goal_done);this._ico1.setPosition(.75*a,24);this._ico1.setScale(.8);this._num=this.buildNumber(0);this._num.setPosition(.75*a,20);this.addChild(this._ico0);this.addChild(this._ico1);this.addChild(this._lb);this.addChild(this._num)},update:function(a,b){this.setVisible(0!=a);this._ico1.setVisible(a<=b);this._num.setVisible(!this._ico1.isVisible());this.buildNumber(Math.max(0,a-b),this._num)},buildNumber:function(a,
b){b=b||new cc.Node;b.removeAllChildren();var c=CUtils.numToArray(a),d=0;0==c.length&&c.push(0);for(var e in c){var f=new cc.Sprite(Resource.CLIENT.goal_num(c[e]));f.setAnchorPoint(0,0);f.setPosition(d,0);d+=f.getContentSize().width;b.addChild(f)}b.setContentSize(0,0);c=b.getBoundingBoxToWorld();b.setContentSize(c.width,c.height);b.setAnchorPoint(.5,.5);b.setScale(.9);return b}});
Client.GoalPanel.Butterfly=cc.Node.extend({_lb:null,_ico0:null,_ico1:null,_num:null,ctor:function(a){this._super();this.setContentSize(a,60);this.setAnchorPoint(.5,0);this._lb=new cc.LabelTTF(Lang.getString(Lang.CL_GOAL_BUTTERFLY),Lang.F_GNUOLANE,16,null,cc.TEXT_ALIGNMENT_CENTER);this._lb.setAnchorPoint(.5,1);this._lb.setPosition(.5*this.getContentSize().width,this.getContentSize().height);this._lb.getContentSize().width>a&&this._lb.setScale(a/this._lb.getContentSize().width);this._ico0=new cc.Sprite(Resource.CLIENT.goal_icon("butterfly"));
this._ico0.setScale(.9);this._ico0.setPosition(.3*a,22);this._ico1=new cc.Sprite(Resource.CLIENT.goal_done);this._ico1.setPosition(.75*a,24);this._ico1.setScale(.8);this._num=this.buildNumber(0);this._num.setPosition(.75*a,20);this.addChild(this._ico0);this.addChild(this._ico1);this.addChild(this._lb);this.addChild(this._num)},update:function(a,b){this.setVisible(0!=a);this._ico1.setVisible(a<=b);this._num.setVisible(!this._ico1.isVisible());this.buildNumber(Math.max(0,a-b),this._num)},buildNumber:function(a,
b){b=b||new cc.Node;b.removeAllChildren();var c=CUtils.numToArray(a),d=0;0==c.length&&c.push(0);for(var e in c){var f=new cc.Sprite(Resource.CLIENT.goal_num(c[e]));f.setAnchorPoint(0,0);f.setPosition(d,0);d+=f.getContentSize().width;b.addChild(f)}b.setContentSize(0,0);c=b.getBoundingBoxToWorld();b.setContentSize(c.width,c.height);b.setAnchorPoint(.5,.5);b.setScale(.9);return b}});
Client.GoalPanel.Rainbow=cc.Node.extend({_lb:null,_ico0:null,_ico1:null,_num:null,ctor:function(a){this._super();this.setContentSize(a,60);this.setAnchorPoint(.5,0);this._lb=new cc.LabelTTF(Lang.getString(Lang.CL_GOAL_RAINBOW),Lang.F_GNUOLANE,16,null,cc.TEXT_ALIGNMENT_CENTER);this._lb.setAnchorPoint(.5,1);this._lb.setPosition(.5*this.getContentSize().width,this.getContentSize().height);this._lb.getContentSize().width>a&&this._lb.setScale(a/this._lb.getContentSize().width);this._ico0=new cc.Sprite(Resource.CLIENT.goal_icon("rainbow"));
this._ico0.setScale(.8);this._ico0.setPosition(.29*a,22);this._ico1=new cc.Sprite(Resource.CLIENT.goal_done);this._ico1.setPosition(.75*a,24);this._ico1.setScale(.8);this._num=this.buildNumber(0);this._num.setPosition(.75*a,20);this.addChild(this._ico0);this.addChild(this._ico1);this.addChild(this._lb);this.addChild(this._num)},update:function(a,b){this.setVisible(0!=a);this._ico1.setVisible(a<=b);this._num.setVisible(!this._ico1.isVisible());this.buildNumber(Math.max(0,a-b),this._num)},buildNumber:function(a,
b){b=b||new cc.Node;b.removeAllChildren();var c=CUtils.numToArray(a),d=0;0==c.length&&c.push(0);for(var e in c){var f=new cc.Sprite(Resource.CLIENT.goal_num(c[e]));f.setAnchorPoint(0,0);f.setPosition(d,0);d+=f.getContentSize().width;b.addChild(f)}b.setContentSize(0,0);c=b.getBoundingBoxToWorld();b.setContentSize(c.width,c.height);b.setAnchorPoint(.5,.5);b.setScale(.9);return b}});
Client.GoalPanel.RowBlast=cc.Node.extend({_lb:null,_ico0:null,_ico1:null,_num:null,ctor:function(a){this._super();this.setContentSize(a,60);this.setAnchorPoint(.5,0);this._lb=new cc.LabelTTF(Lang.getString(Lang.CL_GOAL_ROWBLAST),Lang.F_GNUOLANE,16,null,cc.TEXT_ALIGNMENT_CENTER);this._lb.setAnchorPoint(.5,1);this._lb.setPosition(.5*this.getContentSize().width,this.getContentSize().height);this._lb.getContentSize().width>a&&this._lb.setScale(a/this._lb.getContentSize().width);this._ico0=new cc.Sprite(Resource.CLIENT.goal_icon("rowblast"));
this._ico0.setScale(.8);this._ico0.setPosition(.3*a,22);this._ico1=new cc.Sprite(Resource.CLIENT.goal_done);this._ico1.setPosition(.75*a,24);this._ico1.setScale(.8);this._num=this.buildNumber(0);this._num.setPosition(.75*a,20);this.addChild(this._ico0);this.addChild(this._ico1);this.addChild(this._lb);this.addChild(this._num)},update:function(a,b){this.setVisible(0!=a);this._ico1.setVisible(a<=b);this._num.setVisible(!this._ico1.isVisible());this.buildNumber(Math.max(0,a-b),this._num)},buildNumber:function(a,
b){b=b||new cc.Node;b.removeAllChildren();var c=CUtils.numToArray(a),d=0;0==c.length&&c.push(0);for(var e in c){var f=new cc.Sprite(Resource.CLIENT.goal_num(c[e]));f.setAnchorPoint(0,0);f.setPosition(d,0);d+=f.getContentSize().width;b.addChild(f)}b.setContentSize(0,0);c=b.getBoundingBoxToWorld();b.setContentSize(c.width,c.height);b.setAnchorPoint(.5,.5);b.setScale(.9);return b}});
Client.GoalPanel.ColumnBlast=cc.Node.extend({_lb:null,_ico0:null,_ico1:null,_num:null,ctor:function(a){this._super();this.setContentSize(a,60);this.setAnchorPoint(.5,0);this._lb=new cc.LabelTTF(Lang.getString(Lang.CL_GOAL_COLBLAST),Lang.F_GNUOLANE,16,null,cc.TEXT_ALIGNMENT_CENTER);this._lb.setAnchorPoint(.5,1);this._lb.setPosition(.5*this.getContentSize().width,this.getContentSize().height);this._lb.getContentSize().width>a&&this._lb.setScale(a/this._lb.getContentSize().width);this._ico0=new cc.Sprite(Resource.CLIENT.goal_icon("colblast"));
this._ico0.setScale(.8);this._ico0.setPosition(.3*a,22);this._ico1=new cc.Sprite(Resource.CLIENT.goal_done);this._ico1.setPosition(.75*a,24);this._ico1.setScale(.8);this._num=this.buildNumber(0);this._num.setPosition(.75*a,20);this.addChild(this._ico0);this.addChild(this._ico1);this.addChild(this._lb);this.addChild(this._num)},update:function(a,b){this.setVisible(0!=a);this._ico1.setVisible(a<=b);this._num.setVisible(!this._ico1.isVisible());this.buildNumber(Math.max(0,a-b),this._num)},buildNumber:function(a,
b){b=b||new cc.Node;b.removeAllChildren();var c=CUtils.numToArray(a),d=0;0==c.length&&c.push(0);for(var e in c){var f=new cc.Sprite(Resource.CLIENT.goal_num(c[e]));f.setAnchorPoint(0,0);f.setPosition(d,0);d+=f.getContentSize().width;b.addChild(f)}b.setContentSize(0,0);c=b.getBoundingBoxToWorld();b.setContentSize(c.width,c.height);b.setAnchorPoint(.5,.5);b.setScale(.9);return b}});
Client.GoalPanel.CrossBlast=cc.Node.extend({_lb:null,_ico0:null,_ico1:null,_num:null,ctor:function(a){this._super();this.setContentSize(a,60);this.setAnchorPoint(.5,0);this._lb=new cc.LabelTTF(Lang.getString(Lang.CL_GOAL_CROSSBLAST),Lang.F_GNUOLANE,16,null,cc.TEXT_ALIGNMENT_CENTER);this._lb.setAnchorPoint(.5,1);this._lb.setPosition(.5*this.getContentSize().width,this.getContentSize().height);this._lb.getContentSize().width>a&&this._lb.setScale(a/this._lb.getContentSize().width);this._ico0=new cc.Sprite(Resource.CLIENT.goal_icon("crossblast"));
this._ico0.setScale(.8);this._ico0.setPosition(.3*a,22);this._ico1=new cc.Sprite(Resource.CLIENT.goal_done);this._ico1.setPosition(.75*a,24);this._ico1.setScale(.8);this._num=this.buildNumber(0);this._num.setPosition(.75*a,20);this.addChild(this._ico0);this.addChild(this._ico1);this.addChild(this._lb);this.addChild(this._num)},update:function(a,b){this.setVisible(0!=a);this._ico1.setVisible(a<=b);this._num.setVisible(!this._ico1.isVisible());this.buildNumber(Math.max(0,a-b),this._num)},buildNumber:function(a,
b){b=b||new cc.Node;b.removeAllChildren();var c=CUtils.numToArray(a),d=0;0==c.length&&c.push(0);for(var e in c){var f=new cc.Sprite(Resource.CLIENT.goal_num(c[e]));f.setAnchorPoint(0,0);f.setPosition(d,0);d+=f.getContentSize().width;b.addChild(f)}b.setContentSize(0,0);c=b.getBoundingBoxToWorld();b.setContentSize(c.width,c.height);b.setAnchorPoint(.5,.5);b.setScale(.9);return b}});
Client.GoalPanel.Stone=cc.Node.extend({_lb:null,_ico0:null,_ico1:null,_num:null,ctor:function(a){this._super();this.setContentSize(a,60);this.setAnchorPoint(.5,0);this._lb=new cc.LabelTTF(Lang.getString(Lang.CL_GOAL_STONE),Lang.F_GNUOLANE,16,null,cc.TEXT_ALIGNMENT_CENTER);this._lb.setAnchorPoint(.5,1);this._lb.setPosition(.5*this.getContentSize().width,this.getContentSize().height);this._lb.getContentSize().width>a&&this._lb.setScale(a/this._lb.getContentSize().width);this._ico0=new cc.Sprite(Resource.CLIENT.goal_icon("stone"));
this._ico0.setScale(.8);this._ico0.setPosition(.3*a,22);this._ico1=new cc.Sprite(Resource.CLIENT.goal_done);this._ico1.setPosition(.75*a,24);this._ico1.setScale(.8);this._num=this.buildNumber(0);this._num.setPosition(.75*a,20);this.addChild(this._ico0);this.addChild(this._ico1);this.addChild(this._lb);this.addChild(this._num)},update:function(a,b){this.setVisible(0!=a);this._ico1.setVisible(a<=b);this._num.setVisible(!this._ico1.isVisible());this.buildNumber(Math.max(0,a-b),this._num)},buildNumber:function(a,
b){b=b||new cc.Node;b.removeAllChildren();var c=CUtils.numToArray(a),d=0;0==c.length&&c.push(0);for(var e in c){var f=new cc.Sprite(Resource.CLIENT.goal_num(c[e]));f.setAnchorPoint(0,0);f.setPosition(d,0);d+=f.getContentSize().width;b.addChild(f)}b.setContentSize(0,0);c=b.getBoundingBoxToWorld();b.setContentSize(c.width,c.height);b.setAnchorPoint(.5,.5);b.setScale(.9);return b}});
Client.GoalPanel.Frog=cc.Node.extend({_lb:null,_ico0:null,_ico1:null,_num:null,ctor:function(a){this._super();this.setContentSize(a,60);this.setAnchorPoint(.5,0);this._lb=new cc.LabelTTF(Lang.getString(Lang.CL_GOAL_FROG),Lang.F_GNUOLANE,16,null,cc.TEXT_ALIGNMENT_CENTER);this._lb.setAnchorPoint(.5,1);this._lb.setPosition(.5*this.getContentSize().width,this.getContentSize().height);this._lb.getContentSize().width>a&&this._lb.setScale(a/this._lb.getContentSize().width);this._ico0=new cc.Sprite(Resource.CLIENT.goal_icon("frog"));
this._ico0.setScale(.8);this._ico0.setPosition(.3*a,24);this._ico1=new cc.Sprite(Resource.CLIENT.goal_done);this._ico1.setPosition(.75*a,24);this._ico1.setScale(.8);this._num=this.buildNumber(0);this._num.setPosition(.75*a,20);this.addChild(this._ico0);this.addChild(this._ico1);this.addChild(this._lb);this.addChild(this._num)},update:function(a,b){this.setVisible(0!=a);this._ico1.setVisible(a<=b);this._num.setVisible(!this._ico1.isVisible());this.buildNumber(Math.max(0,a-b),this._num)},buildNumber:function(a,
b){b=b||new cc.Node;b.removeAllChildren();var c=CUtils.numToArray(a),d=0;0==c.length&&c.push(0);for(var e in c){var f=new cc.Sprite(Resource.CLIENT.goal_num(c[e]));f.setAnchorPoint(0,0);f.setPosition(d,0);d+=f.getContentSize().width;b.addChild(f)}b.setContentSize(0,0);c=b.getBoundingBoxToWorld();b.setContentSize(c.width,c.height);b.setAnchorPoint(.5,.5);b.setScale(.9);return b}});
Client.GoalPanel.Mirror=cc.Node.extend({_lb:null,_ico0:null,_ico1:null,_num:null,ctor:function(a){this._super();this.setContentSize(a,60);this.setAnchorPoint(.5,0);this._lb=new cc.LabelTTF(Lang.getString(Lang.CL_GOAL_MIRROR),Lang.F_GNUOLANE,16,null,cc.TEXT_ALIGNMENT_CENTER);this._lb.setAnchorPoint(.5,1);this._lb.setPosition(.5*this.getContentSize().width,this.getContentSize().height);this._lb.getContentSize().width>a&&this._lb.setScale(a/this._lb.getContentSize().width);this._ico0=new cc.Sprite(Resource.CLIENT.goal_icon("mirror"));
this._ico0.setPosition(.3*a,22);this._ico1=new cc.Sprite(Resource.CLIENT.goal_done);this._ico1.setPosition(.75*a,24);this._ico1.setScale(.8);this._num=this.buildNumber(0);this._num.setPosition(.75*a,20);this.addChild(this._ico0);this.addChild(this._ico1);this.addChild(this._lb);this.addChild(this._num)},update:function(a,b){this.setVisible(0!=a);this._ico1.setVisible(a<=b);this._num.setVisible(!this._ico1.isVisible());this.buildNumber(Math.max(0,a-b),this._num)},buildNumber:function(a,b){b=b||new cc.Node;
b.removeAllChildren();var c=CUtils.numToArray(a),d=0;0==c.length&&c.push(0);for(var e in c){var f=new cc.Sprite(Resource.CLIENT.goal_num(c[e]));f.setAnchorPoint(0,0);f.setPosition(d,0);d+=f.getContentSize().width;b.addChild(f)}b.setContentSize(0,0);c=b.getBoundingBoxToWorld();b.setContentSize(c.width,c.height);b.setAnchorPoint(.5,.5);b.setScale(.9);return b}});
Client.GoalPanel.MagicBall=cc.Node.extend({_lb:null,_ico0:null,_ico1:null,_num:null,ctor:function(a){this._super();this.setContentSize(a,60);this.setAnchorPoint(.5,0);this._lb=new cc.LabelTTF(Lang.getString(Lang.CL_GOAL_MAGICBALL),Lang.F_GNUOLANE,16,null,cc.TEXT_ALIGNMENT_CENTER);this._lb.setAnchorPoint(.5,1);this._lb.setPosition(.5*this.getContentSize().width,this.getContentSize().height);this._lb.getContentSize().width>a&&this._lb.setScale(a/this._lb.getContentSize().width);this._ico0=new cc.Sprite(Resource.CLIENT.goal_icon("magicball"));
this._ico0.setPosition(.3*a,22);this._ico1=new cc.Sprite(Resource.CLIENT.goal_done);this._ico1.setPosition(.75*a,24);this._ico1.setScale(.8);this._num=this.buildNumber(0);this._num.setPosition(.75*a,20);this.addChild(this._ico0);this.addChild(this._ico1);this.addChild(this._lb);this.addChild(this._num)},update:function(a,b){this.setVisible(0!=a);this._ico1.setVisible(a<=b);this._num.setVisible(!this._ico1.isVisible());this.buildNumber(Math.max(0,a-b),this._num)},buildNumber:function(a,b){b=b||new cc.Node;
b.removeAllChildren();var c=CUtils.numToArray(a),d=0;0==c.length&&c.push(0);for(var e in c){var f=new cc.Sprite(Resource.CLIENT.goal_num(c[e]));f.setAnchorPoint(0,0);f.setPosition(d,0);d+=f.getContentSize().width;b.addChild(f)}b.setContentSize(0,0);c=b.getBoundingBoxToWorld();b.setContentSize(c.width,c.height);b.setAnchorPoint(.5,.5);b.setScale(.9);return b}});
Client.GoalPanel.Pearl=cc.Node.extend({_lb:null,_ico0:null,_ico1:null,_num:null,ctor:function(a){this._super();this.setContentSize(a,60);this.setAnchorPoint(.5,0);this._lb=new cc.LabelTTF(Lang.getString(Lang.CL_GOAL_PEARL),Lang.F_GNUOLANE,16,null,cc.TEXT_ALIGNMENT_CENTER);this._lb.setAnchorPoint(.5,1);this._lb.setPosition(.5*this.getContentSize().width,this.getContentSize().height);this._lb.getContentSize().width>a&&this._lb.setScale(a/this._lb.getContentSize().width);this._ico0=new cc.Sprite(Resource.CLIENT.goal_icon("pearl"));
this._ico0.setPosition(.3*a,22);this._ico1=new cc.Sprite(Resource.CLIENT.goal_done);this._ico1.setPosition(.75*a,24);this._ico1.setScale(.8);this._num=this.buildNumber(0);this._num.setPosition(.75*a,20);this.addChild(this._ico0);this.addChild(this._ico1);this.addChild(this._lb);this.addChild(this._num)},update:function(a,b){this.setVisible(0!=a);this._ico1.setVisible(a<=b);this._num.setVisible(!this._ico1.isVisible());this.buildNumber(Math.max(0,a-b),this._num)},buildNumber:function(a,b){b=b||new cc.Node;
b.removeAllChildren();var c=CUtils.numToArray(a),d=0;0==c.length&&c.push(0);for(var e in c){var f=new cc.Sprite(Resource.CLIENT.goal_num(c[e]));f.setAnchorPoint(0,0);f.setPosition(d,0);d+=f.getContentSize().width;b.addChild(f)}b.setContentSize(0,0);c=b.getBoundingBoxToWorld();b.setContentSize(c.width,c.height);b.setAnchorPoint(.5,.5);b.setScale(.9);return b}});Client.SpellPanel=cc.Sprite.extend({ctor:function(a){this._super(Resource.CLIENT.empty);a=a.filter(function(a){return a.hasId(Products.IDS.OR_HAMMER)||a.hasId(Products.IDS.OR_HAND)||a.hasId(Products.IDS.OR_UNLOCK)||a.hasId(Products.IDS.OR_SUPER_BOMB)||a.hasId(Products.IDS.OR_COLOR_BLASTER)});a=a.sort(function(a,b){return a.getPanelId()-b.getPanelId()});for(var b=0;6>b;b++){var c=new Client.SpellPanel.Item(a[b]);c.setPosition(90*b,0);this.addChild(c)}}});
Client.SpellPanel.Item=cc.Node.extend({_ext:null,_orb:null,_used:0,_bt0:null,_enabled:!0,_active:!1,_type:null,ctor:function(a){this._super(Resource.CLIENT.empty);this._ext=new CExtNode(this);this._ext.addCustomListener(User.EVENT.UPDATE_ORB,this.eventHandler.bind(this));this._ext.addCustomListener(Client.EVENT.SPELL_USED,this.eventHandler.bind(this));this._ext.addCustomListener(Client.EVENT.SPELL_ACTIVE,this.eventHandler.bind(this));this._ext.addCustomListener(Client.EVENT.SPELL_CANCEL,this.eventHandler.bind(this));
this._type=(this._orb=a)?JSpell.fromProdId(a.getId()):null;this._used=0;this._enabled=!0;this._active=!1;this.updateContent()},getBack:function(a){return a?a.hasId(Products.IDS.OR_UNLOCK)?Resource.CLIENT.spell("back1"):a.hasId(Products.IDS.OR_SUPER_BOMB)?Resource.CLIENT.spell("back2"):a.hasId(Products.IDS.OR_HAND)?Resource.CLIENT.spell("back3"):a.hasId(Products.IDS.OR_HAMMER)?Resource.CLIENT.spell("back4"):Resource.CLIENT.spell("back5"):Resource.CLIENT.spell("back0")},getFront:function(a){return a?
a.hasId(Products.IDS.OR_UNLOCK)?Resource.CLIENT.spell("unlock"):a.hasId(Products.IDS.OR_SUPER_BOMB)?Resource.CLIENT.spell("bomb"):a.hasId(Products.IDS.OR_HAND)?Resource.CLIENT.spell("hand"):a.hasId(Products.IDS.OR_HAMMER)?Resource.CLIENT.spell("hammer"):a.hasId(Products.IDS.OR_COLOR_BLASTER)?Resource.CLIENT.spell("color_blast"):Resource.CLIENT.spell("locked"):Resource.CLIENT.spell("locked")},click:function(){this._orb&&(this._orb.isBought()?cc.eventManager.dispatchCustomEvent(Client.EVENT.SPELL_ACTIVE,
{type:this._type}):Backend.purchase(this._orb.getPurchaseData(),"client_panel"))},updateContent:function(){this.removeAllChildren();if(this._orb){var a=this._orb.getCanUsed()-this._used;if(this._orb.isBought())this._orb.isBought()&&this._enabled&&!this._active&&0<a?(b=new CButton(this.getBack(this._orb),null,{b:.05},{b:-.15}),c=new cc.Sprite(this.getFront(this._orb)),c.setPosition(.5*b.getContentSize().width,.5*b.getContentSize().height),b.addChild(c),b.setCbUp(this.click.bind(this)),this.addChild(b),
1<a&&(c=new cc.Sprite(Resource.CLIENT.spell("circle")),c.setPosition(67,16),b.addChild(c))):this._orb.isBought()&&(!this._enabled||this._active||0>=a)&&(b=new CSprite(this.getBack(this._orb)),c=new cc.Sprite(this.getFront(this._orb)),c.setPosition(.5*b.getContentSize().width,.5*b.getContentSize().height),b.addChild(c),b.setCascadeOpacityEnabled(!0),b.setBrightness(-.15),b.setOpacity(150),this.addChild(b),1<a&&(c=new cc.Sprite(Resource.CLIENT.spell("circle")),c.setPosition(67,16),b.addChild(c)));else{var b=
new CButton(this.getBack(this._orb),null,{b:.05},{b:-.15});var c=new cc.Sprite(this.getFront(this._orb));c.setPosition(.5*b.getContentSize().width,.5*b.getContentSize().height);b.addChild(c);b.setSound(Resource.SND.PURCHASE);b.setCbUp(this.click.bind(this));this.addChild(b);c=new CButton(Resource.POP.bt("green_3"),null,{b:.05},{b:-.15});c.setText(Lang.getString(Lang.CL_ORB_BUY),20,1);c.setPosition(0,-32);c.setScaleX(.8);c.setScaleY(.85);c.setCbUp(this.click.bind(this));c.setSound(Resource.SND.PURCHASE);
this.addChild(c)}}else this.addChild(new cc.Sprite(Resource.CLIENT.spell("back0"))),this.addChild(new cc.Sprite(Resource.CLIENT.spell("locked")))},eventHandler:function(a){var b=a.getEventName();a=a.getUserData()||{};b==User.EVENT.UPDATE_ORB&&a.orb==this._orb?this.updateContent():b==Client.EVENT.SPELL_USED&&this._type==a.type?(this._used++,this._active=!1,this.updateContent()):b==Client.EVENT.SPELL_ACTIVE&&this._type==a.type?(this._active=!0,this.updateContent()):b==Client.EVENT.SPELL_CANCEL&&this._type==
a.type&&(this._active=!1,this.updateContent())}});Client.RubyPanel=cc.Sprite.extend({_ext:null,_rubies:0,_step:0,_key0:0,_key1:0,_key2:0,_dump:null,_jump:0,_done:null,_scheduleOn:!1,_lb:null,ctor:function(a){this._super(Resource.CLIENT.ruby(0));this._ext=new CExtNode(this);a=String(a.r).split(",");this._key0=Number(a[0]);this._key1=Number(a[1]);this._key2=Number(a[2]);this._rubies=0;this._step=Math.min(18,415/(this._key2-1));this._dump=[];this._update=[];this._done=[];this._lb=new cc.LabelTTF("0/"+this._key0,Lang.F_GNUOLANE,14);this._lb.setPosition(37,
458);this.addChild(this._lb,0);a=new cc.Sprite(Resource.CLIENT.ruby(1));var b=new cc.Sprite(Resource.CLIENT.ruby(2)),c=new cc.Sprite(Resource.CLIENT.ruby(2));a.setPosition(31,230);b.setPosition(35,this._step*(this._key0-1)+28);c.setPosition(35,this._step*(this._key1-1)+28);this.addChild(a,10);this.addChild(b,10);this.addChild(c,10);this._ext.addCustomListener(Client.EVENT.UPDATE_RUBY,this.eventHandler.bind(this))},isReady:function(){return 0==this._dump.length&&0==this._jump},isEmptyDump:function(){return 0==
this._dump.length},getSphere:function(){var a=this.getRuby();return a>=this._key2?3:a>=this._key1?2:a>=this._key0?1:0},getRuby:function(a){return 1===a?this._key0:2===a?this._key1:3===a?this._key2:this._rubies+this._jump},eventHandler:function(a){this._dump.push(a.getUserData());this._scheduleOn||(this._scheduleOn=!0,this.schedule(this.checkDump,.08,cc.REPEAT_FOREVER))},checkDump:function(){if(0==this._dump.length)this.unschedule(this.checkDump),this._scheduleOn=!1;else{var a=this._dump.shift(),b=
app.Scene.getCurrent(),c=new cc.Sprite(Resource.CLIENT.jewel_ruby(a.k));c.setPosition(a);c.sr=c.getPosition();c.ds=this.convertToWorldSpace(new cc.Point(36,Math.min(435,(this._done.length+this._jump)*this._step+18)));b.addChild(c);this._jump++;c.runAction(new cc.Sequence(new cc.JumpTo(1,c.ds,Math.min(170,630-c.ds.y),1),new cc.CallFunc(this.jumpDone,this,c)));AudioEngine.playEffect(Resource.SND.CL_TAKE_RUBY)}},jumpDone:function(a){this._jump--;a.removeFromParent();a.setPosition(36,30+this._rubies*
this._step);if(435<a.getPositionY()){if(9<this._step)for(this._done.push(a),this.addChild(a),this._step=415/this._done.length,a=0;a<this._done.length;a++)this._done[a].setPositionY(28+a*this._step)}else this.addChild(a),this._done.push(a);this._rubies++;this._rubies!=this._key0&&this._rubies!=this._key1&&this._rubies!=this._key2||AudioEngine.playEffect(Resource.SND.CL_COLLECT_KEY);this._rubies<this._key0?this._lb.setString(this._rubies+"/"+this._key0):this._rubies<this._key1?this._lb.setString(this._rubies+
"/"+this._key1):this._lb.setString(this._rubies+"/"+this._key2)}});Client.Suggestion=cc.Node.extend({_grid:null,ctor:function(a){this._super();this._grid=a;a=new cc.Sprite(Resource.CLIENT.ui("arrow"));var b=new cc.Sprite(Resource.CLIENT.ui("arrow"));a.setAnchorPoint(.1,.5);b.setAnchorPoint(.9,.5);b.setFlippedY(!0);a.runAction(new cc.RepeatForever(new cc.Sequence([new cc.FadeTo(0,12.75),new cc.ScaleTo(0,1.5),new cc.FadeTo(.1,255),new cc.ScaleTo(.1,1),new cc.DelayTime(.1),new cc.MoveTo(.25,0,-12),new cc.MoveTo(.25,0,2),new cc.MoveTo(.25,0,-12),new cc.MoveTo(.25,0,
2),new cc.MoveTo(.25,0,-12),new cc.MoveTo(.25,0,2),new cc.FadeTo(.2,0),new cc.DelayTime(2)])));b.runAction(new cc.RepeatForever(new cc.Sequence([new cc.FadeTo(0,12.75),new cc.ScaleTo(0,1.5),new cc.FadeTo(.1,255),new cc.ScaleTo(.1,1),new cc.DelayTime(.1),new cc.MoveTo(.25,0,2),new cc.MoveTo(.25,0,-12),new cc.MoveTo(.25,0,2),new cc.MoveTo(.25,0,-12),new cc.MoveTo(.25,0,2),new cc.MoveTo(.25,0,-12),new cc.FadeTo(.2,0),new cc.DelayTime(2)])));this.addChild(a);this.addChild(b)}});Client.StatusPanel=cc.Sprite.extend({_message:"",_callback:null,_lock:null,ctor:function(a,b){this._super(Resource.CLIENT.ui("popup"));this._message=a;this._callback=b;var c=new cc.LabelTTF(a,Lang.F_GNUOLANE,20,null,cc.TEXT_ALIGNMENT_CENTER);c.setPosition(.5*this.getContentSize().width,.5*this.getContentSize().height);this.addChild(c);this.setPosition(435,800);this.runAction(new cc.Sequence([(new cc.MoveTo(.4,435,350)).easing(cc.easeSineOut()),new cc.DelayTime(1),new cc.Spawn((new cc.MoveTo(.3,435,
150)).easing(cc.easeSineIn()),new cc.FadeTo(.3,50)),new cc.RemoveSelf,new cc.CallFunc(function(){this._lock&&(this._lock.removeFromParent(),this._lock=null);this._callback&&this._callback()},this)]));this._lock=new cc.Layer;app.Scene.getCurrent()&&app.Scene.getCurrent().addChild(this._lock);cc.eventManager.addListener({event:cc.EventListener.MOUSE,onMouseMove:function(a){a.stopPropagation()},onMouseDown:function(a){a.stopPropagation()}},this._lock)}});cc.game.onStart=function(){var a=document.getElementById("gameCanvas");a.focus();a.style.width=a.width+"px";a.style.height=a.height+"px";var b=cc.create3DContext(a,{stencil:!0,alpha:!0,antialias:!1});b&&"undefined"!=typeof WebGLRenderingContext&&b instanceof WebGLRenderingContext&&(cc.loader.resPath="res",cc.view.setDesignResolutionSize(760,650,new cc.ResolutionPolicy(cc.ContainerStrategy.ORIGINAL_CONTAINER,cc.ContentStrategy.EXACT_FIT)),app.loadConfig(JSON.parse(a.getAttribute("config"))),app.runGame())};