cocos2d-html5-v3.0-rc1-core.min.js 255 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. var cc=cc||{};cc._tmp=cc._tmp||{};cc._LogInfos={};_p=window;_p=Object.prototype;delete window._p;cc.newElement=function(b){return document.createElement(b)};cc._addEventListener=function(f,e,h,g){f.addEventListener(e,h,g)};cc._isNodeJs="undefined"!==typeof require&&require("fs");cc.each=function(g,f,j){if(g){if(g instanceof Array){for(var i=0,h=g.length;i<h&&!1!==f.call(j,g[i],i);i++){}}else{for(i in g){if(!1===f.call(j,g[i],i)){break}}}}};cc.isCrossOrigin=function(d){if(!d){return cc.log("invalid URL"),!1}var c=d.indexOf("://");if(-1==c){return !1}c=d.indexOf("/",c+3);return(-1==c?d:d.substring(0,c))!=location.origin};cc.async={_counterFunc:function(u){var t=this.counter;if(!t.err){var s=t.length,r=t.results,q=t.option,o=q.cb,n=q.cbTarget,m=q.trigger,q=q.triggerTarget;if(u){if(t.err=u,o){return o.call(n,u)}}else{var j=Array.apply(null,arguments).slice(1),i=j.length;0==i?j=null:1==i&&(j=j[0]);r[this.index]=j;t.count--;m&&m.call(q,j,s-t.count,s);0==t.count&&o&&o.apply(n,[null,r])}}},_emptyFunc:function(){},parallel:function(h,g,m){var k=cc.async;if(void 0!==m){"function"==typeof g&&(g={trigger:g}),g.cb=m||g.cb}else{if(void 0!==g){"function"==typeof g&&(g={cb:g})}else{if(void 0!==h){g={}}else{throw"arguments error!"}}}var j=(m=h instanceof Array)?h.length:Object.keys(h).length;if(0==j){g.cb&&g.cb.call(g.cbTarget,null)}else{var i={length:j,count:j,option:g,results:m?[]:{}};cc.each(h,function(b,f){if(i.err){return !1}var d=!g.cb&&!g.trigger?k._emptyFunc:k._counterFunc.bind({counter:i,index:f});b(d,f)})}},map:function(i,h,o){var n=this,m=arguments.length;"function"==typeof h&&(h={iterator:h});if(3===m){h.cb=o||h.cb}else{if(2>m){throw"arguments error!"}}"function"==typeof h&&(h={iterator:h});if(void 0!==o){h.cb=o||h.cb}else{if(void 0===i){throw"arguments error!"}}var k=(m=i instanceof Array)?i.length:Object.keys(i).length;if(0===k){h.cb&&h.cb.call(h.cbTarget,null)}else{var j={length:k,count:k,option:h,results:m?[]:{}};cc.each(i,function(b,f){if(j.err){return !1}var d=!h.cb?n._emptyFunc:n._counterFunc.bind({counter:j,index:f});h.iterator.call(h.iteratorTarget,b,f,d)})}}};cc.path={join:function(){for(var e=arguments.length,d="",f=0;f<e;f++){d=(d+(""==d?"":"/")+arguments[f]).replace(/(\/|\\\\)$/,"")}return d},extname:function(b){return(b=/(\.[^\.\/\?\\]*)(\?.*)?$/.exec(b))?b[1]:null},mainFileName:function(d){if(d){var c=d.lastIndexOf(".");if(-1!==c){return d.substring(0,c)}}return d},basename:function(e,d){var f=e.indexOf("?");0<f&&(e=e.substring(0,f));f=/(\/|\\\\)([^(\/|\\\\)]+)$/g.exec(e.replace(/(\/|\\\\)$/,""));if(!f){return null}f=f[2];return d&&e.substring(e.length-d.length).toLowerCase()==d.toLowerCase()?f.substring(0,f.length-d.length):f},dirname:function(b){return b.replace(/((.*)(\/|\\|\\\\))?(.*?\..*$)?/,"$2")},changeExtname:function(f,e){e=e||"";var h=f.indexOf("?"),g="";0<h&&(g=f.substring(h),f=f.substring(0,h));h=f.lastIndexOf(".");return 0>h?f+e+g:f.substring(0,h)+e+g},changeBasename:function(g,f,j){if(0==f.indexOf(".")){return this.changeExtname(g,f)}var i=g.indexOf("?"),h="";j=j?this.extname(g):"";0<i&&(h=g.substring(i),g=g.substring(0,i));i=g.lastIndexOf("/");return g.substring(0,0>=i?0:i+1)+f+j+h}};cc.loader={_jsCache:{},_register:{},_langPathCache:{},_aliases:{},resPath:res_path,audioPath:res_path,cache:{},getXMLHttpRequest:function(){return window.XMLHttpRequest?new window.XMLHttpRequest:new ActiveXObject("MSXML2.XMLHTTP")},_getArgs4Js:function(g){var f=g[0],j=g[1],i=g[2],h=["",null,null];if(1===g.length){h[1]=f instanceof Array?f:[f]}else{if(2===g.length){"function"==typeof j?(h[1]=f instanceof Array?f:[f],h[2]=j):(h[0]=f||"",h[1]=j instanceof Array?j:[j])}else{if(3===g.length){h[0]=f||"",h[1]=j instanceof Array?j:[j],h[2]=i}else{throw"arguments error to load js!"}}}return h},loadJs:function(h,g,m){var k=this,j=k._jsCache,i=k._getArgs4Js(arguments);-1<navigator.userAgent.indexOf("Trident/5")?k._loadJs4Dependency(i[0],i[1],0,i[2]):cc.async.map(i[1],function(e,d,f){e=cc.path.join(i[0],e);if(j[e]){return f(null)}k._createScript(e,!1,f)},i[2])},loadJsWithImg:function(g,f,j){var i=this._loadJsImg(),h=this._getArgs4Js(arguments);this.loadJs(h[0],h[1],function(b){if(b){throw b}i.parentNode.removeChild(i);if(h[2]){h[2]()}})},_createScript:function(g,f,j){var i=document,h=cc.newElement("script");h.async=f;h.src=g;this._jsCache[g]=!0;cc._addEventListener(h,"load",function(){this.removeEventListener("load",arguments.callee,!1);j()},!1);cc._addEventListener(h,"error",function(){j("Load "+g+" failed!")},!1);i.body.appendChild(h)},_loadJs4Dependency:function(g,f,j,i){if(j>=f.length){i&&i()}else{var h=this;h._createScript(cc.path.join(g,f[j]),!1,function(a){if(a){return i(a)}h._loadJs4Dependency(g,f,j+1,i)})}},_loadJsImg:function(){var e=document,d=e.getElementById("cocos2d_loadJsImg");if(!d){d=cc.newElement("img");cc._loadingImage&&(d.src=cc._loadingImage);cc.game.config.id="gameCanvas";e=e.getElementById(cc.game.config.id);e.style.backgroundColor="black";e.parentNode.appendChild(d);var f=getComputedStyle?getComputedStyle(e):e.currentStyle;
  2. f||(f={width:e.width,height:e.height});d.style.left=e.offsetLeft+(parseFloat(f.width)-d.width)/2+"px";d.style.top=e.offsetTop+(parseFloat(f.height)-d.height)/2+"px";d.style.position="absolute"}return d},loadTxt:function(f,e){if(cc._isNodeJs){require("fs").readFile(f,function(b,d){b?e(b):e(null,d.toString())})}else{var h=this.getXMLHttpRequest(),g="load "+f+" failed!";h.open("GET",f,!0);/msie/i.test(navigator.userAgent)&&!/opera/i.test(navigator.userAgent)?(h.setRequestHeader("Accept-Charset","utf-8"),h.onreadystatechange=function(){4==h.readyState&&200==h.status?e(null,h.responseText):e(g)}):(h.overrideMimeType&&h.overrideMimeType("text/plain; charset\x3dutf-8"),h.onload=function(){4==h.readyState&&200==h.status?e(null,h.responseText):e(g)});h.send(null)}},_loadTxtSync:function(d){if(cc._isNodeJs){return require("fs").readFileSync(d).toString()}var c=this.getXMLHttpRequest();c.open("GET",d,!1);/msie/i.test(navigator.userAgent)&&!/opera/i.test(navigator.userAgent)?c.setRequestHeader("Accept-Charset","utf-8"):c.overrideMimeType&&c.overrideMimeType("text/plain; charset\x3dutf-8");c.send(null);return 4==!c.readyState||200!=c.status?null:c.responseText},loadJson:function(d,c){this.loadTxt(d,function(f,b){try{f?c(f):c(null,JSON.parse(b))}catch(a){throw"load json ["+d+"] failed : "+a}})},_checkIsImageURL:function(b){return null!=/(\.png)|(\.jpg)|(\.bmp)|(\.jpeg)|(\.gif)/.exec(b)},loadImg:function(g,f,j){var i=!0;void 0!==j?i=null==f.isCrossOrigin?i:f.isCrossOrigin:void 0!==f&&(j=f);var h=new Image;i&&"file://"!=location.origin&&(h.crossOrigin="Anonymous");cc._addEventListener(h,"load",function(){this.removeEventListener("load",arguments.callee,!1);this.removeEventListener("error",arguments.callee,!1);j&&j(null,h)});cc._addEventListener(h,"error",function(){this.removeEventListener("error",arguments.callee,!1);j&&j("load image failed")});h.src=g;return h},_loadResIterator:function(h,g,m){var k=this,j=null,i=h.type;i?(i="."+i.toLowerCase(),j=h.src?h.src:h.name+i):(j=h,i=cc.path.extname(j));if(g=k.cache[j]){return m(null,g)}g=k._register[i.toLowerCase()];if(!g){return cc.error("loader for ["+i+"] not exists!"),m()}i=g.getBasePath?g.getBasePath():k.resPath;i=k.getUrl(i,j);g.load(i,j,h,function(d,c){d?(cc.log(d),k.cache[j]=null,delete k.cache[j],m()):(k.cache[j]=c,m(null,c))})},getUrl:function(g,f){var j=this._langPathCache,i=cc.path;if(void 0!==g&&void 0===f){f=g;var h=i.extname(f),h=h?h.toLowerCase():"";g=(h=this._register[h])?h.getBasePath?h.getBasePath():this.resPath:this.resPath}f=cc.path.join(g||"",f);if(f.match(/[\/(\\\\)]lang[\/(\\\\)]/i)){if(j[f]){return j[f]}i=i.extname(f)||"";f=j[f]=f.substring(0,f.length-i.length)+"_"+cc.sys.language+i}return f},load:function(e,d,f){if(void 0!==f){"function"==typeof d&&(d={trigger:d})}else{if(void 0!==d){"function"==typeof d&&(f=d,d={})}else{if(void 0!==e){d={}}else{throw"arguments error!"}}}d.cb=function(g,c){g&&cc.log(g);f&&f(c)};e instanceof Array||(e=[e]);d.iterator=this._loadResIterator;d.iteratorTarget=this;cc.async.map(e,d)},_handleAliases:function(h,g){var m=this._aliases,k=[],j;for(j in h){var i=h[j];m[j]=i;k.push(i)}this.load(k,g)},loadAliases:function(f,e){var h=this,g=h.getRes(f);g?h._handleAliases(g.filenames,e):h.load(f,function(b){h._handleAliases(b[0].filenames,e)})},register:function(f,e){if(f&&e){if("string"==typeof f){return this._register[f.trim().toLowerCase()]=e}for(var h=0,g=f.length;h<g;h++){this._register["."+f[h].trim().toLowerCase()]=e}}},getRes:function(b){return this.cache[b]||this.cache[this._aliases[b]]},release:function(e){var d=this.cache,f=this._aliases;delete d[e];delete d[f[e]];delete f[e]},releaseAll:function(){var e=this.cache,d=this._aliases,f;for(f in e){delete e[f]}for(f in d){delete d[f]}}};(function(){var g=window,f,j;"undefined"!==typeof document.hidden?(f="hidden",j="visibilitychange"):"undefined"!==typeof document.mozHidden?(f="mozHidden",j="mozvisibilitychange"):"undefined"!==typeof document.msHidden?(f="msHidden",j="msvisibilitychange"):"undefined"!==typeof document.webkitHidden&&(f="webkitHidden",j="webkitvisibilitychange");var i=function(){cc.eventManager&&cc.game._eventHide&&cc.eventManager.dispatchEvent(cc.game._eventHide)},h=function(){cc.eventManager&&cc.game._eventShow&&cc.eventManager.dispatchEvent(cc.game._eventShow)};f?cc._addEventListener(document,j,function(){document[f]?i():h()},!1):(cc._addEventListener(g,"blur",i,!1),cc._addEventListener(g,"focus",h,!1));"onpageshow" in window&&"onpagehide" in window&&(cc._addEventListener(g,"pagehide",i,!1),cc._addEventListener(g,"pageshow",h,!1));j=g=null})();cc.log=cc.warn=cc.error=cc.assert=function(){};cc.create3DContext=function(h,g){for(var m=["webgl","experimental-webgl","webkit-3d","moz-webgl"],k=null,j=0;j<m.length;++j){try{k=h.getContext(m[j],g)}catch(i){}if(k){break}}return k};cc._initSys=function(D,C){cc._RENDER_TYPE_CANVAS=0;cc._RENDER_TYPE_WEBGL=1;var B=cc.sys={};B.LANGUAGE_ENGLISH="en";B.LANGUAGE_CHINESE="zh";B.LANGUAGE_FRENCH="fr";B.LANGUAGE_ITALIAN="it";B.LANGUAGE_GERMAN="de";
  3. B.LANGUAGE_SPANISH="es";B.LANGUAGE_RUSSIAN="ru";B.LANGUAGE_KOREAN="ko";B.LANGUAGE_JAPANESE="ja";B.LANGUAGE_HUNGARIAN="hu";B.LANGUAGE_PORTUGUESE="pt";B.LANGUAGE_ARABIC="ar";B.LANGUAGE_NORWEGIAN="no";B.LANGUAGE_POLISH="pl";B.OS_WINDOWS="Windows";B.OS_IOS="iOS";B.OS_OSX="OS X";B.OS_UNIX="UNIX";B.OS_LINUX="Linux";B.OS_ANDROID="Android";B.OS_UNKNOWN="Unknown";B.BROWSER_TYPE_WECHAT="wechat";B.BROWSER_TYPE_ANDROID="androidbrowser";B.BROWSER_TYPE_IE="ie";B.BROWSER_TYPE_QQ="qqbrowser";B.BROWSER_TYPE_MOBILE_QQ="mqqbrowser";B.BROWSER_TYPE_UC="ucbrowser";B.BROWSER_TYPE_360="360browser";B.BROWSER_TYPE_BAIDU_APP="baiduboxapp";B.BROWSER_TYPE_BAIDU="baidubrowser";B.BROWSER_TYPE_MAXTHON="maxthon";B.BROWSER_TYPE_OPERA="opera";B.BROWSER_TYPE_MIUI="miuibrowser";B.BROWSER_TYPE_FIREFOX="firefox";B.BROWSER_TYPE_SAFARI="safari";B.BROWSER_TYPE_CHROME="chrome";B.BROWSER_TYPE_UNKNOWN="unknown";B.isNative=!1;var A=[B.BROWSER_TYPE_BAIDU,B.BROWSER_TYPE_OPERA,B.BROWSER_TYPE_FIREFOX,B.BROWSER_TYPE_CHROME,B.BROWSER_TYPE_SAFARI],z=[B.BROWSER_TYPE_BAIDU,B.BROWSER_TYPE_OPERA,B.BROWSER_TYPE_FIREFOX,B.BROWSER_TYPE_CHROME,B.BROWSER_TYPE_SAFARI,B.BROWSER_TYPE_UC,B.BROWSER_TYPE_QQ,B.BROWSER_TYPE_MOBILE_QQ,B.BROWSER_TYPE_IE],y=window,x=y.navigator,w=document.documentElement,v=x.userAgent.toLowerCase();B.isMobile=-1!=v.indexOf("mobile")||-1!=v.indexOf("android");var u=x.language,u=(u=u?u:x.browserLanguage)?u.split("-")[0]:B.LANGUAGE_ENGLISH;B.language=u;var u=B.BROWSER_TYPE_UNKNOWN,s=v.match(/micromessenger|qqbrowser|mqqbrowser|ucbrowser|360browser|baiduboxapp|baidubrowser|maxthon|trident|opera|miuibrowser|firefox/i)||v.match(/chrome|safari/i);s&&0<s.length&&(u=s[0].toLowerCase(),"micromessenger"==u?u=B.BROWSER_TYPE_WECHAT:"safari"===u&&v.match(/android.*applewebkit/)?u=B.BROWSER_TYPE_ANDROID:"trident"==u&&(u=B.BROWSER_TYPE_IE));B.browserType=u;B._supportMultipleAudio=-1<z.indexOf(B.browserType);z=parseInt(D[C.renderMode]);u=cc._RENDER_TYPE_WEBGL;s=cc.newElement("Canvas");cc._supportRender=!0;A=-1==A.indexOf(B.browserType);if(1===z||0===z&&(B.isMobile||A)){u=cc._RENDER_TYPE_CANVAS}if(u==cc._RENDER_TYPE_WEBGL&&(!y.WebGLRenderingContext||!cc.create3DContext(s,{stencil:!0,preserveDrawingBuffer:!0}))){0==z?u=cc._RENDER_TYPE_CANVAS:cc._supportRender=!1}if(u==cc._RENDER_TYPE_CANVAS){try{s.getContext("2d")}catch(o){cc._supportRender=!1}}cc._renderType=u;try{B._supportWebAudio=!!new (y.AudioContext||y.webkitAudioContext||y.mozAudioContext)}catch(j){B._supportWebAudio=!1}try{var i=B.localStorage=y.localStorage;i.setItem("storage","");i.removeItem("storage");i=null}catch(E){("SECURITY_ERR"===E.name||"QuotaExceededError"===E.name)&&cc.warn("Warning: localStorage isn't enabled. Please confirm browser cookie or privacy option"),B.localStorage=function(){}}i=B.capabilities={canvas:!0};cc._renderType==cc._RENDER_TYPE_WEBGL&&(i.opengl=!0);void 0!==w.ontouchstart||x.msPointerEnabled?i.touches=!0:void 0!==w.onmouseup&&(i.mouse=!0);void 0!==w.onkeyup&&(i.keyboard=!0);if(y.DeviceMotionEvent||y.DeviceOrientationEvent){i.accelerometer=!0}y=v.match(/(iPad|iPhone|iPod)/i)?!0:!1;v=v.match(/android/i)||x.platform.match(/android/i)?!0:!1;w=B.OS_UNKNOWN;-1!=x.appVersion.indexOf("Win")?w=B.OS_WINDOWS:y?w=B.OS_IOS:-1!=x.appVersion.indexOf("Mac")?w=B.OS_OSX:-1!=x.appVersion.indexOf("X11")?w=B.OS_UNIX:-1!=x.appVersion.indexOf("Linux")?w=B.OS_LINUX:v&&(w=B.OS_ANDROID);B.os=w;B.garbageCollect=function(){};B.dumpRoot=function(){};B.restartVM=function(){};B.dump=function(){var b;b=""+("isMobile : "+this.isMobile+"\r\n");b+="language : "+this.language+"\r\n";b+="browserType : "+this.browserType+"\r\n";b+="capabilities : "+JSON.stringify(this.capabilities)+"\r\n";b+="os : "+this.os+"\r\n";cc.log(b)}};cc.ORIENTATION_PORTRAIT=0;cc.ORIENTATION_PORTRAIT_UPSIDE_DOWN=1;cc.ORIENTATION_LANDSCAPE_LEFT=2;cc.ORIENTATION_LANDSCAPE_RIGHT=3;cc._drawingUtil=null;cc._renderContext=null;cc._canvas=null;cc._gameDiv=null;cc._rendererInitialized=!1;cc._setupCalled=!1;cc._setup=function(h,g,m){if(!cc._setupCalled){cc._setupCalled=!0;var k=window;k.requestAnimFrame=k.requestAnimationFrame||k.webkitRequestAnimationFrame||k.mozRequestAnimationFrame||k.oRequestAnimationFrame||k.msRequestAnimationFrame;var j=cc.$(h)||cc.$("#"+h),i;"CANVAS"==j.tagName?(g=g||j.width,m=m||j.height,i=cc.container=cc.newElement("DIV"),h=cc._canvas=j,h.parentNode.insertBefore(i,h),h.appendTo(i),i.setAttribute("id","Cocos2dGameContainer")):("DIV"!=j.tagName&&cc.log("Warning: target element is not a DIV or CANVAS"),g=g||j.clientWidth,m=m||j.clientHeight,i=cc.container=j,h=cc._canvas=cc.$(cc.newElement("CANVAS")),j.appendChild(h));h.addClass("gameCanvas");h.setAttribute("width",g||480);h.setAttribute("height",m||320);h.setAttribute("tabindex",99);h.style.outline="none";j=i.style;j.width=(g||480)+"px";j.height=(m||320)+"px";j.margin="0 auto";j.position="relative";j.overflow="hidden";i.top="100%";cc._renderType==cc._RENDER_TYPE_WEBGL&&(cc._renderContext=cc.webglContext=cc.create3DContext(h,{stencil:!0,preserveDrawingBuffer:!0,antialias:!cc.sys.isMobile,alpha:!1}));
  4. cc._renderContext?(k.gl=cc._renderContext,cc._drawingUtil=new cc.DrawingPrimitiveWebGL(cc._renderContext),cc._rendererInitialized=!0,cc.textureCache._initializingRenderer(),cc.shaderCache._init()):(cc._renderContext=h.getContext("2d"),cc._mainRenderContextBackup=cc._renderContext,cc._renderContext.translate(0,h.height),cc._drawingUtil=cc.DrawingPrimitiveCanvas?new cc.DrawingPrimitiveCanvas(cc._renderContext):null);cc._gameDiv=i;cc.log(cc.ENGINE_VERSION);cc._setContextMenuEnable(!1);cc.sys.isMobile&&(g=cc.newElement("style"),g.type="text/css",document.body.appendChild(g),g.textContent="body,canvas,div{ -moz-user-select: none;-webkit-user-select: none;-ms-user-select: none;-khtml-user-select: none;-webkit-tap-highlight-color:rgba(0,0,0,0);}");cc.view=cc.EGLView._getInstance();cc.inputManager.registerSystemEvent(cc._canvas);cc.director=cc.Director._getInstance();cc.director.setOpenGLView&&cc.director.setOpenGLView(cc.view);cc.winSize=cc.director.getWinSize();cc.saxParser=new cc.SAXParser;cc.plistParser=new cc.PlistParser}};cc._checkWebGLRenderMode=function(){if(cc._renderType!==cc._RENDER_TYPE_WEBGL){throw"This feature supports WebGL render mode only."}};cc._isContextMenuEnable=!1;cc._setContextMenuEnable=function(b){cc._isContextMenuEnable=b;cc._canvas.oncontextmenu=function(){if(!cc._isContextMenuEnable){return !1}}};cc.game={DEBUG_MODE_NONE:0,DEBUG_MODE_INFO:1,DEBUG_MODE_WARN:2,DEBUG_MODE_ERROR:3,DEBUG_MODE_INFO_FOR_WEB_PAGE:4,DEBUG_MODE_WARN_FOR_WEB_PAGE:5,DEBUG_MODE_ERROR_FOR_WEB_PAGE:6,EVENT_HIDE:"game_on_hide",EVENT_SHOW:"game_on_show",_eventHide:null,_eventShow:null,_onBeforeStartArr:[],CONFIG_KEY:{engineDir:"engineDir",dependencies:"dependencies",debugMode:"debugMode",showFPS:"showFPS",frameRate:"frameRate",id:"id",renderMode:"renderMode",jsList:"jsList",classReleaseMode:"classReleaseMode"},_prepareCalled:!1,_prepared:!1,_paused:!0,_intervalId:null,config:null,onStart:null,onStop:null,setFrameRate:function(b){this.config[this.CONFIG_KEY.frameRate]=b;this._intervalId&&clearInterval(this._intervalId);this._paused=!0;this._runMainLoop()},_runMainLoop:function(){var i=this,h,o=i.config,n=i.CONFIG_KEY,m=window,k=o[n.frameRate],j=cc.director;j.setDisplayStats(o[n.showFPS]);m.requestAnimFrame&&60==k?(h=function(){i._paused||(j.mainLoop(),m.requestAnimFrame(h))},m.requestAnimFrame(h)):(h=function(){j.mainLoop()},i._intervalId=setInterval(h,1000/k));i._paused=!1},run:function(e){var d=this,f=function(){e&&(d.config[d.CONFIG_KEY.id]=e);d._prepareCalled?cc._supportRender&&(d._checkPrepare=setInterval(function(){d._prepared&&(cc._setup(d.config[d.CONFIG_KEY.id]),d._runMainLoop(),d._eventHide=d._eventHide||new cc.EventCustom(d.EVENT_HIDE),d._eventHide.setUserData(d),d._eventShow=d._eventShow||new cc.EventCustom(d.EVENT_SHOW),d._eventShow.setUserData(d),d.onStart(),clearInterval(d._checkPrepare))},10)):d.prepare(function(){cc._supportRender&&(cc._setup(d.config[d.CONFIG_KEY.id]),d._runMainLoop(),d._eventHide=d._eventHide||new cc.EventCustom(d.EVENT_HIDE),d._eventHide.setUserData(d),d._eventShow=d._eventShow||new cc.EventCustom(d.EVENT_SHOW),d._eventShow.setUserData(d),d.onStart())})};document.body?f():cc._addEventListener(window,"load",function(){this.removeEventListener("load",arguments.callee,!1);f()},!1)},_initConfig:function(){var u=this.CONFIG_KEY,t=function(a){a[u.engineDir]=a[u.engineDir]||"frameworks/cocos2d-html5";null==a[u.debugMode]&&(a[u.debugMode]=0);a[u.frameRate]=a[u.frameRate]||60;null==a[u.renderMode]&&(a[u.renderMode]=1);return a};if(document.ccConfig){this.config=t(document.ccConfig)}else{try{for(var s=document.getElementsByTagName("script"),r=0;r<s.length;r++){var q=s[r].getAttribute("cocos");if(""==q||q){break}}var o,n,m;if(r<s.length){if(o=s[r].src){m=/(.*)\//.exec(o)[0],cc.loader.resPath=m,o=cc.path.join(m,"project.json")}n=cc.loader._loadTxtSync(o)}n||(n=cc.loader._loadTxtSync("project.json"));var j=JSON.parse(n);this.config=t(j||{})}catch(i){cc.log("Failed to read or parse project.json"),this.config=t({})}}cc._initSys(this.config,u)},_jsAddedCache:{},_getJsListOfModule:function(u,t,s){var r=this._jsAddedCache;if(r[t]){return null}s=s||"";var q=[],o=u[t];if(!o){throw"can not find module ["+t+"]"}t=cc.path;for(var n=0,m=o.length;n<m;n++){var j=o[n];if(!r[j]){var i=t.extname(j);i?".js"==i.toLowerCase()&&q.push(t.join(s,j)):(i=this._getJsListOfModule(u,j,s))&&(q=q.concat(i));r[j]=1}}return q},prepare:function(i){var h=this,o=h.config,n=h.CONFIG_KEY,m=o[n.engineDir],k=cc.loader;if(cc._supportRender){h._prepareCalled=!0;var j=o[n.jsList]||[];cc.Class?k.loadJsWithImg("",j,function(a){if(a){throw a}h._prepared=!0;i&&i()}):(n=cc.path.join(m,"moduleConfig.json"),k.loadJson(n,function(u,s){if(u){throw u}var b=o.modules||[],a=s.module,v=[];cc._renderType==cc._RENDER_TYPE_WEBGL?b.splice(0,0,"shaders"):0>b.indexOf("core")&&b.splice(0,0,"core");for(var g=0,e=b.length;g<e;g++){var c=h._getJsListOfModule(a,b[g],m);c&&(v=v.concat(c))}v=v.concat(j);cc.loader.loadJsWithImg(v,function(d){if(d){throw d}h._prepared=!0;
  5. i&&i()})}))}else{cc.error("Can not support render!")}}};cc.game._initConfig();var cc=cc||{},ClassManager={id:0|998*Math.random(),instanceId:0|998*Math.random(),compileSuper:function(i,h,o){i=i.toString();var n=i.indexOf("("),m=i.indexOf(")"),n=i.substring(n+1,m),n=n.trim(),m=i.indexOf("{"),k=i.lastIndexOf("}");for(i=i.substring(m+1,k);-1!=i.indexOf("this._super");){var m=i.indexOf("this._super"),k=i.indexOf("(",m),j=i.indexOf(")",k),j=i.substring(k+1,j),j=(j=j.trim())?",":"";i=i.substring(0,m)+"ClassManager["+o+"]."+h+".call(this"+j+i.substring(k+1)}return Function(n,i)},getNewID:function(){return this.id++},getNewInstanceId:function(){return this.instanceId++}};ClassManager.compileSuper.ClassManager=ClassManager;(function(){var d=/\b_super\b/,c=cc.game.config[cc.game.CONFIG_KEY.classReleaseMode];c&&console.log("release Mode");cc.Class=function(){};cc.Class.extend=function(C){function B(){this.__instanceId=ClassManager.getNewInstanceId();this.ctor&&this.ctor.apply(this,arguments)}var A=this.prototype,z=Object.create(A),y=ClassManager.getNewID();ClassManager[y]=A;var x={writable:!0,enumerable:!1,configurable:!0};z.__instanceId=null;B.id=y;x.value=y;Object.defineProperty(z,"__pid",x);B.prototype=z;x.value=B;Object.defineProperty(B.prototype,"constructor",x);this.__getters__&&(B.__getters__=cc.clone(this.__getters__));this.__setters__&&(B.__setters__=cc.clone(this.__setters__));for(var w=0,o=arguments.length;w<o;++w){var j=arguments[w],i;for(i in j){var b="function"===typeof j[i],a="function"===typeof A[i],F=d.test(j[i]);c&&b&&a&&F?(x.value=ClassManager.compileSuper(j[i],i,y),Object.defineProperty(z,i,x)):b&&a&&F?(x.value=function(f,e){return function(){var h=this._super;this._super=A[f];var g=e.apply(this,arguments);this._super=h;return g}}(i,j[i]),Object.defineProperty(z,i,x)):b?(x.value=j[i],Object.defineProperty(z,i,x)):z[i]=j[i];if(b){var G,D;if(this.__getters__&&this.__getters__[i]){var b=this.__getters__[i],E;for(E in this.__setters__){if(this.__setters__[E]==b){D=E;break}}cc.defineGetterSetter(z,b,j[i],j[D]?j[D]:z[D],i,D)}if(this.__setters__&&this.__setters__[i]){b=this.__setters__[i];for(E in this.__getters__){if(this.__getters__[E]==b){G=E;break}}cc.defineGetterSetter(z,b,j[G]?j[G]:z[G],j[i],G,i)}}}}B.extend=cc.Class.extend;B.implement=function(f){for(var e in f){z[e]=f[e]}};return B};Function.prototype.bind=Function.prototype.bind||function(f){var e=this;return function(){var a=Array.prototype.slice.call(arguments);return e.apply(f||null,a)}}})();cc.defineGetterSetter=function(y,x,w,v,u,t){if(y.__defineGetter__){w&&y.__defineGetter__(x,w),v&&y.__defineSetter__(x,v)}else{if(Object.defineProperty){var s={enumerable:!1,configurable:!0};w&&(s.get=w);v&&(s.set=v);Object.defineProperty(y,x,s)}else{throw Error("browser does not support getters")}}if(!u&&!t){for(var s=null!=w,r=void 0!=v,q=Object.getOwnPropertyNames(y),o=0;o<q.length;o++){var j=q[o];if(!((y.__lookupGetter__?y.__lookupGetter__(j):Object.getOwnPropertyDescriptor(y,j))||"function"!==typeof y[j])){var i=y[j];if(s&&i===w&&(u=j,!r||t)){break}if(r&&i===v&&(t=j,!s||u)){break}}}}y=y.constructor;u&&(y.__getters__||(y.__getters__={}),y.__getters__[u]=x);t&&(y.__setters__||(y.__setters__={}),y.__setters__[t]=x)};cc.clone=function(f){var e=f.constructor?new f.constructor:{},h;for(h in f){var g=f[h];e[h]="object"==typeof g&&g&&!(g instanceof cc.Node)&&!(g instanceof HTMLElement)?cc.clone(g):g}return e};cc.Point=function(d,c){this.x=d||0;this.y=c||0};cc.p=function(d,c){return void 0==d?{x:0,y:0}:void 0==c?{x:d.x,y:d.y}:{x:d,y:c}};cc.pointEqualToPoint=function(d,c){return d&&c&&d.x===c.x&&d.y===c.y};cc.Size=function(d,c){this.width=d||0;this.height=c||0};cc.size=function(d,c){return void 0===d?{width:0,height:0}:void 0===c?{width:d.width,height:d.height}:{width:d,height:c}};cc.sizeEqualToSize=function(d,c){return d&&c&&d.width==c.width&&d.height==c.height};cc.Rect=function(f,e,h,g){this.x=f||0;this.y=e||0;this.width=h||0;this.height=g||0};cc.rect=function(f,e,h,g){return void 0===f?{x:0,y:0,width:0,height:0}:void 0===e?{x:f.x,y:f.y,width:f.width,height:f.height}:{x:f,y:e,width:h,height:g}};cc.rectEqualToRect=function(d,c){return d&&c&&d.x===c.x&&d.y===c.y&&d.width===c.width&&d.height===c.height};cc._rectEqualToZero=function(b){return b&&0===b.x&&0===b.y&&0===b.width&&0===b.height};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(e){this._width=e.width,this._height=e.height;var d=this._width,f=this._height;this._topLeft.y=f,this._topRight.x=d,this._topRight.y=f,this._top.x=d/2,this._top.y=f,this._bottomRight.x=d,this._bottom.x=d/2,this._center.x=d/2,this._center.y=f/2,this._left.y=f/2,this._right.x=d,this._right.y=f/2}},cc.visibleRect.width,cc.defineGetterSetter(cc.visibleRect,"width",function(){return this._width}),cc.visibleRect.height,cc.defineGetterSetter(cc.visibleRect,"height",function(){return this._height
  6. }),cc.visibleRect.topLeft,cc.defineGetterSetter(cc.visibleRect,"topLeft",function(){return this._topLeft}),cc.visibleRect.topRight,cc.defineGetterSetter(cc.visibleRect,"topRight",function(){return this._topRight}),cc.visibleRect.top,cc.defineGetterSetter(cc.visibleRect,"top",function(){return this._top}),cc.visibleRect.bottomLeft,cc.defineGetterSetter(cc.visibleRect,"bottomLeft",function(){return this._bottomLeft}),cc.visibleRect.bottomRight,cc.defineGetterSetter(cc.visibleRect,"bottomRight",function(){return this._bottomRight}),cc.visibleRect.bottom,cc.defineGetterSetter(cc.visibleRect,"bottom",function(){return this._bottom}),cc.visibleRect.center,cc.defineGetterSetter(cc.visibleRect,"center",function(){return this._center}),cc.visibleRect.left,cc.defineGetterSetter(cc.visibleRect,"left",function(){return this._left}),cc.visibleRect.right,cc.defineGetterSetter(cc.visibleRect,"right",function(){return this._right});cc.rectContainsRect=function(d,c){return !d||!c?!1:!(d.x>=c.x||d.y>=c.y||d.x+d.width<=c.x+c.width||d.y+d.height<=c.y+c.height)};cc.rectGetMaxX=function(b){return b.x+b.width};cc.rectGetMidX=function(b){return b.x+b.width/2};cc.rectGetMinX=function(b){return b.x};cc.rectGetMaxY=function(b){return b.y+b.height};cc.rectGetMidY=function(b){return b.y+b.height/2};cc.rectGetMinY=function(b){return b.y};cc.rectContainsPoint=function(d,c){return c.x>=cc.rectGetMinX(d)&&c.x<=cc.rectGetMaxX(d)&&c.y>=cc.rectGetMinY(d)&&c.y<=cc.rectGetMaxY(d)};cc.rectIntersectsRect=function(g,f){var j=g.y+g.height,i=f.x+f.width,h=f.y+f.height;return !(g.x+g.width<f.x||i<g.x||j<f.y||h<g.y)};cc.rectOverlapsRect=function(d,c){return !(d.x+d.width<c.x||c.x+c.width<d.x||d.y+d.height<c.y||c.y+c.height<d.y)};cc.rectUnion=function(e,d){var f=cc.rect(0,0,0,0);f.x=Math.min(e.x,d.x);f.y=Math.min(e.y,d.y);f.width=Math.max(e.x+e.width,d.x+d.width)-f.x;f.height=Math.max(e.y+e.height,d.y+d.height)-f.y;return f};cc.rectIntersection=function(e,d){var f=cc.rect(Math.max(cc.rectGetMinX(e),cc.rectGetMinX(d)),Math.max(cc.rectGetMinY(e),cc.rectGetMinY(d)),0,0);f.width=Math.min(cc.rectGetMaxX(e),cc.rectGetMaxX(d))-cc.rectGetMinX(f);f.height=Math.min(cc.rectGetMaxY(e),cc.rectGetMaxY(d))-cc.rectGetMinY(f);return f};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(b){return this._parseXML(b)},_parseXML:function(d){var c;this._isSupportDOMParser?c=this._parser.parseFromString(d,"text/xml"):(c=new ActiveXObject("Microsoft.XMLDOM"),c.async="false",c.loadXML(d));return c}});cc.PlistParser=cc.SAXParser.extend({parse:function(f){f=this._parseXML(f).documentElement;if("plist"!=f.tagName){throw"Not a plist file!"}for(var e=null,h=0,g=f.childNodes.length;h<g&&!(e=f.childNodes[h],1==e.nodeType);h++){}return this._parseNode(e)},_parseNode:function(e){var d=null,f=e.tagName;if("dict"==f){d=this._parseDict(e)}else{if("array"==f){d=this._parseArray(e)}else{if("string"==f){if(1==e.childNodes.length){d=e.firstChild.nodeValue}else{d="";for(f=0;f<e.childNodes.length;f++){d+=e.childNodes[f].nodeValue}}}else{"false"==f?d=!1:"true"==f?d=!0:"real"==f?d=parseFloat(e.firstChild.nodeValue):"integer"==f&&(d=parseInt(e.firstChild.nodeValue,10))}}}return d},_parseArray:function(g){for(var f=[],j=0,i=g.childNodes.length;j<i;j++){var h=g.childNodes[j];1==h.nodeType&&f.push(this._parseNode(h))}return f},_parseDict:function(h){for(var g={},m=null,k=0,j=h.childNodes.length;k<j;k++){var i=h.childNodes[k];1==i.nodeType&&("key"==i.tagName?m=i.firstChild.nodeValue:g[m]=this._parseNode(i))}return g}});cc._txtLoader={load:function(f,e,h,g){cc.loader.loadTxt(f,g)}};cc.loader.register(["txt","xml","vsh","fsh","atlas"],cc._txtLoader);cc._jsonLoader={load:function(f,e,h,g){cc.loader.loadJson(f,g)}};cc.loader.register(["json","ExportJson"],cc._jsonLoader);cc._imgLoader={load:function(f,e,h,g){cc.loader.cache[e]=cc.loader.loadImg(f,function(b,d){if(b){return g(b)}cc.textureCache.handleLoadedTexture(e);g(null,d)})}};cc.loader.register("png jpg bmp jpeg gif ico".split(" "),cc._imgLoader);cc._serverImgLoader={load:function(f,e,h,g){cc.loader.cache[e]=cc.loader.loadImg(h.src,function(b,d){if(b){return g(b)}cc.textureCache.handleLoadedTexture(e);g(null,d)})}};cc.loader.register(["serverImg"],cc._serverImgLoader);cc._plistLoader={load:function(f,e,h,g){cc.loader.loadTxt(f,function(d,c){if(d){return g(d)}g(null,cc.plistParser.parse(c))})}};cc.loader.register(["plist"],cc._plistLoader);cc._fontLoader={TYPE:{".eot":"embedded-opentype",".ttf":"truetype",".woff":"woff",".svg":"svg"},_loadFont:function(u,t,s){var r=document,q=cc.path,o=this.TYPE,n=cc.newElement("style");n.type="text/css";r.body.appendChild(n);var m="@font-face { font-family:"+u+"; src:";if(t instanceof Array){for(var j=0,i=t.length;j<i;j++){s=q.extname(t[j]).toLowerCase(),m+="url('"+t[j]+"') format('"+o[s]+"')",m+=j==i-1?";":","}}else{m+="url('"+t+"') format('"+o[s]+"');"}n.textContent+=m+"};";
  7. t=cc.newElement("div");s=t.style;s.fontFamily=u;t.innerHTML=".";s.position="absolute";s.left="-100px";s.top="-100px";r.body.appendChild(t)},load:function(f,e,h,g){e=h.type;f=h.name;e=h.srcs;"string"==typeof h?(e=cc.path.extname(h),f=cc.path.basename(h,e),this._loadFont(f,h,e)):this._loadFont(f,e);g(null,!0)}};cc.loader.register(["font","eot","ttf","woff","svg"],cc._fontLoader);cc._binaryLoader={load:function(f,e,h,g){cc.loader.loadBinary(f,g)}};window.CocosEngine=cc.ENGINE_VERSION="Cocos2d-html5 v3.0 RC0";cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL=0;cc.DIRECTOR_STATS_POSITION=cc.p(0,0);cc.DIRECTOR_FPS_INTERVAL=0.5;cc.COCOSNODE_RENDER_SUBPIXEL=1;cc.SPRITEBATCHNODE_RENDER_SUBPIXEL=1;cc.OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA=0;cc.TEXTURE_ATLAS_USE_TRIANGLE_STRIP=0;cc.TEXTURE_ATLAS_USE_VAO=0;cc.TEXTURE_NPOT_SUPPORT=0;cc.RETINA_DISPLAY_SUPPORT=1;cc.RETINA_DISPLAY_FILENAME_SUFFIX="-hd";cc.USE_LA88_LABELS=1;cc.SPRITE_DEBUG_DRAW=0;cc.SPRITEBATCHNODE_DEBUG_DRAW=0;cc.LABELBMFONT_DEBUG_DRAW=0;cc.LABELATLAS_DEBUG_DRAW=0;cc.IS_RETINA_DISPLAY_SUPPORTED=1;cc.DEFAULT_ENGINE=cc.ENGINE_VERSION+"-canvas";cc.ENABLE_STACKABLE_ACTIONS=1;cc.ENABLE_GL_STATE_CACHE=1;cc.$=function(d){var c=this==cc?document:this;if(d=d instanceof HTMLElement?d:c.querySelector(d)){d.find=d.find||cc.$,d.hasClass=d.hasClass||function(b){return this.className.match(RegExp("(\\s|^)"+b+"(\\s|$)"))},d.addClass=d.addClass||function(b){this.hasClass(b)||(this.className&&(this.className+=" "),this.className+=b);return this},d.removeClass=d.removeClass||function(b){this.hasClass(b)&&(this.className=this.className.replace(b,""));return this},d.remove=d.remove||function(){this.parentNode&&this.parentNode.removeChild(this);return this},d.appendTo=d.appendTo||function(b){b.appendChild(this);return this},d.prependTo=d.prependTo||function(b){b.childNodes[0]?b.insertBefore(this,b.childNodes[0]):b.appendChild(this);return this},d.transforms=d.transforms||function(){this.style[cc.$.trans]=cc.$.translate(this.position)+cc.$.rotate(this.rotation)+cc.$.scale(this.scale)+cc.$.skew(this.skew);return this},d.position=d.position||{x:0,y:0},d.rotation=d.rotation||0,d.scale=d.scale||{x:1,y:1},d.skew=d.skew||{x:0,y:0},d.translates=function(f,e){this.position.x=f;this.position.y=e;this.transforms();return this},d.rotate=function(b){this.rotation=b;this.transforms();return this},d.resize=function(f,e){this.scale.x=f;this.scale.y=e;this.transforms();return this},d.setSkew=function(f,e){this.skew.x=f;this.skew.y=e;this.transforms();return this}}return d};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(b){return"translate3d("+b.x+"px, "+b.y+"px, 0) "}:function(b){return"translate("+b.x+"px, "+b.y+"px) "};cc.$.rotate=cc.$.hd?function(b){return"rotateZ("+b+"deg) "}:function(b){return"rotate("+b+"deg) "};cc.$.scale=function(b){return"scale("+b.x+", "+b.y+") "};cc.$.skew=function(b){return"skewX("+-b.x+"deg) skewY("+b.y+"deg)"};cc.$new=function(b){return cc.$(document.createElement(b))};cc.$.findpos=function(e){var d=0,f=0;do{d+=e.offsetLeft,f+=e.offsetTop}while(e=e.offsetParent);return{x:d,y:f}};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(f,e,h){if("object"==typeof h&&"undefined"!=typeof h.x&&"undefined"!=typeof h.y){var g=h[f];h[f]=h[e];h[e]=g}else{cc.log(cc._LogInfos.swap)}};cc.lerp=function(e,d,f){return e+(d-e)*f};cc.rand=function(){return 16777215*Math.random()};cc.randomMinus1To1=function(){return 2*(Math.random()-0.5)};cc.random0To1=Math.random;cc.degreesToRadians=function(b){return b*cc.RAD};cc.radiansToDegrees=function(b){return b*cc.DEG};cc.radiansToDegress=function(b){cc.log(cc._LogInfos.radiansToDegress);return b*cc.DEG};cc.REPEAT_FOREVER=Number.MAX_VALUE-1;cc.BLEND_SRC=cc.OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA?1:770;cc.BLEND_DST=771;cc.nodeDrawSetup=function(b){b._shaderProgram&&(b._shaderProgram.use(),b._shaderProgram.setUniformForModelViewAndProjectionMatrixWithMat4())};cc.enableDefaultGLStates=function(){};cc.disableDefaultGLStates=function(){};cc.incrementGLDraws=function(b){cc.g_NumberOfDraws+=b};cc.FLT_EPSILON=1.192092896e-7;cc.contentScaleFactor=cc.IS_RETINA_DISPLAY_SUPPORTED?function(){return cc.director.getContentScaleFactor()}:function(){return 1};cc.pointPointsToPixels=function(d){var c=cc.contentScaleFactor();return cc.p(d.x*c,d.y*c)};cc.pointPixelsToPoints=function(d){var c=cc.contentScaleFactor();return cc.p(d.x/c,d.y/c)};cc._pointPixelsToPointsOut=function(e,d){var f=cc.contentScaleFactor();d.x=e.x/f;d.y=e.y/f};cc.sizePointsToPixels=function(d){var c=cc.contentScaleFactor();
  8. return cc.size(d.width*c,d.height*c)};cc.sizePixelsToPoints=function(d){var c=cc.contentScaleFactor();return cc.size(d.width/c,d.height/c)};cc._sizePixelsToPointsOut=function(e,d){var f=cc.contentScaleFactor();d.width=e.width/f;d.height=e.height/f};cc.rectPixelsToPoints=cc.IS_RETINA_DISPLAY_SUPPORTED?function(d){var c=cc.contentScaleFactor();return cc.rect(d.x/c,d.y/c,d.width/c,d.height/c)}:function(b){return b};cc.rectPointsToPixels=cc.IS_RETINA_DISPLAY_SUPPORTED?function(d){var c=cc.contentScaleFactor();return cc.rect(d.x*c,d.y*c,d.width*c,d.height*c)}:function(b){return 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.checkGLErrorDebug=function(){if(cc.renderMode==cc._RENDER_TYPE_WEBGL){var b=cc._renderContext.getError();b&&cc.log(CC._localZOrder.checkGLErrorDebug,b)}};cc.DEVICE_ORIENTATION_PORTRAIT=0;cc.DEVICE_ORIENTATION_LANDSCAPE_LEFT=1;cc.DEVICE_ORIENTATION_PORTRAIT_UPSIDE_DOWN=2;cc.DEVICE_ORIENTATION_LANDSCAPE_RIGHT=3;cc.DEVICE_MAX_ORIENTATIONS=2;cc.VERTEX_ATTRIB_FLAG_NONE=0;cc.VERTEX_ATTRIB_FLAG_POSITION=1;cc.VERTEX_ATTRIB_FLAG_COLOR=2;cc.VERTEX_ATTRIB_FLAG_TEX_COORDS=4;cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX=cc.VERTEX_ATTRIB_FLAG_POSITION|cc.VERTEX_ATTRIB_FLAG_COLOR|cc.VERTEX_ATTRIB_FLAG_TEX_COORDS;cc.GL_ALL=0;cc.VERTEX_ATTRIB_POSITION=0;cc.VERTEX_ATTRIB_COLOR=1;cc.VERTEX_ATTRIB_TEX_COORDS=2;cc.VERTEX_ATTRIB_MAX=3;cc.UNIFORM_PMATRIX=0;cc.UNIFORM_MVMATRIX=1;cc.UNIFORM_MVPMATRIX=2;cc.UNIFORM_TIME=3;cc.UNIFORM_SINTIME=4;cc.UNIFORM_COSTIME=5;cc.UNIFORM_RANDOM01=6;cc.UNIFORM_SAMPLER=7;cc.UNIFORM_MAX=8;cc.SHADER_POSITION_TEXTURECOLOR="ShaderPositionTextureColor";cc.SHADER_POSITION_TEXTURECOLORALPHATEST="ShaderPositionTextureColorAlphaTest";cc.SHADER_POSITION_COLOR="ShaderPositionColor";cc.SHADER_POSITION_TEXTURE="ShaderPositionTexture";cc.SHADER_POSITION_TEXTURE_UCOLOR="ShaderPositionTexture_uColor";cc.SHADER_POSITION_TEXTUREA8COLOR="ShaderPositionTextureA8Color";cc.SHADER_POSITION_UCOLOR="ShaderPosition_uColor";cc.SHADER_POSITION_LENGTHTEXTURECOLOR="ShaderPositionLengthTextureColor";cc.UNIFORM_PMATRIX_S="CC_PMatrix";cc.UNIFORM_MVMATRIX_S="CC_MVMatrix";cc.UNIFORM_MVPMATRIX_S="CC_MVPMatrix";cc.UNIFORM_TIME_S="CC_Time";cc.UNIFORM_SINTIME_S="CC_SinTime";cc.UNIFORM_COSTIME_S="CC_CosTime";cc.UNIFORM_RANDOM01_S="CC_Random01";cc.UNIFORM_SAMPLER_S="CC_Texture0";cc.UNIFORM_ALPHA_TEST_VALUE_S="CC_alpha_value";cc.ATTRIBUTE_NAME_COLOR="a_color";cc.ATTRIBUTE_NAME_POSITION="a_position";cc.ATTRIBUTE_NAME_TEX_COORD="a_texCoord";cc.ITEM_SIZE=32;cc.CURRENT_ITEM=3233828865;cc.ZOOM_ACTION_TAG=3233828866;cc.NORMAL_TAG=8801;cc.SELECTED_TAG=8802;cc.DISABLE_TAG=8803;cc._tmp.PrototypeColor=function(){var b=cc.color;b._getWhite=function(){return b(255,255,255)};b._getYellow=function(){return b(255,255,0)};b._getBlue=function(){return b(0,0,255)};b._getGreen=function(){return b(0,255,0)};b._getRed=function(){return b(255,0,0)};b._getMagenta=function(){return b(255,0,255)};b._getBlack=function(){return b(0,0,0)};b._getOrange=function(){return b(255,127,0)};b._getGray=function(){return b(166,166,166)};cc.defineGetterSetter(b,"WHITE",b._getWhite);cc.defineGetterSetter(b,"YELLOW",b._getYellow);cc.defineGetterSetter(b,"BLUE",b._getBlue);cc.defineGetterSetter(b,"GREEN",b._getGreen);cc.defineGetterSetter(b,"RED",b._getRed);cc.defineGetterSetter(b,"MAGENTA",b._getMagenta);cc.defineGetterSetter(b,"BLACK",b._getBlack);cc.defineGetterSetter(b,"ORANGE",b._getOrange);cc.defineGetterSetter(b,"GRAY",b._getGray)};cc.Color=function(f,e,h,g){this.r=f||0;this.g=e||0;this.b=h||0;this.a=g||255};cc.color=function(f,e,h,g){return void 0===f?{r:0,g:0,b:0,a:255}:"string"===typeof f?cc.hexToColor(f):"object"===typeof f?{r:f.r,g:f.g,b:f.b,a:f.a||255}:{r:f,g:e,b:h,a:g||255}};cc.colorEqual=function(d,c){return d.r===c.r&&d.g===c.g&&d.b===c.b};cc.Acceleration=function(f,e,h,g){this.x=f||0;this.y=e||0;this.z=h||0;this.timestamp=g||0};cc.Vertex2F=function(d,c){this.x=d||0;this.y=c||0};cc.vertex2=function(d,c){return new cc.Vertex2F(d,c)};cc.Vertex3F=function(e,d,f){this.x=e||0;this.y=d||0;this.z=f||0};cc.vertex3=function(e,d,f){return new cc.Vertex3F(e,d,f)};cc.Tex2F=function(d,c){this.u=d||0;this.v=c||0};cc.tex2=function(d,c){return new cc.Tex2F(d,c)};cc.BlendFunc=function(d,c){this.src=d;this.dst=c};cc.blendFuncDisable=function(){return new cc.BlendFunc(cc.ONE,cc.ZERO)};cc.hexToColor=function(b){b=b.replace(/^#?/,"0x");b=parseInt(b);return cc.color(b>>16,(b>>8)%256,b%256)};cc.colorToHex=function(f){var e=f.r.toString(16),h=f.g.toString(16),g=f.b.toString(16);return"#"+(16>f.r?"0"+e:e)+(16>f.g?"0"+h:h)+(16>f.b?"0"+g:g)};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={};
  9. this._valueMapTb={};this.__currId=2<<(0|10*Math.random())},__getKey:function(){this.__currId++;return"key_"+this.__currId},setObject:function(e,d){if(null!=d){var f=this.__getKey();this._keyMapTb[f]=d;this._valueMapTb[f]=e}},objectForKey:function(e){if(null==e){return null}var d=this._keyMapTb,f;for(f in d){if(d[f]===e){return this._valueMapTb[f]}}return null},valueForKey:function(b){return this.objectForKey(b)},removeObjectForKey:function(e){if(null!=e){var d=this._keyMapTb,f;for(f in d){if(d[f]===e){delete this._valueMapTb[f];delete d[f];break}}}},removeObjectsForKeys:function(d){if(null!=d){for(var c=0;c<d.length;c++){this.removeObjectForKey(d[c])}}},allKeys:function(){var e=[],d=this._keyMapTb,f;for(f in d){e.push(d[f])}return e},removeAllObjects:function(){this._keyMapTb={};this._valueMapTb={}},count:function(){return this.allKeys().length}});cc.FontDefinition=function(){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.shadowEnabled=!1;this.shadowBlur=this.shadowOffsetY=this.shadowOffsetX=0;this.shadowOpacity=1};cc._renderType===cc._RENDER_TYPE_WEBGL&&(cc.assert("function"===typeof cc._tmp.WebGLColor,cc._LogInfos.MissingFile,"CCTypesWebGL.js"),cc._tmp.WebGLColor(),delete cc._tmp.WebGLColor);cc.assert("function"===typeof cc._tmp.PrototypeColor,cc._LogInfos.MissingFile,"CCTypesPropertyDefine.js");cc._tmp.PrototypeColor();delete cc._tmp.PrototypeColor;cc.Touches=[];cc.TouchesIntergerDict={};cc.EGLView=cc.Class.extend({_delegate:null,_frameSize:null,_designResolutionSize:null,_originalDesignResolutionSize:null,_viewPortRect:null,_visibleRect:null,_retinaEnabled:!1,_autoFullScreen:!0,_devicePixelRatio:1,_viewName:"",_resizeCallback:null,_scaleX:1,_originalScaleX:1,_scaleY:1,_originalScaleY:1,_indexBitsUsed:0,_maxTouches:5,_resolutionPolicy:null,_rpExactFit:null,_rpShowAll:null,_rpNoBorder:null,_rpFixedHeight:null,_rpFixedWidth:null,_initialized:!1,_captured:!1,_wnd:null,_hDC:null,_hRC:null,_supportTouch:!1,_contentTranslateLeftTop:null,_frame:null,_frameZoomFactor:1,__resizeWithBrowserSize:!1,_isAdjustViewPort:!0,ctor:function(){var f=document,e=cc.ContainerStrategy,h=cc.ContentStrategy;this._frame=cc.container.parentNode===f.body?f.documentElement:cc.container.parentNode;this._frameSize=cc.size(0,0);this._initFrameSize();var f=cc._canvas.width,g=cc._canvas.height;this._designResolutionSize=cc.size(f,g);this._originalDesignResolutionSize=cc.size(f,g);this._viewPortRect=cc.rect(0,0,f,g);this._visibleRect=cc.rect(0,0,f,g);this._contentTranslateLeftTop={left:0,top:0};this._viewName="Cocos2dHTML5";f=cc.sys;this.enableRetina(f.os==f.OS_IOS||f.os==f.OS_OSX);cc.visibleRect&&cc.visibleRect.init(this._visibleRect);this._rpExactFit=new cc.ResolutionPolicy(e.EQUAL_TO_FRAME,h.EXACT_FIT);this._rpShowAll=new cc.ResolutionPolicy(e.PROPORTION_TO_FRAME,h.SHOW_ALL);this._rpNoBorder=new cc.ResolutionPolicy(e.EQUAL_TO_FRAME,h.NO_BORDER);this._rpFixedHeight=new cc.ResolutionPolicy(e.EQUAL_TO_FRAME,h.FIXED_HEIGHT);this._rpFixedWidth=new cc.ResolutionPolicy(e.EQUAL_TO_FRAME,h.FIXED_WIDTH);this._hDC=cc._canvas;this._hRC=cc._renderContext},_resizeEvent:function(){var d=this._originalDesignResolutionSize.width,c=this._originalDesignResolutionSize.height;this._resizeCallback&&(this._initFrameSize(),this._resizeCallback.call());0<d&&this.setDesignResolutionSize(d,c,this._resolutionPolicy)},resizeWithBrowserSize:function(b){b?this.__resizeWithBrowserSize||(this.__resizeWithBrowserSize=!0,b=this._resizeEvent.bind(this),cc._addEventListener(window,"resize",b,!1)):this.__resizeWithBrowserSize&&(this.__resizeWithBrowserSize=!0,b=this._resizeEvent.bind(this),window.removeEventListener("resize",b,!1))},setResizeCallback:function(b){if("function"==typeof b||null==b){this._resizeCallback=b}},_initFrameSize:function(){var b=this._frameSize;b.width=this._frame.clientWidth;b.height=this._frame.clientHeight},_adjustSizeKeepCanvasSize:function(){var d=this._originalDesignResolutionSize.width,c=this._originalDesignResolutionSize.height;0<d&&this.setDesignResolutionSize(d,c,this._resolutionPolicy)},_setViewPortMeta:function(h,g){if(this._isAdjustViewPort){var m={"user-scalable":"no","maximum-scale":"1.0","initial-scale":"1.0"},k=document.getElementsByName("viewport"),j;0==k.length?(k=cc.newElement("meta"),k.name="viewport",k.content="",document.head.appendChild(k)):k=k[0];if(cc.sys.isMobile&&cc.sys.browserType==cc.sys.BROWSER_TYPE_FIREFOX){k.content="initial-scale:1"}else{j=k.content;for(var i in m){RegExp(i).test(j)||(j+=(""==j?"":",")+i+"\x3d"+m[i])}k.content=j}}},_setScaleXYForRenderTexture:function(){var b=cc.contentScaleFactor();this._scaleY=this._scaleX=b},_resetScale:function(){this._scaleX=this._originalScaleX;this._scaleY=this._originalScaleY},_adjustSizeToBrowser:function(){},initialize:function(){this._initialized=!0
  10. },adjustViewPort:function(b){this._isAdjustViewPort=b},enableRetina:function(b){this._retinaEnabled=b?!0:!1},isRetinaEnabled:function(){return this._retinaEnabled},enableAutoFullScreen:function(b){this._autoFullScreen=b?!0:!1},isAutoFullScreenEnabled:function(){return this._autoFullScreen},end:function(){},isOpenGLReady:function(){return null!=this._hDC&&null!=this._hRC},setFrameZoomFactor:function(b){this._frameZoomFactor=b;this.centerWindow();cc.director.setProjection(cc.director.getProjection())},swapBuffers:function(){},setIMEKeyboardState:function(b){},setContentTranslateLeftTop:function(d,c){this._contentTranslateLeftTop={left:d,top:c}},getContentTranslateLeftTop:function(){return this._contentTranslateLeftTop},getFrameSize:function(){return cc.size(this._frameSize.width,this._frameSize.height)},setFrameSize:function(d,c){this._frameSize.width=d;this._frameSize.height=c;this._frame.style.width=d+"px";this._frame.style.height=c+"px";this._resizeEvent();cc.director.setProjection(cc.director.getProjection())},centerWindow:function(){},getVisibleSize:function(){return cc.size(this._visibleRect.width,this._visibleRect.height)},getVisibleOrigin:function(){return cc.p(this._visibleRect.x,this._visibleRect.y)},canSetContentScaleFactor:function(){return !0},getResolutionPolicy:function(){return this._resolutionPolicy},setResolutionPolicy:function(d){if(d instanceof cc.ResolutionPolicy){this._resolutionPolicy=d}else{var c=cc.ResolutionPolicy;d===c.EXACT_FIT&&(this._resolutionPolicy=this._rpExactFit);d===c.SHOW_ALL&&(this._resolutionPolicy=this._rpShowAll);d===c.NO_BORDER&&(this._resolutionPolicy=this._rpNoBorder);d===c.FIXED_HEIGHT&&(this._resolutionPolicy=this._rpFixedHeight);d===c.FIXED_WIDTH&&(this._resolutionPolicy=this._rpFixedWidth)}},setDesignResolutionSize:function(h,g,m){if(isNaN(h)||0==h||isNaN(g)||0==g){cc.log(cc._LogInfos.EGLView_setDesignResolutionSize)}else{this.setResolutionPolicy(m);var k=this._resolutionPolicy;if(k){k.preApply(this);var j=this._frameSize.width,i=this._frameSize.height;cc.sys.isMobile&&this._setViewPortMeta(this._frameSize.width,this._frameSize.height);this._initFrameSize();m==this._resolutionPolicy&&h==this._originalDesignResolutionSize.width&&g==this._originalDesignResolutionSize.height&&j==this._frameSize.width&&i==this._frameSize.height||(this._designResolutionSize=cc.size(h,g),this._originalDesignResolutionSize=cc.size(h,g),h=k.apply(this,this._designResolutionSize),h.scale&&2==h.scale.length&&(this._scaleX=h.scale[0],this._scaleY=h.scale[1]),h.viewport&&(h=this._viewPortRect=h.viewport,g=this._visibleRect,g.width=cc._canvas.width/this._scaleX,g.height=cc._canvas.height/this._scaleY,g.x=-h.x/this._scaleX,g.y=-h.y/this._scaleY),h=cc.director,cc.winSize.width=h._winSizeInPoints.width=this._visibleRect.width,cc.winSize.height=h._winSizeInPoints.height=this._visibleRect.height,k.postApply(this),cc._renderType==cc._RENDER_TYPE_WEBGL&&(h._createStatsLabel(),h.setGLDefaultValues()),this._originalScaleX=this._scaleX,this._originalScaleY=this._scaleY,cc.DOM&&cc.DOM._resetEGLViewDiv(),cc.visibleRect&&cc.visibleRect.init(this._visibleRect))}else{cc.log(cc._LogInfos.EGLView_setDesignResolutionSize_2)}}},getDesignResolutionSize:function(){return cc.size(this._designResolutionSize.width,this._designResolutionSize.height)},setViewPortInPoints:function(i,h,o,n){var m=this._frameZoomFactor,k=this._scaleX,j=this._scaleY;cc._renderContext.viewport(i*k*m+this._viewPortRect.x*m,h*j*m+this._viewPortRect.y*m,o*k*m,n*j*m)},setScissorInPoints:function(i,h,o,n){var m=this._frameZoomFactor,k=this._scaleX,j=this._scaleY;cc._renderContext.scissor(i*k*m+this._viewPortRect.x*m,h*j*m+this._viewPortRect.y*m,o*k*m,n*j*m)},isScissorEnabled:function(){var b=cc._renderContext;return b.isEnabled(b.SCISSOR_TEST)},getScissorRect:function(){var e=cc._renderContext,d=this._scaleX,f=this._scaleY,e=e.getParameter(e.SCISSOR_BOX);return cc.rect((e[0]-this._viewPortRect.x)/d,(e[1]-this._viewPortRect.y)/f,e[2]/d,e[3]/f)},setViewName:function(b){null!=b&&0<b.length&&(this._viewName=b)},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(e,d,f){return{x:this._devicePixelRatio*(e-f.left),y:this._devicePixelRatio*(f.top+f.height-d)}},_convertMouseToLocationInView:function(e,d){var f=this._viewPortRect;e.x=(this._devicePixelRatio*(e.x-d.left)-f.x)/this._scaleX;e.y=(this._devicePixelRatio*(d.top+d.height-e.y)-f.y)/this._scaleY},_convertTouchesWithScale:function(j){for(var i=this._viewPortRect,r=this._scaleX,q=this._scaleY,o,n,m,k=0;k<j.length;k++){o=j[k],n=o._point,m=o._prevPoint,o._setPoint((n.x-i.x)/r,(n.y-i.y)/q),o._setPrevPoint((m.x-i.x)/r,(m.y-i.y)/q)}}});cc.EGLView._getInstance=function(){this._instance||(this._instance=this._instance||new cc.EGLView,this._instance.initialize());return this._instance
  11. };cc.ContainerStrategy=cc.Class.extend({preApply:function(b){},apply:function(d,c){},postApply:function(b){},_setupContainer:function(h,g,m){var k=h._frame;cc.view._autoFullScreen&&(cc.sys.isMobile&&k==document.documentElement)&&cc.screen.autoFullScreen(k);var k=cc._canvas,j=cc.container;j.style.width=k.style.width=g+"px";j.style.height=k.style.height=m+"px";j=h._devicePixelRatio=1;h.isRetinaEnabled()&&(j=h._devicePixelRatio=window.devicePixelRatio||1);k.width=g*j;k.height=m*j;h=document.body;var i;if(h&&(i=h.style)){i.paddingTop=i.paddingTop||"0px",i.paddingRight=i.paddingRight||"0px",i.paddingBottom=i.paddingBottom||"0px",i.paddingLeft=i.paddingLeft||"0px",i.borderTop=i.borderTop||"0px",i.borderRight=i.borderRight||"0px",i.borderBottom=i.borderBottom||"0px",i.borderLeft=i.borderLeft||"0px",i.marginTop=i.marginTop||"0px",i.marginRight=i.marginRight||"0px",i.marginBottom=i.marginBottom||"0px",i.marginLeft=i.marginLeft||"0px"}},_fixContainer:function(){document.body.insertBefore(cc.container,document.body.firstChild);var b=document.body.style;b.width=window.innerWidth+"px";b.height=window.innerHeight+"px";b.overflow="hidden";b=cc.container.style;b.position="fixed";b.left=b.top="0px";document.body.scrollTop=0}});cc.ContentStrategy=cc.Class.extend({_result:{scale:[1,1],viewport:null},_buildResult:function(h,g,m,k,j,i){2>Math.abs(h-m)&&(m=h);2>Math.abs(g-k)&&(k=g);h=cc.rect(Math.round((h-m)/2),Math.round((g-k)/2),m,k);cc._renderType==cc._RENDER_TYPE_CANVAS&&cc._renderContext.translate(h.x,h.y+k);this._result.scale=[j,i];this._result.viewport=h;return this._result},preApply:function(b){},apply:function(d,c){return{scale:[1,1]}},postApply:function(b){}});(function(){var g=cc.ContainerStrategy.extend({apply:function(b){this._setupContainer(b,b._frameSize.width,b._frameSize.height)}}),f=cc.ContainerStrategy.extend({apply:function(A,z){var y=A._frameSize.width,x=A._frameSize.height,w=cc.container.style,v=z.width,u=z.height,o=y/v,k=x/u,B,C;o<k?(B=y,C=u*o):(B=v*k,C=x);v=Math.round((y-B)/2);C=Math.round((x-C)/2);this._setupContainer(A,y-2*v,x-2*C);w.marginLeft=v+"px";w.marginRight=v+"px";w.marginTop=C+"px";w.marginBottom=C+"px"}});g.extend({preApply:function(b){this._super(b);b._frame=document.documentElement},apply:function(b){this._super(b);this._fixContainer()}});f.extend({preApply:function(b){this._super(b);b._frame=document.documentElement},apply:function(d,c){this._super(d,c);this._fixContainer()}});var j=cc.ContainerStrategy.extend({apply:function(b){this._setupContainer(b,cc._canvas.width,cc._canvas.height)}});cc.ContainerStrategy.EQUAL_TO_FRAME=new g;cc.ContainerStrategy.PROPORTION_TO_FRAME=new f;cc.ContainerStrategy.ORIGINAL_CONTAINER=new j;var g=cc.ContentStrategy.extend({apply:function(k,e){var n=cc._canvas.width,m=cc._canvas.height;return this._buildResult(n,m,n,m,n/e.width,m/e.height)}}),f=cc.ContentStrategy.extend({apply:function(A,z){var y=cc._canvas.width,x=cc._canvas.height,w=z.width,v=z.height,u=y/w,o=x/v,k=0,B,C;u<o?(k=u,B=y,C=v*k):(k=o,B=w*k,C=x);return this._buildResult(y,x,B,C,k,k)}}),j=cc.ContentStrategy.extend({apply:function(A,z){var y=cc._canvas.width,x=cc._canvas.height,w=z.width,v=z.height,u=y/w,o=x/v,k,B,C;u<o?(k=o,B=w*k,C=x):(k=u,B=y,C=v*k);return this._buildResult(y,x,B,C,k,k)}}),i=cc.ContentStrategy.extend({apply:function(m,k){var q=cc._canvas.width,o=cc._canvas.height,n=o/k.height;return this._buildResult(q,o,q,o,n,n)},postApply:function(b){cc.director._winSizeInPoints=b.getVisibleSize()}}),h=cc.ContentStrategy.extend({apply:function(m,k){var q=cc._canvas.width,o=cc._canvas.height,n=q/k.width;return this._buildResult(q,o,q,o,n,n)},postApply:function(b){cc.director._winSizeInPoints=b.getVisibleSize()}});cc.ContentStrategy.EXACT_FIT=new g;cc.ContentStrategy.SHOW_ALL=new f;cc.ContentStrategy.NO_BORDER=new j;cc.ContentStrategy.FIXED_HEIGHT=new i;cc.ContentStrategy.FIXED_WIDTH=new h})();cc.ResolutionPolicy=cc.Class.extend({_containerStrategy:null,_contentStrategy:null,ctor:function(d,c){this.setContainerStrategy(d);this.setContentStrategy(c)},preApply:function(b){this._containerStrategy.preApply(b);this._contentStrategy.preApply(b)},apply:function(d,c){this._containerStrategy.apply(d,c);return this._contentStrategy.apply(d,c)},postApply:function(b){this._containerStrategy.postApply(b);this._contentStrategy.postApply(b)},setContainerStrategy:function(b){b instanceof cc.ContainerStrategy&&(this._containerStrategy=b)},setContentStrategy:function(b){b instanceof cc.ContentStrategy&&(this._contentStrategy=b)}});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.UIInterfaceOrientationLandscapeLeft=-90;cc.UIInterfaceOrientationLandscapeRight=90;cc.UIInterfaceOrientationPortraitUpsideDown=180;cc.UIInterfaceOrientationPortrait=0;cc.inputManager={_mousePressed:!1,_isRegisterEvent:!1,_preTouchPoint:cc.p(0,0),_prevMousePoint:cc.p(0,0),_preTouchPool:[],_preTouchPoolPointer:0,_touches:[],_touchesIntegerDict:{},_indexBitsUsed:0,_maxTouches:5,_accelEnabled:!1,_accelInterval:1/30,_accelMinus:1,_accelCurTime:0,_acceleration:null,_accelDeviceEvent:null,_getUnUsedIndex:function(){for(var d=this._indexBitsUsed,c=0;
  12. c<this._maxTouches;c++){if(!(d&1)){return this._indexBitsUsed|=1<<c,c}d>>=1}return -1},_removeUsedIndexBit:function(b){0>b||b>=this._maxTouches||(b=~(1<<b),this._indexBitsUsed&=b)},_glView:null,handleTouchesBegin:function(j){for(var i,r,q,o=[],n=this._touchesIntegerDict,m=0,k=j.length;m<k;m++){i=j[m],q=i.getID(),r=n[q],null==r&&(r=this._getUnUsedIndex(),-1==r?cc.log(cc._LogInfos.inputManager_handleTouchesBegin,r):(i=this._touches[r]=i,n[q]=r,o.push(i)))}0<o.length&&(this._glView._convertTouchesWithScale(o),j=new cc.EventTouch(o),j._eventCode=cc.EventTouch.EventCode.BEGAN,cc.eventManager.dispatchEvent(j))},handleTouchesMove:function(i){for(var h,o,n=[],m=this._touches,k=0,j=i.length;k<j;k++){h=i[k],o=h.getID(),o=this._touchesIntegerDict[o],null!=o&&m[o]&&(m[o]._setPoint(h._point),m[o]._setPrevPoint(h._prevPoint),n.push(m[o]))}0<n.length&&(this._glView._convertTouchesWithScale(n),i=new cc.EventTouch(n),i._eventCode=cc.EventTouch.EventCode.MOVED,cc.eventManager.dispatchEvent(i))},handleTouchesEnd:function(b){b=this.getSetOfTouchesEndOrCancel(b);0<b.length&&(this._glView._convertTouchesWithScale(b),b=new cc.EventTouch(b),b._eventCode=cc.EventTouch.EventCode.ENDED,cc.eventManager.dispatchEvent(b))},handleTouchesCancel:function(b){b=this.getSetOfTouchesEndOrCancel(b);0<b.length&&(this._glView._convertTouchesWithScale(b),b=new cc.EventTouch(b),b._eventCode=cc.EventTouch.EventCode.CANCELLED,cc.eventManager.dispatchEvent(b))},getSetOfTouchesEndOrCancel:function(t){for(var s,r,q,o=[],n=this._touches,m=this._touchesIntegerDict,j=0,i=t.length;j<i;j++){s=t[j],q=s.getID(),r=m[q],null!=r&&n[r]&&(n[r]._setPoint(s._point),n[r]._setPrevPoint(s._prevPoint),o.push(n[r]),this._removeUsedIndexBit(r),delete m[q])}return o},getHTMLElementPosition:function(f){var e=document.documentElement,h=window,g=null,g="function"===typeof f.getBoundingClientRect?f.getBoundingClientRect():f instanceof HTMLCanvasElement?{left:0,top:0,width:f.width,height:f.height}:{left:0,top:0,width:parseInt(f.style.width),height:parseInt(f.style.height)};return{left:g.left+h.pageXOffset-e.clientLeft,top:g.top+h.pageYOffset-e.clientTop,width:g.width,height:g.height}},getPreTouch:function(g){for(var f=null,j=this._preTouchPool,i=g.getId(),h=j.length-1;0<=h;h--){if(j[h].getId()==i){f=j[h];break}}f||(f=g);return f},setPreTouch:function(g){for(var f=!1,j=this._preTouchPool,i=g.getId(),h=j.length-1;0<=h;h--){if(j[h].getId()==i){j[h]=g;f=!0;break}}f||(50>=j.length?j.push(g):(j[this._preTouchPoolPointer]=g,this._preTouchPoolPointer=(this._preTouchPoolPointer+1)%50))},getTouchByXY:function(f,e,h){var g=this._preTouchPoint;f=this._glView.convertToLocationInView(f,e,h);e=new cc.Touch(f.x,f.y);e._setPrevPoint(g.x,g.y);g.x=f.x;g.y=f.y;return e},getMouseEvent:function(f,e,h){var g=this._prevMousePoint;this._glView._convertMouseToLocationInView(f,e);e=new cc.EventMouse(h);e.setLocation(f.x,f.y);e._setPrevCursor(g.x,g.y);g.x=f.x;g.y=f.y;return e},getPointByEvent:function(d,c){if(null!=d.pageX){return{x:d.pageX,y:d.pageY}}c.left-=document.body.scrollLeft;c.top-=document.body.scrollTop;return{x:d.clientX,y:d.clientY}},getTouchesByEvent:function(u,t){for(var s=[],r=this._glView,q,o,n=this._preTouchPoint,m=u.changedTouches.length,j=0;j<m;j++){if(q=u.changedTouches[j]){var i;i=cc.sys.BROWSER_TYPE_FIREFOX===cc.sys.browserType?r.convertToLocationInView(q.pageX,q.pageY,t):r.convertToLocationInView(q.clientX,q.clientY,t);null!=q.identifier?(q=new cc.Touch(i.x,i.y,q.identifier),o=this.getPreTouch(q).getLocation(),q._setPrevPoint(o.x,o.y),this.setPreTouch(q)):(q=new cc.Touch(i.x,i.y),q._setPrevPoint(n.x,n.y));n.x=i.x;n.y=i.y;s.push(q)}}return s},registerSystemEvent:function(h){if(!this._isRegisterEvent){var g=this._glView=cc.view,m=this,k="touches" in cc.sys.capabilities;"mouse" in cc.sys.capabilities&&(cc._addEventListener(window,"mousedown",function(){m._mousePressed=!0},!1),cc._addEventListener(window,"mouseup",function(a){var d=m._mousePressed;m._mousePressed=!1;if(d){var d=m.getHTMLElementPosition(h),c=m.getPointByEvent(a,d);cc.rectContainsPoint(new cc.Rect(d.left,d.top,d.width,d.height),c)||(k||m.handleTouchesEnd([m.getTouchByXY(c.x,c.y,d)]),d=m.getMouseEvent(c,d,cc.EventMouse.UP),d.setButton(a.button),cc.eventManager.dispatchEvent(d))}},!1),cc._addEventListener(h,"mousedown",function(a){m._mousePressed=!0;var d=m.getHTMLElementPosition(h),c=m.getPointByEvent(a,d);k||m.handleTouchesBegin([m.getTouchByXY(c.x,c.y,d)]);d=m.getMouseEvent(c,d,cc.EventMouse.DOWN);d.setButton(a.button);cc.eventManager.dispatchEvent(d);a.stopPropagation();a.preventDefault();h.focus()},!1),cc._addEventListener(h,"mouseup",function(a){m._mousePressed=!1;var d=m.getHTMLElementPosition(h),c=m.getPointByEvent(a,d);k||m.handleTouchesEnd([m.getTouchByXY(c.x,c.y,d)]);d=m.getMouseEvent(c,d,cc.EventMouse.UP);d.setButton(a.button);cc.eventManager.dispatchEvent(d);a.stopPropagation();a.preventDefault()},!1),cc._addEventListener(h,"mousemove",function(a){var d=m.getHTMLElementPosition(h),c=m.getPointByEvent(a,d);k||m.handleTouchesMove([m.getTouchByXY(c.x,c.y,d)]);
  13. d=m.getMouseEvent(c,d,cc.EventMouse.MOVE);m._mousePressed?d.setButton(a.button):d.setButton(null);cc.eventManager.dispatchEvent(d);a.stopPropagation();a.preventDefault()},!1),cc._addEventListener(h,"mousewheel",function(a){var f=m.getHTMLElementPosition(h),c=m.getPointByEvent(a,f),f=m.getMouseEvent(c,f,cc.EventMouse.SCROLL);f.setButton(a.button);f.setScrollData(0,a.wheelDelta);cc.eventManager.dispatchEvent(f);a.stopPropagation();a.preventDefault()},!1),cc._addEventListener(h,"DOMMouseScroll",function(a){var f=m.getHTMLElementPosition(h),c=m.getPointByEvent(a,f),f=m.getMouseEvent(c,f,cc.EventMouse.SCROLL);f.setButton(a.button);f.setScrollData(0,-120*a.detail);cc.eventManager.dispatchEvent(f);a.stopPropagation();a.preventDefault()},!1));if(window.navigator.msPointerEnabled){var j={MSPointerDown:m.handleTouchesBegin,MSPointerMove:m.handleTouchesMove,MSPointerUp:m.handleTouchesEnd,MSPointerCancel:m.handleTouchesCancel},i;for(i in j){(function(a,c){cc._addEventListener(h,a,function(d){var f=m.getHTMLElementPosition(h);f.left-=document.documentElement.scrollLeft;f.top-=document.documentElement.scrollTop;c.call(m,[m.getTouchByXY(d.clientX,d.clientY,f)]);d.stopPropagation()},!1)})(i,j[i])}}k&&(cc._addEventListener(h,"touchstart",function(a){if(a.changedTouches){var c=m.getHTMLElementPosition(h);c.left-=document.body.scrollLeft;c.top-=document.body.scrollTop;m.handleTouchesBegin(m.getTouchesByEvent(a,c));a.stopPropagation();a.preventDefault();h.focus()}},!1),cc._addEventListener(h,"touchmove",function(a){if(a.changedTouches){var c=m.getHTMLElementPosition(h);c.left-=document.body.scrollLeft;c.top-=document.body.scrollTop;m.handleTouchesMove(m.getTouchesByEvent(a,c));a.stopPropagation();a.preventDefault()}},!1),cc._addEventListener(h,"touchend",function(a){if(a.changedTouches){var c=m.getHTMLElementPosition(h);c.left-=document.body.scrollLeft;c.top-=document.body.scrollTop;m.handleTouchesEnd(m.getTouchesByEvent(a,c));a.stopPropagation();a.preventDefault()}},!1),cc._addEventListener(h,"touchcancel",function(b){if(b.changedTouches){var a=m.getHTMLElementPosition(h);a.left-=document.body.scrollLeft;a.top-=document.body.scrollTop;g.handleTouchesCancel(m.getTouchesByEvent(b,a));b.stopPropagation();b.preventDefault()}},!1));this._registerKeyboardEvent();this._registerAccelerometerEvent();this._isRegisterEvent=!0}},_registerKeyboardEvent:function(){},_registerAccelerometerEvent:function(){},update:function(b){this._accelCurTime>this._accelInterval&&(this._accelCurTime-=this._accelInterval,cc.eventManager.dispatchEvent(new cc.EventAcceleration(this._acceleration)));this._accelCurTime+=b}};cc.AffineTransform=function(h,g,m,k,j,i){this.a=h;this.b=g;this.c=m;this.d=k;this.tx=j;this.ty=i};cc.AffineTransformMake=function(h,g,m,k,j,i){return{a:h,b:g,c:m,d:k,tx:j,ty:i}};cc.PointApplyAffineTransform=function(d,c){return{x:c.a*d.x+c.c*d.y+c.tx,y:c.b*d.x+c.d*d.y+c.ty}};cc._PointApplyAffineTransform=function(e,d,f){return{x:f.a*e+f.c*d+f.tx,y:f.b*e+f.d*d+f.ty}};cc.SizeApplyAffineTransform=function(d,c){return{width:c.a*d.width+c.c*d.height,height:c.b*d.width+c.d*d.height}};cc.AffineTransformMakeIdentity=function(){return{a:1,b:0,c:0,d:1,tx:0,ty:0}};cc.AffineTransformIdentity=function(){return{a:1,b:0,c:0,d:1,tx:0,ty:0}};cc.RectApplyAffineTransform=function(t,s){var r=cc.rectGetMinY(t),q=cc.rectGetMinX(t),o=cc.rectGetMaxX(t),n=cc.rectGetMaxY(t),m=cc._PointApplyAffineTransform(q,r,s),r=cc._PointApplyAffineTransform(o,r,s),q=cc._PointApplyAffineTransform(q,n,s),j=cc._PointApplyAffineTransform(o,n,s),o=Math.min(m.x,r.x,q.x,j.x),n=Math.max(m.x,r.x,q.x,j.x),i=Math.min(m.y,r.y,q.y,j.y),m=Math.max(m.y,r.y,q.y,j.y);return cc.rect(o,i,n-o,m-i)};cc._RectApplyAffineTransformIn=function(t,s){var r=cc.rectGetMinY(t),q=cc.rectGetMinX(t),o=cc.rectGetMaxX(t),n=cc.rectGetMaxY(t),m=cc._PointApplyAffineTransform(q,r,s),r=cc._PointApplyAffineTransform(o,r,s),q=cc._PointApplyAffineTransform(q,n,s),j=cc._PointApplyAffineTransform(o,n,s),o=Math.min(m.x,r.x,q.x,j.x),n=Math.max(m.x,r.x,q.x,j.x),i=Math.min(m.y,r.y,q.y,j.y),m=Math.max(m.y,r.y,q.y,j.y);t.x=o;t.y=i;t.width=n-o;t.height=m-i;return t};cc.AffineTransformTranslate=function(e,d,f){return{a:e.a,b:e.b,c:e.c,d:e.d,tx:e.tx+e.a*d+e.c*f,ty:e.ty+e.b*d+e.d*f}};cc.AffineTransformScale=function(e,d,f){return{a:e.a*d,b:e.b*d,c:e.c*f,d:e.d*f,tx:e.tx,ty:e.ty}};cc.AffineTransformRotate=function(f,e){var h=Math.sin(e),g=Math.cos(e);return{a:f.a*g+f.c*h,b:f.b*g+f.d*h,c:f.c*g-f.a*h,d:f.d*g-f.b*h,tx:f.tx,ty:f.ty}};cc.AffineTransformConcat=function(d,c){return{a:d.a*c.a+d.b*c.c,b:d.a*c.b+d.b*c.d,c:d.c*c.a+d.d*c.c,d:d.c*c.b+d.d*c.d,tx:d.tx*c.a+d.ty*c.c+c.tx,ty:d.tx*c.b+d.ty*c.d+c.ty}};cc.AffineTransformEqualToTransform=function(d,c){return d.a===c.a&&d.b===c.b&&d.c===c.c&&d.d===c.d&&d.tx===c.tx&&d.ty===c.ty};cc.AffineTransformInvert=function(d){var c=1/(d.a*d.d-d.b*d.c);return{a:c*d.d,b:-c*d.b,c:-c*d.c,d:c*d.a,tx:c*(d.c*d.ty-d.d*d.tx),ty:c*(d.b*d.tx-d.a*d.ty)}};cc.POINT_EPSILON=parseFloat("1.192092896e-07F");cc.pNeg=function(b){return cc.p(-b.x,-b.y)
  14. };cc.pAdd=function(d,c){return cc.p(d.x+c.x,d.y+c.y)};cc.pSub=function(d,c){return cc.p(d.x-c.x,d.y-c.y)};cc.pMult=function(d,c){return cc.p(d.x*c,d.y*c)};cc.pMidpoint=function(d,c){return cc.pMult(cc.pAdd(d,c),0.5)};cc.pDot=function(d,c){return d.x*c.x+d.y*c.y};cc.pCross=function(d,c){return d.x*c.y-d.y*c.x};cc.pPerp=function(b){return cc.p(-b.y,b.x)};cc.pRPerp=function(b){return cc.p(b.y,-b.x)};cc.pProject=function(d,c){return cc.pMult(c,cc.pDot(d,c)/cc.pDot(c,c))};cc.pRotate=function(d,c){return cc.p(d.x*c.x-d.y*c.y,d.x*c.y+d.y*c.x)};cc.pUnrotate=function(d,c){return cc.p(d.x*c.x+d.y*c.y,d.y*c.x-d.x*c.y)};cc.pLengthSQ=function(b){return cc.pDot(b,b)};cc.pDistanceSQ=function(d,c){return cc.pLengthSQ(cc.pSub(d,c))};cc.pLength=function(b){return Math.sqrt(cc.pLengthSQ(b))};cc.pDistance=function(d,c){return cc.pLength(cc.pSub(d,c))};cc.pNormalize=function(b){return cc.pMult(b,1/cc.pLength(b))};cc.pForAngle=function(b){return cc.p(Math.cos(b),Math.sin(b))};cc.pToAngle=function(b){return Math.atan2(b.y,b.x)};cc.clampf=function(f,e,h){if(e>h){var g=e;e=h;h=g}return f<e?e:f<h?f:h};cc.pClamp=function(e,d,f){return cc.p(cc.clampf(e.x,d.x,f.x),cc.clampf(e.y,d.y,f.y))};cc.pFromSize=function(b){return cc.p(b.width,b.height)};cc.pCompOp=function(d,c){return cc.p(c(d.x),c(d.y))};cc.pLerp=function(e,d,f){return cc.pAdd(cc.pMult(e,1-f),cc.pMult(d,f))};cc.pFuzzyEqual=function(e,d,f){return e.x-f<=d.x&&d.x<=e.x+f&&e.y-f<=d.y&&d.y<=e.y+f?!0:!1};cc.pCompMult=function(d,c){return cc.p(d.x*c.x,d.y*c.y)};cc.pAngleSigned=function(f,e){var h=cc.pNormalize(f),g=cc.pNormalize(e),h=Math.atan2(h.x*g.y-h.y*g.x,cc.pDot(h,g));return Math.abs(h)<cc.POINT_EPSILON?0:h};cc.pAngle=function(e,d){var f=Math.acos(cc.pDot(cc.pNormalize(e),cc.pNormalize(d)));return Math.abs(f)<cc.POINT_EPSILON?0:f};cc.pRotateByAngle=function(g,f,j){g=cc.pSub(g,f);var i=Math.cos(j);j=Math.sin(j);var h=g.x;g.x=h*i-g.y*j+f.x;g.y=h*j+g.y*i+f.y;return g};cc.pLineIntersect=function(j,i,r,q,o){if(j.x==i.x&&j.y==i.y||r.x==q.x&&r.y==q.y){return !1}var n=i.x-j.x;i=i.y-j.y;var m=q.x-r.x;q=q.y-r.y;var k=j.x-r.x;j=j.y-r.y;r=q*n-m*i;o.x=m*j-q*k;o.y=n*j-i*k;if(0==r){return 0==o.x||0==o.y?!0:!1}o.x/=r;o.y/=r;return !0};cc.pSegmentIntersect=function(g,f,j,i){var h=cc.p(0,0);return cc.pLineIntersect(g,f,j,i,h)&&0<=h.x&&1>=h.x&&0<=h.y&&1>=h.y?!0:!1};cc.pIntersectPoint=function(g,f,j,i){var h=cc.p(0,0);return cc.pLineIntersect(g,f,j,i,h)?(j=cc.p(0,0),j.x=g.x+h.x*(f.x-g.x),j.y=g.y+h.x*(f.y-g.y),j):cc.p(0,0)};cc.pSameAs=function(d,c){return null!=d&&null!=c?d.x==c.x&&d.y==c.y:!1};cc.pZeroIn=function(b){b.x=0;b.y=0};cc.pIn=function(d,c){d.x=c.x;d.y=c.y};cc.pMultIn=function(d,c){d.x*=c;d.y*=c};cc.pSubIn=function(d,c){d.x-=c.x;d.y-=c.y};cc.pAddIn=function(d,c){d.x+=c.x;d.y+=c.y};cc.pNormalizeIn=function(b){cc.pMultIn(b,1/Math.sqrt(b.x*b.x+b.y*b.y))};cc.Touch=cc.Class.extend({_point:null,_prevPoint:null,_id:0,_startPointCaptured:!1,_startPoint:null,ctor:function(e,d,f){this._point=cc.p(e||0,d||0);this._id=f||0},getLocation:function(){return{x:this._point.x,y:this._point.y}},getLocationX:function(){return this._point.x},getLocationY:function(){return this._point.y},getPreviousLocation:function(){return{x:this._prevPoint.x,y:this._prevPoint.y}},getStartLocation:function(){return{x:this._startPoint.x,y:this._startPoint.y}},getDelta:function(){return cc.pSub(this._point,this._prevPoint)},getLocationInView:function(){return{x:this._point.x,y:this._point.y}},getPreviousLocationInView:function(){return{x:this._prevPoint.x,y:this._prevPoint.y}},getStartLocationInView:function(){return{x:this._startPoint.x,y:this._startPoint.y}},getID:function(){return this._id},getId:function(){return this._id},setTouchInfo:function(e,d,f){this._prevPoint=this._point;this._point=cc.p(d||0,f||0);this._id=e;this._startPointCaptured||(this._startPoint=cc.p(this._point),this._startPointCaptured=!0)},_setPoint:function(d,c){void 0===c?(this._point.x=d.x,this._point.y=d.y):(this._point.x=d,this._point.y=c)},_setPrevPoint:function(d,c){this._prevPoint=void 0===c?cc.p(d.x,d.y):cc.p(d||0,c||0)}});cc.Event=cc.Class.extend({_type:0,_isStopped:!1,_currentTarget:null,_setCurrentTarget:function(b){this._currentTarget=b},ctor:function(b){this._type=b},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.CUSTOM=4;cc.EventCustom=cc.Event.extend({_eventName:null,_userData:null,ctor:function(b){cc.Event.prototype.ctor.call(this,cc.Event.CUSTOM);this._eventName=b},setUserData:function(b){this._userData=b},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(b){cc.Event.prototype.ctor.call(this,cc.Event.MOUSE);this._eventType=b},setScrollData:function(d,c){this._scrollX=d;
  15. this._scrollY=c},getScrollX:function(){return this._scrollX},getScrollY:function(){return this._scrollY},setLocation:function(d,c){this._x=d;this._y=c},getLocation:function(){return{x:this._x,y:this._y}},getLocationInView:function(){return{x:this._x,y:cc.view._designResolutionSize.height-this._y}},_setPrevCursor:function(d,c){this._prevX=d;this._prevY=c},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(b){this._button=b},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(b){cc.Event.prototype.ctor.call(this,cc.Event.TOUCH);this._touches=b||[]},getEventCode:function(){return this._eventCode},getTouches:function(){return this._touches},_setEventCode:function(b){this._eventCode=b},_setTouches:function(b){this._touches=b}});cc.EventTouch.MAX_TOUCHES=5;cc.EventTouch.EventCode={BEGAN:0,MOVED:1,ENDED:2,CANCELLED:3};cc.EventListener=cc.Class.extend({_onEvent:null,_type:0,_listenerID:null,_registered:!1,_fixedPriority:0,_node:null,_paused:!1,_isEnabled:!0,ctor:function(e,d,f){this._onEvent=f;this._type=e||0;this._listenerID=d||""},_setPaused:function(b){this._paused=b},_isPaused:function(){return this._paused},_setRegistered:function(b){this._registered=b},_isRegistered:function(){return this._registered},_getType:function(){return this._type},_getListenerID:function(){return this._listenerID},_setFixedPriority:function(b){this._fixedPriority=b},_getFixedPriority:function(){return this._fixedPriority},_setSceneGraphPriority:function(b){this._node=b},_getSceneGraphPriority:function(){return this._node},checkAvailable:function(){return null!=this._onEvent},clone:function(){return null},setEnabled:function(b){this._isEnabled=b},isEnabled:function(){return this._isEnabled},retain:function(){},release:function(){}});cc.EventListener.UNKNOWN=0;cc.EventListener.TOUCH_ONE_BY_ONE=1;cc.EventListener.TOUCH_ALL_AT_ONCE=2;cc.EventListener.KEYBOARD=3;cc.EventListener.MOUSE=4;cc.EventListener.ACCELERATION=5;cc.EventListener.CUSTOM=6;cc._EventListenerCustom=cc.EventListener.extend({_onCustomEvent:null,ctor:function(e,d){this._onCustomEvent=d;var f=this;cc.EventListener.prototype.ctor.call(this,cc.EventListener.CUSTOM,e,function(b){null!=f._onCustomEvent&&f._onCustomEvent(b)})},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(d,c){return new cc._EventListenerCustom(d,c)};cc._EventListenerMouse=cc.EventListener.extend({onMouseDown:null,onMouseUp:null,onMouseMove:null,onMouseScroll:null,ctor:function(){var b=this;cc.EventListener.prototype.ctor.call(this,cc.EventListener.MOUSE,cc._EventListenerMouse.LISTENER_ID,function(a){var d=cc.EventMouse;switch(a._eventType){case d.DOWN:if(b.onMouseDown){b.onMouseDown(a)}break;case d.UP:if(b.onMouseUp){b.onMouseUp(a)}break;case d.MOVE:if(b.onMouseMove){b.onMouseMove(a)}break;case d.SCROLL:if(b.onMouseScroll){b.onMouseScroll(a)}}})},clone:function(){var b=new cc._EventListenerMouse;b.onMouseDown=this.onMouseDown;b.onMouseUp=this.onMouseUp;b.onMouseMove=this.onMouseMove;b.onMouseScroll=this.onMouseScroll;return b},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(b){this.swallowTouches=b},clone:function(){var b=new cc._EventListenerTouchOneByOne;b.onTouchBegan=this.onTouchBegan;b.onTouchMoved=this.onTouchMoved;b.onTouchEnded=this.onTouchEnded;b.onTouchCancelled=this.onTouchCancelled;b.swallowTouches=this.swallowTouches;return b},checkAvailable:function(){return !this.onTouchBegan?(cc.log(cc._LogInfos._EventListenerTouchOneByOne_checkAvailable),!1):!0}});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)
  16. },clone:function(){var b=new cc._EventListenerTouchAllAtOnce;b.onTouchesBegan=this.onTouchesBegan;b.onTouchesMoved=this.onTouchesMoved;b.onTouchesEnded=this.onTouchesEnded;b.onTouchesCancelled=this.onTouchesCancelled;return b},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(f){cc.assert(f&&f.event,cc._LogInfos.EventListener_create);var e=f.event;delete f.event;var h=null;e===cc.EventListener.TOUCH_ONE_BY_ONE?h=new cc._EventListenerTouchOneByOne:e===cc.EventListener.TOUCH_ALL_AT_ONCE?h=new cc._EventListenerTouchAllAtOnce:e===cc.EventListener.MOUSE?h=new cc._EventListenerMouse:e===cc.EventListener.CUSTOM?(h=new cc._EventListenerCustom(f.eventName,f.callback),delete f.eventName,delete f.callback):e===cc.EventListener.KEYBOARD?h=new cc._EventListenerKeyboard:e===cc.EventListener.ACCELERATION&&(h=new cc._EventListenerAcceleration(f.callback),delete f.callback);for(var g in f){h[g]=f[g]}return h};cc.copyArray=function(f){var e,h=f.length,g=Array(h);for(e=0;e<h;e+=1){g[e]=f[e]}return g};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(b){0==b._getFixedPriority()?this._sceneGraphListeners.push(b):this._fixedListeners.push(b)},clearSceneGraphListeners:function(){this._sceneGraphListeners.length=0},clearFixedListeners:function(){this._fixedListeners.length=0},clear:function(){this._sceneGraphListeners.length=0;this._fixedListeners.length=0},getFixedPriorityListeners:function(){return this._fixedListeners},getSceneGraphPriorityListeners:function(){return this._sceneGraphListeners}});cc.__getListenerID=function(e){var d=cc.Event,f=e.getType();if(f===d.ACCELERATION){return cc._EventListenerAcceleration.LISTENER_ID}if(f===d.CUSTOM){return e.getEventName()}if(f===d.KEYBOARD){return cc._EventListenerKeyboard.LISTENER_ID}if(f===d.MOUSE){return cc._EventListenerMouse.LISTENER_ID}f===d.TOUCH&&cc.log(cc._LogInfos.__getListenerID);return""};cc.eventManager={DIRTY_NONE:0,DIRTY_FIXED_PRIORITY:1,DIRTY_SCENE_GRAPH_PRIORITY:2,DIRTY_ALL:3,_listenersMap:{},_priorityDirtyFlagMap:{},_nodeListenersMap:{},_nodePriorityMap:{},_globalZOrderNodeMap:{},_toAddedListeners:[],_dirtyNodes:[],_inDispatch:0,_isEnabled:!1,_nodePriorityIndex:0,_internalCustomListenerIDs:[cc.game.EVENT_HIDE,cc.game.EVENT_SHOW],_setDirtyForNode:function(e){null!=this._nodeListenersMap[e.__instanceId]&&this._dirtyNodes.push(e);e=e.getChildren();for(var d=0,f=e.length;d<f;d++){this._setDirtyForNode(e[d])}},pauseTarget:function(g,f){var j=this._nodeListenersMap[g.__instanceId],i,h;if(j){i=0;for(h=j.length;i<h;i++){j[i]._setPaused(!0)}}if(!0===f){j=g.getChildren();i=0;for(h=j.length;i<h;i++){this.pauseTarget(j[i],!0)}}},resumeTarget:function(g,f){var j=this._nodeListenersMap[g.__instanceId],i,h;if(j){i=0;for(h=j.length;i<h;i++){j[i]._setPaused(!1)}}this._setDirtyForNode(g);if(!0===f){j=g.getChildren();i=0;for(h=j.length;i<h;i++){this.resumeTarget(j[i],!0)}}},_addListener:function(b){0===this._inDispatch?this._forceAddEventListener(b):this._toAddedListeners.push(b)},_forceAddEventListener:function(e){var d=e._getListenerID(),f=this._listenersMap[d];f||(f=new cc._EventListenerVector,this._listenersMap[d]=f);f.push(e);0==e._getFixedPriority()?(this._setDirty(d,this.DIRTY_SCENE_GRAPH_PRIORITY),d=e._getSceneGraphPriority(),null==d&&cc.log(cc._LogInfos.eventManager__forceAddEventListener),this._associateNodeAndEventListener(d,e),d.isRunning()&&this.resumeTarget(d)):this._setDirty(d,this.DIRTY_FIXED_PRIORITY)},_getListeners:function(b){return this._listenersMap[b]},_updateDirtyFlagForSceneGraph:function(){if(0!=this._dirtyNodes.length){for(var j=this._dirtyNodes,i,r,q=this._nodeListenersMap,o=0,n=j.length;o<n;o++){if(i=q[j[o].__instanceId]){for(var m=0,k=i.length;m<k;m++){(r=i[m])&&this._setDirty(r._getListenerID(),this.DIRTY_SCENE_GRAPH_PRIORITY)}}}this._dirtyNodes.length=0}},_removeAllListenersInVector:function(e){if(e){for(var d,f=0;f<e.length;){d=e[f],d._setRegistered(!1),null!=d._getSceneGraphPriority()&&(this._dissociateNodeAndEventListener(d._getSceneGraphPriority(),d),d._setSceneGraphPriority(null)),0===this._inDispatch?cc.arrayRemoveObject(e,d):++f}}},_removeListenersForListenerID:function(f){var e=this._listenersMap[f];if(e){var h=e.getFixedPriorityListeners(),g=e.getSceneGraphPriorityListeners();this._removeAllListenersInVector(g);this._removeAllListenersInVector(h);delete this._priorityDirtyFlagMap[f];
  17. this._inDispatch||(e.clear(),delete this._listenersMap[f])}h=this._toAddedListeners;for(e=0;e<h.length;){(g=h[e])&&g._getListenerID()==f?cc.arrayRemoveObject(h,g):++e}},_sortEventListeners:function(e){var d=this.DIRTY_NONE,f=this._priorityDirtyFlagMap;f[e]&&(d=f[e]);d!=this.DIRTY_NONE&&(f[e]=this.DIRTY_NONE,d&this.DIRTY_FIXED_PRIORITY&&this._sortListenersOfFixedPriority(e),d&this.DIRTY_SCENE_GRAPH_PRIORITY&&((d=cc.director.getRunningScene())?this._sortListenersOfSceneGraphPriority(e,d):f[e]=this.DIRTY_SCENE_GRAPH_PRIORITY))},_sortListenersOfSceneGraphPriority:function(f,e){var h=this._getListeners(f);if(h){var g=h.getSceneGraphPriorityListeners();g&&0!==g.length&&(this._nodePriorityIndex=0,this._nodePriorityMap={},this._visitTarget(e,!0),h.getSceneGraphPriorityListeners().sort(this._sortEventListenersOfSceneGraphPriorityDes))}},_sortEventListenersOfSceneGraphPriorityDes:function(e,d){var f=cc.eventManager._nodePriorityMap;return f[d._getSceneGraphPriority().__instanceId]-f[e._getSceneGraphPriority().__instanceId]},_sortListenersOfFixedPriority:function(f){if(f=this._listenersMap[f]){var e=f.getFixedPriorityListeners();if(e&&0!==e.length){e.sort(this._sortListenersOfFixedPriorityAsc);for(var h=0,g=e.length;h<g&&!(0<=e[h]._getFixedPriority());){++h}f.gt0Index=h}}},_sortListenersOfFixedPriorityAsc:function(d,c){return d._getFixedPriority()-c._getFixedPriority()},_onUpdateListeners:function(g){if(g=this._listenersMap[g]){var f=g.getFixedPriorityListeners(),j=g.getSceneGraphPriorityListeners(),i,h;if(j){for(i=0;i<j.length;){h=j[i],h._isRegistered()?++i:cc.arrayRemoveObject(j,h)}}if(f){for(i=0;i<f.length;){h=f[i],h._isRegistered()?++i:cc.arrayRemoveObject(f,h)}}j&&0===j.length&&g.clearSceneGraphListeners();f&&0===f.length&&g.clearFixedListeners()}},_updateListeners:function(e){var d=this._inDispatch;cc.assert(0<d,cc._LogInfos.EventManager__updateListeners);e.getType()==cc.Event.TOUCH?(this._onUpdateListeners(cc._EventListenerTouchOneByOne.LISTENER_ID),this._onUpdateListeners(cc._EventListenerTouchAllAtOnce.LISTENER_ID)):this._onUpdateListeners(cc.__getListenerID(e));if(!(1<d)){cc.assert(1==d,cc._LogInfos.EventManager__updateListeners_2);e=this._listenersMap;var d=this._priorityDirtyFlagMap,f;for(f in e){e[f].empty()&&(delete d[f],delete e[f])}f=this._toAddedListeners;if(0!==f.length){e=0;for(d=f.length;e<d;e++){this._forceAddEventListener(f[e])}this._toAddedListeners.length=0}}},_onTouchEventCallback:function(j,i){if(!j._isRegistered){return !1}var r=i.event,q=i.selTouch;r._setCurrentTarget(j._node);var o=!1,n,m=r.getEventCode(),k=cc.EventTouch.EventCode;if(m==k.BEGAN){j.onTouchBegan&&(o=j.onTouchBegan(q,r))&&j._registered&&j._claimedTouches.push(q)}else{if(0<j._claimedTouches.length&&-1!=(n=j._claimedTouches.indexOf(q))){if(o=!0,m===k.MOVED&&j.onTouchMoved){j.onTouchMoved(q,r)}else{if(m===k.ENDED){if(j.onTouchEnded){j.onTouchEnded(q,r)}j._registered&&j._claimedTouches.splice(n,1)}else{if(m===k.CANCELLED){if(j.onTouchCancelled){j.onTouchCancelled(q,r)}j._registered&&j._claimedTouches.splice(n,1)}}}}}return r.isStopped()?(cc.eventManager._updateListeners(r),!0):o&&j._registered&&j.swallowTouches?(i.needsMutableSet&&i.touches.splice(q,1),!0):!1},_dispatchTouchEvent:function(i){this._sortEventListeners(cc._EventListenerTouchOneByOne.LISTENER_ID);this._sortEventListeners(cc._EventListenerTouchAllAtOnce.LISTENER_ID);var h=this._getListeners(cc._EventListenerTouchOneByOne.LISTENER_ID),o=this._getListeners(cc._EventListenerTouchAllAtOnce.LISTENER_ID);if(!(null==h&&null==o)){var n=i.getTouches(),m=cc.copyArray(n),k={event:i,needsMutableSet:h&&o,touches:m,selTouch:null};if(h){for(var j=0;j<n.length;j++){if(k.selTouch=n[j],this._dispatchEventToListeners(h,this._onTouchEventCallback,k),i.isStopped()){return}}}if(o&&0<m.length&&(this._dispatchEventToListeners(o,this._onTouchesEventCallback,{event:i,touches:m}),i.isStopped())){return}this._updateListeners(i)}},_onTouchesEventCallback:function(h,g){if(!h._registered){return !1}var m=cc.EventTouch.EventCode,k=g.event,j=g.touches,i=k.getEventCode();k._setCurrentTarget(h._node);if(i==m.BEGAN&&h.onTouchesBegan){h.onTouchesBegan(j,k)}else{if(i==m.MOVED&&h.onTouchesMoved){h.onTouchesMoved(j,k)}else{if(i==m.ENDED&&h.onTouchesEnded){h.onTouchesEnded(j,k)}else{if(i==m.CANCELLED&&h.onTouchesCancelled){h.onTouchesCancelled(j,k)}}}}return k.isStopped()?(cc.eventManager._updateListeners(k),!0):!1},_associateNodeAndEventListener:function(e,d){var f=this._nodeListenersMap[e.__instanceId];f||(f=[],this._nodeListenersMap[e.__instanceId]=f);f.push(d)},_dissociateNodeAndEventListener:function(e,d){var f=this._nodeListenersMap[e.__instanceId];f&&(cc.arrayRemoveObject(f,d),0===f.length&&delete this._nodeListenersMap[e.__instanceId])},_dispatchEventToListeners:function(j,i,r){var q=!1,o=j.getFixedPriorityListeners(),n=j.getSceneGraphPriorityListeners(),m=0,k;if(o&&0!==o.length){for(;m<j.gt0Index;++m){if(k=o[m],k.isEnabled()&&!k._isPaused()&&k._isRegistered()&&i(k,r)){q=!0;break}}}if(n&&!q){for(j=0;j<n.length;
  18. j++){if(k=n[j],k.isEnabled()&&!k._isPaused()&&k._isRegistered()&&i(k,r)){q=!0;break}}}if(o&&!q){for(;m<o.length&&!(k=o[m],k.isEnabled()&&!k._isPaused()&&k._isRegistered()&&i(k,r));++m){}}},_setDirty:function(e,d){var f=this._priorityDirtyFlagMap;f[e]=null==f[e]?d:d|f[e]},_visitTarget:function(t,s){var r=t.getChildren(),q=0,o=r.length,n=this._globalZOrderNodeMap,m=this._nodeListenersMap;if(0<o){for(var j;q<o;q++){if((j=r[q])&&0>j.getLocalZOrder()){this._visitTarget(j,!1)}else{break}}null!=m[t.__instanceId]&&(n[t.getGlobalZOrder()]||(n[t.getGlobalZOrder()]=[]),n[t.getGlobalZOrder()].push(t.__instanceId));for(;q<o;q++){(j=r[q])&&this._visitTarget(j,!1)}}else{null!=m[t.__instanceId]&&(n[t.getGlobalZOrder()]||(n[t.getGlobalZOrder()]=[]),n[t.getGlobalZOrder()].push(t.__instanceId))}if(s){var r=[],i;for(i in n){r.push(i)}r.sort(this._sortNumberAsc);i=r.length;j=this._nodePriorityMap;for(q=0;q<i;q++){o=n[r[q]];for(m=0;m<o.length;m++){j[o[m]]=++this._nodePriorityIndex}}this._globalZOrderNodeMap={}}},_sortNumberAsc:function(d,c){return d-c},addListener:function(d,c){cc.assert(d&&c,cc._LogInfos.eventManager_addListener_2);if(d instanceof cc.EventListener){if(d._isRegistered()){cc.log(cc._LogInfos.eventManager_addListener_4);return}}else{cc.assert("number"!==typeof c,cc._LogInfos.eventManager_addListener_3),d=cc.EventListener.create(d)}d.checkAvailable()&&("number"==typeof c?0==c?cc.log(cc._LogInfos.eventManager_addListener):(d._setSceneGraphPriority(null),d._setFixedPriority(c),d._setRegistered(!0),d._setPaused(!1),this._addListener(d)):(d._setSceneGraphPriority(c),d._setFixedPriority(0),d._setRegistered(!0),this._addListener(d)))},addCustomListener:function(e,d){var f=cc._EventListenerCustom.create(e,d);this.addListener(f,1);return f},removeListener:function(h){if(null!=h){var g,m=this._listenersMap,k;for(k in m){var j=m[k],i=j.getFixedPriorityListeners();g=j.getSceneGraphPriorityListeners();(g=this._removeListenerInVector(g,h))?this._setDirty(h._getListenerID(),this.DIRTY_SCENE_GRAPH_PRIORITY):(g=this._removeListenerInVector(i,h))&&this._setDirty(h._getListenerID(),this.DIRTY_FIXED_PRIORITY);j.empty()&&(delete this._priorityDirtyFlagMap[h._getListenerID()],delete m[k]);if(g){break}}if(!g){m=this._toAddedListeners;k=0;for(j=m.length;k<j;k++){if(i=m[k],i==h){cc.arrayRemoveObject(m,i);break}}}}},_removeListenerInVector:function(g,f){if(null==g){return !1}for(var j=0,i=g.length;j<i;j++){var h=g[j];if(h==f){return h._setRegistered(!1),null!=h._getSceneGraphPriority()&&(this._dissociateNodeAndEventListener(h._getSceneGraphPriority(),h),h._setSceneGraphPriority(null)),0==this._inDispatch&&cc.arrayRemoveObject(g,h),!0}}return !1},removeListeners:function(g,f){if(g instanceof cc.Node){delete this._nodePriorityMap[g.__instanceId];cc.arrayRemoveObject(this._dirtyNodes,g);var j=this._nodeListenersMap[g.__instanceId];if(j){for(var i=cc.copyArray(j),j=0;j<i.length;j++){this.removeListener(i[j])}i.length=0;i=this._toAddedListeners;for(j=0;j<i.length;){var h=i[j];h._getSceneGraphPriority()==g?(h._setSceneGraphPriority(null),h._setRegistered(!1),i.splice(j,1)):++j}if(!0===f){i=g.getChildren();j=0;for(h=i.length;j<h;j++){this.removeListeners(i[j],!0)}}}}else{g==cc.EventListener.TOUCH_ONE_BY_ONE?this._removeListenersForListenerID(cc._EventListenerTouchOneByOne.LISTENER_ID):g==cc.EventListener.TOUCH_ALL_AT_ONCE?this._removeListenersForListenerID(cc._EventListenerTouchAllAtOnce.LISTENER_ID):g==cc.EventListener.MOUSE?this._removeListenersForListenerID(cc._EventListenerMouse.LISTENER_ID):g==cc.EventListener.ACCELERATION?this._removeListenersForListenerID(cc._EventListenerAcceleration.LISTENER_ID):g==cc.EventListener.KEYBOARD?this._removeListenersForListenerID(cc._EventListenerKeyboard.LISTENER_ID):cc.log(cc._LogInfos.eventManager_removeListeners)}},removeCustomListeners:function(b){this._removeListenersForListenerID(b)},removeAllListeners:function(){var e=this._listenersMap,d=this._internalCustomListenerIDs,f;for(f in e){-1===d.indexOf(f)&&this._removeListenersForListenerID(f)}},setPriority:function(g,f){if(null!=g){var j=this._listenersMap,i;for(i in j){var h=j[i].getFixedPriorityListeners();if(h&&-1!=h.indexOf(g)){null!=g._getSceneGraphPriority()&&cc.log(cc._LogInfos.eventManager_setPriority);g._getFixedPriority()!==f&&(g._setFixedPriority(f),this._setDirty(g._getListenerID(),this.DIRTY_FIXED_PRIORITY));break}}}},setEnabled:function(b){this._isEnabled=b},isEnabled:function(){return this._isEnabled},dispatchEvent:function(d){if(this._isEnabled){this._updateDirtyFlagForSceneGraph();this._inDispatch++;if(!d||!d.getType){throw"event is undefined"}if(d.getType()==cc.Event.TOUCH){this._dispatchTouchEvent(d)}else{var c=cc.__getListenerID(d);this._sortEventListeners(c);c=this._listenersMap[c];null!=c&&this._dispatchEventToListeners(c,this._onListenerCallback,d);this._updateListeners(d)}this._inDispatch--}},_onListenerCallback:function(d,c){c._setCurrentTarget(d._getSceneGraphPriority());d._onEvent(c);return c.isStopped()},dispatchCustomEvent:function(e,d){var f=new cc.EventCustom(e);
  19. f.setUserData(d);this.dispatchEvent(f)}};cc._tmp.PrototypeCCNode=function(){var b=cc.Node.prototype;cc.defineGetterSetter(b,"x",b.getPositionX,b.setPositionX);cc.defineGetterSetter(b,"y",b.getPositionY,b.setPositionY);cc.defineGetterSetter(b,"width",b._getWidth,b._setWidth);cc.defineGetterSetter(b,"height",b._getHeight,b._setHeight);cc.defineGetterSetter(b,"anchorX",b._getAnchorX,b._setAnchorX);cc.defineGetterSetter(b,"anchorY",b._getAnchorY,b._setAnchorY);cc.defineGetterSetter(b,"skewX",b.getSkewX,b.setSkewX);cc.defineGetterSetter(b,"skewY",b.getSkewY,b.setSkewY);cc.defineGetterSetter(b,"zIndex",b.getLocalZOrder,b.setLocalZOrder);cc.defineGetterSetter(b,"vertexZ",b.getVertexZ,b.setVertexZ);cc.defineGetterSetter(b,"rotation",b.getRotation,b.setRotation);cc.defineGetterSetter(b,"rotationX",b.getRotationX,b.setRotationX);cc.defineGetterSetter(b,"rotationY",b.getRotationY,b.setRotationY);cc.defineGetterSetter(b,"scale",b.getScale,b.setScale);cc.defineGetterSetter(b,"scaleX",b.getScaleX,b.setScaleX);cc.defineGetterSetter(b,"scaleY",b.getScaleY,b.setScaleY);cc.defineGetterSetter(b,"children",b.getChildren);cc.defineGetterSetter(b,"childrenCount",b.getChildrenCount);cc.defineGetterSetter(b,"parent",b.getParent,b.setParent);cc.defineGetterSetter(b,"visible",b.isVisible,b.setVisible);cc.defineGetterSetter(b,"running",b.isRunning);cc.defineGetterSetter(b,"ignoreAnchor",b.isIgnoreAnchorPointForPosition,b.ignoreAnchorPointForPosition);cc.defineGetterSetter(b,"actionManager",b.getActionManager,b.setActionManager);cc.defineGetterSetter(b,"scheduler",b.getScheduler,b.setScheduler);cc.defineGetterSetter(b,"shaderProgram",b.getShaderProgram,b.setShaderProgram);cc.defineGetterSetter(b,"glServerState",b.getGLServerState,b.setGLServerState)};cc._tmp.PrototypeCCNodeRGBA=function(){var b=cc.NodeRGBA.prototype;cc.defineGetterSetter(b,"opacity",b.getOpacity,b.setOpacity);cc.defineGetterSetter(b,"opacityModifyRGB",b.isOpacityModifyRGB,b.setOpacityModifyRGB);cc.defineGetterSetter(b,"cascadeOpacity",b.isCascadeOpacityEnabled,b.setCascadeOpacityEnabled);cc.defineGetterSetter(b,"color",b.getColor,b.setColor);cc.defineGetterSetter(b,"cascadeColor",b.isCascadeColorEnabled,b.setCascadeColorEnabled)};cc.NODE_TAG_INVALID=-1;cc.s_globalOrderOfArrival=1;cc.Node=cc.Class.extend({_localZOrder:0,_globalZOrder:0,_vertexZ:0,_rotationX:0,_rotationY:0,_scaleX:1,_scaleY:1,_position:null,_skewX:0,_skewY:0,_children:null,_visible:!0,_anchorPoint:null,_anchorPointInPoints:null,_contentSize:null,_running:!1,_parent:null,_ignoreAnchorPointForPosition:!1,tag:cc.NODE_TAG_INVALID,userData:null,userObject:null,_transformDirty:!0,_inverseDirty:!0,_cacheDirty:!0,_cachedParent:null,_transformGLDirty:null,_transform:null,_inverse:null,_reorderChildDirty:!1,_shaderProgram:null,arrivalOrder:0,_actionManager:null,_scheduler:null,_eventDispatcher:null,_initializedNode:!1,_additionalTransformDirty:!1,_additionalTransform:null,_componentContainer:null,_isTransitionFinished:!1,_rotationRadiansX:0,_rotationRadiansY:0,_className:"Node",_showNode:!1,_name:"",_initNode:function(){this._anchorPoint=cc.p(0,0);this._anchorPointInPoints=cc.p(0,0);this._contentSize=cc.size(0,0);this._position=cc.p(0,0);this._children=[];this._transform={a:1,b:0,c:0,d:1,tx:0,ty:0};var b=cc.director;this._actionManager=b.getActionManager();this._scheduler=b.getScheduler();this._initializedNode=!0;this._additionalTransform=cc.AffineTransformMakeIdentity();cc.ComponentContainer&&(this._componentContainer=new cc.ComponentContainer(this))},init:function(){!1===this._initializedNode&&this._initNode();return !0},_arrayMakeObjectsPerformSelector:function(g,f){if(g&&0!==g.length){var j,i=g.length,h;j=cc.Node.StateCallbackType;switch(f){case j.onEnter:for(j=0;j<i;j++){if(h=g[j]){h.onEnter()}}break;case j.onExit:for(j=0;j<i;j++){if(h=g[j]){h.onExit()}}break;case j.onEnterTransitionDidFinish:for(j=0;j<i;j++){if(h=g[j]){h.onEnterTransitionDidFinish()}}break;case j.cleanup:for(j=0;j<i;j++){(h=g[j])&&h.cleanup()}break;case j.updateTransform:for(j=0;j<i;j++){(h=g[j])&&h.updateTransform()}break;case j.onExitTransitionDidStart:for(j=0;j<i;j++){if(h=g[j]){h.onExitTransitionDidStart()}}break;case j.sortAllChildren:for(j=0;j<i;j++){(h=g[j])&&h.sortAllChildren()}break;default:cc.assert(0,cc._LogInfos.Node__arrayMakeObjectsPerformSelector)}}},setNodeDirty:null,attr:function(d){for(var c in d){this[c]=d[c]}},getSkewX:function(){return this._skewX},setSkewX:function(b){this._skewX=b;this.setNodeDirty()},getSkewY:function(){return this._skewY},setSkewY:function(b){this._skewY=b;this.setNodeDirty()},setLocalZOrder:function(b){this._localZOrder=b;this._parent&&this._parent.reorderChild(this,b);cc.eventManager._setDirtyForNode(this)},_setLocalZOrder:function(b){this._localZOrder=b},getLocalZOrder:function(){return this._localZOrder},getZOrder:function(){cc.log(cc._LogInfos.Node_getZOrder);return this.getLocalZOrder()},setZOrder:function(b){cc.log(cc._LogInfos.Node_setZOrder);this.setLocalZOrder(b)},setGlobalZOrder:function(b){this._globalZOrder!=b&&(this._globalZOrder=b,cc.eventManager._setDirtyForNode(this))
  20. },getGlobalZOrder:function(){return this._globalZOrder},getVertexZ:function(){return this._vertexZ},setVertexZ:function(b){this._vertexZ=b},getRotation:function(){this._rotationX!==this._rotationY&&cc.log(cc._LogInfos.Node_getRotation);return this._rotationX},setRotation:function(b){this._rotationX=this._rotationY=b;this._rotationRadiansX=0.017453292519943295*this._rotationX;this._rotationRadiansY=0.017453292519943295*this._rotationY;this.setNodeDirty()},getRotationX:function(){return this._rotationX},setRotationX:function(b){this._rotationX=b;this._rotationRadiansX=0.017453292519943295*this._rotationX;this.setNodeDirty()},getRotationY:function(){return this._rotationY},setRotationY:function(b){this._rotationY=b;this._rotationRadiansY=0.017453292519943295*this._rotationY;this.setNodeDirty()},getScale:function(){this._scaleX!==this._scaleY&&cc.log(cc._LogInfos.Node_getScale);return this._scaleX},setScale:function(d,c){this._scaleX=d;this._scaleY=c||0===c?c:d;this.setNodeDirty()},getScaleX:function(){return this._scaleX},setScaleX:function(b){this._scaleX=b;this.setNodeDirty()},getScaleY:function(){return this._scaleY},setScaleY:function(b){this._scaleY=b;this.setNodeDirty()},setPosition:function(e,d){var f=this._position;void 0===d?(f.x=e.x,f.y=e.y):(f.x=e,f.y=d);this.setNodeDirty()},getPosition:function(){return cc.p(this._position)},getPositionX:function(){return this._position.x},setPositionX:function(b){this._position.x=b;this.setNodeDirty()},getPositionY:function(){return this._position.y},setPositionY:function(b){this._position.y=b;this.setNodeDirty()},getChildrenCount:function(){return this._children.length},getChildren:function(){return this._children},isVisible:function(){return this._visible},setVisible:function(b){this._visible=b;this.setNodeDirty()},getAnchorPoint:function(){return this._anchorPoint},setAnchorPoint:function(g,f){var j=this._anchorPoint;if(void 0===f){if(g.x===j.x&&g.y===j.y){return}j.x=g.x;j.y=g.y}else{if(g===j.x&&f===j.y){return}j.x=g;j.y=f}var i=this._anchorPointInPoints,h=this._contentSize;i.x=h.width*j.x;i.y=h.height*j.y;this.setNodeDirty()},_getAnchor:function(){return this._anchorPoint},_setAnchor:function(d){var c=d.x;d=d.y;this._anchorPoint.x!==c&&(this._anchorPoint.x=c,this._anchorPointInPoints.x=this._contentSize.width*c);this._anchorPoint.y!==d&&(this._anchorPoint.y=d,this._anchorPointInPoints.y=this._contentSize.height*d);this.setNodeDirty()},_getAnchorX:function(){return this._anchorPoint.x},_setAnchorX:function(b){this._anchorPoint.x!==b&&(this._anchorPoint.x=b,this._anchorPointInPoints.x=this._contentSize.width*b,this.setNodeDirty())},_getAnchorY:function(){return this._anchorPoint.y},_setAnchorY:function(b){this._anchorPoint.y!==b&&(this._anchorPoint.y=b,this._anchorPointInPoints.y=this._contentSize.height*b,this.setNodeDirty())},getAnchorPointInPoints:function(){return this._anchorPointInPoints},_getWidth:function(){return this._contentSize.width},_setWidth:function(b){this._contentSize.width=b;this._anchorPointInPoints.x=b*this._anchorPoint.x;this.setNodeDirty()},_getHeight:function(){return this._contentSize.height},_setHeight:function(b){this._contentSize.height=b;this._anchorPointInPoints.y=b*this._anchorPoint.y;this.setNodeDirty()},getContentSize:function(){return this._contentSize},setContentSize:function(g,f){var j=this._contentSize;if(void 0===f){if(g.width===j.width&&g.height===j.height){return}j.width=g.width;j.height=g.height}else{if(g===j.width&&f===j.height){return}j.width=g;j.height=f}var i=this._anchorPointInPoints,h=this._anchorPoint;i.x=j.width*h.x;i.y=j.height*h.y;this.setNodeDirty()},isRunning:function(){return this._running},getParent:function(){return this._parent},setParent:function(b){this._parent=b},isIgnoreAnchorPointForPosition:function(){return this._ignoreAnchorPointForPosition},ignoreAnchorPointForPosition:function(b){b!=this._ignoreAnchorPointForPosition&&(this._ignoreAnchorPointForPosition=b,this.setNodeDirty())},getTag:function(){return this.tag},setTag:function(b){this.tag=b},setName:function(b){this._name},getName:function(){return this._name},getUserData:function(){return this.userData},setUserData:function(b){this.userData=b},getUserObject:function(){return this.userObject},setUserObject:function(b){this.userObject!=b&&(this.userObject=b)},getOrderOfArrival:function(){return this.arrivalOrder},setOrderOfArrival:function(b){this.arrivalOrder=b},getActionManager:function(){this._actionManager||(this._actionManager=cc.director.getActionManager());return this._actionManager},setActionManager:function(b){this._actionManager!=b&&(this.stopAllActions(),this._actionManager=b)},getScheduler:function(){this._scheduler||(this._scheduler=cc.director.getScheduler());return this._scheduler},setScheduler:function(b){this._scheduler!=b&&(this.unscheduleAllCallbacks(),this._scheduler=b)},getBoundingBox:function(){var b=cc.rect(0,0,this._contentSize.width,this._contentSize.height);return cc._RectApplyAffineTransformIn(b,this.nodeToParentTransform())
  21. },cleanup:function(){this.stopAllActions();this.unscheduleAllCallbacks();cc.eventManager.removeListeners(this);this._arrayMakeObjectsPerformSelector(this._children,cc.Node.StateCallbackType.cleanup)},getChildByTag:function(f){var e=this._children;if(null!=e){for(var h=0;h<e.length;h++){var g=e[h];if(g&&g.tag==f){return g}}}return null},getChildByName:function(f){if(!f){return cc.log("Invalid name"),null}for(var e=this._children,h=0,g=e.length;h<g;h++){if(e[h]._name==f){return e[h]}}return null},addChild:function(e,d,f){cc.assert(e,cc._LogInfos.Node_addChild_3);if(e===this){cc.log(cc._LogInfos.Node_addChild)}else{if(null!==e._parent){cc.log(cc._LogInfos.Node_addChild_2)}else{if(d=null!=d?d:e._localZOrder,e.tag=null!=f?f:e.tag,this._insertChild(e,d),e._parent=this,this._cachedParent&&(e._cachedParent=this._cachedParent),this._running&&(e.onEnter(),this._isTransitionFinished)){e.onEnterTransitionDidFinish()}}}},removeFromParent:function(b){this._parent&&(null==b&&(b=!0),this._parent.removeChild(this,b))},removeFromParentAndCleanup:function(b){cc.log(cc._LogInfos.Node_removeFromParentAndCleanup);this.removeFromParent(b)},removeChild:function(d,c){0!==this._children.length&&(null==c&&(c=!0),-1<this._children.indexOf(d)&&this._detachChild(d,c),this.setNodeDirty())},removeChildByTag:function(e,d){e===cc.NODE_TAG_INVALID&&cc.log(cc._LogInfos.Node_removeChildByTag);var f=this.getChildByTag(e);null==f?cc.log(cc._LogInfos.Node_removeChildByTag_2,e):this.removeChild(f,d)},removeAllChildrenWithCleanup:function(b){cc.log(cc._LogInfos.Node_removeAllChildrenWithCleanup);this.removeAllChildren(b)},removeAllChildren:function(f){var e=this._children;if(null!=e){null==f&&(f=!0);for(var h=0;h<e.length;h++){var g=e[h];g&&(this._running&&(g.onExitTransitionDidStart(),g.onExit()),f&&g.cleanup(),g.parent=null)}this._children.length=0}},_detachChild:function(d,c){this._running&&(d.onExitTransitionDidStart(),d.onExit());c&&d.cleanup();d.parent=null;cc.arrayRemoveObject(this._children,d)},_insertChild:function(d,c){this._reorderChildDirty=!0;this._children.push(d);d._setLocalZOrder(c)},reorderChild:function(d,c){cc.assert(d,cc._LogInfos.Node_reorderChild);this._reorderChildDirty=!0;d.arrivalOrder=cc.s_globalOrderOfArrival;cc.s_globalOrderOfArrival++;d._setLocalZOrder(c);this.setNodeDirty()},sortAllChildren:function(){if(this._reorderChildDirty){var g=this._children,f=g.length,j,i,h;for(j=1;j<f;j++){h=g[j];for(i=j-1;0<=i;){if(h._localZOrder<g[i]._localZOrder){g[i+1]=g[i]}else{if(h._localZOrder===g[i]._localZOrder&&h.arrivalOrder<g[i].arrivalOrder){g[i+1]=g[i]}else{break}}i--}g[i+1]=h}this._reorderChildDirty=!1}},draw:function(b){},transformAncestors:function(){null!=this._parent&&(this._parent.transformAncestors(),this._parent.transform())},onEnter:function(){this._isTransitionFinished=!1;this._running=!0;this._arrayMakeObjectsPerformSelector(this._children,cc.Node.StateCallbackType.onEnter);this.resume()},onEnterTransitionDidFinish:function(){this._isTransitionFinished=!0;this._arrayMakeObjectsPerformSelector(this._children,cc.Node.StateCallbackType.onEnterTransitionDidFinish)},onExitTransitionDidStart:function(){this._arrayMakeObjectsPerformSelector(this._children,cc.Node.StateCallbackType.onExitTransitionDidStart)},onExit:function(){this._running=!1;this.pause();this._arrayMakeObjectsPerformSelector(this._children,cc.Node.StateCallbackType.onExit);this._componentContainer&&this._componentContainer.removeAll()},runAction:function(b){cc.assert(b,cc._LogInfos.Node_runAction);this.actionManager.addAction(b,this,!this._running);return b},stopAllActions:function(){this.actionManager&&this.actionManager.removeAllActionsFromTarget(this)},stopAction:function(b){this.actionManager.removeAction(b)},stopActionByTag:function(b){b===cc.ACTION_TAG_INVALID?cc.log(cc._LogInfos.Node_stopActionByTag):this.actionManager.removeActionByTag(b,this)},getActionByTag:function(b){return b===cc.ACTION_TAG_INVALID?(cc.log(cc._LogInfos.Node_getActionByTag),null):this.actionManager.getActionByTag(b,this)},getNumberOfRunningActions:function(){return this.actionManager.numberOfRunningActionsInTarget(this)},scheduleUpdate:function(){this.scheduleUpdateWithPriority(0)},scheduleUpdateWithPriority:function(b){this.scheduler.scheduleUpdateForTarget(this,b,!this._running)},unscheduleUpdate:function(){this.scheduler.unscheduleUpdateForTarget(this)},schedule:function(f,e,h,g){e=e||0;cc.assert(f,cc._LogInfos.Node_schedule);cc.assert(0<=e,cc._LogInfos.Node_schedule_2);h=null==h?cc.REPEAT_FOREVER:h;this.scheduler.scheduleCallbackForTarget(this,f,e,h,g||0,!this._running)},scheduleOnce:function(d,c){this.schedule(d,0,0,c)},unschedule:function(b){b&&this.scheduler.unscheduleCallbackForTarget(this,b)},unscheduleAllCallbacks:function(){this.scheduler.unscheduleAllCallbacksForTarget(this)},resumeSchedulerAndActions:function(){cc.log(cc._LogInfos.Node_resumeSchedulerAndActions);this.resume()},resume:function(){this.scheduler.resumeTarget(this);this.actionManager&&this.actionManager.resumeTarget(this);
  22. 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(b){this._additionalTransform=b;this._additionalTransformDirty=this._transformDirty=!0},parentToNodeTransform:function(){this._inverseDirty&&(this._inverse=cc.AffineTransformInvert(this.nodeToParentTransform()),this._inverseDirty=!1);return this._inverse},nodeToWorldTransform:function(){for(var d=this.nodeToParentTransform(),c=this._parent;null!=c;c=c.parent){d=cc.AffineTransformConcat(d,c.nodeToParentTransform())}return d},worldToNodeTransform:function(){return cc.AffineTransformInvert(this.nodeToWorldTransform())},convertToNodeSpace:function(b){return cc.PointApplyAffineTransform(b,this.worldToNodeTransform())},convertToWorldSpace:function(b){b=b||cc.p(0,0);return cc.PointApplyAffineTransform(b,this.nodeToWorldTransform())},convertToNodeSpaceAR:function(b){return cc.pSub(this.convertToNodeSpace(b),this._anchorPointInPoints)},convertToWorldSpaceAR:function(b){b=b||cc.p(0,0);b=cc.pAdd(b,this._anchorPointInPoints);return this.convertToWorldSpace(b)},_convertToWindowSpace:function(b){b=this.convertToWorldSpace(b);return cc.director.convertToUI(b)},convertTouchToNodeSpace:function(b){b=b.getLocation();return this.convertToNodeSpace(b)},convertTouchToNodeSpaceAR:function(b){b=b.getLocation();b=cc.director.convertToGL(b);return this.convertToNodeSpaceAR(b)},update:function(b){this._componentContainer&&!this._componentContainer.isEmpty()&&this._componentContainer.visit(b)},updateTransform:function(){this._arrayMakeObjectsPerformSelector(this._children,cc.Node.StateCallbackType.updateTransform)},retain:function(){},release:function(){},getComponent:function(b){return this._componentContainer.getComponent(b)},addComponent:function(b){this._componentContainer.add(b)},removeComponent:function(b){return this._componentContainer.remove(b)},removeAllComponents:function(){this._componentContainer.removeAll()},grid:null,ctor:null,visit:null,transform:null,nodeToParentTransform:null,_setNodeDirtyForCache:function(){if(!1===this._cacheDirty){this._cacheDirty=!0;var b=this._cachedParent;b&&b!=this&&b._setNodeDirtyForCache()}},_setCachedParent:function(f){if(this._cachedParent!=f){this._cachedParent=f;for(var e=this._children,h=0,g=e.length;h<g;h++){e[h]._setCachedParent(f)}}},getCamera:function(){this._camera||(this._camera=new cc.Camera);return this._camera},getGrid:function(){return this.grid},setGrid:function(b){this.grid=b},getShaderProgram:function(){return this._shaderProgram},setShaderProgram:function(b){this._shaderProgram=b},getGLServerState:function(){return this._glServerState},setGLServerState:function(b){this._glServerState=b},getBoundingBoxToWorld:function(){var g=cc.rect(0,0,this._contentSize.width,this._contentSize.height),f=this.nodeToWorldTransform(),g=cc.RectApplyAffineTransform(g,this.nodeToWorldTransform());if(!this._children){return g}for(var j=this._children,i=0;i<j.length;i++){var h=j[i];h&&h._visible&&(h=h._getBoundingBoxToCurrentNode(f))&&(g=cc.rectUnion(g,h))}return g},_getBoundingBoxToCurrentNode:function(g){var f=cc.rect(0,0,this._contentSize.width,this._contentSize.height);g=null==g?this.nodeToParentTransform():cc.AffineTransformConcat(this.nodeToParentTransform(),g);f=cc.RectApplyAffineTransform(f,g);if(!this._children){return f}for(var j=this._children,i=0;i<j.length;i++){var h=j[i];h&&h._visible&&(h=h._getBoundingBoxToCurrentNode(g))&&(f=cc.rectUnion(f,h))}return f},_nodeToParentTransformForWebGL:function(){if(this._transformDirty){var C=this._position.x,B=this._position.y,A=this._anchorPointInPoints.x,z=-A,y=this._anchorPointInPoints.y,x=-y,w=this._scaleX,v=this._scaleY;this._ignoreAnchorPointForPosition&&(C+=A,B+=y);var u=1,t=0,s=1,o=0;if(0!==this._rotationX||0!==this._rotationY){u=Math.cos(-this._rotationRadiansX),t=Math.sin(-this._rotationRadiansX),s=Math.cos(-this._rotationRadiansY),o=Math.sin(-this._rotationRadiansY)}var j=this._skewX||this._skewY;if(!j&&(0!==A||0!==y)){C+=s*z*w+-t*x*v,B+=o*z*w+u*x*v}var i=this._transform;i.a=s*w;i.b=o*w;i.c=-t*v;i.d=u*v;i.tx=C;i.ty=B;if(j&&(i=cc.AffineTransformConcat({a:1,b:Math.tan(cc.degreesToRadians(this._skewY)),c:Math.tan(cc.degreesToRadians(this._skewX)),d:1,tx:0,ty:0},i),0!==A||0!==y)){i=cc.AffineTransformTranslate(i,z,x)}this._additionalTransformDirty&&(i=cc.AffineTransformConcat(i,this._additionalTransform),this._additionalTransformDirty=!1);this._transform=i;this._transformDirty=!1}return this._transform}});cc.Node.create=function(){return new cc.Node};cc.Node.StateCallbackType={onEnter:1,onExit:2,cleanup:3,onEnterTransitionDidFinish:4,updateTransform:5,onExitTransitionDidStart:6,sortAllChildren:7};if(cc._renderType===cc._RENDER_TYPE_CANVAS){var _p=cc.Node.prototype;_p.ctor=function(){this._initNode()};_p.setNodeDirty=function(){this._setNodeDirtyForCache();
  23. !1===this._transformDirty&&(this._transformDirty=this._inverseDirty=!0)};_p.visit=function(g){if(this._visible){g=g||cc._renderContext;var f,j=this._children,i;g.save();this.transform(g);var h=j.length;if(0<h){this.sortAllChildren();for(f=0;f<h;f++){if(i=j[f],0>i._localZOrder){i.visit(g)}else{break}}for(this.draw(g);f<h;f++){j[f].visit(g)}}else{this.draw(g)}this._cacheDirty=!1;this.arrivalOrder=0;g.restore()}};_p.transform=function(e){e=e||cc._renderContext;var d=cc.view,f=this.nodeToParentTransform();e.transform(f.a,f.c,f.b,f.d,f.tx*d.getScaleX(),-f.ty*d.getScaleY())};_p.nodeToParentTransform=function(){if(this._transformDirty){var A=this._transform;A.tx=this._position.x;A.ty=this._position.y;var z=1,y=0;this._rotationX&&(z=Math.cos(this._rotationRadiansX),y=Math.sin(this._rotationRadiansX));A.a=A.d=z;A.b=-y;A.c=y;var x=this._scaleX,w=this._scaleY,v=this._anchorPointInPoints.x,u=this._anchorPointInPoints.y,t=0.000001>x&&-0.000001<x?0.000001:x,s=0.000001>w&&-0.000001<w?0.000001:w;if(this._skewX||this._skewY){var r=Math.tan(-this._skewX*Math.PI/180),o=Math.tan(-this._skewY*Math.PI/180);Infinity===r&&(r=99999999);Infinity===o&&(o=99999999);var j=u*r*t,i=v*o*s;A.a=z+-y*o;A.b=z*r+-y;A.c=y+z*o;A.d=y*r+z;A.tx+=z*j+-y*i;A.ty+=y*j+z*i}if(1!==x||1!==w){A.a*=t,A.c*=t,A.b*=s,A.d*=s}A.tx+=z*-v*t+-y*u*s;A.ty-=y*-v*t+z*u*s;this._ignoreAnchorPointForPosition&&(A.tx+=v,A.ty+=u);this._additionalTransformDirty&&(this._transform=cc.AffineTransformConcat(A,this._additionalTransform),this._additionalTransformDirty=!1);this._transformDirty=!1}return this._transform};_p=null}else{cc.assert("function"===typeof cc._tmp.WebGLCCNode,cc._LogInfos.MissingFile,"BaseNodesWebGL.js"),cc._tmp.WebGLCCNode(),delete cc._tmp.WebGLCCNode}cc.assert("function"===typeof cc._tmp.PrototypeCCNode,cc._LogInfos.MissingFile,"BaseNodesPropertyDefine.js");cc._tmp.PrototypeCCNode();delete cc._tmp.PrototypeCCNode;cc.NodeRGBA=cc.Node.extend({RGBAProtocol:!0,_displayedOpacity:255,_realOpacity:255,_displayedColor:null,_realColor:null,_cascadeColorEnabled:!1,_cascadeOpacityEnabled:!1,ctor:function(){cc.Node.prototype.ctor.call(this);this._realOpacity=this._displayedOpacity=255;this._displayedColor=cc.color(255,255,255,255);this._realColor=cc.color(255,255,255,255);this._cascadeOpacityEnabled=this._cascadeColorEnabled=!1},_updateColor:function(){},getOpacity:function(){return this._realOpacity},getDisplayedOpacity:function(){return this._displayedOpacity},setOpacity:function(e){this._displayedOpacity=this._realOpacity=e;var d=255,f=this._parent;f&&(f.RGBAProtocol&&f.cascadeOpacity)&&(d=f.getDisplayedOpacity());this.updateDisplayedOpacity(d);this._displayedColor.a=this._realColor.a=e},updateDisplayedOpacity:function(e){this._displayedOpacity=this._realOpacity*e/255;if(this._cascadeOpacityEnabled){e=this._children;for(var d=0;d<e.length;d++){var f=e[d];f&&f.RGBAProtocol&&f.updateDisplayedOpacity(this._displayedOpacity)}}},isCascadeOpacityEnabled:function(){return this._cascadeOpacityEnabled},setCascadeOpacityEnabled:function(b){this._cascadeOpacityEnabled!==b&&((this._cascadeOpacityEnabled=b)?this._enableCascadeOpacity():this._disableCascadeOpacity())},_enableCascadeOpacity:function(){var d=255,c=this._parent;c&&(c.RGBAProtocol&&c.cascadeOpacity)&&(d=c.getDisplayedOpacity());this.updateDisplayedOpacity(d)},_disableCascadeOpacity:function(){this._displayedOpacity=this._realOpacity;for(var e=this._children,d=0;d<e.length;d++){var f=e[d];f&&f.RGBAProtocol&&f.updateDisplayedOpacity(255)}},getColor:function(){var b=this._realColor;return cc.color(b.r,b.g,b.b,b.a)},getDisplayedColor:function(){var b=this._displayedColor;return cc.color(b.r,b.g,b.b,b.a)},setColor:function(e){var d=this._displayedColor,f=this._realColor;d.r=f.r=e.r;d.g=f.g=e.g;d.b=f.b=e.b;d=(d=this._parent)&&d.RGBAProtocol&&d.cascadeColor?d.getDisplayedColor():cc.color.WHITE;this.updateDisplayedColor(d);void 0!==e.a&&!e.a_undefined&&this.setOpacity(e.a)},updateDisplayedColor:function(f){var e=this._displayedColor,h=this._realColor;e.r=0|h.r*f.r/255;e.g=0|h.g*f.g/255;e.b=0|h.b*f.b/255;if(this._cascadeColorEnabled){f=this._children;for(h=0;h<f.length;h++){var g=f[h];g&&g.RGBAProtocol&&g.updateDisplayedColor(e)}}},isCascadeColorEnabled:function(){return this._cascadeColorEnabled},setCascadeColorEnabled:function(b){this._cascadeColorEnabled!==b&&((this._cascadeColorEnabled=b)?this._enableCascadeColor():this._disableCascadeColor())},_enableCascadeColor:function(){var b;b=(b=this._parent)&&b.RGBAProtocol&&b.cascadeColor?b.getDisplayedColor():cc.color.WHITE;this.updateDisplayedColor(b)},_disableCascadeColor:function(){var f=this._displayedColor,e=this._realColor;f.r=e.r;f.g=e.g;f.b=e.b;for(var f=this._children,e=cc.color.WHITE,h=0;h<f.length;h++){var g=f[h];g&&g.RGBAProtocol&&g.updateDisplayedColor(e)}},addChild:function(e,d,f){cc.Node.prototype.addChild.call(this,e,d,f);this._cascadeColorEnabled&&this._enableCascadeColor();this._cascadeOpacityEnabled&&this._enableCascadeOpacity()},setOpacityModifyRGB:function(b){},isOpacityModifyRGB:function(){return !1
  24. }});cc.NodeRGBA.create=function(){var b=new cc.NodeRGBA;b.init();return b};cc.assert("function"===typeof cc._tmp.PrototypeCCNodeRGBA,cc._LogInfos.MissingFile,"BaseNodesPropertyDefine.js");cc._tmp.PrototypeCCNodeRGBA();delete cc._tmp.PrototypeCCNodeRGBA;cc.Node.ON_ENTER=0;cc.Node.ON_EXIT=1;cc.Node.ON_ENTER_TRANSITION_DID_FINISH=2;cc.Node.ON_EXIT_TRANSITOIN_DID_START=3;cc.Node.ON_CLEAN_UP=4;cc._tmp.PrototypeTexture2D=function(){var d=cc.Texture2D;d.PVRImagesHavePremultipliedAlpha=function(b){cc.PVRHaveAlphaPremultiplied_=b};d.PIXEL_FORMAT_RGBA8888=2;d.PIXEL_FORMAT_RGB888=3;d.PIXEL_FORMAT_RGB565=4;d.PIXEL_FORMAT_A8=5;d.PIXEL_FORMAT_I8=6;d.PIXEL_FORMAT_AI88=7;d.PIXEL_FORMAT_RGBA4444=8;d.PIXEL_FORMAT_RGB5A1=7;d.PIXEL_FORMAT_PVRTC4=9;d.PIXEL_FORMAT_PVRTC2=10;d.PIXEL_FORMAT_DEFAULT=d.PIXEL_FORMAT_RGBA8888;var c=cc.Texture2D._M={};c[d.PIXEL_FORMAT_RGBA8888]="RGBA8888";c[d.PIXEL_FORMAT_RGB888]="RGB888";c[d.PIXEL_FORMAT_RGB565]="RGB565";c[d.PIXEL_FORMAT_A8]="A8";c[d.PIXEL_FORMAT_I8]="I8";c[d.PIXEL_FORMAT_AI88]="AI88";c[d.PIXEL_FORMAT_RGBA4444]="RGBA4444";c[d.PIXEL_FORMAT_RGB5A1]="RGB5A1";c[d.PIXEL_FORMAT_PVRTC4]="PVRTC4";c[d.PIXEL_FORMAT_PVRTC2]="PVRTC2";c=cc.Texture2D._B={};c[d.PIXEL_FORMAT_RGBA8888]=32;c[d.PIXEL_FORMAT_RGB888]=24;c[d.PIXEL_FORMAT_RGB565]=16;c[d.PIXEL_FORMAT_A8]=8;c[d.PIXEL_FORMAT_I8]=8;c[d.PIXEL_FORMAT_AI88]=16;c[d.PIXEL_FORMAT_RGBA4444]=16;c[d.PIXEL_FORMAT_RGB5A1]=16;c[d.PIXEL_FORMAT_PVRTC4]=4;c[d.PIXEL_FORMAT_PVRTC2]=3;c=cc.Texture2D.prototype;cc.defineGetterSetter(c,"name",c.getName);cc.defineGetterSetter(c,"pixelFormat",c.getPixelFormat);cc.defineGetterSetter(c,"pixelsWidth",c.getPixelsWide);cc.defineGetterSetter(c,"pixelsHeight",c.getPixelsHigh);cc.defineGetterSetter(c,"width",c._getWidth);cc.defineGetterSetter(c,"height",c._getHeight);d.defaultPixelFormat=d.PIXEL_FORMAT_DEFAULT};cc._tmp.PrototypeTextureAtlas=function(){var b=cc.TextureAtlas.prototype;cc.defineGetterSetter(b,"totalQuads",b.getTotalQuads);cc.defineGetterSetter(b,"capacity",b.getCapacity);cc.defineGetterSetter(b,"quads",b.getQuads,b.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._renderType===cc._RENDER_TYPE_CANVAS?cc.Texture2D=cc.Class.extend({_contentSize:null,_isLoaded:!1,_htmlElementObj:null,_loadedEventListeners:null,url:null,ctor:function(){this._contentSize=cc.size(0,0);this._isLoaded=!1;this._htmlElementObj=null},getPixelsWide:function(){return this._contentSize.width},getPixelsHigh:function(){return this._contentSize.height},getContentSize:function(){var b=cc.contentScaleFactor();return cc.size(this._contentSize.width/b,this._contentSize.height/b)},_getWidth:function(){return this._contentSize.width/cc.contentScaleFactor()},_getHeight:function(){return this._contentSize.height/cc.contentScaleFactor()},getContentSizeInPixels:function(){return this._contentSize},initWithElement:function(b){b&&(this._htmlElementObj=b)},getHtmlElementObj:function(){return this._htmlElementObj},isLoaded:function(){return this._isLoaded},handleLoadedTexture:function(){if(!this._isLoaded){if(!this._htmlElementObj){var b=cc.loader.getRes(this.url);if(!b){return}this.initWithElement(b)}this._isLoaded=!0;b=this._htmlElementObj;this._contentSize.width=b.width;this._contentSize.height=b.height;this._callLoadedEventCallbacks()}},description:function(){return"\x3ccc.Texture2D | width \x3d "+this._contentSize.width+" height "+this._contentSize.height+"\x3e"},initWithData:function(g,f,j,i,h){return !1},initWithImage:function(b){return !1},initWithString:function(h,g,m,k,j,i){return !1},releaseTexture:function(){},getName:function(){return null},getMaxS:function(){return 1},setMaxS:function(b){},getMaxT:function(){return 1},setMaxT:function(b){},getPixelFormat:function(){return null},getShaderProgram:function(){return null},setShaderProgram:function(b){},hasPremultipliedAlpha:function(){return !1},hasMipmaps:function(){return !1},releaseData:function(b){},keepData:function(d,c){return d},drawAtPoint:function(b){},drawInRect:function(b){},initWithETCFile:function(b){cc.log(cc._LogInfos.Texture2D_initWithETCFile);return !1},initWithPVRFile:function(b){cc.log(cc._LogInfos.Texture2D_initWithPVRFile);return !1},initWithPVRTCData:function(h,g,m,k,j,i){cc.log(cc._LogInfos.Texture2D_initWithPVRTCData);return !1},setTexParameters:function(b){},setAntiAliasTexParameters:function(){},setAliasTexParameters:function(){},generateMipmap:function(){},stringForFormat:function(){return""},bitsPerPixelForFormat:function(b){return -1},addLoadedEventListener:function(d,c){this._loadedEventListeners||(this._loadedEventListeners=[]);this._loadedEventListeners.push({eventCallback:d,eventTarget:c})},removeLoadedEventListener:function(e){if(this._loadedEventListeners){for(var d=this._loadedEventListeners,f=0;f<d.length;f++){d[f].eventTarget==e&&d.splice(f,1)}}},_callLoadedEventCallbacks:function(){if(this._loadedEventListeners){for(var f=this._loadedEventListeners,e=0,h=f.length;
  25. e<h;e++){var g=f[e];g.eventCallback.call(g.eventTarget,this)}f.length=0}}}):(cc.assert("function"===typeof cc._tmp.WebGLTexture2D,cc._LogInfos.MissingFile,"TexturesWebGL.js"),cc._tmp.WebGLTexture2D(),delete cc._tmp.WebGLTexture2D);cc.assert("function"===typeof cc._tmp.PrototypeTexture2D,cc._LogInfos.MissingFile,"TexturesPropertyDefine.js");cc._tmp.PrototypeTexture2D();delete cc._tmp.PrototypeTexture2D;cc.textureCache={_textures:{},_textureColorsCache:{},_textureKeySeq:0|1000*Math.random(),_loadedTexturesBefore:{},_initializingRenderer:function(){var f,e=this._loadedTexturesBefore,h=this._textures;for(f in e){var g=e[f];g.handleLoadedTexture();h[f]=g}this._loadedTexturesBefore={}},addPVRTCImage:function(b){cc.log(cc._LogInfos.textureCache_addPVRTCImage)},addETCImage:function(b){cc.log(cc._LogInfos.textureCache_addETCImage)},description:function(){return"\x3cTextureCache | Number of textures \x3d "+this._textures.length+"\x3e"},textureForKey:function(b){return this._textures[b]||this._textures[cc.loader._aliases[b]]},getKeyByTexture:function(d){for(var c in this._textures){if(this._textures[c]==d){return c}}return null},_generalTextureKey:function(){this._textureKeySeq++;return"_textureKey_"+this._textureKeySeq},getTextureColors:function(d){var c=this.getKeyByTexture(d);c||(c=d instanceof HTMLImageElement?d.src:this._generalTextureKey());this._textureColorsCache[c]||(this._textureColorsCache[c]=cc.generateTextureCacheForColor(d));return this._textureColorsCache[c]},addPVRImage:function(b){cc.log(cc._LogInfos.textureCache_addPVRImage)},removeAllTextures:function(){var d=this._textures,c;for(c in d){d[c]&&d[c].releaseTexture()}this._textures={}},removeTexture:function(e){if(e){var d=this._textures,f;for(f in d){d[f]==e&&(d[f].releaseTexture(),delete d[f])}}},removeTextureForKey:function(b){null!=b&&this._textures[b]&&delete this._textures[b]},cacheImage:function(e,d){if(d instanceof cc.Texture2D){this._textures[e]=d}else{var f=new cc.Texture2D;f.initWithElement(d);f.handleLoadedTexture();this._textures[e]=f}},addUIImage:function(e,d){cc.assert(e,cc._LogInfos.textureCache_addUIImage_2);if(d&&this._textures[d]){return this._textures[d]}var f=new cc.Texture2D;f.initWithImage(e);null!=d&&null!=f?this._textures[d]=f:cc.log(cc._LogInfos.textureCache_addUIImage);return f},dumpCachedTextureInfo:function(){var i=0,h=0,o=this._textures,n;for(n in o){var m=o[n];i++;m.getHtmlElementObj() instanceof HTMLImageElement?cc.log(cc._LogInfos.textureCache_dumpCachedTextureInfo,n,m.getHtmlElementObj().src,m.pixelsWidth,m.pixelsHeight):cc.log(cc._LogInfos.textureCache_dumpCachedTextureInfo_2,n,m.pixelsWidth,m.pixelsHeight);h+=4*m.pixelsWidth*m.pixelsHeight}o=this._textureColorsCache;for(n in o){var m=o[n],k;for(k in m){var j=m[k];i++;cc.log(cc._LogInfos.textureCache_dumpCachedTextureInfo_2,n,j.width,j.height);h+=4*j.width*j.height}}cc.log(cc._LogInfos.textureCache_dumpCachedTextureInfo_3,i,h/1024,(h/1048576).toFixed(2))},_clear:function(){this._textures={};this._textureColorsCache={};this._textureKeySeq=0|1000*Math.random();this._loadedTexturesBefore={}}};cc._renderType===cc._RENDER_TYPE_CANVAS?(_p=cc.textureCache,_p.handleLoadedTexture=function(e){var d=this._textures,f=d[e];f||(f=d[e]=new cc.Texture2D,f.url=e);f.handleLoadedTexture()},_p.addImage=function(g,f,j){cc.assert(g,cc._LogInfos.Texture2D_addImage);var i=this._textures,h=i[g]||i[cc.loader._aliases[g]];if(h){return f&&f.call(j),h}h=i[g]=new cc.Texture2D;h.url=g;cc.loader.getRes(g)?h.handleLoadedTexture():cc.loader._checkIsImageURL(g)?cc.loader.load(g,function(b){f&&f.call(j)}):cc.loader.cache[g]=cc.loader.loadImg(g,function(b,a){if(b){return f?f(b):b}cc.textureCache.handleLoadedTexture(g);f&&f(null,a)});return h},_p=null):(cc.assert("function"===typeof cc._tmp.WebGLTextureCache,cc._LogInfos.MissingFile,"TexturesWebGL.js"),cc._tmp.WebGLTextureCache(),delete cc._tmp.WebGLTextureCache);cc.Scene=cc.Node.extend({_className:"Scene",ctor:function(){cc.Node.prototype.ctor.call(this);this._ignoreAnchorPointForPosition=!0;this.setAnchorPoint(0.5,0.5);this.setContentSize(cc.director.getWinSize())}});cc.Scene.create=function(){return new cc.Scene};cc.LoaderScene=cc.Scene.extend({_interval:null,_length:0,_count:0,_label:null,_className:"LoaderScene",init:function(){var g=this,f=200,j=g._bgLayer=cc.LayerColor.create(cc.color(32,32,32,255));j.setPosition(cc.visibleRect.bottomLeft);g.addChild(j,0);var i=24,h=-f/2+100;cc._loaderImage&&(cc.loader.loadImg(cc._loaderImage,{isCrossOrigin:!1},function(b,a){f=a.height;g._initStage(a,cc.visibleRect.center)}),i=14,h=-f/2-10);i=g._label=cc.LabelTTF.create("Loading... 0%","Arial",i);i.setPosition(cc.pAdd(cc.visibleRect.center,cc.p(0,h)));i.setColor(cc.color(180,180,180));j.addChild(this._label,10);return !0},_initStage:function(e,d){var f=this._texture2d=new cc.Texture2D;f.initWithElement(e);f.handleLoadedTexture();f=this._logo=cc.Sprite.create(f);f.setScale(cc.contentScaleFactor());f.x=d.x;f.y=d.y;this._bgLayer.addChild(f,10)},onEnter:function(){cc.Node.prototype.onEnter.call(this);
  26. this.schedule(this._startLoading,0.3)},onExit:function(){cc.Node.prototype.onExit.call(this);this._label.setString("Loading... 0%")},initWithResources:function(d,c){"string"==typeof d&&(d=[d]);this.resources=d||[];this.cb=c},_startLoading:function(){var d=this;d.unschedule(d._startLoading);var c=d.resources;d._length=c.length;d._count=0;cc.loader.load(c,function(a,e){d._count=e},function(){d.cb&&d.cb()});d.schedule(d._updatePercent)},_updatePercent:function(){var e=this._count,d=this._length,f;f=Math.min(100*(e/d)|0,100);this._label.setString("Loading... "+f+"%");e>=d&&this.unschedule(this._updatePercent)}});cc.LoaderScene.preload=function(e,d){var f=cc;f.loaderScene||(f.loaderScene=new cc.LoaderScene,f.loaderScene.init());f.loaderScene.initWithResources(e,d);cc.director.runScene(f.loaderScene);return f.loaderScene};cc._tmp.PrototypeLayerRGBA=function(){var b=cc.LayerRGBA.prototype;cc.defineGetterSetter(b,"opacityModifyRGB",b.isOpacityModifyRGB,b.setOpacityModifyRGB);cc.defineGetterSetter(b,"opacity",b.getOpacity,b.setOpacity);cc.defineGetterSetter(b,"cascadeOpacity",b.isCascadeOpacityEnabled,b.setCascadeOpacityEnabled);cc.defineGetterSetter(b,"color",b.getColor,b.setColor);cc.defineGetterSetter(b,"cascadeColor",b.isCascadeColorEnabled,b.setCascadeColorEnabled)};cc._tmp.PrototypeLayerColor=function(){var b=cc.LayerColor.prototype;cc.defineGetterSetter(b,"width",b._getWidth,b._setWidth);cc.defineGetterSetter(b,"height",b._getHeight,b._setHeight)};cc._tmp.PrototypeLayerGradient=function(){var b=cc.LayerGradient.prototype;cc.defineGetterSetter(b,"startColor",b.getStartColor,b.setStartColor);cc.defineGetterSetter(b,"endColor",b.getEndColor,b.setEndColor);cc.defineGetterSetter(b,"startOpacity",b.getStartOpacity,b.setStartOpacity);cc.defineGetterSetter(b,"endOpacity",b.getEndOpacity,b.setEndOpacity);cc.defineGetterSetter(b,"vector",b.getVector,b.setVector)};cc.Layer=cc.Node.extend({_isBaked:!1,_bakeSprite:null,_className:"Layer",ctor:function(){var b=cc.Node.prototype;b.ctor.call(this);this._ignoreAnchorPointForPosition=!0;b.setAnchorPoint.call(this,0.5,0.5);b.setContentSize.call(this,cc.winSize)},bake:null,unbake:null,isBaked:function(){return this._isBaked},visit:null});cc.Layer.create=function(){return new cc.Layer};if(cc._renderType===cc._RENDER_TYPE_CANVAS){var p=cc.Layer.prototype;p.bake=function(){if(!this._isBaked){this._isBaked=this._cacheDirty=!0;this._cachedParent=this;for(var e=this._children,d=0,f=e.length;d<f;d++){e[d]._setCachedParent(this)}this._bakeSprite||(this._bakeSprite=new cc.BakeSprite)}};p.unbake=function(){if(this._isBaked){this._isBaked=!1;this._cacheDirty=!0;this._cachedParent=null;for(var e=this._children,d=0,f=e.length;d<f;d++){e[d]._setCachedParent(null)}}};p.visit=function(i){if(this._isBaked){i=i||cc._renderContext;var h,o=this._children,n=o.length;if(this._visible&&0!==n){var m=this._bakeSprite;i.save();this.transform(i);if(this._cacheDirty){h=this._getBoundingBoxForBake();h.width|=0;h.height|=0;var k=m.getCacheContext();m.resetCanvasSize(h.width,h.height);k.translate(0-h.x,h.height+h.y);var j=m.getAnchorPointInPoints();m.setPosition(j.x+h.x,j.y+h.y);this.sortAllChildren();for(h=0;h<n;h++){o[h].visit(k)}this._cacheDirty=!1}m.visit(i);this.arrivalOrder=0;i.restore()}}else{cc.Node.prototype.visit.call(this,i)}};p._getBoundingBoxForBake=function(){var f=null;if(!this._children||0===this._children.length){return cc.rect(0,0,10,10)}for(var e=this._children,h=0;h<e.length;h++){var g=e[h];g&&g._visible&&(f?(g=g._getBoundingBoxToCurrentNode())&&(f=cc.rectUnion(f,g)):f=g._getBoundingBoxToCurrentNode())}return f};p=null}else{cc.assert("function"===typeof cc._tmp.LayerDefineForWebGL,cc._LogInfos.MissingFile,"CCLayerWebGL.js"),cc._tmp.LayerDefineForWebGL(),delete cc._tmp.LayerDefineForWebGL}cc.LayerRGBA=cc.Layer.extend({RGBAProtocol:!0,_displayedOpacity:255,_realOpacity:255,_displayedColor:null,_realColor:null,_cascadeOpacityEnabled:!1,_cascadeColorEnabled:!1,_className:"LayerRGBA",ctor:function(){cc.Layer.prototype.ctor.call(this);this._displayedColor=cc.color(255,255,255,255);this._realColor=cc.color(255,255,255,255)},init:function(){var b=cc.Layer.prototype;this._ignoreAnchorPointForPosition=!0;b.setAnchorPoint.call(this,0.5,0.5);b.setContentSize.call(this,cc.winSize);this.cascadeColor=this.cascadeOpacity=!1;return !0},getOpacity:function(){return this._realOpacity},getDisplayedOpacity:function(){return this._displayedOpacity},setOpacity:function(e){this._displayedOpacity=this._realOpacity=e;var d=255,f=this._parent;f&&(f.RGBAProtocol&&f.cascadeOpacity)&&(d=f.getDisplayedOpacity());this.updateDisplayedOpacity(d);this._displayedColor.a=this._realColor.a=e},updateDisplayedOpacity:function(e){this._displayedOpacity=0|this._realOpacity*e/255;if(this._cascadeOpacityEnabled){e=this._children;for(var d,f=0;f<e.length;f++){(d=e[f])&&d.RGBAProtocol&&d.updateDisplayedOpacity(this._displayedOpacity)}}},isCascadeOpacityEnabled:function(){return this._cascadeOpacityEnabled},setCascadeOpacityEnabled:function(b){this._cascadeOpacityEnabled!==b&&((this._cascadeOpacityEnabled=b)?this._enableCascadeOpacity():this._disableCascadeOpacity())
  27. },_enableCascadeOpacity:function(){var d=255,c=this._parent;c&&(c.RGBAProtocol&&c.cascadeOpacity)&&(d=c.getDisplayedOpacity());this.updateDisplayedOpacity(d)},_disableCascadeOpacity:function(){this._displayedOpacity=this._realOpacity;for(var e=this._children,d,f=0;f<e.length;f++){(d=e[f])&&d.RGBAProtocol&&d.updateDisplayedOpacity(255)}},getColor:function(){var b=this._realColor;return cc.color(b.r,b.g,b.b,b.a)},getDisplayedColor:function(){var b=this._displayedColor;return cc.color(b.r,b.g,b.b)},setColor:function(e){var d=this._displayedColor,f=this._realColor;d.r=f.r=e.r;d.g=f.g=e.g;d.b=f.b=e.b;d=(d=this._parent)&&d.RGBAProtocol&&d.cascadeColor?d.getDisplayedColor():cc.color.WHITE;this.updateDisplayedColor(d);void 0!==e.a&&!e.a_undefined&&this.setOpacity(e.a)},updateDisplayedColor:function(f){var e=this._displayedColor,h=this._realColor;e.r=0|h.r*f.r/255;e.g=0|h.g*f.g/255;e.b=0|h.b*f.b/255;if(this._cascadeColorEnabled){f=this._children;for(var g=0;g<f.length;g++){(h=f[g])&&h.RGBAProtocol&&h.updateDisplayedColor(e)}}},isCascadeColorEnabled:function(){return this._cascadeColorEnabled},setCascadeColorEnabled:function(b){this._cascadeColorEnabled!==b&&((this._cascadeColorEnabled=b)?this._enableCascadeColor():this._disableCascadeColor())},_enableCascadeColor:function(){var b;b=(b=this._parent)&&b.RGBAProtocol&&b.cascadeColor?b.getDisplayedColor():cc.color.WHITE;this.updateDisplayedColor(b)},_disableCascadeColor:function(){var f=this._displayedColor,e=this._realColor;f.r=e.r;f.g=e.g;f.b=e.b;var f=this._children,e=cc.color.WHITE,h,g;for(g=0;g<f.length;g++){(h=f[g])&&h.RGBAProtocol&&h.updateDisplayedColor(e)}},addChild:function(e,d,f){cc.Node.prototype.addChild.call(this,e,d,f);this._cascadeColorEnabled&&this._enableCascadeColor();this._cascadeOpacityEnabled&&this._enableCascadeOpacity()},setOpacityModifyRGB:function(b){},isOpacityModifyRGB:function(){return !1}});cc.assert("function"===typeof cc._tmp.PrototypeLayerRGBA,cc._LogInfos.MissingFile,"CCLayerPropertyDefine.js");cc._tmp.PrototypeLayerRGBA();delete cc._tmp.PrototypeLayerRGBA;cc.LayerColor=cc.LayerRGBA.extend({_blendFunc:null,_className:"LayerColor",getBlendFunc:function(){return this._blendFunc},changeWidthAndHeight:function(d,c){this.width=d;this.height=c},changeWidth:function(b){this.width=b},changeHeight:function(b){this.height=b},setOpacityModifyRGB:function(b){},isOpacityModifyRGB:function(){return !1},setColor:function(b){cc.LayerRGBA.prototype.setColor.call(this,b);this._updateColor()},setOpacity:function(b){cc.LayerRGBA.prototype.setOpacity.call(this,b);this._updateColor()},_isLighterMode:!1,ctor:null,init:function(f,e,h){cc._renderType!==cc._RENDER_TYPE_CANVAS&&(this.shaderProgram=cc.shaderCache.programForKey(cc.SHADER_POSITION_COLOR));var g=cc.director.getWinSize();f=f||cc.color(0,0,0,255);e=void 0===e?g.width:e;h=void 0===h?g.height:h;g=this._displayedColor;g.r=f.r;g.g=f.g;g.b=f.b;g=this._realColor;g.r=f.r;g.g=f.g;g.b=f.b;this._realOpacity=this._displayedOpacity=f.a;f=cc.LayerColor.prototype;f.setContentSize.call(this,e,h);f._updateColor.call(this);return !0},setBlendFunc:function(d,c){this._blendFunc=void 0===c?d:{src:d,dst:c};cc._renderType===cc._RENDER_TYPE_CANVAS&&(this._isLighterMode=this._blendFunc&&1==this._blendFunc.src&&771==this._blendFunc.dst)},_setWidth:null,_setHeight:null,_updateColor:null,updateDisplayedColor:function(b){cc.LayerRGBA.prototype.updateDisplayedColor.call(this,b);this._updateColor()},updateDisplayedOpacity:function(b){cc.LayerRGBA.prototype.updateDisplayedOpacity.call(this,b);this._updateColor()},draw:null});cc.LayerColor.create=function(e,d,f){return new cc.LayerColor(e,d,f)};cc._renderType===cc._RENDER_TYPE_CANVAS?(_p=cc.LayerColor.prototype,_p.ctor=function(e,d,f){cc.LayerRGBA.prototype.ctor.call(this);this._blendFunc=new cc.BlendFunc(cc.BLEND_SRC,cc.BLEND_DST);cc.LayerColor.prototype.init.call(this,e,d,f)},_p._setWidth=cc.LayerRGBA.prototype._setWidth,_p._setHeight=cc.LayerRGBA.prototype._setHeight,_p._updateColor=function(){},_p.draw=function(e){e=e||cc._renderContext;var d=cc.view,f=this._displayedColor;e.fillStyle="rgba("+(0|f.r)+","+(0|f.g)+","+(0|f.b)+","+this._displayedOpacity/255+")";e.fillRect(0,0,this.width*d.getScaleX(),-this.height*d.getScaleY());cc.g_NumberOfDraws++},_p.visit=function(u){if(this._isBaked){u=u||cc._renderContext;var t,s=this._children,r=s.length;if(this._visible){var q=this._bakeSprite;u.save();this.transform(u);if(this._cacheDirty){t=this._getBoundingBoxForBake();t.width|=0;t.height|=0;var o=q.getCacheContext();q.resetCanvasSize(t.width,t.height);var n=q.getAnchorPointInPoints(),m=this._position;if(this._ignoreAnchorPointForPosition){o.translate(0-t.x+m.x,t.height+t.y-m.y),q.setPosition(n.x+t.x-m.x,n.y+t.y-m.y)}else{var j=this.getAnchorPointInPoints(),i=m.x-j.x,m=m.y-j.y;o.translate(0-t.x+i,t.height+t.y-m);q.setPosition(n.x+t.x-i,n.y+t.y-m)}if(0<r){this.sortAllChildren();for(t=0;t<r;t++){if(n=s[t],0>n._localZOrder){n.visit(o)}else{break}}for(this.draw(o);t<r;t++){s[t].visit(o)}}else{this.draw(o)
  28. }this._cacheDirty=!1}q.visit(u);this.arrivalOrder=0;u.restore()}}else{cc.Node.prototype.visit.call(this,u)}},_p._getBoundingBoxForBake=function(){var g=cc.rect(0,0,this._contentSize.width,this._contentSize.height),f=this.nodeToWorldTransform(),g=cc.RectApplyAffineTransform(g,this.nodeToWorldTransform());if(!this._children||0===this._children.length){return g}for(var j=this._children,i=0;i<j.length;i++){var h=j[i];h&&h._visible&&(h=h._getBoundingBoxToCurrentNode(f),g=cc.rectUnion(g,h))}return g},_p=null):(cc.assert("function"===typeof cc._tmp.WebGLLayerColor,cc._LogInfos.MissingFile,"CCLayerWebGL.js"),cc._tmp.WebGLLayerColor(),delete cc._tmp.WebGLLayerColor);cc.assert("function"===typeof cc._tmp.PrototypeLayerColor,cc._LogInfos.MissingFile,"CCLayerPropertyDefine.js");cc._tmp.PrototypeLayerColor();delete cc._tmp.PrototypeLayerColor;cc.LayerGradient=cc.LayerColor.extend({_startColor:null,_endColor:null,_startOpacity:255,_endOpacity:255,_alongVector:null,_compressedInterpolation:!1,_gradientStartPoint:null,_gradientEndPoint:null,_className:"LayerGradient",ctor:function(e,d,f){cc.LayerColor.prototype.ctor.call(this);this._startColor=cc.color(0,0,0,255);this._endColor=cc.color(0,0,0,255);this._alongVector=cc.p(0,-1);this._endOpacity=this._startOpacity=255;this._gradientStartPoint=cc.p(0,0);this._gradientEndPoint=cc.p(0,0);cc.LayerGradient.prototype.init.call(this,e,d,f)},init:function(g,f,j){g=g||cc.color(0,0,0,255);f=f||cc.color(0,0,0,255);j=j||cc.p(0,-1);var i=this._startColor,h=this._endColor;i.r=g.r;i.g=g.g;i.b=g.b;this._startOpacity=g.a;h.r=f.r;h.g=f.g;h.b=f.b;this._endOpacity=f.a;this._alongVector=j;this._compressedInterpolation=!0;this._gradientStartPoint=cc.p(0,0);this._gradientEndPoint=cc.p(0,0);cc.LayerColor.prototype.init.call(this,cc.color(g.r,g.g,g.b,255));cc.LayerGradient.prototype._updateColor.call(this);return !0},setContentSize:function(d,c){cc.LayerColor.prototype.setContentSize.call(this,d,c);this._updateColor()},_setWidth:function(b){cc.LayerColor.prototype._setWidth.call(this,b);this._updateColor()},_setHeight:function(b){cc.LayerColor.prototype._setHeight.call(this,b);this._updateColor()},getStartColor:function(){return this._realColor},setStartColor:function(b){this.color=b},setEndColor:function(b){this._endColor=b;this._updateColor()},getEndColor:function(){return this._endColor},setStartOpacity:function(b){this._startOpacity=b;this._updateColor()},getStartOpacity:function(){return this._startOpacity},setEndOpacity:function(b){this._endOpacity=b;this._updateColor()},getEndOpacity:function(){return this._endOpacity},setVector:function(b){this._alongVector.x=b.x;this._alongVector.y=b.y;this._updateColor()},getVector:function(){return cc.p(this._alongVector.x,this._alongVector.y)},isCompressedInterpolation:function(){return this._compressedInterpolation},setCompressedInterpolation:function(b){this._compressedInterpolation=b;this._updateColor()},_draw:null,_updateColor:null});cc.LayerGradient.create=function(e,d,f){return new cc.LayerGradient(e,d,f)};cc._renderType===cc._RENDER_TYPE_CANVAS?(_p=cc.LayerGradient.prototype,_p.draw=function(i){i=i||cc._renderContext;this._isLighterMode&&(i.globalCompositeOperation="lighter");i.save();var h=cc.view,o=this._displayedOpacity/255,n=this.width*h.getScaleX(),h=this.height*h.getScaleY(),m=i.createLinearGradient(this._gradientStartPoint.x,this._gradientStartPoint.y,this._gradientEndPoint.x,this._gradientEndPoint.y),k=this._displayedColor,j=this._endColor;m.addColorStop(0,"rgba("+Math.round(k.r)+","+Math.round(k.g)+","+Math.round(k.b)+","+(o*(this._startOpacity/255)).toFixed(4)+")");m.addColorStop(1,"rgba("+Math.round(j.r)+","+Math.round(j.g)+","+Math.round(j.b)+","+(o*(this._endOpacity/255)).toFixed(4)+")");i.fillStyle=m;i.fillRect(0,0,n,-h);0!=this._rotation&&i.rotate(this._rotationRadians);i.restore()},_p._updateColor=function(){var e=this._alongVector,d=0.5*this.width,f=0.5*this.height;this._gradientStartPoint.x=d*-e.x+d;this._gradientStartPoint.y=f*e.y-f;this._gradientEndPoint.x=d*e.x+d;this._gradientEndPoint.y=f*-e.y-f},_p=null):(cc.assert("function"===typeof cc._tmp.WebGLLayerGradient,cc._LogInfos.MissingFile,"CCLayerWebGL.js"),cc._tmp.WebGLLayerGradient(),delete cc._tmp.WebGLLayerGradient);cc.assert("function"===typeof cc._tmp.PrototypeLayerGradient,cc._LogInfos.MissingFile,"CCLayerPropertyDefine.js");cc._tmp.PrototypeLayerGradient();delete cc._tmp.PrototypeLayerGradient;cc.LayerMultiplex=cc.Layer.extend({_enabledLayer:0,_layers:null,_className:"LayerMultiplex",ctor:function(b){cc.Layer.prototype.ctor.call(this);b&&cc.LayerMultiplex.prototype.initWithLayers.call(this,b)},initWithLayers:function(b){0<b.length&&null==b[b.length-1]&&cc.log(cc._LogInfos.LayerMultiplex_initWithLayers);this._layers=b;this._enabledLayer=0;this.addChild(this._layers[this._enabledLayer]);return !0},switchTo:function(b){b>=this._layers.length?cc.log(cc._LogInfos.LayerMultiplex_switchTo):(this.removeChild(this._layers[this._enabledLayer],!0),this._enabledLayer=b,this.addChild(this._layers[b]))
  29. },switchToAndReleaseMe:function(b){b>=this._layers.length?cc.log(cc._LogInfos.LayerMultiplex_switchToAndReleaseMe):(this.removeChild(this._layers[this._enabledLayer],!0),this._layers[this._enabledLayer]=null,this._enabledLayer=b,this.addChild(this._layers[b]))},addLayer:function(b){b?this._layers.push(b):cc.log(cc._LogInfos.LayerMultiplex_addLayer)}});cc.LayerMultiplex.create=function(){return new cc.LayerMultiplex(arguments)};cc._tmp.PrototypeSprite=function(){var b=cc.Sprite.prototype;cc.defineGetterSetter(b,"opacityModifyRGB",b.isOpacityModifyRGB,b.setOpacityModifyRGB);cc.defineGetterSetter(b,"opacity",b.getOpacity,b.setOpacity);cc.defineGetterSetter(b,"color",b.getColor,b.setColor);cc.defineGetterSetter(b,"flippedX",b.isFlippedX,b.setFlippedX);cc.defineGetterSetter(b,"flippedY",b.isFlippedY,b.setFlippedY);cc.defineGetterSetter(b,"offsetX",b._getOffsetX);cc.defineGetterSetter(b,"offsetY",b._getOffsetY);cc.defineGetterSetter(b,"texture",b.getTexture,b.setTexture);cc.defineGetterSetter(b,"textureRectRotated",b.isTextureRectRotated);cc.defineGetterSetter(b,"batchNode",b.getBatchNode,b.setBatchNode);cc.defineGetterSetter(b,"quad",b.getQuad)};cc.generateTextureCacheForColor=function(f){function e(){var u=cc.generateTextureCacheForColor,t=f.width,s=f.height;h[0].width=t;h[0].height=s;h[1].width=t;h[1].height=s;h[2].width=t;h[2].height=s;h[3].width=t;h[3].height=s;u.canvas.width=t;u.canvas.height=s;var r=u.canvas.getContext("2d");r.drawImage(f,0,0);u.tempCanvas.width=t;u.tempCanvas.height=s;for(var r=r.getImageData(0,0,t,s).data,o=0;4>o;o++){var j=h[o].getContext("2d");j.getImageData(0,0,t,s).data;u.tempCtx.drawImage(f,0,0);for(var i=u.tempCtx.getImageData(0,0,t,s),c=i.data,a=0;a<r.length;a+=4){c[a]=0===o?r[a]:0,c[a+1]=1===o?r[a+1]:0,c[a+2]=2===o?r[a+2]:0,c[a+3]=r[a+3]}j.putImageData(i,0,0)}f.onload=null}if(f.channelCache){return f.channelCache}var h=[cc.newElement("canvas"),cc.newElement("canvas"),cc.newElement("canvas"),cc.newElement("canvas")];try{e()}catch(g){f.onload=e}return f.channelCache=h};cc.generateTextureCacheForColor.canvas=cc.newElement("canvas");cc.generateTextureCacheForColor.tempCanvas=cc.newElement("canvas");cc.generateTextureCacheForColor.tempCtx=cc.generateTextureCacheForColor.tempCanvas.getContext("2d");cc.generateTintImage2=function(g,f,j){j||(j=cc.rect(0,0,g.width,g.height),j=cc.rectPixelsToPoints(j));var i=cc.newElement("canvas"),h=i.getContext("2d");i.width!=j.width&&(i.width=j.width);i.height!=j.height&&(i.height=j.height);h.save();h.drawImage(g,j.x,j.y,j.width,j.height,0,0,j.width,j.height);h.globalCompositeOperation="source-in";h.globalAlpha=f.a/255;h.fillStyle="rgb("+f.r+","+f.g+","+f.b+")";h.fillRect(0,0,j.width,j.height);h.restore();return i};cc.generateTintImage=function(u,t,s,r,q){r||(r=cc.rect(0,0,u.width,u.height));u=s.r/255;var o=s.g/255;s=s.b/255;var n=Math.min(r.width,t[0].width),m=Math.min(r.height,t[0].height),j;q?(j=q.getContext("2d"),j.clearRect(0,0,n,m)):(q=cc.newElement("canvas"),q.width=n,q.height=m,j=q.getContext("2d"));j.save();j.globalCompositeOperation="lighter";var i=j.globalAlpha;0<u&&(j.globalAlpha=u*i,j.drawImage(t[0],r.x,r.y,n,m,0,0,n,m));0<o&&(j.globalAlpha=o*i,j.drawImage(t[1],r.x,r.y,n,m,0,0,n,m));0<s&&(j.globalAlpha=s*i,j.drawImage(t[2],r.x,r.y,n,m,0,0,n,m));1>u+o+s&&(j.globalAlpha=i,j.drawImage(t[3],r.x,r.y,n,m,0,0,n,m));j.restore();return q};cc.cutRotateImageToCanvas=function(f,e){if(!f){return null}if(!e){return f}var h=cc.newElement("canvas");h.width=e.width;h.height=e.height;var g=h.getContext("2d");g.translate(h.width/2,h.height/2);g.rotate(-1.5707963267948966);g.drawImage(f,e.x,e.y,e.height,e.width,-e.height/2,-e.width/2,e.height,e.width);return h};cc.Sprite=cc.NodeRGBA.extend({RGBAProtocol:!0,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,_loadedEventListeners:null,_newTextureWhenChangeColor:null,_className:"Sprite",textureLoaded:function(){return this._textureLoaded},addLoadedEventListener:function(d,c){this._loadedEventListeners||(this._loadedEventListeners=[]);this._loadedEventListeners.push({eventCallback:d,eventTarget:c})},_callLoadedEventCallbacks:function(){if(this._loadedEventListeners){for(var f=this._loadedEventListeners,e=0,h=f.length;e<h;e++){var g=f[e];g.eventCallback.call(g.eventTarget,this)}f.length=0}},isDirty:function(){return this.dirty},setDirty:function(b){this.dirty=b},isTextureRectRotated:function(){return this._rectRotated},getAtlasIndex:function(){return this.atlasIndex},setAtlasIndex:function(b){this.atlasIndex=b},getTextureRect:function(){return cc.rect(this._rect.x,this._rect.y,this._rect.width,this._rect.height)},getTextureAtlas:function(){return this.textureAtlas},setTextureAtlas:function(b){this.textureAtlas=b},getOffsetPosition:function(){return this._offsetPosition
  30. },_getOffsetX:function(){return this._offsetPosition.x},_getOffsetY:function(){return this._offsetPosition.y},getBlendFunc:function(){return this._blendFunc},initWithSpriteFrame:function(d){cc.assert(d,cc._LogInfos.Sprite_initWithSpriteFrame);d.textureLoaded()||(this._textureLoaded=!1,d.addLoadedEventListener(this._spriteFrameLoadedCallback,this));var c=cc._renderType===cc._RENDER_TYPE_CANVAS?!1:d._rotated,c=this.initWithTexture(d.getTexture(),d.getRect(),c);this.setSpriteFrame(d);return c},_spriteFrameLoadedCallback:null,initWithSpriteFrameName:function(d){cc.assert(d,cc._LogInfos.Sprite_initWithSpriteFrameName);var c=cc.spriteFrameCache.getSpriteFrame(d);cc.assert(c,d+cc._LogInfos.Sprite_initWithSpriteFrameName1);return this.initWithSpriteFrame(c)},useBatchNode:function(b){this.textureAtlas=b.textureAtlas;this._batchNode=b},setVertexRect:function(b){this._rect.x=b.x;this._rect.y=b.y;this._rect.width=b.width;this._rect.height=b.height},sortAllChildren:function(){if(this._reorderChildDirty){var g=this._children,f=g.length,j,i,h;for(j=1;j<f;j++){h=g[j];for(i=j-1;0<=i;){if(h._localZOrder<g[i]._localZOrder){g[i+1]=g[i]}else{if(h._localZOrder===g[i]._localZOrder&&h.arrivalOrder<g[i].arrivalOrder){g[i+1]=g[i]}else{break}}i--}g[i+1]=h}this._batchNode&&this._arrayMakeObjectsPerformSelector(g,cc.Node.StateCallbackType.sortAllChildren);this._reorderChildDirty=!1}},reorderChild:function(d,c){cc.assert(d,cc._LogInfos.Sprite_reorderChild_2);-1===this._children.indexOf(d)?cc.log(cc._LogInfos.Sprite_reorderChild):c!==d.zIndex&&(this._batchNode&&!this._reorderChildDirty&&(this._setReorderChildDirtyRecursively(),this._batchNode.reorderBatch(!0)),cc.Node.prototype.reorderChild.call(this,d,c))},removeChild:function(d,c){this._batchNode&&this._batchNode.removeSpriteFromAtlas(d);cc.Node.prototype.removeChild.call(this,d,c)},removeAllChildren:function(g){var f=this._children,j=this._batchNode;if(j&&null!=f){for(var i=0,h=f.length;i<h;i++){j.removeSpriteFromAtlas(f[i])}}cc.Node.prototype.removeAllChildren.call(this,g);this._hasChildren=!1},setDirtyRecursively:function(f){this.dirty=this._recursiveDirty=f;f=this._children;for(var e,h=f?f.length:0,g=0;g<h;g++){e=f[g],e instanceof cc.Sprite&&e.setDirtyRecursively(!0)}},setNodeDirty:function(b){cc.Node.prototype.setNodeDirty.call(this);!b&&(this._batchNode&&!this._recursiveDirty)&&(this._hasChildren?this.setDirtyRecursively(!0):this.dirty=this._recursiveDirty=!0)},ignoreAnchorPointForPosition:function(b){this._batchNode?cc.log(cc._LogInfos.Sprite_ignoreAnchorPointForPosition):cc.Node.prototype.ignoreAnchorPointForPosition.call(this,b)},setFlippedX:function(b){this._flippedX!=b&&(this._flippedX=b,this.setTextureRect(this._rect,this._rectRotated,this._contentSize),this.setNodeDirty(!0))},setFlippedY:function(b){this._flippedY!=b&&(this._flippedY=b,this.setTextureRect(this._rect,this._rectRotated,this._contentSize),this.setNodeDirty(!0))},isFlippedX:function(){return this._flippedX},isFlippedY:function(){return this._flippedY},setOpacityModifyRGB:null,isOpacityModifyRGB:function(){return this._opacityModifyRGB},updateDisplayedOpacity:null,setDisplayFrameWithAnimationName:function(e,d){cc.assert(e,cc._LogInfos.Sprite_setDisplayFrameWithAnimationName_3);var f=cc.animationCache.getAnimation(e);f?(f=f.getFrames()[d])?this.setSpriteFrame(f.getSpriteFrame()):cc.log(cc._LogInfos.Sprite_setDisplayFrameWithAnimationName_2):cc.log(cc._LogInfos.Sprite_setDisplayFrameWithAnimationName)},getBatchNode:function(){return this._batchNode},_setReorderChildDirtyRecursively:function(){if(!this._reorderChildDirty){this._reorderChildDirty=!0;for(var b=this._parent;b&&b!=this._batchNode;){b._setReorderChildDirtyRecursively(),b=b.parent}}},getTexture:function(){return this._texture},_quad:null,_quadWebBuffer:null,_quadDirty:!1,_colorized:!1,_isLighterMode:!1,_originalTexture:null,_textureRect_Canvas:null,_drawSize_Canvas:null,ctor:null,_softInit:function(e,d,f){if(void 0===e){cc.Sprite.prototype.init.call(this)}else{if("string"===typeof e){"#"===e[0]?(e=e.substr(1,e.length-1),e=cc.spriteFrameCache.getSpriteFrame(e),this.initWithSpriteFrame(e)):cc.Sprite.prototype.init.call(this,e,d)}else{if("object"===typeof e){if(e instanceof cc.Texture2D){this.initWithTexture(e,d,f)}else{if(e instanceof cc.SpriteFrame){this.initWithSpriteFrame(e)}else{if(e instanceof HTMLImageElement||e instanceof HTMLCanvasElement){d=new cc.Texture2D,d.initWithElement(e),d.handleLoadedTexture(),this.initWithTexture(d)}}}}}}},getQuad:function(){return this._quad},setBlendFunc:null,init:null,initWithFile:function(f,e){cc.assert(f,cc._LogInfos.Sprite_initWithFile);var h=cc.textureCache.textureForKey(f);if(h){if(!e){var g=h.getContentSize();e=cc.rect(0,0,g.width,g.height)}return this.initWithTexture(h,e)}h=cc.textureCache.addImage(f);return this.initWithTexture(h,e||cc.rect(0,0,h._contentSize.width,h._contentSize.height))},initWithTexture:null,_textureLoadedCallback:null,setTextureRect:null,updateTransform:null,addChild:null,updateColor:function(){var d=this._displayedColor,c=this._displayedOpacity,d={r:d.r,g:d.g,b:d.b,a:c};
  31. this._opacityModifyRGB&&(d.r*=c/255,d.g*=c/255,d.b*=c/255);c=this._quad;c.bl.colors=d;c.br.colors=d;c.tl.colors=d;c.tr.colors=d;this._batchNode&&(this.atlasIndex!=cc.Sprite.INDEX_NOT_INITIALIZED?this.textureAtlas.updateQuad(c,this.atlasIndex):this.dirty=!0);this._quadDirty=!0},setOpacity:null,setColor:null,updateDisplayedColor:null,setSpriteFrame:null,setDisplayFrame:function(b){cc.log(cc._LogInfos.Sprite_setDisplayFrame);this.setSpriteFrame(b)},isFrameDisplayed:null,displayFrame:function(){return cc.SpriteFrame.create(this._texture,cc.rectPointsToPixels(this._rect),this._rectRotated,cc.pointPointsToPixels(this._unflippedOffsetPositionFromCenter),cc.sizePointsToPixels(this._contentSize))},setBatchNode:null,setTexture:null,_updateBlendFunc:function(){this._batchNode?cc.log(cc._LogInfos.Sprite__updateBlendFunc):!this._texture||!this._texture.hasPremultipliedAlpha()?(this._blendFunc.src=cc.SRC_ALPHA,this._blendFunc.dst=cc.ONE_MINUS_SRC_ALPHA,this.opacityModifyRGB=!1):(this._blendFunc.src=cc.BLEND_SRC,this._blendFunc.dst=cc.BLEND_DST,this.opacityModifyRGB=!0)},_changeTextureColor:function(){var e,d=this._texture,f=this._textureRect_Canvas;if(d&&(f.validRect&&this._originalTexture)&&(e=d.getHtmlElementObj())){if(d=cc.textureCache.getTextureColors(this._originalTexture.getHtmlElementObj())){this._colorized=!0,e instanceof HTMLCanvasElement&&!this._rectRotated&&!this._newTextureWhenChangeColor?cc.generateTintImage(e,d,this._displayedColor,f,e):(e=cc.generateTintImage(e,d,this._displayedColor,f),d=new cc.Texture2D,d.initWithElement(e),d.handleLoadedTexture(),this.texture=d)}}},_setTextureCoords:function(h){h=cc.rectPointsToPixels(h);var g=this._batchNode?this.textureAtlas.texture:this._texture;if(g){var m=g.pixelsWidth,k=g.pixelsHeight,j,i=this._quad;this._rectRotated?(cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL?(g=(2*h.x+1)/(2*m),m=g+(2*h.height-2)/(2*m),j=(2*h.y+1)/(2*k),h=j+(2*h.width-2)/(2*k)):(g=h.x/m,m=(h.x+h.height)/m,j=h.y/k,h=(h.y+h.width)/k),this._flippedX&&(k=j,j=h,h=k),this._flippedY&&(k=g,g=m,m=k),i.bl.texCoords.u=g,i.bl.texCoords.v=j,i.br.texCoords.u=g,i.br.texCoords.v=h,i.tl.texCoords.u=m,i.tl.texCoords.v=j,i.tr.texCoords.u=m,i.tr.texCoords.v=h):(cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL?(g=(2*h.x+1)/(2*m),m=g+(2*h.width-2)/(2*m),j=(2*h.y+1)/(2*k),h=j+(2*h.height-2)/(2*k)):(g=h.x/m,m=(h.x+h.width)/m,j=h.y/k,h=(h.y+h.height)/k),this._flippedX&&(k=g,g=m,m=k),this._flippedY&&(k=j,j=h,h=k),i.bl.texCoords.u=g,i.bl.texCoords.v=h,i.br.texCoords.u=m,i.br.texCoords.v=h,i.tl.texCoords.u=g,i.tl.texCoords.v=j,i.tr.texCoords.u=m,i.tr.texCoords.v=j);this._quadDirty=!0}},draw:null});cc.Sprite.create=function(e,d,f){return new cc.Sprite(e,d,f)};cc.Sprite.INDEX_NOT_INITIALIZED=-1;cc._renderType===cc._RENDER_TYPE_CANVAS?(_p=cc.Sprite.prototype,_p._spriteFrameLoadedCallback=function(b){this.setNodeDirty(!0);this.setTextureRect(b.getRect(),b.isRotated(),b.getOriginalSize());b=this.color;(255!==b.r||255!==b.g||255!==b.b)&&this._changeTextureColor();this._callLoadedEventCallbacks()},_p.setOpacityModifyRGB=function(b){this._opacityModifyRGB!==b&&(this._opacityModifyRGB=b,this.setNodeDirty(!0))},_p.updateDisplayedOpacity=function(b){cc.NodeRGBA.prototype.updateDisplayedOpacity.call(this,b);this._setNodeDirtyForCache()},_p.ctor=function(e,d,f){cc.NodeRGBA.prototype.ctor.call(this);this._shouldBeHidden=!1;this._offsetPosition=cc.p(0,0);this._unflippedOffsetPositionFromCenter=cc.p(0,0);this._blendFunc={src:cc.BLEND_SRC,dst:cc.BLEND_DST};this._rect=cc.rect(0,0,0,0);this._newTextureWhenChangeColor=!1;this._textureLoaded=!0;this._textureRect_Canvas={x:0,y:0,width:0,height:0,validRect:!1};this._drawSize_Canvas=cc.size(0,0);this._softInit(e,d,f)},_p.setBlendFunc=function(e,d){var f=this._blendFunc;void 0===d?(f.src=e.src,f.dst=e.dst):(f.src=e,f.dst=d);this._isLighterMode=f&&(f.src==cc.SRC_ALPHA&&f.dst==cc.ONE||f.src==cc.ONE&&f.dst==cc.ONE)},_p.init=function(){if(0<arguments.length){return this.initWithFile(arguments[0],arguments[1])}cc.NodeRGBA.prototype.init.call(this);this.dirty=this._recursiveDirty=!1;this._opacityModifyRGB=!0;this._blendFunc.src=cc.BLEND_SRC;this._blendFunc.dst=cc.BLEND_DST;this.texture=null;this._textureLoaded=!0;this._flippedX=this._flippedY=!1;this.anchorY=this.anchorX=0.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},_p.initWithTexture=function(g,f,j){cc.assert(0!=arguments.length,cc._LogInfos.CCSpriteBatchNode_initWithTexture);if((j=j||!1)&&g.isLoaded()){var i=g.getHtmlElementObj(),i=cc.cutRotateImageToCanvas(i,f),h=new cc.Texture2D;h.initWithElement(i);h.handleLoadedTexture();g=h;this._rect=cc.rect(0,0,f.width,f.height)}if(!cc.NodeRGBA.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.anchorY=this.anchorX=0.5;this._offsetPosition.x=0;this._offsetPosition.y=0;this._hasChildren=!1;
  32. this._textureLoaded=i=g.isLoaded();if(!i){return this._rectRotated=j,f&&(this._rect.x=f.x,this._rect.y=f.y,this._rect.width=f.width,this._rect.height=f.height),g.addLoadedEventListener(this._textureLoadedCallback,this),!0}f||(f=cc.rect(0,0,g.width,g.height));g&&(i=f.y+f.height,f.x+f.width>g.width&&cc.error(cc._LogInfos.RectWidth,g.url),i>g.height&&cc.error(cc._LogInfos.RectHeight,g.url));this.texture=this._originalTexture=g;this.setTextureRect(f,j);this.batchNode=null;return !0},_p._textureLoadedCallback=function(d){if(!this._textureLoaded){this._textureLoaded=!0;var c=this._rect;c?cc._rectEqualToZero(c)&&(c.width=d.width,c.height=d.height):c=cc.rect(0,0,d.width,d.height);this.texture=this._originalTexture=d;this.setTextureRect(c,this._rectRotated);this.batchNode=this._batchNode;this._callLoadedEventCallbacks()}},_p.setTextureRect=function(e,d,f){this._rectRotated=d||!1;this.setContentSize(f||e);this.setVertexRect(e);d=this._textureRect_Canvas;f=cc.contentScaleFactor();d.x=0|e.x*f;d.y=0|e.y*f;d.width=0|e.width*f;d.height=0|e.height*f;d.validRect=!(0===d.width||0===d.height||0>d.x||0>d.y);e=this._unflippedOffsetPositionFromCenter;this._flippedX&&(e.x=-e.x);this._flippedY&&(e.y=-e.y);this._offsetPosition.x=e.x+(this._contentSize.width-this._rect.width)/2;this._offsetPosition.y=e.y+(this._contentSize.height-this._rect.height)/2;this._batchNode&&(this.dirty=!0)},_p.updateTransform=function(){if(this.dirty){var b=this._parent;!this._visible||b&&b!=this._batchNode&&b._shouldBeHidden?this._shouldBeHidden=!0:(this._shouldBeHidden=!1,this._transformToBatch=!b||b==this._batchNode?this.nodeToParentTransform():cc.AffineTransformConcat(this.nodeToParentTransform(),b._transformToBatch));this.dirty=this._recursiveDirty=!1}this._hasChildren&&this._arrayMakeObjectsPerformSelector(this._children,cc.Node.StateCallbackType.updateTransform)},_p.addChild=function(e,d,f){cc.assert(e,cc._LogInfos.CCSpriteBatchNode_addChild_2);null==d&&(d=e._localZOrder);null==f&&(f=e.tag);cc.NodeRGBA.prototype.addChild.call(this,e,d,f);this._hasChildren=!0},_p.setOpacity=function(b){cc.NodeRGBA.prototype.setOpacity.call(this,b);this._setNodeDirtyForCache()},_p.setColor=function(d){var c=this.color;c.r===d.r&&c.g===d.g&&c.b===d.b||(cc.NodeRGBA.prototype.setColor.call(this,d),this._changeTextureColor(),this._setNodeDirtyForCache())},_p.updateDisplayedColor=function(d){var c=this.color;cc.NodeRGBA.prototype.updateDisplayedColor.call(this,d);d=this._displayedColor;c.r===d.r&&c.g===d.g&&c.b===d.b||(this._changeTextureColor(),this._setNodeDirtyForCache())},_p.setSpriteFrame=function(f){var e=this;"string"==typeof f&&(f=cc.spriteFrameCache.getSpriteFrame(f),cc.assert(f,cc._LogInfos.CCSpriteBatchNode_setSpriteFrame));e.setNodeDirty(!0);var h=f.getOffset();e._unflippedOffsetPositionFromCenter.x=h.x;e._unflippedOffsetPositionFromCenter.y=h.y;e._rectRotated=f.isRotated();var h=f.getTexture(),g=f.textureLoaded();g||(e._textureLoaded=!1,f.addLoadedEventListener(function(b){e._textureLoaded=!0;var d=b.getTexture();d!=e._texture&&(e.texture=d);e.setTextureRect(b.getRect(),b.isRotated(),b.getOriginalSize());e._callLoadedEventCallbacks()},e));h!=e._texture&&(e.texture=h);e._rectRotated&&(e._originalTexture=h);e.setTextureRect(f.getRect(),e._rectRotated,f.getOriginalSize());e._colorized=!1;g&&(f=e.color,(255!==f.r||255!==f.g||255!==f.b)&&e._changeTextureColor())},_p.isFrameDisplayed=function(b){return b.getTexture()!=this._texture?!1:cc.rectEqualToRect(b.getRect(),this._rect)},_p.setBatchNode=function(b){(this._batchNode=b)?(this._transformToBatch=cc.AffineTransformIdentity(),this.textureAtlas=this._batchNode.textureAtlas):(this.atlasIndex=cc.Sprite.INDEX_NOT_INITIALIZED,this.textureAtlas=null,this.dirty=this._recursiveDirty=!1)},_p.setTexture=function(b){b&&"string"===typeof b?(b=cc.textureCache.addImage(b),this.setTexture(b),b=b.getContentSize(),this.setTextureRect(cc.rect(0,0,b.width,b.height))):(cc.assert(!b||b instanceof cc.Texture2D,cc._LogInfos.CCSpriteBatchNode_setTexture),this._texture!=b&&(b&&b.getHtmlElementObj() instanceof HTMLImageElement&&(this._originalTexture=b),this._texture=b))},_p.draw=function(u){if(this._textureLoaded){u=u||cc._renderContext;this._isLighterMode&&(u.globalCompositeOperation="lighter");var t=cc.view.getScaleX(),s=cc.view.getScaleY();u.globalAlpha=this._displayedOpacity/255;var r=this._rect,q=this._contentSize,o=this._offsetPosition,n=this._drawSize_Canvas,m=0|o.x,j=-o.y-r.height,i=this._textureRect_Canvas;n.width=r.width*t;n.height=r.height*s;if(this._flippedX||this._flippedY){u.save(),this._flippedX&&(m=-o.x-r.width,u.scale(-1,1)),this._flippedY&&(j=o.y,u.scale(1,-1))}m*=t;j*=s;this._texture&&i.validRect?(q=this._texture.getHtmlElementObj(),this._colorized?u.drawImage(q,0,0,i.width,i.height,m,j,n.width,n.height):u.drawImage(q,i.x,i.y,i.width,i.height,m,j,n.width,n.height)):!this._texture&&i.validRect&&(n=this.color,u.fillStyle="rgba("+n.r+","+n.g+","+n.b+",1)",u.fillRect(m,j,q.width*t,q.height*s));1===cc.SPRITE_DEBUG_DRAW||this._showNode?(u.strokeStyle="rgba(0,255,0,1)",m/=t,j=-(j/s),m=[cc.p(m,j),cc.p(m+r.width,j),cc.p(m+r.width,j-r.height),cc.p(m,j-r.height)],cc._drawingUtil.drawPoly(m,4,!0)):2===cc.SPRITE_DEBUG_DRAW&&(u.strokeStyle="rgba(0,255,0,1)",t=this._rect,j=-j,m=[cc.p(m,j),cc.p(m+t.width,j),cc.p(m+t.width,j-t.height),cc.p(m,j-t.height)],cc._drawingUtil.drawPoly(m,4,!0));
  33. (this._flippedX||this._flippedY)&&u.restore();cc.g_NumberOfDraws++}},delete _p):(cc.assert("function"===typeof cc._tmp.WebGLSprite,cc._LogInfos.MissingFile,"SpritesWebGL.js"),cc._tmp.WebGLSprite(),delete cc._tmp.WebGLSprite);cc.assert("function"===typeof cc._tmp.PrototypeSprite,cc._LogInfos.MissingFile,"SpritesPropertyDefine.js");cc._tmp.PrototypeSprite();delete cc._tmp.PrototypeSprite;cc.AnimationFrame=cc.Class.extend({_spriteFrame:null,_delayPerUnit:0,_userInfo:null,ctor:function(e,d,f){this._spriteFrame=e||null;this._delayPerUnit=d||0;this._userInfo=f||null},clone:function(){var b=new cc.AnimationFrame;b.initWithSpriteFrame(this._spriteFrame.clone(),this._delayPerUnit,this._userInfo);return b},copyWithZone:function(b){return cc.clone(this)},copy:function(b){b=new cc.AnimationFrame;b.initWithSpriteFrame(this._spriteFrame.clone(),this._delayPerUnit,this._userInfo);return b},initWithSpriteFrame:function(e,d,f){this._spriteFrame=e;this._delayPerUnit=d;this._userInfo=f;return !0},getSpriteFrame:function(){return this._spriteFrame},setSpriteFrame:function(b){this._spriteFrame=b},getDelayUnits:function(){return this._delayPerUnit},setDelayUnits:function(b){this._delayPerUnit=b},getUserInfo:function(){return this._userInfo},setUserInfo:function(b){this._userInfo=b}});cc.AnimationFrame.create=function(e,d,f){return new cc.AnimationFrame(e,d,f)};cc.Animation=cc.Class.extend({_frames:null,_loops:0,_restoreOriginalFrame:!1,_duration:0,_delayPerUnit:0,_totalDelayUnits:0,ctor:function(f,e,h){this._frames=[];if(void 0===f){this.initWithSpriteFrames(null,0)}else{var g=f[0];g&&(g instanceof cc.SpriteFrame?this.initWithSpriteFrames(f,e,h):g instanceof cc.AnimationFrame&&this.initWithAnimationFrames(f,e,h))}},getFrames:function(){return this._frames},setFrames:function(b){this._frames=b},addSpriteFrame:function(d){var c=new cc.AnimationFrame;c.initWithSpriteFrame(d,1,null);this._frames.push(c);this._totalDelayUnits++},addSpriteFrameWithFile:function(d){d=cc.textureCache.addImage(d);var c=cc.rect(0,0,0,0);c.width=d.width;c.height=d.height;d=cc.SpriteFrame.create(d,c);this.addSpriteFrame(d)},addSpriteFrameWithTexture:function(e,d){var f=cc.SpriteFrame.create(e,d);this.addSpriteFrame(f)},initWithAnimationFrames:function(f,e,h){cc.arrayVerifyType(f,cc.AnimationFrame);this._delayPerUnit=e;this._loops=void 0===h?1:h;this._totalDelayUnits=0;e=this._frames;for(h=e.length=0;h<f.length;h++){var g=f[h];e.push(g);this._totalDelayUnits+=g.getDelayUnits()}return !0},clone:function(){var b=new cc.Animation;b.initWithAnimationFrames(this._copyFrames(),this._delayPerUnit,this._loops);b.setRestoreOriginalFrame(this._restoreOriginalFrame);return b},copyWithZone:function(b){b=new cc.Animation;b.initWithAnimationFrames(this._copyFrames(),this._delayPerUnit,this._loops);b.setRestoreOriginalFrame(this._restoreOriginalFrame);return b},_copyFrames:function(){for(var d=[],c=0;c<this._frames.length;c++){d.push(this._frames[c].clone())}return d},copy:function(b){return this.copyWithZone(null)},getLoops:function(){return this._loops},setLoops:function(b){this._loops=b},setRestoreOriginalFrame:function(b){this._restoreOriginalFrame=b},getRestoreOriginalFrame:function(){return this._restoreOriginalFrame},getDuration:function(){return this._totalDelayUnits*this._delayPerUnit},getDelayPerUnit:function(){return this._delayPerUnit},setDelayPerUnit:function(b){this._delayPerUnit=b},getTotalDelayUnits:function(){return this._totalDelayUnits},initWithSpriteFrames:function(g,f,j){cc.arrayVerifyType(g,cc.SpriteFrame);this._loops=void 0===j?1:j;this._delayPerUnit=f||0;this._totalDelayUnits=0;f=this._frames;f.length=0;if(g){for(j=0;j<g.length;j++){var i=g[j],h=new cc.AnimationFrame;h.initWithSpriteFrame(i,1,null);f.push(h)}this._totalDelayUnits+=g.length}return !0},retain:function(){},release:function(){}});cc.Animation.create=function(e,d,f){return new cc.Animation(e,d,f)};cc.animationCache={_animations:{},addAnimation:function(d,c){this._animations[c]=d},removeAnimation:function(b){b&&this._animations[b]&&delete this._animations[b]},getAnimation:function(b){return this._animations[b]?this._animations[b]:null},_addAnimationsWithDictionary:function(j,i){var r=j.animations;if(r){var q=1,o=j.properties;if(o){for(var q=null!=o.format?parseInt(o.format):q,o=o.spritesheets,n=cc.spriteFrameCache,m=cc.path,k=0;k<o.length;k++){n.addSpriteFrames(m.changeBasename(i,o[k]))}}switch(q){case 1:this._parseVersion1(r);break;case 2:this._parseVersion2(r);break;default:cc.log(cc._LogInfos.animationCache__addAnimationsWithDictionary_2)}}else{cc.log(cc._LogInfos.animationCache__addAnimationsWithDictionary)}},addAnimations:function(d){cc.assert(d,cc._LogInfos.animationCache_addAnimations_2);var c=cc.loader.getRes(d);c?this._addAnimationsWithDictionary(c,d):cc.log(cc._LogInfos.animationCache_addAnimations)},_parseVersion1:function(t){var s=cc.spriteFrameCache,r;for(r in t){var q=t[r],o=q.frames,q=parseFloat(q.delay)||0,n=null;if(o){for(var n=[],m=0;m<o.length;m++){var j=s.getSpriteFrame(o[m]);
  34. if(j){var i=new cc.AnimationFrame;i.initWithSpriteFrame(j,1,null);n.push(i)}else{cc.log(cc._LogInfos.animationCache__parseVersion1_2,r,o[m])}}0===n.length?cc.log(cc._LogInfos.animationCache__parseVersion1_3,r):(n.length!=o.length&&cc.log(cc._LogInfos.animationCache__parseVersion1_4,r),n=cc.Animation.create(n,q,1),cc.animationCache.addAnimation(n,r))}else{cc.log(cc._LogInfos.animationCache__parseVersion1,r)}}},_parseVersion2:function(A){var z=cc.spriteFrameCache,y;for(y in A){var x=A[y],w=x.loop,v=parseInt(x.loops),w=w?cc.REPEAT_FOREVER:isNaN(v)?1:v,v=x.restoreOriginalFrame&&!0==x.restoreOriginalFrame?!0:!1,u=x.frames;if(u){for(var t=[],s=0;s<u.length;s++){var r=u[s],o=r.spriteframe,j=z.getSpriteFrame(o);if(j){var o=parseFloat(r.delayUnits)||0,r=r.notification,i=new cc.AnimationFrame;i.initWithSpriteFrame(j,o,r);t.push(i)}else{cc.log(cc._LogInfos.animationCache__parseVersion2_2,y,o)}}x=parseFloat(x.delayPerUnit)||0;u=new cc.Animation;u.initWithAnimationFrames(t,x,w);u.setRestoreOriginalFrame(v);cc.animationCache.addAnimation(u,y)}else{cc.log(cc._LogInfos.animationCache__parseVersion2,y)}}},_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,_eventListeners:null,ctor:function(g,f,j,i,h){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!==g&&void 0!==f&&(void 0===j||void 0===i||void 0===h?this.initWithTexture(g,f):this.initWithTexture(g,f,j,i,h))},textureLoaded:function(){return this._textureLoaded},addLoadedEventListener:function(d,c){null==this._eventListeners&&(this._eventListeners=[]);this._eventListeners.push({eventCallback:d,eventTarget:c})},_callLoadedEventCallbacks:function(){var f=this._eventListeners;if(f){for(var e=0,h=f.length;e<h;e++){var g=f[e];g.eventCallback.call(g.eventTarget,this)}f.length=0}},getRectInPixels:function(){var b=this._rectInPixels;return cc.rect(b.x,b.y,b.width,b.height)},setRectInPixels:function(b){this._rectInPixels||(this._rectInPixels=cc.rect(0,0,0,0));this._rectInPixels.x=b.x;this._rectInPixels.y=b.y;this._rectInPixels.width=b.width;this._rectInPixels.height=b.height;this._rect=cc.rectPixelsToPoints(b)},isRotated:function(){return this._rotated},setRotated:function(b){this._rotated=b},getRect:function(){var b=this._rect;return cc.rect(b.x,b.y,b.width,b.height)},setRect:function(b){this._rect||(this._rect=cc.rect(0,0,0,0));this._rect.x=b.x;this._rect.y=b.y;this._rect.width=b.width;this._rect.height=b.height;this._rectInPixels=cc.rectPointsToPixels(this._rect)},getOffsetInPixels:function(){return this._offsetInPixels},setOffsetInPixels:function(b){this._offsetInPixels.x=b.x;this._offsetInPixels.y=b.y;cc._pointPixelsToPointsOut(this._offsetInPixels,this._offset)},getOriginalSizeInPixels:function(){return this._originalSizeInPixels},setOriginalSizeInPixels:function(b){this._originalSizeInPixels.width=b.width;this._originalSizeInPixels.height=b.height},getOriginalSize:function(){return this._originalSize},setOriginalSize:function(b){this._originalSize.width=b.width;this._originalSize.height=b.height},getTexture:function(){if(this._texture){return this._texture}if(""!==this._textureFilename){var b=cc.textureCache.addImage(this._textureFilename);b&&(this._textureLoaded=b.isLoaded());return b}return null},setTexture:function(d){if(this._texture!=d){var c=d.isLoaded();this._textureLoaded=c;this._texture=d;c||d.addLoadedEventListener(function(g){this._textureLoaded=!0;if(this._rotated&&cc._renderType===cc._RENDER_TYPE_CANVAS){var f=g.getHtmlElementObj(),f=cc.cutRotateImageToCanvas(f,this.getRect()),h=new cc.Texture2D;h.initWithElement(f);h.handleLoadedTexture();this.setTexture(h);f=this.getRect();this.setRect(cc.rect(0,0,f.width,f.height))}f=this._rect;0===f.width&&0===f.height&&(f=g.width,g=g.height,this._rect.width=f,this._rect.height=g,this._rectInPixels=cc.rectPointsToPixels(this._rect),this._originalSizeInPixels.width=this._rectInPixels.width,this._originalSizeInPixels.height=this._rectInPixels.height,this._originalSize.width=f,this._originalSize.height=g);this._callLoadedEventCallbacks()},this)}},getOffset:function(){return this._offset},setOffset:function(b){this._offset.x=b.x;this._offset.y=b.y},clone:function(){var b=new cc.SpriteFrame;b.initWithTexture(this._textureFilename,this._rectInPixels,this._rotated,this._offsetInPixels,this._originalSizeInPixels);b.setTexture(this._texture);return b},copyWithZone:function(){var b=new cc.SpriteFrame;b.initWithTexture(this._textureFilename,this._rectInPixels,this._rotated,this._offsetInPixels,this._originalSizeInPixels);b.setTexture(this._texture);return b},copy:function(){return this.copyWithZone()},initWithTexture:function(i,h,o,n,m){2===arguments.length&&(h=cc.rectPointsToPixels(h));
  35. n=n||cc.p(0,0);m=m||h;o=o||!1;"string"==typeof i?(this._texture=null,this._textureFilename=i):i instanceof cc.Texture2D&&this.setTexture(i);if(i=this.getTexture()){var k,j;o?(k=h.x+h.height,j=h.y+h.width):(k=h.x+h.width,j=h.y+h.height);k>i.width&&cc.error(cc._LogInfos.RectWidth,i.url);j>i.height&&cc.error(cc._LogInfos.RectHeight,i.url)}this._rectInPixels=h;this._rect=cc.rectPixelsToPoints(h);this._offsetInPixels.x=n.x;this._offsetInPixels.y=n.y;cc._pointPixelsToPointsOut(n,this._offset);this._originalSizeInPixels.width=m.width;this._originalSizeInPixels.height=m.height;cc._sizePixelsToPointsOut(m,this._originalSize);this._rotated=o;return !0}});cc.SpriteFrame.create=function(g,f,j,i,h){return new cc.SpriteFrame(g,f,j,i,h)};cc.SpriteFrame._frameWithTextureForCanvas=function(h,g,m,k,j){var i=new cc.SpriteFrame;i._texture=h;i._rectInPixels=g;i._rect=cc.rectPixelsToPoints(g);i._offsetInPixels.x=k.x;i._offsetInPixels.y=k.y;cc._pointPixelsToPointsOut(i._offsetInPixels,i._offset);i._originalSizeInPixels.width=j.width;i._originalSizeInPixels.height=j.height;cc._sizePixelsToPointsOut(i._originalSizeInPixels,i._originalSize);i._rotated=m;return i};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(b){b=this._CCNS_REG2.exec(b);return !b?cc.rect(0,0,0,0):cc.rect(parseFloat(b[1]),parseFloat(b[2]),parseFloat(b[3]),parseFloat(b[4]))},_pointFromString:function(b){b=this._CCNS_REG1.exec(b);return !b?cc.p(0,0):cc.p(parseFloat(b[1]),parseFloat(b[2]))},_sizeFromString:function(b){b=this._CCNS_REG1.exec(b);return !b?cc.size(0,0):cc.size(parseFloat(b[1]),parseFloat(b[2]))},_getFrameConfig:function(u){var t=cc.loader.getRes(u);cc.assert(t,cc._LogInfos.spriteFrameCache__getFrameConfig_2,u);cc.loader.release(u);if(t._inited){return this._frameConfigCache[u]=t}var s=t.frames,r=t.metadata||t.meta,t={},q={},o=0;r&&(o=r.format,o=1>=o.length?parseInt(o):o,q.image=r.textureFileName||r.textureFileName||r.image);for(var n in s){var m=s[n];if(m){r={};if(0==o){r.rect=cc.rect(m.x,m.y,m.width,m.height);r.rotated=!1;r.offset=cc.p(m.offsetX,m.offsetY);var j=m.originalWidth,m=m.originalHeight;(!j||!m)&&cc.log(cc._LogInfos.spriteFrameCache__getFrameConfig);j=Math.abs(j);m=Math.abs(m);r.size=cc.size(j,m)}else{if(1==o||2==o){r.rect=this._rectFromString(m.frame),r.rotated=m.rotated||!1,r.offset=this._pointFromString(m.offset),r.size=this._sizeFromString(m.sourceSize)}else{if(3==o){var j=this._sizeFromString(m.spriteSize),i=this._rectFromString(m.textureRect);j&&(i=cc.rect(i.x,i.y,j.width,j.height));r.rect=i;r.rotated=m.textureRotated||!1;r.offset=this._pointFromString(m.spriteOffset);r.size=this._sizeFromString(m.spriteSourceSize);r.aliases=m.aliases}else{j=m.frame,i=m.sourceSize,n=m.filename||n,r.rect=cc.rect(j.x,j.y,j.w,j.h),r.rotated=m.rotated||!1,r.offset=cc.p(0,0),r.size=cc.size(i.w,i.h)}}}t[n]=r}}return this._frameConfigCache[u]={_inited:!0,frames:t,meta:q}},addSpriteFrames:function(w,v){cc.assert(w,cc._LogInfos.spriteFrameCache_addSpriteFrames_2);var u=this._frameConfigCache[w]||cc.loader.getRes(w);if(u&&u.frames){var t=this._frameConfigCache[w]||this._getFrameConfig(w),u=t.frames,t=t.meta;v?v instanceof cc.Texture2D||("string"==typeof v?v=cc.textureCache.addImage(v):cc.assert(0,cc._LogInfos.spriteFrameCache_addSpriteFrames_3)):(t=cc.path.changeBasename(w,t.image||".png"),v=cc.textureCache.addImage(t));var t=this._spriteFramesAliases,s=this._spriteFrames,r;for(r in u){var q=u[r],o=s[r];if(!o){o=cc.SpriteFrame.create(v,q.rect,q.rotated,q.offset,q.size);if(q=q.aliases){for(var n=0,j=q.length;n<j;n++){var i=q[n];t[i]&&cc.log(cc._LogInfos.spriteFrameCache_addSpriteFrames,i);t[i]=r}}cc._renderType===cc._RENDER_TYPE_CANVAS&&o.isRotated()&&o.getTexture().isLoaded()&&(q=o.getTexture().getHtmlElementObj(),q=cc.cutRotateImageToCanvas(q,o.getRectInPixels()),n=new cc.Texture2D,n.initWithElement(q),n.handleLoadedTexture(),o.setTexture(n),q=o._rect,o.setRect(cc.rect(0,0,q.width,q.height)));s[r]=o}}}},_checkConflict:function(d){d=d.frames;for(var c in d){this._spriteFrames[c]&&cc.log(cc._LogInfos.spriteFrameCache__checkConflict,c)}},addSpriteFrame:function(d,c){this._spriteFrames[c]=d},removeSpriteFrames:function(){this._spriteFrames={};this._spriteFramesAliases={}},removeSpriteFrameByName:function(b){b&&(this._spriteFramesAliases[b]&&delete this._spriteFramesAliases[b],this._spriteFrames[b]&&delete this._spriteFrames[b])},removeSpriteFramesFromFile:function(g){var f=this._spriteFrames,j=this._spriteFramesAliases;if(g=this._frameConfigCache[g]){g=g.frames;for(var i in g){if(f[i]){delete f[i];for(var h in j){j[h]==i&&delete j[h]}}}}},removeSpriteFramesFromTexture:function(h){var g=this._spriteFrames,m=this._spriteFramesAliases,k;for(k in g){var j=g[k];if(j&&j.getTexture()==h){delete g[k];for(var i in m){m[i]==k&&delete m[i]
  36. }}}},getSpriteFrame:function(e){var d=this._spriteFrames[e];if(!d){var f=this._spriteFramesAliases[e];f&&((d=this._spriteFrames[f.toString()])||delete this._spriteFramesAliases[e])}d||cc.log(cc._LogInfos.spriteFrameCache_getSpriteFrame,e);return d},_clear:function(){this._spriteFrames={};this._spriteFramesAliases={};this._frameConfigCache={}}};cc.g_NumberOfDraws=0;cc.GLToClipTransform=function(e){var d=new cc.kmMat4;cc.kmGLGetMatrix(cc.KM_GL_PROJECTION,d);var f=new cc.kmMat4;cc.kmGLGetMatrix(cc.KM_GL_MODELVIEW,f);cc.kmMat4Multiply(e,d,f)};cc.Director=cc.Class.extend({_landscape:!1,_nextDeltaTimeZero:!1,_paused:!1,_purgeDirectorInNextLoop:!1,_sendCleanupToScene:!1,_animationInterval:0,_oldAnimationInterval:0,_projection:0,_accumDt:0,_contentScaleFactor:1,_displayStats:!1,_deltaTime:0,_frameRate:0,_FPSLabel:null,_SPFLabel:null,_drawsLabel:null,_winSizeInPoints:null,_lastUpdate:null,_nextScene:null,_notificationNode:null,_openGLView:null,_scenesStack:null,_projectionDelegate:null,_runningScene:null,_frames:0,_totalFrames:0,_secondsPerFrame:0,_dirtyRegion:null,_scheduler:null,_actionManager:null,_eventProjectionChanged:null,_eventAfterDraw:null,_eventAfterVisit:null,_eventAfterUpdate:null,ctor:function(){var b=this;b._lastUpdate=Date.now();cc.eventManager.addCustomListener(cc.game.EVENT_SHOW,function(){b._lastUpdate=Date.now()})},init:function(){this._oldAnimationInterval=this._animationInterval=1/cc.defaultFPS;this._scenesStack=[];this._projection=cc.Director.PROJECTION_DEFAULT;this._projectionDelegate=null;this._frameRate=this._accumDt=0;this._displayStats=!1;this._totalFrames=this._frames=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;this._actionManager=cc.ActionManager?new cc.ActionManager:null;this._scheduler.scheduleUpdateForTarget(this._actionManager,cc.Scheduler.PRIORITY_SYSTEM,!1);this._eventAfterDraw=new cc.EventCustom(cc.Director.EVENT_AFTER_DRAW);this._eventAfterDraw.setUserData(this);this._eventAfterVisit=new cc.EventCustom(cc.Director.EVENT_AFTER_VISIT);this._eventAfterVisit.setUserData(this);this._eventAfterUpdate=new cc.EventCustom(cc.Director.EVENT_AFTER_UPDATE);this._eventAfterUpdate.setUserData(this);this._eventProjectionChanged=new cc.EventCustom(cc.Director.EVENT_PROJECTION_CHANGED);this._eventProjectionChanged.setUserData(this);return !0},calculateDeltaTime:function(){var b=Date.now();this._nextDeltaTimeZero?(this._deltaTime=0,this._nextDeltaTimeZero=!1):this._deltaTime=(b-this._lastUpdate)/1000;0<cc.game.config[cc.game.CONFIG_KEY.debugMode]&&0.2<this._deltaTime&&(this._deltaTime=1/60);this._lastUpdate=b},drawScene:function(){this.calculateDeltaTime();this._paused||(this._scheduler.update(this._deltaTime),cc.eventManager.dispatchEvent(this._eventAfterUpdate));this._clear();this._nextScene&&this.setNextScene();this._beforeVisitScene&&this._beforeVisitScene();this._runningScene&&(this._runningScene.visit(),cc.eventManager.dispatchEvent(this._eventAfterVisit));this._notificationNode&&this._notificationNode.visit();this._displayStats&&this._showStats();this._afterVisitScene&&this._afterVisitScene();cc.eventManager.dispatchEvent(this._eventAfterDraw);this._totalFrames++;this._displayStats&&this._calculateMPF()},_beforeVisitScene:null,_afterVisitScene:null,end:function(){this._purgeDirectorInNextLoop=!0},getContentScaleFactor:function(){return this._contentScaleFactor},getNotificationNode:function(){return this._notificationNode},getWinSize:function(){return this._winSizeInPoints},getWinSizeInPixels:function(){return cc.size(this._winSizeInPoints.width*this._contentScaleFactor,this._winSizeInPoints.height*this._contentScaleFactor)},pause:function(){this._paused||(this._oldAnimationInterval=this._animationInterval,this.setAnimationInterval(0.25),this._paused=!0)},popScene:function(){cc.assert(this._runningScene,cc._LogInfos.Director_popScene);this._scenesStack.pop();var b=this._scenesStack.length;0==b?this.end():(this._sendCleanupToScene=!0,this._nextScene=this._scenesStack[b-1])},purgeCachedData:function(){cc.animationCache._clear();cc.spriteFrameCache._clear();cc.textureCache._clear()},purgeDirector:function(){this.getScheduler().unscheduleAllCallbacks();cc.eventManager&&cc.eventManager.setEnabled(!1);this._runningScene&&(this._runningScene.onExitTransitionDidStart(),this._runningScene.onExit(),this._runningScene.cleanup());this._nextScene=this._runningScene=null;this._scenesStack.length=0;this.stopAnimation();this.purgeCachedData();cc.checkGLErrorDebug()},pushScene:function(b){cc.assert(b,cc._LogInfos.Director_pushScene);this._sendCleanupToScene=!1;this._scenesStack.push(b);this._nextScene=b},runScene:function(d){cc.assert(d,cc._LogInfos.Director_pushScene);if(this._runningScene){var c=this._scenesStack.length;0===c?(this._sendCleanupToScene=!0,this._scenesStack[c]=d):(this._sendCleanupToScene=!0,this._scenesStack[c-1]=d);this._nextScene=d}else{this.pushScene(d),this.startAnimation()
  37. }},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(b){b!=this._contentScaleFactor&&(this._contentScaleFactor=b,this._createStatsLabel())},setDefaultValues:function(){},setNextDeltaTimeZero:function(b){this._nextDeltaTimeZero=b},setNextScene:function(){var d=!1,c=!1;cc.TransitionScene&&(d=this._runningScene?this._runningScene instanceof cc.TransitionScene:!1,c=this._nextScene?this._nextScene instanceof cc.TransitionScene:!1);if(!c){if(c=this._runningScene){c.onExitTransitionDidStart(),c.onExit()}this._sendCleanupToScene&&c&&c.cleanup()}this._runningScene=this._nextScene;this._nextScene=null;!d&&null!=this._runningScene&&(this._runningScene.onEnter(),this._runningScene.onEnterTransitionDidFinish())},setNotificationNode:function(b){this._notificationNode=b},getDelegate:function(){return this._projectionDelegate},setDelegate:function(b){this._projectionDelegate=b},_showStats:function(){this._frames++;this._accumDt+=this._deltaTime;this._FPSLabel&&this._SPFLabel&&this._drawsLabel?(this._accumDt>cc.DIRECTOR_FPS_INTERVAL&&(this._SPFLabel.string=this._secondsPerFrame.toFixed(3),this._frameRate=this._frames/this._accumDt,this._accumDt=this._frames=0,this._FPSLabel.string=this._frameRate.toFixed(1),this._drawsLabel.string=(0|cc.g_NumberOfDraws).toString()),this._FPSLabel.visit(),this._SPFLabel.visit(),this._drawsLabel.visit()):this._createStatsLabel();cc.g_NumberOfDraws=0},isSendCleanupToScene:function(){return this._sendCleanupToScene},getRunningScene:function(){return this._runningScene},getAnimationInterval:function(){return this._animationInterval},isDisplayStats:function(){return this._displayStats},setDisplayStats:function(b){this._displayStats=b},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(f){cc.assert(this._runningScene,cc._LogInfos.Director_popToSceneStackLevel_2);var e=this._scenesStack,h=e.length;if(0==h){this.end()}else{if(!(f>h)){for(;h>f;){var g=e.pop();g.running&&(g.onExitTransitionDidStart(),g.onExit());g.cleanup();h--}this._nextScene=e[e.length-1];this._sendCleanupToScene=!1}}},getScheduler:function(){return this._scheduler},setScheduler:function(b){this._scheduler!=b&&(this._scheduler=b)},getActionManager:function(){return this._actionManager},setActionManager:function(b){this._actionManager!=b&&(this._actionManager=b)},getDeltaTime:function(){return this._deltaTime},_createStatsLabel:null,_calculateMPF:function(){this._secondsPerFrame=(Date.now()-this._lastUpdate)/1000}});cc.Director.EVENT_PROJECTION_CHANGED="director_projection_changed";cc.Director.EVENT_AFTER_DRAW="director_after_draw";cc.Director.EVENT_AFTER_VISIT="director_after_visit";cc.Director.EVENT_AFTER_UPDATE="director_after_update";cc.DisplayLinkDirector=cc.Director.extend({invalid:!1,startAnimation:function(){this._nextDeltaTimeZero=!0;this.invalid=!1},mainLoop:function(){this._purgeDirectorInNextLoop?(this._purgeDirectorInNextLoop=!1,this.purgeDirector()):this.invalid||this.drawScene()},stopAnimation:function(){this.invalid=!0},setAnimationInterval:function(b){this._animationInterval=b;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_3D;cc._renderType===cc._RENDER_TYPE_CANVAS?(_p=cc.Director.prototype,_p.setProjection=function(b){this._projection=b;cc.eventManager.dispatchEvent(this._eventProjectionChanged)},_p.setDepthTest=function(){},_p.setOpenGLView=function(b){this._winSizeInPoints.width=cc._canvas.width;this._winSizeInPoints.height=cc._canvas.height;this._openGLView=b||cc.view;cc.eventManager&&cc.eventManager.setEnabled(!0)},_p._clear=function(){var b=this._openGLView.getViewPortRect();cc._renderContext.clearRect(-b.x,b.y,b.width,-b.height)},_p._createStatsLabel=function(){var b=0,b=this._winSizeInPoints.width>this._winSizeInPoints.height?0|24*(this._winSizeInPoints.height/320):0|24*(this._winSizeInPoints.width/320);this._FPSLabel=cc.LabelTTF.create("000.0","Arial",b);this._SPFLabel=cc.LabelTTF.create("0.000","Arial",b);this._drawsLabel=cc.LabelTTF.create("0000","Arial",b);b=cc.DIRECTOR_STATS_POSITION;this._drawsLabel.setPosition(this._drawsLabel.width/2+b.x,5*this._drawsLabel.height/2+b.y);this._SPFLabel.setPosition(this._SPFLabel.width/2+b.x,3*this._SPFLabel.height/2+b.y);
  38. this._FPSLabel.setPosition(this._FPSLabel.width/2+b.x,this._FPSLabel.height/2+b.y)},_p.getVisibleSize=function(){return this.getWinSize()},_p.getVisibleOrigin=function(){return cc.p(0,0)}):(cc.Director._fpsImage=new Image,cc._addEventListener(cc.Director._fpsImage,"load",function(){cc.Director._fpsImageLoaded=!0}),cc._fpsImage&&(cc.Director._fpsImage.src=cc._fpsImage),cc.assert("function"===typeof cc._tmp.DirectorWebGL,cc._LogInfos.MissingFile,"CCDirectorWebGL.js"),cc._tmp.DirectorWebGL(),delete cc._tmp.DirectorWebGL);cc.PRIORITY_NON_SYSTEM=cc.PRIORITY_SYSTEM+1;cc.arrayVerifyType=function(e,d){if(e&&0<e.length){for(var f=0;f<e.length;f++){if(!(e[f] instanceof d)){return cc.log(cc._LogInfos.arrayVerifyType),!1}}}return !0};cc.arrayRemoveObject=function(f,e){for(var h=0,g=f.length;h<g;h++){if(f[h]==e){f.splice(h,1);break}}};cc.arrayRemoveArray=function(f,e){for(var h=0,g=e.length;h<g;h++){cc.arrayRemoveObject(f,e[h])}};cc.arrayAppendObjectsToIndex=function(e,d,f){e.splice.apply(e,[f,0].concat(d));return e};cc.ListEntry=function(h,g,m,k,j,i){this.prev=h;this.next=g;this.target=m;this.priority=k;this.paused=j;this.markedForDeletion=i};cc.HashUpdateEntry=function(f,e,h,g){this.list=f;this.entry=e;this.target=h;this.hh=g};cc.HashTimerEntry=function(i,h,o,n,m,k,j){this.timers=i;this.target=h;this.timerIndex=o;this.currentTimer=n;this.currentTimerSalvaged=m;this.paused=k;this.hh=j};cc.Timer=cc.Class.extend({_interval:0,_callback:null,_target:null,_elapsed:0,_runForever:!1,_useDelay:!1,_timesExecuted:0,_repeat:0,_delay:0,getInterval:function(){return this._interval},setInterval:function(b){this._interval=b},getCallback:function(){return this._callback},ctor:function(g,f,j,i,h){this._target=g;this._callback=f;this._elapsed=-1;this._interval=j||0;this._delay=h||0;this._useDelay=0<this._delay;this._repeat=null==i?cc.REPEAT_FOREVER:i;this._runForever=this._repeat==cc.REPEAT_FOREVER},_doCallback:function(){if("string"==typeof this._callback){this._target[this._callback](this._elapsed)}else{this._callback.call(this._target,this._elapsed)}},update:function(e){if(-1==this._elapsed){this._timesExecuted=this._elapsed=0}else{var d=this._target,f=this._callback;this._elapsed+=e;this._runForever&&!this._useDelay?this._elapsed>=this._interval&&(d&&f&&this._doCallback(),this._elapsed=0):(this._useDelay?this._elapsed>=this._delay&&(d&&f&&this._doCallback(),this._elapsed-=this._delay,this._timesExecuted+=1,this._useDelay=!1):this._elapsed>=this._interval&&(d&&f&&this._doCallback(),this._elapsed=0,this._timesExecuted+=1),this._timesExecuted>this._repeat&&cc.director.getScheduler().unscheduleCallbackForTarget(d,f))}}});cc.Scheduler=cc.Class.extend({_timeScale:1,_updates:null,_hashForUpdates:null,_arrayForUpdates:null,_hashForTimers:null,_arrayForTimes:null,_currentTarget:null,_currentTargetSalvaged:!1,_updateHashLocked:!1,ctor:function(){this._timeScale=1;this._updates=[[],[],[]];this._hashForUpdates={};this._arrayForUpdates=[];this._hashForTimers={};this._arrayForTimers=[];this._currentTarget=null;this._updateHashLocked=this._currentTargetSalvaged=!1},_removeHashElement:function(b){delete this._hashForTimers[b.target.__instanceId];cc.arrayRemoveObject(this._arrayForTimers,b);b.Timer=null;b.target=null},_removeUpdateFromHash:function(b){if(b=this._hashForUpdates[b.target.__instanceId]){cc.arrayRemoveObject(b.list,b.entry),delete this._hashForUpdates[b.target.__instanceId],cc.arrayRemoveObject(this._arrayForUpdates,b),b.entry=null,b.target=null}},_priorityIn:function(h,g,m,k){k=new cc.ListEntry(null,null,g,m,k,!1);if(h){for(var j=h.length-1,i=0;i<=j&&!(m<h[i].priority);i++){}h.splice(i,0,k)}else{h=[],h.push(k)}m=new cc.HashUpdateEntry(h,k,g,null);this._arrayForUpdates.push(m);this._hashForUpdates[g.__instanceId]=m;return h},_appendIn:function(e,d,f){f=new cc.ListEntry(null,null,d,0,f,!1);e.push(f);e=new cc.HashUpdateEntry(e,f,d,null);this._arrayForUpdates.push(e);this._hashForUpdates[d.__instanceId]=e},setTimeScale:function(b){this._timeScale=b},getTimeScale:function(){return this._timeScale},update:function(t){var s=this._updates,r=this._arrayForTimers,q,o,n;this._updateHashLocked=!0;1!=this._timeScale&&(t*=this._timeScale);o=0;for(n=s.length;o<n&&0<=o;o++){for(var m=this._updates[o],j=0,i=m.length;j<i;j++){q=m[j],!q.paused&&!q.markedForDeletion&&q.target.update(t)}}o=0;for(n=r.length;o<n;o++){q=r[o];if(!q){break}this._currentTarget=q;this._currentTargetSalvaged=!1;if(!q.paused){for(q.timerIndex=0;q.timerIndex<q.timers.length;q.timerIndex++){q.currentTimer=q.timers[q.timerIndex],q.currentTimerSalvaged=!1,q.currentTimer.update(t),q.currentTimer=null}}this._currentTargetSalvaged&&0==q.timers.length&&(this._removeHashElement(q),o--)}o=0;for(n=s.length;o<n;o++){m=this._updates[o];j=0;for(i=m.length;j<i;){q=m[j];if(!q){break}q.markedForDeletion?this._removeUpdateFromHash(q):j++}}this._updateHashLocked=!1;this._currentTarget=null},scheduleCallbackForTarget:function(j,i,r,q,o,n){cc.assert(i,cc._LogInfos.Scheduler_scheduleCallbackForTarget_2);
  39. cc.assert(j,cc._LogInfos.Scheduler_scheduleCallbackForTarget_3);r=r||0;q=null==q?cc.REPEAT_FOREVER:q;o=o||0;n=n||!1;var m=this._hashForTimers[j.__instanceId];m||(m=new cc.HashTimerEntry(null,j,0,null,null,n,null),this._arrayForTimers.push(m),this._hashForTimers[j.__instanceId]=m);if(null==m.timers){m.timers=[]}else{for(var k=0;k<m.timers.length;k++){if(n=m.timers[k],i==n._callback){cc.log(cc._LogInfos.Scheduler_scheduleCallbackForTarget,n.getInterval().toFixed(4),r.toFixed(4));n._interval=r;return}}}n=new cc.Timer(j,i,r,q,o);m.timers.push(n)},scheduleUpdateForTarget:function(g,f,j){if(null!==g){var i=this._updates,h=this._hashForUpdates[g.__instanceId];h?h.entry.markedForDeletion=!1:0==f?this._appendIn(i[1],g,j):0>f?i[0]=this._priorityIn(i[0],g,f,j):i[2]=this._priorityIn(i[2],g,f,j)}},unscheduleCallbackForTarget:function(i,h){if(!(null==i||null==h)){var o=this._hashForTimers[i.__instanceId];if(o){for(var n=o.timers,m=0,k=n.length;m<k;m++){var j=n[m];if(h==j._callback){j==o.currentTimer&&!o.currentTimerSalvaged&&(o.currentTimerSalvaged=!0);n.splice(m,1);o.timerIndex>=m&&o.timerIndex--;0==n.length&&(this._currentTarget==o?this._currentTargetSalvaged=!0:this._removeHashElement(o));break}}}}},unscheduleUpdateForTarget:function(b){null!=b&&(b=this._hashForUpdates[b.__instanceId],null!=b&&(this._updateHashLocked?b.entry.markedForDeletion=!0:this._removeUpdateFromHash(b.entry)))},unscheduleAllCallbacksForTarget:function(e){if(null!=e){var d=this._hashForTimers[e.__instanceId];if(d){var f=d.timers;!d.currentTimerSalvaged&&0<=f.indexOf(d.currentTimer)&&(d.currentTimerSalvaged=!0);f.length=0;this._currentTarget==d?this._currentTargetSalvaged=!0:this._removeHashElement(d)}this.unscheduleUpdateForTarget(e)}},unscheduleAllCallbacks:function(){this.unscheduleAllCallbacksWithMinPriority(cc.Scheduler.PRIORITY_SYSTEM)},unscheduleAllCallbacksWithMinPriority:function(h){for(var g=this._arrayForTimers,m=this._updates,k=0,j=g.length;k<j;k++){this.unscheduleAllCallbacksForTarget(g[k].target)}for(k=2;0<=k;k--){if(!(1==k&&0<h||0==k&&0<=h)){for(var g=m[k],j=0,i=g.length;j<i;j++){this.unscheduleUpdateForTarget(g[j].target)}}}},pauseAllTargets:function(){return this.pauseAllTargetsWithMinPriority(cc.Scheduler.PRIORITY_SYSTEM)},pauseAllTargetsWithMinPriority:function(j){j=[];for(var i,r=this._arrayForTimers,q=this._updates,o=0,n=r.length;o<n;o++){if(i=r[o]){i.paused=!0,j.push(i.target)}}o=0;for(n=q.length;o<n;o++){for(var r=q[o],m=0,k=r.length;m<k;m++){if(i=r[m]){i.paused=!0,j.push(i.target)}}}return j},resumeTargets:function(d){if(d){for(var c=0;c<d.length;c++){this.resumeTarget(d[c])}}},pauseTarget:function(d){cc.assert(d,cc._LogInfos.Scheduler_pauseTarget);var c=this._hashForTimers[d.__instanceId];c&&(c.paused=!0);if(d=this._hashForUpdates[d.__instanceId]){d.entry.paused=!0}},resumeTarget:function(d){cc.assert(d,cc._LogInfos.Scheduler_resumeTarget);var c=this._hashForTimers[d.__instanceId];c&&(c.paused=!1);if(d=this._hashForUpdates[d.__instanceId]){d.entry.paused=!1}},isTargetPaused:function(b){cc.assert(b,cc._LogInfos.Scheduler_isTargetPaused);return(b=this._hashForTimers[b.__instanceId])?b.paused:!1}});cc.Scheduler.PRIORITY_SYSTEM=-2147483648;cc._tmp.PrototypeLabelTTF=function(){var b=cc.LabelTTF.prototype;cc.defineGetterSetter(b,"color",b.getColor,b.setColor);cc.defineGetterSetter(b,"opacity",b.getOpacity,b.setOpacity);cc.defineGetterSetter(b,"string",b.getString,b.setString);cc.defineGetterSetter(b,"textAlign",b.getHorizontalAlignment,b.setHorizontalAlignment);cc.defineGetterSetter(b,"verticalAlign",b.getVerticalAlignment,b.setVerticalAlignment);cc.defineGetterSetter(b,"fontSize",b.getFontSize,b.setFontSize);cc.defineGetterSetter(b,"fontName",b.getFontName,b.setFontName);cc.defineGetterSetter(b,"font",b._getFont,b._setFont);cc.defineGetterSetter(b,"boundingWidth",b._getBoundingWidth,b._setBoundingWidth);cc.defineGetterSetter(b,"boundingHeight",b._getBoundingHeight,b._setBoundingHeight);cc.defineGetterSetter(b,"fillStyle",b._getFillStyle,b.setFontFillColor);cc.defineGetterSetter(b,"strokeStyle",b._getStrokeStyle,b._setStrokeStyle);cc.defineGetterSetter(b,"lineWidth",b._getLineWidth,b._setLineWidth);cc.defineGetterSetter(b,"shadowOffsetX",b._getShadowOffsetX,b._setShadowOffsetX);cc.defineGetterSetter(b,"shadowOffsetY",b._getShadowOffsetY,b._setShadowOffsetY);cc.defineGetterSetter(b,"shadowOpacity",b._getShadowOpacity,b._setShadowOpacity);cc.defineGetterSetter(b,"shadowBlur",b._getShadowBlur,b._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,_isMultiLine:!1,_fontStyleStr:null,_shadowEnabled:!1,_shadowOffset:null,_shadowOpacity:0,_shadowBlur:0,_shadowColorStr:null,_strokeEnabled:!1,_strokeColor:null,_strokeSize:0,_strokeColorStr:null,_textFillColor:null,_fillColorStr:null,_strokeShadowOffsetX:0,_strokeShadowOffsetY:0,_needUpdateTexture:!1,_labelCanvas:null,_labelContext:null,_lineWidths:null,_className:"LabelTTF",ctor:function(h,g,m,k,j,i){cc.Sprite.prototype.ctor.call(this);
  40. this._dimensions=cc.size(0,0);this._hAlignment=cc.TEXT_ALIGNMENT_LEFT;this._vAlignment=cc.VERTICAL_TEXT_ALIGNMENT_TOP;this._opacityModifyRGB=!1;this._fontStyleStr="";this._fontName="Arial";this._shadowEnabled=this._isMultiLine=!1;this._shadowOffset=cc.p(0,0);this._shadowBlur=this._shadowOpacity=0;this._shadowColorStr="rgba(128, 128, 128, 0.5)";this._strokeEnabled=!1;this._strokeColor=cc.color(255,255,255,255);this._strokeSize=0;this._strokeColorStr="";this._textFillColor=cc.color(255,255,255,255);this._fillColorStr="rgba(255,255,255,1)";this._strokeShadowOffsetY=this._strokeShadowOffsetX=0;this._needUpdateTexture=!1;this._lineWidths=[];this._setColorsString();g&&g instanceof cc.FontDefinition?this.initWithStringAndTextDefinition(h,g):cc.LabelTTF.prototype.initWithString.call(this,h,g,m,k,j,i)},init:function(){return this.initWithString(" ",this._fontName,this._fontSize)},_measureConfig:function(){this._getLabelContext().font=this._fontStyleStr},_measure:function(b){return this._getLabelContext().measureText(b).width},_checkNextline:function(y,x){var w=this._measure(y),v=Math.floor(y.length*x/w),u=y.indexOf("\n");if(0.8*v>=u&&0<u){return u+1}if(w<x){return y.length}for(var w=!1,t=x+1,u=-1,s=v,r,q=cc.LabelTTF._checkRegEx,o=cc.LabelTTF._reverseCheckRegEx,j=cc.LabelTTF._checkEnRegEx,i=y.substr(v);r=q.exec(i);){s+=r[0].length;t=y.substr(0,s);t=this._measure(t);if("\n"==r[2]&&t<x){w=!0;u=s;break}if(t>x){-1!=u&&(w=!0);break}u=s;i=y.substr(s)}if(w){return u}i=y.substr(0,v);for(u=v;r=o.exec(i);){if(u=r[1].length,i=r[1],t=this._measure(i),t<x){j.test(r[2])&&u++;break}}return u||1},description:function(){return"\x3ccc.LabelTTF | FontName \x3d"+this._fontName+" FontSize \x3d "+this._fontSize.toFixed(1)+"\x3e"},setColor:null,_setColorsString:null,updateDisplayedColor:null,setOpacity:null,updateDisplayedOpacity:null,updateDisplayedOpacityForCanvas:function(b){cc.NodeRGBA.prototype.updateDisplayedOpacity.call(this,b);this._setColorsString()},getString:function(){return this._string},getHorizontalAlignment:function(){return this._hAlignment},getVerticalAlignment:function(){return this._vAlignment},getDimensions:function(){return cc.size(this._dimensions.width,this._dimensions.height)},getFontSize:function(){return this._fontSize},getFontName:function(){return this._fontName},initWithString:function(h,g,m,k,j,i){h=h?h+"":"";m=m||16;k=k||cc.size(0,m);j=j||cc.TEXT_ALIGNMENT_LEFT;i=i||cc.VERTICAL_TEXT_ALIGNMENT_TOP;this._opacityModifyRGB=!1;this._dimensions=cc.size(k.width,k.height);this._fontName=g||"Arial";this._hAlignment=j;this._vAlignment=i;this._fontSize=m;this._fontStyleStr=this._fontSize+"px '"+g+"'";this._fontClientHeight=cc.LabelTTF.__getFontHeightByDiv(g,this._fontSize);this.string=h;this._setColorsString();this._updateTexture();this._needUpdateTexture=!1;return !0},initWithStringAndTextDefinition:null,setTextDefinition:function(b){b&&this._updateWithTextDefinition(b,!0)},getTextDefinition:function(){return this._prepareTextDefinition(!1)},enableShadow:function(g,f,j,i){j=j||0.5;!1===this._shadowEnabled&&(this._shadowEnabled=!0);var h=this._shadowOffset;if(h&&h.x!=g||h._y!=f){h.x=g,h.y=f}this._shadowOpacity!=j&&(this._shadowOpacity=j);this._setColorsString();this._shadowBlur!=i&&(this._shadowBlur=i);this._needUpdateTexture=!0},_getShadowOffsetX:function(){return this._shadowOffset.x},_setShadowOffsetX:function(b){!1===this._shadowEnabled&&(this._shadowEnabled=!0);this._shadowOffset.x!=b&&(this._shadowOffset.x=b,this._needUpdateTexture=!0)},_getShadowOffsetY:function(){return this._shadowOffset._y},_setShadowOffsetY:function(b){!1===this._shadowEnabled&&(this._shadowEnabled=!0);this._shadowOffset._y!=b&&(this._shadowOffset._y=b,this._needUpdateTexture=!0)},_getShadowOffset:function(){return cc.p(this._shadowOffset.x,this._shadowOffset.y)},_setShadowOffset:function(b){!1===this._shadowEnabled&&(this._shadowEnabled=!0);if(this._shadowOffset.x!=b.x||this._shadowOffset.y!=b.y){this._shadowOffset.x=b.x,this._shadowOffset.y=b.y,this._needUpdateTexture=!0}},_getShadowOpacity:function(){return this._shadowOpacity},_setShadowOpacity:function(b){!1===this._shadowEnabled&&(this._shadowEnabled=!0);this._shadowOpacity!=b&&(this._shadowOpacity=b,this._setColorsString(),this._needUpdateTexture=!0)},_getShadowBlur:function(){return this._shadowBlur},_setShadowBlur:function(b){!1===this._shadowEnabled&&(this._shadowEnabled=!0);this._shadowBlur!=b&&(this._shadowBlur=b,this._needUpdateTexture=!0)},disableShadow:function(){this._shadowEnabled&&(this._shadowEnabled=!1,this._needUpdateTexture=!0)},enableStroke:function(e,d){!1===this._strokeEnabled&&(this._strokeEnabled=!0);var f=this._strokeColor;if(f.r!==e.r||f.g!==e.g||f.b!==e.b){f.r=e.r,f.g=e.g,f.b=e.b,this._setColorsString()}this._strokeSize!==d&&(this._strokeSize=d||0);this._needUpdateTexture=!0},_getStrokeStyle:function(){return this._strokeColor},_setStrokeStyle:function(d){!1===this._strokeEnabled&&(this._strokeEnabled=!0);var c=this._strokeColor;if(c.r!==d.r||c.g!==d.g||c.b!==d.b){c.r=d.r,c.g=d.g,c.b=d.b,this._setColorsString(),this._needUpdateTexture=!0
  41. }},_getLineWidth:function(){return this._strokeSize},_setLineWidth:function(b){!1===this._strokeEnabled&&(this._strokeEnabled=!0);this._strokeSize!==b&&(this._strokeSize=b||0,this._needUpdateTexture=!0)},disableStroke:function(){this._strokeEnabled&&(this._strokeEnabled=!1,this._needUpdateTexture=!0)},setFontFillColor:null,_getFillStyle:function(){return this._textFillColor},_updateWithTextDefinition:function(d,c){d.fontDimensions?(this._dimensions.width=d.boundingWidth,this._dimensions.height=d.boundingHeight):(this._dimensions.width=0,this._dimensions.height=0);this._hAlignment=d.textAlign;this._vAlignment=d.verticalAlign;this._fontName=d.fontName;this._fontSize=d.fontSize||12;this._fontStyleStr=this._fontSize+"px '"+this._fontName+"'";this._fontClientHeight=cc.LabelTTF.__getFontHeightByDiv(this._fontName,this._fontSize);d.shadowEnabled&&this.enableShadow(d.shadowOffsetX,d.shadowOffsetY,d.shadowOpacity,d.shadowBlur);d.strokeEnabled&&this.enableStroke(d.strokeStyle,d.lineWidth);this.setFontFillColor(d.fillStyle);c&&this._updateTexture()},_prepareTextDefinition:function(e){var d=new cc.FontDefinition;e?(d.fontSize=this._fontSize,d.boundingWidth=cc.contentScaleFactor()*this._dimensions.width,d.boundingHeight=cc.contentScaleFactor()*this._dimensions.height):(d.fontSize=this._fontSize,d.boundingWidth=this._dimensions.width,d.boundingHeight=this._dimensions.height);d.fontName=this._fontName;d.textAlign=this._hAlignment;d.verticalAlign=this._vAlignment;if(this._strokeEnabled){d.strokeEnabled=!0;var f=this._strokeColor;d.strokeStyle=cc.color(f.r,f.g,f.b);d.lineWidth=this._strokeSize}else{d.strokeEnabled=!1}this._shadowEnabled?(d.shadowEnabled=!0,d.shadowBlur=this._shadowBlur,d.shadowOpacity=this._shadowOpacity,d.shadowOffsetX=(e?cc.contentScaleFactor():1)*this._shadowOffset.x,d.shadowOffsetY=(e?cc.contentScaleFactor():1)*this._shadowOffset.y):d._shadowEnabled=!1;e=this._textFillColor;d.fillStyle=cc.color(e.r,e.g,e.b);return d},_fontClientHeight:18,setString:function(b){b=String(b);this._originalText!=b&&(this._originalText=b+"",this._updateString(),this._needUpdateTexture=!0)},_updateString:function(){this._string=this._originalText},setHorizontalAlignment:function(b){b!==this._hAlignment&&(this._hAlignment=b,this._needUpdateTexture=!0)},setVerticalAlignment:function(b){b!=this._vAlignment&&(this._vAlignment=b,this._needUpdateTexture=!0)},setDimensions:function(b){if(b.width!=this._dimensions.width||b.height!=this._dimensions.height){this._dimensions=b,this._updateString(),this._needUpdateTexture=!0}},_getBoundingWidth:function(){return this._dimensions.width},_setBoundingWidth:function(b){b!=this._dimensions.width&&(this._dimensions.width=b,this._updateString(),this._needUpdateTexture=!0)},_getBoundingHeight:function(){return this._dimensions.height},_setBoundingHeight:function(b){b!=this._dimensions.height&&(this._dimensions.height=b,this._updateString(),this._needUpdateTexture=!0)},setFontSize:function(b){this._fontSize!==b&&(this._fontSize=b,this._fontStyleStr=b+"px '"+this._fontName+"'",this._fontClientHeight=cc.LabelTTF.__getFontHeightByDiv(this._fontName,b),this._needUpdateTexture=!0)},setFontName:function(b){this._fontName&&this._fontName!=b&&(this._fontName=b,this._fontStyleStr=this._fontSize+"px '"+b+"'",this._fontClientHeight=cc.LabelTTF.__getFontHeightByDiv(b,this._fontSize),this._needUpdateTexture=!0)},_getFont:function(){return this._fontStyleStr},_setFont:function(d){var c=cc.LabelTTF._fontStyleRE.exec(d);c&&(this._fontSize=parseInt(c[1]),this._fontName=c[2],this._fontStyleStr=d,this._fontClientHeight=cc.LabelTTF.__getFontHeightByDiv(this._fontName,this._fontSize),this._needUpdateTexture=!0)},_drawTTFInCanvas:function(u){if(u){var t=this._strokeShadowOffsetX,s=this._strokeShadowOffsetY,r=this._contentSize.height-s,q=this._vAlignment,o=this._hAlignment,n=this._fontClientHeight,m=this._strokeSize;u.setTransform(1,0,0,1,0+0.5*t,r+0.5*s);u.font!=this._fontStyleStr&&(u.font=this._fontStyleStr);u.fillStyle=this._fillColorStr;var j=s=0,i=this._strokeEnabled;i&&(u.lineWidth=2*m,u.strokeStyle=this._strokeColorStr);this._shadowEnabled&&(m=this._shadowOffset,u.shadowColor=this._shadowColorStr,u.shadowOffsetX=m.x,u.shadowOffsetY=-m.y,u.shadowBlur=this._shadowBlur);u.textBaseline=cc.LabelTTF._textBaseline[q];u.textAlign=cc.LabelTTF._textAlign[o];t=this._contentSize.width-t;s=o===cc.TEXT_ALIGNMENT_RIGHT?s+t:o===cc.TEXT_ALIGNMENT_CENTER?s+t/2:s+0;if(this._isMultiLine){o=this._strings.length;q===cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM?j=n+r-n*o:q===cc.VERTICAL_TEXT_ALIGNMENT_CENTER&&(j=n/2+(r-n*o)/2);for(q=0;q<o;q++){t=this._strings[q],m=-r+n*q+j,i&&u.strokeText(t,s,m),u.fillText(t,s,m)}}else{q!==cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM&&(j=q===cc.VERTICAL_TEXT_ALIGNMENT_TOP?j-r:j-0.5*r),i&&u.strokeText(this._string,s,j),u.fillText(this._string,s,j)}}},_getLabelContext:function(){if(this._labelContext){return this._labelContext}if(!this._labelCanvas){var d=cc.newElement("canvas"),c=new cc.Texture2D;c.initWithElement(d);this.texture=c;
  42. this._labelCanvas=d}return this._labelContext=this._labelCanvas.getContext("2d")},_updateTTF:function(){var i=this._dimensions.width,h,o,n=this._lineWidths;n.length=0;this._isMultiLine=!1;this._measureConfig();if(0!==i){var m=this._string;this._strings=[];h=0;for(o=this._string.length;h<o;){var k=this._checkNextline(m.substr(h),i),j=m.substr(h,k);this._strings.push(j);h+=k}}else{this._strings=this._string.split("\n");h=0;for(o=this._strings.length;h<o;h++){n.push(this._measure(this._strings[h]))}}0<this._strings.length&&(this._isMultiLine=!0);o=h=0;this._strokeEnabled&&(h=o=2*this._strokeSize);this._shadowEnabled&&(m=this._shadowOffset,h+=2*Math.abs(m.x),o+=2*Math.abs(m.y));i=0===i?this._isMultiLine?cc.size(0|Math.max.apply(Math,n)+h,0|this._fontClientHeight*this._strings.length+o):cc.size(0|this._measure(this._string)+h,0|this._fontClientHeight+o):0===this._dimensions.height?this._isMultiLine?cc.size(0|i+h,0|this._fontClientHeight*this._strings.length+o):cc.size(0|i+h,0|this._fontClientHeight+o):cc.size(0|i+h,0|this._dimensions.height+o);this.setContentSize(i);this._strokeShadowOffsetX=h;this._strokeShadowOffsetY=o;n=this._anchorPoint;this._anchorPointInPoints.x=0.5*h+(i.width-h)*n.x;this._anchorPointInPoints.y=0.5*o+(i.height-o)*n.y},getContentSize:function(){this._needUpdateTexture&&this._updateTTF();return cc.Sprite.prototype.getContentSize.call(this)},_getWidth:function(){this._needUpdateTexture&&this._updateTTF();return cc.Sprite.prototype._getWidth.call(this)},_getHeight:function(){this._needUpdateTexture&&this._updateTTF();return cc.Sprite.prototype._getHeight.call(this)},_updateTexture:function(){var g=this._getLabelContext(),f=this._labelCanvas,j=this._contentSize;if(0===this._string.length){return f.width=1,f.height=j.height,this.setTextureRect(cc.rect(0,0,1,j.height)),!0}g.font=this._fontStyleStr;this._updateTTF();var i=j.width,j=j.height,h=f.width==i&&f.height==j;f.width=i;f.height=j;h&&g.clearRect(0,0,i,j);this._drawTTFInCanvas(g);this._texture&&this._texture.handleLoadedTexture();this.setTextureRect(cc.rect(0,0,i,j));return !0},visit:function(b){this._string&&""!=this._string&&(this._needUpdateTexture&&(this._needUpdateTexture=!1,this._updateTexture()),cc.Sprite.prototype.visit.call(this,b||cc._renderContext))},draw:null,_setTextureCoords:function(h){var g=this._batchNode?this.textureAtlas.texture:this._texture;if(g){var m=g.pixelsWidth,k=g.pixelsHeight,j,i=this._quad;this._rectRotated?(cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL?(g=(2*h.x+1)/(2*m),m=g+(2*h.height-2)/(2*m),j=(2*h.y+1)/(2*k),h=j+(2*h.width-2)/(2*k)):(g=h.x/m,m=(h.x+h.height)/m,j=h.y/k,h=(h.y+h.width)/k),this._flippedX&&(k=j,j=h,h=k),this._flippedY&&(k=g,g=m,m=k),i.bl.texCoords.u=g,i.bl.texCoords.v=j,i.br.texCoords.u=g,i.br.texCoords.v=h,i.tl.texCoords.u=m,i.tl.texCoords.v=j,i.tr.texCoords.u=m,i.tr.texCoords.v=h):(cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL?(g=(2*h.x+1)/(2*m),m=g+(2*h.width-2)/(2*m),j=(2*h.y+1)/(2*k),h=j+(2*h.height-2)/(2*k)):(g=h.x/m,m=(h.x+h.width)/m,j=h.y/k,h=(h.y+h.height)/k),this._flippedX&&(k=g,g=m,m=k),this._flippedY&&(k=j,j=h,h=k),i.bl.texCoords.u=g,i.bl.texCoords.v=h,i.br.texCoords.u=m,i.br.texCoords.v=h,i.tl.texCoords.u=g,i.tl.texCoords.v=j,i.tr.texCoords.u=m,i.tr.texCoords.v=j);this._quadDirty=!0}}});cc._renderType===cc._RENDER_TYPE_CANVAS?(_p=cc.LabelTTF.prototype,_p.setColor=function(b){cc.NodeRGBA.prototype.setColor.call(this,b);this._setColorsString()},_p._setColorsString=function(){this._needUpdateTexture=!0;var f=this._displayedColor,e=this._displayedOpacity,h=this._strokeColor,g=this._textFillColor;this._shadowColorStr="rgba("+(0|0.5*f.r)+","+(0|0.5*f.g)+","+(0|0.5*f.b)+","+this._shadowOpacity+")";this._fillColorStr="rgba("+(0|f.r/255*g.r)+","+(0|f.g/255*g.g)+","+(0|f.b/255*g.b)+", "+e/255+")";this._strokeColorStr="rgba("+(0|f.r/255*h.r)+","+(0|f.g/255*h.g)+","+(0|f.b/255*h.b)+", "+e/255+")"},_p.updateDisplayedColor=function(b){cc.NodeRGBA.prototype.updateDisplayedColor.call(this,b);this._setColorsString()},_p.setOpacity=function(b){this._opacity!==b&&(cc.Sprite.prototype.setOpacity.call(this,b),this._setColorsString(),this._needUpdateTexture=!0)},_p.updateDisplayedOpacity=cc.Sprite.prototype.updateDisplayedOpacity,_p.initWithStringAndTextDefinition=function(d,c){this._updateWithTextDefinition(c,!1);this.string=d;return !0},_p.setFontFillColor=function(d){var c=this._textFillColor;if(c.r!=d.r||c.g!=d.g||c.b!=d.b){c.r=d.r,c.g=d.g,c.b=d.b,this._setColorsString(),this._needUpdateTexture=!0}},_p.draw=cc.Sprite.prototype.draw,_p.setTextureRect=function(e,d,f){this._rectRotated=d||!1;this.setContentSize(f||e);this.setVertexRect(e);d=this._textureRect_Canvas;d.x=e.x;d.y=e.y;d.width=e.width;d.height=e.height;d.validRect=!(0===d.width||0===d.height||0>d.x||0>d.y);e=this._unflippedOffsetPositionFromCenter;this._flippedX&&(e.x=-e.x);this._flippedY&&(e.y=-e.y);this._offsetPosition.x=e.x+(this._contentSize.width-this._rect.width)/2;this._offsetPosition.y=e.y+(this._contentSize.height-this._rect.height)/2;this._batchNode&&(this.dirty=!0)
  43. },_p=null):(cc.assert("function"===typeof cc._tmp.WebGLLabelTTF,cc._LogInfos.MissingFile,"LabelTTFWebGL.js"),cc._tmp.WebGLLabelTTF(),delete cc._tmp.WebGLLabelTTF);cc.assert("function"===typeof cc._tmp.PrototypeLabelTTF,cc._LogInfos.MissingFile,"LabelTTFPropertyDefine.js");cc._tmp.PrototypeLabelTTF();delete cc._tmp.PrototypeLabelTTF;cc.LabelTTF._textAlign=["left","center","right"];cc.LabelTTF._textBaseline=["top","middle","bottom"];cc.LabelTTF._checkRegEx=/(.+?)([\s\n\r\-\/\\\:]|[\u4E00-\u9FA5]|[\uFE30-\uFFA0])/;cc.LabelTTF._reverseCheckRegEx=/(.*)([\s\n\r\-\/\\\:]|[\u4E00-\u9FA5]|[\uFE30-\uFFA0])/;cc.LabelTTF._checkEnRegEx=/[\s\-\/\\\:]/;cc.LabelTTF._fontStyleRE=/^(\d+)px\s+['"]?([\w\s\d]+)['"]?$/;cc.LabelTTF.create=function(h,g,m,k,j,i){return new cc.LabelTTF(h,g,m,k,j,i)};cc.LabelTTF._SHADER_PROGRAM=cc.USE_LA88_LABELS?cc.SHADER_POSITION_TEXTURECOLOR:cc.SHADER_POSITION_TEXTUREA8COLOR;cc.LabelTTF.__labelHeightDiv=cc.newElement("div");cc.LabelTTF.__labelHeightDiv.style.fontFamily="Arial";cc.LabelTTF.__labelHeightDiv.style.position="absolute";cc.LabelTTF.__labelHeightDiv.style.left="-100px";cc.LabelTTF.__labelHeightDiv.style.top="-100px";cc.LabelTTF.__labelHeightDiv.style.lineHeight="normal";document.body?document.body.appendChild(cc.LabelTTF.__labelHeightDiv):cc._addEventListener(window,"load",function(){this.removeEventListener("load",arguments.callee,!1);document.body.appendChild(cc.LabelTTF.__labelHeightDiv)},!1);cc.LabelTTF.__getFontHeightByDiv=function(f,e){var h=cc.LabelTTF.__fontHeightCache[f+"."+e];if(0<h){return h}var g=cc.LabelTTF.__labelHeightDiv;g.innerHTML="ajghl~!";g.style.fontFamily=f;g.style.fontSize=e+"px";h=g.clientHeight;cc.LabelTTF.__fontHeightCache[f+"."+e]=h;g.innerHTML="";return h};cc.LabelTTF.__fontHeightCache={};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 f,e,g,h=this._fnMap;for(f=0,l=h.length;l>f;f++){if(e=h[f],e&&e[1] in document){for(f=0,g=e.length;g>f;f++){this._fn[h[0][f]]=e[f]}break}}this._supportsFullScreen=void 0!=this._fn.requestFullscreen,this._touchEvent="ontouchstart" in window?"touchstart":"mousedown"},fullScreen:function(){return this._supportsFullScreen&&document[this._fn.fullscreenEnabled]},requestFullScreen:function(e,d){if(this._supportsFullScreen){if(e=e||document.documentElement,e[this._fn.requestFullscreen](),d){var f=this._fn.fullscreenchange;this._preOnFullScreenChange&&document.removeEventListener(f,this._preOnFullScreenChange),this._preOnFullScreenChange=d,cc._addEventListener(document,f,d,!1)}return e[this._fn.requestFullscreen]()}},exitFullScreen:function(){return this._supportsFullScreen?document[this._fn.exitFullscreen]():!0},autoFullScreen:function(g,f){function h(){i.requestFullScreen(g,f),j.removeEventListener(i._touchEvent,h)}g=g||document.body;var j=cc._canvas||g,i=this;this.requestFullScreen(g,f),cc._addEventListener(j,this._touchEvent,h)}},cc.screen.init();cc.ACTION_TAG_INVALID=-1,cc.Action=cc.Class.extend({originalTarget:null,target:null,tag:cc.ACTION_TAG_INVALID,ctor:function(){this.originalTarget=null,this.target=null,this.tag=cc.ACTION_TAG_INVALID},copy:function(){return cc.log("copy is deprecated. Please use clone instead."),this.clone()},clone:function(){var b=new cc.Action;return b.originalTarget=null,b.target=null,b.tag=this.tag,b},isDone:function(){return !0},startWithTarget:function(b){this.originalTarget=b,this.target=b},stop:function(){this.target=null},step:function(){cc.log("[Action step]. override me")},update:function(){cc.log("[Action update]. override me")},getTarget:function(){return this.target},setTarget:function(b){this.target=b},getOriginalTarget:function(){return this.originalTarget},setOriginalTarget:function(b){this.originalTarget=b},getTag:function(){return this.tag},setTag:function(b){this.tag=b},retain:function(){},release:function(){}}),cc.Action.create=function(){return new 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._times||1)},setDuration:function(b){this._duration=b},reverse:function(){return cc.log("cocos2d: FiniteTimeAction#reverse: Implement me"),null},clone:function(){return new cc.FiniteTimeAction}}),cc.Speed=cc.Action.extend({_speed:0,_innerAction:null,ctor:function(d,c){cc.Action.prototype.ctor.call(this),this._speed=0,this._innerAction=null,d&&this.initWithAction(d,c)
  44. },getSpeed:function(){return this._speed},setSpeed:function(b){this._speed=b},initWithAction:function(d,c){if(!d){throw"cc.Speed.initWithAction(): action must be non nil"}return this._innerAction=d,this._speed=c,!0},clone:function(){var b=new cc.Speed;return b.initWithAction(this._innerAction.clone(),this._speed),b},startWithTarget:function(b){cc.Action.prototype.startWithTarget.call(this,b),this._innerAction.startWithTarget(b)},stop:function(){this._innerAction.stop(),cc.Action.prototype.stop.call(this)},step:function(b){this._innerAction.step(b*this._speed)},isDone:function(){return this._innerAction.isDone()},reverse:function(){return cc.Speed.create(this._innerAction.reverse(),this._speed)},setInnerAction:function(b){this._innerAction!=b&&(this._innerAction=b)},getInnerAction:function(){return this._innerAction}}),cc.Speed.create=function(d,c){return new cc.Speed(d,c)},cc.Follow=cc.Action.extend({_followedNode:null,_boundarySet:!1,_boundaryFullyCovered:!1,_halfScreenSize:null,_fullScreenSize:null,leftBoundary:0,rightBoundary:0,topBoundary:0,bottomBoundary:0,_worldRect:null,ctor:function(d,c){cc.Action.prototype.ctor.call(this),this._followedNode=null,this._boundarySet=!1,this._boundaryFullyCovered=!1,this._halfScreenSize=null,this._fullScreenSize=null,this.leftBoundary=0,this.rightBoundary=0,this.topBoundary=0,this.bottomBoundary=0,this._worldRect=cc.rect(0,0,0,0),d&&(c?this.initWithTarget(d,c):this.initWithTarget(d))},clone:function(){var e=new cc.Follow,d=this._worldRect,f=new cc.Rect(d.x,d.y,d.width,d.height);return e.initWithTarget(this._followedNode,f),e},isBoundarySet:function(){return this._boundarySet},setBoudarySet:function(b){this._boundarySet=b},initWithTarget:function(f,e){if(!f){throw"cc.Follow.initWithAction(): followedNode must be non nil"}var h=this;e=e||cc.rect(0,0,0,0),h._followedNode=f,h._worldRect=e,h._boundarySet=!cc._rectEqualToZero(e),h._boundaryFullyCovered=!1;var g=cc.director.getWinSize();return h._fullScreenSize=cc.p(g.width,g.height),h._halfScreenSize=cc.pMult(h._fullScreenSize,0.5),h._boundarySet&&(h.leftBoundary=-(e.x+e.width-h._fullScreenSize.x),h.rightBoundary=-e.x,h.topBoundary=-e.y,h.bottomBoundary=-(e.y+e.height-h._fullScreenSize.y),h.rightBoundary<h.leftBoundary&&(h.rightBoundary=h.leftBoundary=(h.leftBoundary+h.rightBoundary)/2),h.topBoundary<h.bottomBoundary&&(h.topBoundary=h.bottomBoundary=(h.topBoundary+h.bottomBoundary)/2),h.topBoundary==h.bottomBoundary&&h.leftBoundary==h.rightBoundary&&(h._boundaryFullyCovered=!0)),!0},step:function(){var a=this._followedNode.x,d=this._followedNode.y;if(a=this._halfScreenSize.x-a,d=this._halfScreenSize.y-d,this._boundarySet){if(this._boundaryFullyCovered){return}this.target.setPosition(cc.clampf(a,this.leftBoundary,this.rightBoundary),cc.clampf(d,this.bottomBoundary,this.topBoundary))}else{this.target.setPosition(a,d)}},isDone:function(){return !this._followedNode.running},stop:function(){this.target=null,cc.Action.prototype.stop.call(this)}}),cc.Follow.create=function(d,c){return new cc.Follow(d,c)};cc.ActionInstant=cc.FiniteTimeAction.extend({isDone:function(){return !0},step:function(){this.update(1)},update:function(){},reverse:function(){return this.clone()},clone:function(){return new cc.ActionInstant}}),cc.Show=cc.ActionInstant.extend({update:function(){this.target.visible=!0},reverse:function(){return cc.Hide.create()},clone:function(){return new cc.Show}}),cc.Show.create=function(){return new cc.Show},cc.Hide=cc.ActionInstant.extend({update:function(){this.target.visible=!1},reverse:function(){return cc.Show.create()},clone:function(){return new cc.Hide}}),cc.Hide.create=function(){return new cc.Hide},cc.ToggleVisibility=cc.ActionInstant.extend({update:function(){this.target.visible=!this.target.visible},reverse:function(){return new cc.ToggleVisibility},clone:function(){return new cc.ToggleVisibility}}),cc.ToggleVisibility.create=function(){return new cc.ToggleVisibility},cc.RemoveSelf=cc.ActionInstant.extend({_isNeedCleanUp:!0,ctor:function(b){cc.FiniteTimeAction.prototype.ctor.call(this),void 0!==b&&this.init(b)},update:function(){this.target.removeFromParent(this._isNeedCleanUp)},init:function(b){return this._isNeedCleanUp=b,!0},reverse:function(){return new cc.RemoveSelf(this._isNeedCleanUp)},clone:function(){return new cc.RemoveSelf(this._isNeedCleanUp)}}),cc.RemoveSelf.create=function(b){return new cc.RemoveSelf(b)},cc.FlipX=cc.ActionInstant.extend({_flippedX:!1,ctor:function(b){cc.FiniteTimeAction.prototype.ctor.call(this),this._flippedX=!1,void 0!==b&&this.initWithFlipX(b)},initWithFlipX:function(b){return this._flippedX=b,!0},update:function(){this.target.flippedX=this._flippedX},reverse:function(){return cc.FlipX.create(!this._flippedX)},clone:function(){var b=new cc.FlipX;return b.initWithFlipX(this._flippedX),b}}),cc.FlipX.create=function(b){return new cc.FlipX(b)},cc.FlipY=cc.ActionInstant.extend({_flippedY:!1,ctor:function(b){cc.FiniteTimeAction.prototype.ctor.call(this),this._flippedY=!1,void 0!==b&&this.initWithFlipY(b)
  45. },initWithFlipY:function(b){return this._flippedY=b,!0},update:function(){this.target.flippedY=this._flippedY},reverse:function(){return cc.FlipY.create(!this._flippedY)},clone:function(){var b=new cc.FlipY;return b.initWithFlipY(this._flippedY),b}}),cc.FlipY.create=function(b){return new cc.FlipY(b)},cc.Place=cc.ActionInstant.extend({_x:0,_y:0,ctor:function(d,c){cc.FiniteTimeAction.prototype.ctor.call(this),this._x=0,this._y=0,void 0!==d&&(void 0!==d.x&&(c=d.y,d=d.x),this.initWithPosition(d,c))},initWithPosition:function(d,c){return this._x=d,this._y=c,!0},update:function(){this.target.setPosition(this._x,this._y)},clone:function(){var b=new cc.Place;return b.initWithPosition(this._x,this._y),b}}),cc.Place.create=function(d,c){return new cc.Place(d,c)},cc.CallFunc=cc.ActionInstant.extend({_selectorTarget:null,_callFunc:null,_function:null,_data:null,ctor:function(e,d,f){cc.FiniteTimeAction.prototype.ctor.call(this),void 0!==e&&(void 0===d?this.initWithFunction(e):this.initWithFunction(e,d,f))},initWithFunction:function(e,d,f){return d?(this._data=f,this._callFunc=e,this._selectorTarget=d):e&&(this._function=e),!0},execute:function(){null!=this._callFunc?this._callFunc.call(this._selectorTarget,this.target,this._data):this._function&&this._function.call(null,this.target)},update:function(){this.execute()},getTargetCallback:function(){return this._selectorTarget},setTargetCallback:function(b){b!=this._selectorTarget&&(this._selectorTarget&&(this._selectorTarget=null),this._selectorTarget=b)},clone:function(){var b=new cc.CallFunc;return this._selectorTarget?b.initWithFunction(this._callFunc,this._selectorTarget,this._data):this._function&&b.initWithFunction(this._function),b}}),cc.CallFunc.create=function(e,d,f){return new cc.CallFunc(e,d,f)};cc.ActionInterval=cc.FiniteTimeAction.extend({_elapsed:0,_firstTick:!1,_easeList:null,_times:1,_repeatForever:!1,_repeatMethod:!1,_speed:1,_speedMethod:!1,ctor:function(b){this._speed=1,this._times=1,this._repeatForever=!1,this.MAX_VALUE=2,this._repeatMethod=!1,this._speedMethod=!1,cc.FiniteTimeAction.prototype.ctor.call(this),void 0!==b&&this.initWithDuration(b)},getElapsed:function(){return this._elapsed},initWithDuration:function(b){return this._duration=0===b?cc.FLT_EPSILON:b,this._elapsed=0,this._firstTick=!0,!0},isDone:function(){return this._elapsed>=this._duration},_cloneDecoration:function(b){b._repeatForever=this._repeatForever,b._speed=this._speed,b._times=this._times,b._easeList=this._easeList,b._speedMethod=this._speedMethod,b._repeatMethod=this._repeatMethod},_reverseEaseList:function(d){if(this._easeList){d._easeList=[];for(var c=0;c<this._easeList.length;c++){d._easeList.push(this._easeList[c].reverse())}}},clone:function(){var b=new cc.ActionInterval(this._duration);return this._cloneDecoration(b),b},easing:function(){this._easeList?this._easeList.length=0:this._easeList=[];for(var a=0;a<arguments.length;a++){this._easeList.push(arguments[a])}return this},_computeEaseTime:function(f){var e=this._easeList;if(!e||0===e.length){return f}for(var h=0,g=e.length;g>h;h++){f=e[h].easing(f)}return f},step:function(d){this._firstTick?(this._firstTick=!1,this._elapsed=0):this._elapsed+=d;var c=this._elapsed/(this._duration>1.192092896e-7?this._duration:1.192092896e-7);c=1>c?c:1,this.update(c>0?c:0),this._repeatMethod&&this._times>1&&this.isDone()&&(this._repeatForever||this._times--,this.startWithTarget(this.target),this.step(this._elapsed-this._duration))},startWithTarget:function(b){cc.Action.prototype.startWithTarget.call(this,b),this._elapsed=0,this._firstTick=!0},reverse:function(){return cc.log("cc.IntervalAction: reverse not implemented."),null},setAmplitudeRate:function(){cc.log("cc.ActionInterval.setAmplitudeRate(): it should be overridden in subclass.")},getAmplitudeRate:function(){return cc.log("cc.ActionInterval.getAmplitudeRate(): it should be overridden in subclass."),0},speed:function(b){return 0>=b?(cc.log("The speed parameter error"),this):(this._speedMethod=!0,this._speed*=b,this)},getSpeed:function(){return this._speed},setSpeed:function(b){return this._speed=b,this},repeat:function(b){return b=Math.round(b),isNaN(b)||1>b?(cc.log("The repeat parameter error"),this):(this._repeatMethod=!0,this._times*=b,this)},repeatForever:function(){return this._repeatMethod=!0,this._times=this.MAX_VALUE,this._repeatForever=!0,this}}),cc.ActionInterval.create=function(b){return new cc.ActionInterval(b)},cc.Sequence=cc.ActionInterval.extend({_actions:null,_split:null,_last:0,ctor:function(h){cc.ActionInterval.prototype.ctor.call(this),this._actions=[];var g=h instanceof Array?h:arguments,m=g.length-1;if(m>=0&&null==g[m]&&cc.log("parameters should not be ending with null in Javascript"),m>=0){for(var j,k=g[0],i=1;m>i;i++){g[i]&&(j=k,k=cc.Sequence.create(),k.initWithTwoActions(j,g[i]))}this.initWithTwoActions(k,g[m])}},initWithTwoActions:function(e,d){if(!e||!d){throw"cc.Sequence.initWithTwoActions(): arguments must all be non nil"}var f=e._duration+d._duration;return this.initWithDuration(f),this._actions[0]=e,this._actions[1]=d,!0
  46. },clone:function(){var b=new cc.Sequence;return this._cloneDecoration(b),b.initWithTwoActions(this._actions[0].clone(),this._actions[1].clone()),b},startWithTarget:function(b){cc.ActionInterval.prototype.startWithTarget.call(this,b),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(h){h=this._computeEaseTime(h);var g,m=0,k=this._split,j=this._actions,i=this._last;k>h?(g=0!==k?h/k:1,0===m&&1===i&&(j[1].update(0),j[1].stop())):(m=1,g=1===k?1:(h-k)/(1-k),-1===i&&(j[0].startWithTarget(this.target),j[0].update(1),j[0].stop()),i||(j[0].update(1),j[0].stop())),i===m&&j[m].isDone()||(i!==m&&j[m].startWithTarget(this.target),j[m].update(g),this._last=m)},reverse:function(){var b=cc.Sequence._actionOneTwo(this._actions[1].reverse(),this._actions[0].reverse());return this._cloneDecoration(b),this._reverseEaseList(b),b}}),cc.Sequence.create=function(f){var e=f instanceof Array?f:arguments;e.length>0&&null==e[e.length-1]&&cc.log("parameters should not be ending with null in Javascript");for(var h=e[0],g=1;g<e.length;g++){e[g]&&(h=cc.Sequence._actionOneTwo(h,e[g]))}return h},cc.Sequence._actionOneTwo=function(e,d){var f=new cc.Sequence;return f.initWithTwoActions(e,d),f},cc.Repeat=cc.ActionInterval.extend({_times:0,_total:0,_nextDt:0,_actionInstant:!1,_innerAction:null,ctor:function(d,c){cc.ActionInterval.prototype.ctor.call(this),void 0!==c&&this.initWithAction(d,c)},initWithAction:function(e,d){var f=e._duration*d;return this.initWithDuration(f)?(this._times=d,this._innerAction=e,e instanceof cc.ActionInstant&&(this._actionInstant=!0,this._times-=1),this._total=0,!0):!1},clone:function(){var b=new cc.Repeat;return this._cloneDecoration(b),b.initWithAction(this._innerAction.clone(),this._times),b},startWithTarget:function(b){this._total=0,this._nextDt=this._innerAction._duration/this._duration,cc.ActionInterval.prototype.startWithTarget.call(this,b),this._innerAction.startWithTarget(b)},stop:function(){this._innerAction.stop(),cc.Action.prototype.stop.call(this)},update:function(g){g=this._computeEaseTime(g);var f=this._innerAction,j=this._duration,i=this._times,h=this._nextDt;if(g>=h){for(;g>h&&this._total<i;){f.update(1),this._total++,f.stop(),f.startWithTarget(this.target),h+=f._duration/j,this._nextDt=h}g>=1&&this._total<i&&this._total++,this._actionInstant||(this._total===i?(f.update(1),f.stop()):f.update(g-(h-f._duration/j)))}else{f.update(g*i%1)}},isDone:function(){return this._total==this._times},reverse:function(){var b=cc.Repeat.create(this._innerAction.reverse(),this._times);return this._cloneDecoration(b),this._reverseEaseList(b),b},setInnerAction:function(b){this._innerAction!=b&&(this._innerAction=b)},getInnerAction:function(){return this._innerAction}}),cc.Repeat.create=function(d,c){return new cc.Repeat(d,c)},cc.RepeatForever=cc.ActionInterval.extend({_innerAction:null,ctor:function(b){cc.ActionInterval.prototype.ctor.call(this),this._innerAction=null,b&&this.initWithAction(b)},initWithAction:function(b){if(!b){throw"cc.RepeatForever.initWithAction(): action must be non null"}return this._innerAction=b,!0},clone:function(){var b=new cc.RepeatForever;return this._cloneDecoration(b),b.initWithAction(this._innerAction.clone()),b},startWithTarget:function(b){cc.ActionInterval.prototype.startWithTarget.call(this,b),this._innerAction.startWithTarget(b)},step:function(d){var c=this._innerAction;c.step(d),c.isDone()&&(c.startWithTarget(this.target),c.step(c.getElapsed()-c._duration))},isDone:function(){return !1},reverse:function(){var b=cc.RepeatForever.create(this._innerAction.reverse());return this._cloneDecoration(b),this._reverseEaseList(b),b},setInnerAction:function(b){this._innerAction!=b&&(this._innerAction=b)},getInnerAction:function(){return this._innerAction}}),cc.RepeatForever.create=function(b){return new cc.RepeatForever(b)},cc.Spawn=cc.ActionInterval.extend({_one:null,_two:null,ctor:function(h){cc.ActionInterval.prototype.ctor.call(this),this._one=null,this._two=null;var g=h instanceof Array?h:arguments,m=g.length-1;if(m>=0&&null==g[m]&&cc.log("parameters should not be ending with null in Javascript"),m>=0){for(var j,k=g[0],i=1;m>i;i++){g[i]&&(j=k,k=cc.Spwan.create(),k.initWithTwoActions(j,g[i]))}this.initWithTwoActions(k,g[m])}},initWithTwoActions:function(g,f){if(!g||!f){throw"cc.Spawn.initWithTwoActions(): arguments must all be non null"}var j=!1,i=g._duration,h=f._duration;return this.initWithDuration(Math.max(i,h))&&(this._one=g,this._two=f,i>h?this._two=cc.Sequence._actionOneTwo(f,cc.DelayTime.create(i-h)):h>i&&(this._one=cc.Sequence._actionOneTwo(g,cc.DelayTime.create(h-i))),j=!0),j},clone:function(){var b=new cc.Spawn;return this._cloneDecoration(b),b.initWithTwoActions(this._one.clone(),this._two.clone()),b},startWithTarget:function(b){cc.ActionInterval.prototype.startWithTarget.call(this,b),this._one.startWithTarget(b),this._two.startWithTarget(b)},stop:function(){this._one.stop(),this._two.stop(),cc.Action.prototype.stop.call(this)
  47. },update:function(b){b=this._computeEaseTime(b),this._one&&this._one.update(b),this._two&&this._two.update(b)},reverse:function(){var b=cc.Spawn._actionOneTwo(this._one.reverse(),this._two.reverse());return this._cloneDecoration(b),this._reverseEaseList(b),b}}),cc.Spawn.create=function(f){var e=f instanceof Array?f:arguments;e.length>0&&null==e[e.length-1]&&cc.log("parameters should not be ending with null in Javascript");for(var h=e[0],g=1;g<e.length;g++){null!=e[g]&&(h=this._actionOneTwo(h,e[g]))}return h},cc.Spawn._actionOneTwo=function(e,d){var f=new cc.Spawn;return f.initWithTwoActions(e,d),f},cc.RotateTo=cc.ActionInterval.extend({_dstAngleX:0,_startAngleX:0,_diffAngleX:0,_dstAngleY:0,_startAngleY:0,_diffAngleY:0,ctor:function(e,d,f){cc.ActionInterval.prototype.ctor.call(this),void 0!==d&&this.initWithDuration(e,d,f)},initWithDuration:function(e,d,f){return cc.ActionInterval.prototype.initWithDuration.call(this,e)?(this._dstAngleX=d||0,this._dstAngleY=f||this._dstAngleX,!0):!1},clone:function(){var b=new cc.RotateTo;return this._cloneDecoration(b),b.initWithDuration(this._duration,this._dstAngleX,this._dstAngleY),b},startWithTarget:function(f){cc.ActionInterval.prototype.startWithTarget.call(this,f);var e=f.rotationX%360,h=this._dstAngleX-e;h>180&&(h-=360),-180>h&&(h+=360),this._startAngleX=e,this._diffAngleX=h,this._startAngleY=f.rotationY%360;var g=this._dstAngleY-this._startAngleY;g>180&&(g-=360),-180>g&&(g+=360),this._diffAngleY=g},reverse:function(){cc.log("cc.RotateTo.reverse(): it should be overridden in subclass.")},update:function(b){b=this._computeEaseTime(b),this.target&&(this.target.rotationX=this._startAngleX+this._diffAngleX*b,this.target.rotationY=this._startAngleY+this._diffAngleY*b)}}),cc.RotateTo.create=function(e,d,f){return new cc.RotateTo(e,d,f)},cc.RotateBy=cc.ActionInterval.extend({_angleX:0,_startAngleX:0,_angleY:0,_startAngleY:0,ctor:function(e,d,f){cc.ActionInterval.prototype.ctor.call(this),void 0!==d&&this.initWithDuration(e,d,f)},initWithDuration:function(e,d,f){return cc.ActionInterval.prototype.initWithDuration.call(this,e)?(this._angleX=d||0,this._angleY=f||this._angleX,!0):!1},clone:function(){var b=new cc.RotateBy;return this._cloneDecoration(b),b.initWithDuration(this._duration,this._angleX,this._angleY),b},startWithTarget:function(b){cc.ActionInterval.prototype.startWithTarget.call(this,b),this._startAngleX=b.rotationX,this._startAngleY=b.rotationY},update:function(b){b=this._computeEaseTime(b),this.target&&(this.target.rotationX=this._startAngleX+this._angleX*b,this.target.rotationY=this._startAngleY+this._angleY*b)},reverse:function(){var b=cc.RotateBy.create(this._duration,-this._angleX,-this._angleY);return this._cloneDecoration(b),this._reverseEaseList(b),b}}),cc.RotateBy.create=function(f,e,h){var g=new cc.RotateBy;return g.initWithDuration(f,e,h),g},cc.MoveBy=cc.ActionInterval.extend({_positionDelta:null,_startPosition:null,_previousPosition:null,ctor:function(e,d,f){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!==d&&this.initWithDuration(e,d,f)},initWithDuration:function(e,d,f){return cc.ActionInterval.prototype.initWithDuration.call(this,e)?(void 0!==d.x&&(f=d.y,d=d.x),this._positionDelta.x=d,this._positionDelta.y=f,!0):!1},clone:function(){var b=new cc.MoveBy;return this._cloneDecoration(b),b.initWithDuration(this._duration,this._positionDelta),b},startWithTarget:function(e){cc.ActionInterval.prototype.startWithTarget.call(this,e);var d=e.getPositionX(),f=e.getPositionY();this._previousPosition.x=d,this._previousPosition.y=f,this._startPosition.x=d,this._startPosition.y=f},update:function(i){if(i=this._computeEaseTime(i),this.target){var h=this._positionDelta.x*i,o=this._positionDelta.y*i,n=this._startPosition;if(cc.ENABLE_STACKABLE_ACTIONS){var m=this.target.getPositionX(),k=this.target.getPositionY(),j=this._previousPosition;n.x=n.x+m-j.x,n.y=n.y+k-j.y,h+=n.x,o+=n.y,j.x=h,j.y=o,this.target.setPosition(h,o)}else{this.target.setPosition(n.x+h,n.y+o)}}},reverse:function(){var b=cc.MoveBy.create(this._duration,cc.p(-this._positionDelta.x,-this._positionDelta.y));return this._cloneDecoration(b),this._reverseEaseList(b),b}}),cc.MoveBy.create=function(e,d,f){return new cc.MoveBy(e,d,f)},cc.MoveTo=cc.MoveBy.extend({_endPosition:null,ctor:function(e,d,f){cc.MoveBy.prototype.ctor.call(this),this._endPosition=cc.p(0,0),void 0!==d&&this.initWithDuration(e,d,f)},initWithDuration:function(e,d,f){return cc.MoveBy.prototype.initWithDuration.call(this,e,d,f)?(void 0!==d.x&&(f=d.y,d=d.x),this._endPosition.x=d,this._endPosition.y=f,!0):!1},clone:function(){var b=new cc.MoveTo;return this._cloneDecoration(b),b.initWithDuration(this._duration,this._endPosition),b},startWithTarget:function(b){cc.MoveBy.prototype.startWithTarget.call(this,b),this._positionDelta.x=this._endPosition.x-b.getPositionX(),this._positionDelta.y=this._endPosition.y-b.getPositionY()}}),cc.MoveTo.create=function(e,d,f){return new cc.MoveTo(e,d,f)
  48. },cc.SkewTo=cc.ActionInterval.extend({_skewX:0,_skewY:0,_startSkewX:0,_startSkewY:0,_endSkewX:0,_endSkewY:0,_deltaX:0,_deltaY:0,ctor:function(e,d,f){cc.ActionInterval.prototype.ctor.call(this),void 0!==f&&this.initWithDuration(e,d,f)},initWithDuration:function(f,e,h){var g=!1;return cc.ActionInterval.prototype.initWithDuration.call(this,f)&&(this._endSkewX=e,this._endSkewY=h,g=!0),g},clone:function(){var b=new cc.SkewTo;return this._cloneDecoration(b),b.initWithDuration(this._duration,this._endSkewX,this._endSkewY),b},startWithTarget:function(b){cc.ActionInterval.prototype.startWithTarget.call(this,b),this._startSkewX=b.skewX%180,this._deltaX=this._endSkewX-this._startSkewX,this._deltaX>180&&(this._deltaX-=360),this._deltaX<-180&&(this._deltaX+=360),this._startSkewY=b.skewY%360,this._deltaY=this._endSkewY-this._startSkewY,this._deltaY>180&&(this._deltaY-=360),this._deltaY<-180&&(this._deltaY+=360)},update:function(b){b=this._computeEaseTime(b),this.target.skewX=this._startSkewX+this._deltaX*b,this.target.skewY=this._startSkewY+this._deltaY*b}}),cc.SkewTo.create=function(e,d,f){return new cc.SkewTo(e,d,f)},cc.SkewBy=cc.SkewTo.extend({ctor:function(e,d,f){cc.SkewTo.prototype.ctor.call(this),void 0!==f&&this.initWithDuration(e,d,f)},initWithDuration:function(f,e,h){var g=!1;return cc.SkewTo.prototype.initWithDuration.call(this,f,e,h)&&(this._skewX=e,this._skewY=h,g=!0),g},clone:function(){var b=new cc.SkewBy;return this._cloneDecoration(b),b.initWithDuration(this._duration,this._skewX,this._skewY),b},startWithTarget:function(b){cc.SkewTo.prototype.startWithTarget.call(this,b),this._deltaX=this._skewX,this._deltaY=this._skewY,this._endSkewX=this._startSkewX+this._deltaX,this._endSkewY=this._startSkewY+this._deltaY},reverse:function(){var b=cc.SkewBy.create(this._duration,-this._skewX,-this._skewY);return this._cloneDecoration(b),this._reverseEaseList(b),b}}),cc.SkewBy.create=function(f,e,h){var g=new cc.SkewBy;return g&&g.initWithDuration(f,e,h),g},cc.JumpBy=cc.ActionInterval.extend({_startPosition:null,_delta:null,_height:0,_jumps:0,_previousPosition:null,ctor:function(g,f,j,i,h){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!==i&&this.initWithDuration(g,f,j,i,h)},initWithDuration:function(g,f,j,i,h){return cc.ActionInterval.prototype.initWithDuration.call(this,g)?(void 0===h&&(h=i,i=j,j=f.y,f=f.x),this._delta.x=f,this._delta.y=j,this._height=i,this._jumps=h,!0):!1},clone:function(){var b=new cc.JumpBy;return this._cloneDecoration(b),b.initWithDuration(this._duration,this._delta,this._height,this._jumps),b},startWithTarget:function(e){cc.ActionInterval.prototype.startWithTarget.call(this,e);var d=e.getPositionX(),f=e.getPositionY();this._previousPosition.x=d,this._previousPosition.y=f,this._startPosition.x=d,this._startPosition.y=f},update:function(j){if(j=this._computeEaseTime(j),this.target){var i=j*this._jumps%1,r=4*this._height*i*(1-i);r+=this._delta.y*j;var q=this._delta.x*j,o=this._startPosition;if(cc.ENABLE_STACKABLE_ACTIONS){var n=this.target.getPositionX(),m=this.target.getPositionY(),k=this._previousPosition;o.x=o.x+n-k.x,o.y=o.y+m-k.y,q+=o.x,r+=o.y,k.x=q,k.y=r,this.target.setPosition(q,r)}else{this.target.setPosition(o.x+q,o.y+r)}}},reverse:function(){var b=cc.JumpBy.create(this._duration,cc.p(-this._delta.x,-this._delta.y),this._height,this._jumps);return this._cloneDecoration(b),this._reverseEaseList(b),b}}),cc.JumpBy.create=function(g,f,j,i,h){return new cc.JumpBy(g,f,j,i,h)},cc.JumpTo=cc.JumpBy.extend({startWithTarget:function(b){cc.JumpBy.prototype.startWithTarget.call(this,b),this._delta.x=this._delta.x-this._startPosition.x,this._delta.y=this._delta.y-this._startPosition.y},clone:function(){var b=new cc.JumpTo;return this._cloneDecoration(b),b.initWithDuration(this._duration,this._delta,this._height,this._jumps),b}}),cc.JumpTo.create=function(g,f,j,i,h){return new cc.JumpTo(g,f,j,i,h)},cc.bezierAt=function(g,f,j,i,h){return Math.pow(1-h,3)*g+3*h*Math.pow(1-h,2)*f+3*Math.pow(h,2)*(1-h)*j+Math.pow(h,3)*i},cc.BezierBy=cc.ActionInterval.extend({_config:null,_startPosition:null,_previousPosition:null,ctor:function(d,c){cc.ActionInterval.prototype.ctor.call(this),this._config=[],this._startPosition=cc.p(0,0),this._previousPosition=cc.p(0,0),c&&this.initWithDuration(d,c)},initWithDuration:function(d,c){return cc.ActionInterval.prototype.initWithDuration.call(this,d)?(this._config=c,!0):!1},clone:function(){var f=new cc.BezierBy;this._cloneDecoration(f);for(var e=[],h=0;h<this._config.length;h++){var g=this._config[h];e.push(cc.p(g.x,g.y))}return f.initWithDuration(this._duration,e),f},startWithTarget:function(e){cc.ActionInterval.prototype.startWithTarget.call(this,e);var d=e.getPositionX(),f=e.getPositionY();this._previousPosition.x=d,this._previousPosition.y=f,this._startPosition.x=d,this._startPosition.y=f},update:function(F){if(F=this._computeEaseTime(F),this.target){var E=this._config,D=0,C=E[0].x,B=E[1].x,A=E[2].x,z=0,y=E[0].y,x=E[1].y,w=E[2].y,v=cc.bezierAt(D,C,B,A,F),u=cc.bezierAt(z,y,x,w,F),t=this._startPosition;
  49. if(cc.ENABLE_STACKABLE_ACTIONS){var s=this.target.getPositionX(),r=this.target.getPositionY(),q=this._previousPosition;t.x=t.x+s-q.x,t.y=t.y+r-q.y,v+=t.x,u+=t.y,q.x=v,q.y=u,this.target.setPosition(v,u)}else{this.target.setPosition(t.x+v,t.y+u)}}},reverse:function(){var e=this._config,d=[cc.pAdd(e[1],cc.pNeg(e[2])),cc.pAdd(e[0],cc.pNeg(e[2])),cc.pNeg(e[2])],f=cc.BezierBy.create(this._duration,d);return this._cloneDecoration(f),this._reverseEaseList(f),f}}),cc.BezierBy.create=function(d,c){return new cc.BezierBy(d,c)},cc.BezierTo=cc.BezierBy.extend({_toConfig:null,ctor:function(d,c){cc.BezierBy.prototype.ctor.call(this),this._toConfig=[],c&&this.initWithDuration(d,c)},initWithDuration:function(d,c){return cc.ActionInterval.prototype.initWithDuration.call(this,d)?(this._toConfig=c,!0):!1},clone:function(){var b=new cc.BezierTo;return this._cloneDecoration(b),b.initWithDuration(this._duration,this._toConfig),b},startWithTarget:function(f){cc.BezierBy.prototype.startWithTarget.call(this,f);var e=this._startPosition,h=this._toConfig,g=this._config;g[0]=cc.pSub(h[0],e),g[1]=cc.pSub(h[1],e),g[2]=cc.pSub(h[2],e)}}),cc.BezierTo.create=function(d,c){return new cc.BezierTo(d,c)},cc.ScaleTo=cc.ActionInterval.extend({_scaleX:1,_scaleY:1,_startScaleX:1,_startScaleY:1,_endScaleX:0,_endScaleY:0,_deltaX:0,_deltaY:0,ctor:function(e,d,f){cc.ActionInterval.prototype.ctor.call(this),void 0!==d&&this.initWithDuration(e,d,f)},initWithDuration:function(e,d,f){return cc.ActionInterval.prototype.initWithDuration.call(this,e)?(this._endScaleX=d,this._endScaleY=null!=f?f:d,!0):!1},clone:function(){var b=new cc.ScaleTo;return this._cloneDecoration(b),b.initWithDuration(this._duration,this._endScaleX,this._endScaleY),b},startWithTarget:function(b){cc.ActionInterval.prototype.startWithTarget.call(this,b),this._startScaleX=b.scaleX,this._startScaleY=b.scaleY,this._deltaX=this._endScaleX-this._startScaleX,this._deltaY=this._endScaleY-this._startScaleY},update:function(b){b=this._computeEaseTime(b),this.target&&(this.target.scaleX=this._startScaleX+this._deltaX*b,this.target.scaleY=this._startScaleY+this._deltaY*b)}}),cc.ScaleTo.create=function(f,e,h){var g=new cc.ScaleTo;return g.initWithDuration(f,e,h),g},cc.ScaleBy=cc.ScaleTo.extend({startWithTarget:function(b){cc.ScaleTo.prototype.startWithTarget.call(this,b),this._deltaX=this._startScaleX*this._endScaleX-this._startScaleX,this._deltaY=this._startScaleY*this._endScaleY-this._startScaleY},reverse:function(){var b=cc.ScaleBy.create(this._duration,1/this._endScaleX,1/this._endScaleY);return this._cloneDecoration(b),this._reverseEaseList(b),b},clone:function(){var b=new cc.ScaleBy;return this._cloneDecoration(b),b.initWithDuration(this._duration,this._endScaleX,this._endScaleY),b}}),cc.ScaleBy.create=function(e,d,f){return new cc.ScaleBy(e,d,f)},cc.Blink=cc.ActionInterval.extend({_times:0,_originalState:!1,ctor:function(d,c){cc.ActionInterval.prototype.ctor.call(this),void 0!==c&&this.initWithDuration(d,c)},initWithDuration:function(d,c){return cc.ActionInterval.prototype.initWithDuration.call(this,d)?(this._times=c,!0):!1},clone:function(){var b=new cc.Blink;return this._cloneDecoration(b),b.initWithDuration(this._duration,this._times),b},update:function(e){if(e=this._computeEaseTime(e),this.target&&!this.isDone()){var d=1/this._times,f=e%d;this.target.visible=f>d/2}},startWithTarget:function(b){cc.ActionInterval.prototype.startWithTarget.call(this,b),this._originalState=b.visible},stop:function(){this.target.visible=this._originalState,cc.ActionInterval.prototype.stop.call(this)},reverse:function(){var b=cc.Blink.create(this._duration,this._times);return this._cloneDecoration(b),this._reverseEaseList(b),b}}),cc.Blink.create=function(e,d){var f=new cc.Blink;return f.initWithDuration(e,d),f},cc.FadeTo=cc.ActionInterval.extend({_toOpacity:0,_fromOpacity:0,ctor:function(d,c){cc.ActionInterval.prototype.ctor.call(this),void 0!==c&&this.initWithDuration(d,c)},initWithDuration:function(d,c){return cc.ActionInterval.prototype.initWithDuration.call(this,d)?(this._toOpacity=c,!0):!1},clone:function(){var b=new cc.FadeTo;return this._cloneDecoration(b),b.initWithDuration(this._duration,this._toOpacity),b},update:function(d){if(d=this._computeEaseTime(d),this.target.RGBAProtocol){var c=void 0!==this._fromOpacity?this._fromOpacity:255;this.target.opacity=c+(this._toOpacity-c)*d}},startWithTarget:function(b){cc.ActionInterval.prototype.startWithTarget.call(this,b),this.target.RGBAProtocol&&(this._fromOpacity=b.opacity)}}),cc.FadeTo.create=function(d,c){return new cc.FadeTo(d,c)},cc.FadeIn=cc.FadeTo.extend({_reverseAction:null,reverse:function(){var b=new cc.FadeOut;return b.initWithDuration(this._duration,0),this._cloneDecoration(b),this._reverseEaseList(b),b},clone:function(){var b=new cc.FadeIn;return this._cloneDecoration(b),b.initWithDuration(this._duration,this._toOpacity),b},startWithTarget:function(b){this._reverseAction&&(this._toOpacity=this._reverseAction._fromOpacity),cc.FadeTo.prototype.startWithTarget.call(this,b)
  50. }}),cc.FadeIn.create=function(d,c){return null==c&&(c=255),new cc.FadeIn(d,c)},cc.FadeOut=cc.FadeTo.extend({reverse:function(){var b=new cc.FadeIn;return b._reverseAction=this,b.initWithDuration(this._duration,255),this._cloneDecoration(b),this._reverseEaseList(b),b},clone:function(){var b=new cc.FadeOut;return this._cloneDecoration(b),b.initWithDuration(this._duration,this._toOpacity),b}}),cc.FadeOut.create=function(d){var c=new cc.FadeOut;return c.initWithDuration(d,0),c},cc.TintTo=cc.ActionInterval.extend({_to:null,_from:null,ctor:function(f,e,h,g){cc.ActionInterval.prototype.ctor.call(this),this._to=cc.color(0,0,0),this._from=cc.color(0,0,0),void 0!==g&&this.initWithDuration(f,e,h,g)},initWithDuration:function(f,e,h,g){return cc.ActionInterval.prototype.initWithDuration.call(this,f)?(this._to=cc.color(e,h,g),!0):!1},clone:function(){var d=new cc.TintTo;this._cloneDecoration(d);var c=this._to;return d.initWithDuration(this._duration,c.r,c.g,c.b),d},startWithTarget:function(b){cc.ActionInterval.prototype.startWithTarget.call(this,b),this.target.RGBAProtocol&&(this._from=this.target.color)},update:function(e){e=this._computeEaseTime(e);var d=this._from,f=this._to;d&&this.target.RGBAProtocol&&(this.target.color=cc.color(d.r+(f.r-d.r)*e,d.g+(f.g-d.g)*e,d.b+(f.b-d.b)*e))}}),cc.TintTo.create=function(f,e,h,g){return new cc.TintTo(f,e,h,g)},cc.TintBy=cc.ActionInterval.extend({_deltaR:0,_deltaG:0,_deltaB:0,_fromR:0,_fromG:0,_fromB:0,ctor:function(f,e,h,g){cc.ActionInterval.prototype.ctor.call(this),void 0!==g&&this.initWithDuration(f,e,h,g)},initWithDuration:function(f,e,h,g){return cc.ActionInterval.prototype.initWithDuration.call(this,f)?(this._deltaR=e,this._deltaG=h,this._deltaB=g,!0):!1},clone:function(){var b=new cc.TintBy;return this._cloneDecoration(b),b.initWithDuration(this._duration,this._deltaR,this._deltaG,this._deltaB),b},startWithTarget:function(d){if(cc.ActionInterval.prototype.startWithTarget.call(this,d),d.RGBAProtocol){var c=d.color;this._fromR=c.r,this._fromG=c.g,this._fromB=c.b}},update:function(b){b=this._computeEaseTime(b),this.target.RGBAProtocol&&(this.target.color=cc.color(this._fromR+this._deltaR*b,this._fromG+this._deltaG*b,this._fromB+this._deltaB*b))},reverse:function(){var b=cc.TintBy.create(this._duration,-this._deltaR,-this._deltaG,-this._deltaB);return this._cloneDecoration(b),this._reverseEaseList(b),b}}),cc.TintBy.create=function(f,e,h,g){return new cc.TintBy(f,e,h,g)},cc.DelayTime=cc.ActionInterval.extend({update:function(){},reverse:function(){var b=cc.DelayTime.create(this._duration);return this._cloneDecoration(b),this._reverseEaseList(b),b},clone:function(){var b=new cc.DelayTime;return this._cloneDecoration(b),b.initWithDuration(this._duration),b}}),cc.DelayTime.create=function(b){return new cc.DelayTime(b)},cc.ReverseTime=cc.ActionInterval.extend({_other:null,ctor:function(b){cc.ActionInterval.prototype.ctor.call(this),this._other=null,b&&this.initWithAction(b)},initWithAction:function(b){if(!b){throw"cc.ReverseTime.initWithAction(): action must be non null"}if(b==this._other){throw"cc.ReverseTime.initWithAction(): the action was already passed in."}return cc.ActionInterval.prototype.initWithDuration.call(this,b._duration)?(this._other=b,!0):!1},clone:function(){var b=new cc.ReverseTime;return this._cloneDecoration(b),b.initWithAction(this._other.clone()),b},startWithTarget:function(b){cc.ActionInterval.prototype.startWithTarget.call(this,b),this._other.startWithTarget(b)},update:function(b){b=this._computeEaseTime(b),this._other&&this._other.update(1-b)},reverse:function(){return this._other.clone()},stop:function(){this._other.stop(),cc.Action.prototype.stop.call(this)}}),cc.ReverseTime.create=function(b){return new cc.ReverseTime(b)},cc.Animate=cc.ActionInterval.extend({_animation:null,_nextFrame:0,_origFrame:null,_executedLoops:0,_splitTimes:null,ctor:function(b){cc.ActionInterval.prototype.ctor.call(this),this._splitTimes=[],b&&this.initWithAnimation(b)},getAnimation:function(){return this._animation},setAnimation:function(b){this._animation=b},initWithAnimation:function(t){if(!t){throw"cc.Animate.initWithAnimation(): animation must be non-NULL"}var s=t.getDuration();if(this.initWithDuration(s*t.getLoops())){this._nextFrame=0,this.setAnimation(t),this._origFrame=null,this._executedLoops=0;var r=this._splitTimes;r.length=0;var q=0,o=s/t.getTotalDelayUnits(),n=t.getFrames();cc.arrayVerifyType(n,cc.AnimationFrame);for(var m=0;m<n.length;m++){var k=n[m],j=q*o/s;q+=k.getDelayUnits(),r.push(j)}return !0}return !1},clone:function(){var b=new cc.Animate;return this._cloneDecoration(b),b.initWithAnimation(this._animation.clone()),b},startWithTarget:function(b){cc.ActionInterval.prototype.startWithTarget.call(this,b),this._animation.getRestoreOriginalFrame()&&(this._origFrame=b.displayFrame()),this._nextFrame=0,this._executedLoops=0},update:function(h){if(h=this._computeEaseTime(h),1>h){h*=this._animation.getLoops();var g=0|h;g>this._executedLoops&&(this._nextFrame=0,this._executedLoops++),h%=1
  51. }for(var m=this._animation.getFrames(),k=m.length,j=this._splitTimes,i=this._nextFrame;k>i&&j[i]<=h;i++){this.target.setSpriteFrame(m[i].getSpriteFrame()),this._nextFrame=i+1}},reverse:function(){var i=this._animation,h=i.getFrames(),o=[];if(cc.arrayVerifyType(h,cc.AnimationFrame),h.length>0){for(var n=h.length-1;n>=0;n--){var m=h[n];if(!m){break}o.push(m.clone())}}var k=cc.Animation.create(o,i.getDelayPerUnit(),i.getLoops());k.setRestoreOriginalFrame(i.getRestoreOriginalFrame());var j=cc.Animate.create(k);return this._cloneDecoration(j),this._reverseEaseList(j),j},stop:function(){this._animation.getRestoreOriginalFrame()&&this.target&&this.target.setSpriteFrame(this._origFrame),cc.Action.prototype.stop.call(this)}}),cc.Animate.create=function(b){return new cc.Animate(b)},cc.TargetedAction=cc.ActionInterval.extend({_action:null,_forcedTarget:null,ctor:function(d,c){cc.ActionInterval.prototype.ctor.call(this),c&&this.initWithTarget(d,c)},initWithTarget:function(d,c){return this.initWithDuration(c._duration)?(this._forcedTarget=d,this._action=c,!0):!1},clone:function(){var b=new cc.TargetedAction;return this._cloneDecoration(b),b.initWithTarget(this._forcedTarget,this._action.clone()),b},startWithTarget:function(b){cc.ActionInterval.prototype.startWithTarget.call(this,b),this._action.startWithTarget(this._forcedTarget)},stop:function(){this._action.stop()},update:function(b){b=this._computeEaseTime(b),this._action.update(b)},getForcedTarget:function(){return this._forcedTarget},setForcedTarget:function(b){this._forcedTarget!=b&&(this._forcedTarget=b)}}),cc.TargetedAction.create=function(d,c){return new cc.TargetedAction(d,c)};cc.HashElement=cc.Class.extend({actions:null,target:null,actionIndex:0,currentAction:null,currentActionSalvaged:!1,paused:!1,hh:null,ctor:function(){this.actions=[],this.target=null,this.actionIndex=0,this.currentAction=null,this.currentActionSalvaged=!1,this.paused=!1,this.hh=null}}),cc.ActionManager=cc.Class.extend({_hashTargets:null,_arrayTargets:null,_currentTarget:null,_currentTargetSalvaged:!1,_searchElementByTarget:function(e,d){for(var f=0;f<e.length;f++){if(d==e[f].target){return e[f]}}return null},ctor:function(){this._hashTargets={},this._arrayTargets=[],this._currentTarget=null,this._currentTargetSalvaged=!1},addAction:function(f,e,h){if(!f){throw"cc.ActionManager.addAction(): action must be non-null"}if(!e){throw"cc.ActionManager.addAction(): action must be non-null"}var g=this._hashTargets[e.__instanceId];g||(g=new cc.HashElement,g.paused=h,g.target=e,this._hashTargets[e.__instanceId]=g,this._arrayTargets.push(g)),this._actionAllocWithHashElement(g),g.actions.push(f),f.startWithTarget(e)},removeAllActions:function(){for(var e=this._arrayTargets,d=0;d<e.length;d++){var f=e[d];f&&this.removeAllActionsFromTarget(f.target,!0)}},removeAllActionsFromTarget:function(e,d){if(null!=e){var f=this._hashTargets[e.__instanceId];f&&(-1===f.actions.indexOf(f.currentAction)||f.currentActionSalvaged||(f.currentActionSalvaged=!0),f.actions.length=0,this._currentTarget!=f||d?this._deleteHashElement(f):this._currentTargetSalvaged=!0)}},removeAction:function(f){if(null!=f){var e=f.getOriginalTarget(),h=this._hashTargets[e.__instanceId];if(h){for(var g=0;g<h.actions.length;g++){if(h.actions[g]==f){h.actions.splice(g,1);break}}}else{cc.log(cc._LogInfos.ActionManager_removeAction)}}},removeActionByTag:function(h,g){h==cc.ACTION_TAG_INVALID&&cc.log(cc._LogInfos.ActionManager_addAction),cc.assert(g,cc._LogInfos.ActionManager_addAction);var m=this._hashTargets[g.__instanceId];if(m){for(var k=m.actions.length,j=0;k>j;++j){var i=m.actions[j];if(i&&i.getTag()===h&&i.getOriginalTarget()==g){this._removeActionAtIndex(j,m);break}}}},getActionByTag:function(g,f){g==cc.ACTION_TAG_INVALID&&cc.log(cc._LogInfos.ActionManager_getActionByTag);var j=this._hashTargets[f.__instanceId];if(j){if(null!=j.actions){for(var i=0;i<j.actions.length;++i){var h=j.actions[i];if(h&&h.getTag()===g){return h}}}cc.log(cc._LogInfos.ActionManager_getActionByTag_2,g)}return null},numberOfRunningActionsInTarget:function(d){var c=this._hashTargets[d.__instanceId];return c?c.actions?c.actions.length:0:0},pauseTarget:function(d){var c=this._hashTargets[d.__instanceId];c&&(c.paused=!0)},resumeTarget:function(d){var c=this._hashTargets[d.__instanceId];c&&(c.paused=!1)},pauseAllRunningActions:function(){for(var f=[],e=this._arrayTargets,h=0;h<e.length;h++){var g=e[h];g&&!g.paused&&(g.paused=!0,f.push(g.target))}return f},resumeTargets:function(d){if(d){for(var c=0;c<d.length;c++){d[c]&&this.resumeTarget(d[c])}}},purgeSharedManager:function(){cc.director.getScheduler().unscheduleUpdateForTarget(this)},_removeActionAtIndex:function(e,d){var f=d.actions[e];f!=d.currentAction||d.currentActionSalvaged||(d.currentActionSalvaged=!0),d.actions.splice(e,1),d.actionIndex>=e&&d.actionIndex--,0==d.actions.length&&(this._currentTarget==d?this._currentTargetSalvaged=!0:this._deleteHashElement(d))},_deleteHashElement:function(b){b&&(delete this._hashTargets[b.target.__instanceId],cc.arrayRemoveObject(this._arrayTargets,b),b.actions=null,b.target=null)
  52. },_actionAllocWithHashElement:function(b){null==b.actions&&(b.actions=[])},update:function(g){for(var j,f=this._arrayTargets,i=0;i<f.length;i++){if(this._currentTarget=f[i],j=this._currentTarget,!j.paused){for(j.actionIndex=0;j.actionIndex<j.actions.length;j.actionIndex++){if(j.currentAction=j.actions[j.actionIndex],j.currentAction){if(j.currentActionSalvaged=!1,j.currentAction.step(g*(j.currentAction._speedMethod?j.currentAction._speed:1)),j.currentActionSalvaged){j.currentAction=null}else{if(j.currentAction.isDone()){j.currentAction.stop();var h=j.currentAction;j.currentAction=null,this.removeAction(h)}}j.currentAction=null}}}this._currentTargetSalvaged&&0===j.actions.length&&this._deleteHashElement(j)}}});cc.ActionTweenDelegate=cc.Class.extend({updateTweenAction:function(){}}),cc.ActionTween=cc.ActionInterval.extend({key:"",from:0,to:0,delta:0,ctor:function(f,e,h,g){cc.ActionInterval.prototype.ctor.call(this),this.key="",void 0!==g&&this.initWithDuration(f,e,h,g)},initWithDuration:function(f,e,h,g){return cc.ActionInterval.prototype.initWithDuration.call(this,f)?(this.key=e,this.to=g,this.from=h,!0):!1},startWithTarget:function(b){if(!b||!b.updateTweenAction){throw"cc.ActionTween.startWithTarget(): target must be non-null, and target must implement updateTweenAction function"}cc.ActionInterval.prototype.startWithTarget.call(this,b),this.delta=this.to-this.from},update:function(b){this.target.updateTweenAction(this.to-this.delta*(1-b),this.key)},reverse:function(){return cc.ActionTween.create(this.duration,this.key,this.to,this.from)},clone:function(){var b=new cc.ActionTween;return b.initWithDuration(this._duration,this.key,this.from,this.to),b}}),cc.ActionTween.create=function(g,f,j,i){var h=new cc.ActionTween;return h.initWithDuration(g,f,j,i)?h:null},cc.action=cc.Action.create,cc.speed=cc.Speed.create,cc.follow=cc.Follow.create,cc.orbitCamera=cc.OrbitCamera.create,cc.cardinalSplineTo=cc.CardinalSplineTo.create,cc.cardinalSplineBy=cc.CardinalSplineBy.create,cc.catmullRomTo=cc.CatmullRomTo.create,cc.catmullRomBy=cc.CatmullRomBy.create,cc.show=cc.Show.create,cc.hide=cc.Hide.create,cc.toggleVisibility=cc.ToggleVisibility.create,cc.removeSelf=cc.RemoveSelf.create,cc.flipX=cc.FlipX.create,cc.flipY=cc.FlipY.create,cc.place=cc.Place.create,cc.callFunc=cc.CallFunc.create,cc.actionInterval=cc.ActionInterval.create,cc.sequence=cc.Sequence.create,cc.repeat=cc.Repeat.create,cc.repeatForever=cc.RepeatForever.create,cc.spawn=cc.Spawn.create,cc.rotateTo=cc.RotateTo.create,cc.rotateBy=cc.RotateBy.create,cc.moveBy=cc.MoveBy.create,cc.moveTo=cc.MoveTo.create,cc.skewTo=cc.SkewTo.create,cc.skewBy=cc.SkewBy.create,cc.jumpBy=cc.JumpBy.create,cc.jumpTo=cc.JumpTo.create,cc.bezierBy=cc.BezierBy.create,cc.bezierTo=cc.BezierTo.create,cc.scaleTo=cc.ScaleTo.create,cc.scaleBy=cc.ScaleBy.create,cc.blink=cc.Blink.create,cc.fadeTo=cc.FadeTo.create,cc.fadeIn=cc.FadeIn.create,cc.fadeOut=cc.FadeOut.create,cc.tintTo=cc.TintTo.create,cc.tintBy=cc.TintBy.create,cc.delayTime=cc.DelayTime.create,cc.reverseTime=cc.ReverseTime.create,cc.animate=cc.Animate.create,cc.targetedAction=cc.TargetedAction.create,cc.actionTween=cc.ActionTween.create;