var cc = cc || {}; cc._tmp = cc._tmp || {}; cc._LogInfos = {}; _p = window; _p = Object.prototype; delete window._p; cc.newElement = function(a) { return document.createElement(a) }; cc._addEventListener = function(a, b, c, d) { a.addEventListener(b, c, d) }; cc._isNodeJs = "undefined" !== typeof require && require("fs"); cc.each = function(a, b, c) { if (a) if (a instanceof Array) for (var d = 0, e = a.length; d < e && !1 !== b.call(c, a[d], d); d++); else for (d in a) if (!1 === b.call(c, a[d], d)) break }; cc.extend = function(a) { var b = 2 <= arguments.length ? Array.prototype.slice.call(arguments, 1) : []; cc.each(b, function(b) { for (var d in b) b.hasOwnProperty(d) && (a[d] = b[d]) }); return a }; cc.isFunction = function(a) { return "function" === typeof a }; cc.isNumber = function(a) { return "number" === typeof a || "[object Number]" === Object.prototype.toString.call(a) }; cc.isString = function(a) { return "string" === typeof a || "[object String]" === Object.prototype.toString.call(a) }; cc.isArray = function(a) { return Array.isArray(a) || "object" === typeof a && "[object Array]" === Object.prototype.toString.call(a) }; cc.isUndefined = function(a) { return "undefined" === typeof a }; cc.isObject = function(a) { return "object" === typeof a && "[object Object]" === Object.prototype.toString.call(a) }; cc.isCrossOrigin = function(a) { if (!a) return cc.log("invalid URL"), !1; var b = a.indexOf("://"); if (-1 === b) return !1; b = a.indexOf("/", b + 3); return (-1 === b ? a : a.substring(0, b)) !== location.origin }; cc.AsyncPool = function(a, b, c, d, e) { var f = this; f._srcObj = a; f._limit = b; f._pool = []; f._iterator = c; f._iteratorTarget = e; f._onEnd = d; f._onEndTarget = e; f._results = a instanceof Array ? [] : {}; f._isErr = !1; cc.each(a, function(a, b) { f._pool.push({ index: b, value: a }) }); f.size = f._pool.length; f.finishedSize = 0; f._workingSize = 0; f._limit = f._limit || f.size; f.onIterator = function(a, b) { f._iterator = a; f._iteratorTarget = b }; f.onEnd = function(a, b) { f._onEnd = a; f._onEndTarget = b }; f._handleItem = function() { var a = this; if (!(0 === a._pool.length || a._workingSize >= a._limit)) { var b = a._pool.shift(), c = b.value, d = b.index; a._workingSize++; a._iterator.call(a._iteratorTarget, c, d, function(b) { if (!a._isErr) if (a.finishedSize++, a._workingSize--, b) a._isErr = !0, a._onEnd && a._onEnd.call(a._onEndTarget, b); else { var c = Array.prototype.slice.call(arguments, 1); a._results[this.index] = c[0]; a.finishedSize === a.size ? a._onEnd && a._onEnd.call(a._onEndTarget, null, a._results) : a._handleItem() } }.bind(b), a) } }; f.flow = function() { if (0 === this._pool.length) this._onEnd && this._onEnd.call(this._onEndTarget, null, []); else for (var a = 0; a < this._limit; a++) this._handleItem() } }; cc.async = { series: function(a, b, c) { a = new cc.AsyncPool(a, 1, function(a, b, f) { a.call(c, f) }, b, c); a.flow(); return a }, parallel: function(a, b, c) { a = new cc.AsyncPool(a, 0, function(a, b, f) { a.call(c, f) }, b, c); a.flow(); return a }, waterfall: function(a, b, c) { var d = [], e = [null], f = new cc.AsyncPool(a, 1, function(b, f, k) { d.push(function(b) { d = Array.prototype.slice.call(arguments, 1); a.length - 1 === f && (e = e.concat(d)); k.apply(null, arguments) }); b.apply(c, d) }, function(a) { if (b) { if (a) return b.call(c, a); b.apply(c, e) } }); f.flow(); return f }, map: function(a, b, c, d) { var e = b; "object" === typeof b && (c = b.cb, d = b.iteratorTarget, e = b.iterator); a = new cc.AsyncPool(a, 0, e, c, d); a.flow(); return a }, mapLimit: function(a, b, c, d, e) { a = new cc.AsyncPool(a, b, c, d, e); a.flow(); return a } }; cc.path = { join: function() { for (var a = arguments.length, b = "", c = 0; c < a; c++) b = (b + ("" === b ? "" : "/") + arguments[c]).replace(/(\/|\\\\)$/, ""); return b }, extname: function(a) { return (a = /(\.[^\.\/\?\\]*)(\?.*)?$/.exec(a)) ? a[1] : null }, mainFileName: function(a) { if (a) { var b = a.lastIndexOf("."); if (-1 !== b) return a.substring(0, b) } return a }, basename: function(a, b) { var c = a.indexOf("?"); 0 < c && (a = a.substring(0, c)); c = /(\/|\\\\)([^(\/|\\\\)]+)$/g.exec(a.replace(/(\/|\\\\)$/, "")); if (!c) return null; c = c[2]; return b && a.substring(a.length - b.length).toLowerCase() === b.toLowerCase() ? c.substring(0, c.length - b.length) : c }, dirname: function(a) { return a.replace(/((.*)(\/|\\|\\\\))?(.*?\..*$)?/, "$2") }, changeExtname: function(a, b) { b = b || ""; var c = a.indexOf("?"), d = ""; 0 < c && (d = a.substring(c), a = a.substring(0, c)); c = a.lastIndexOf("."); return 0 > c ? a + b + d : a.substring(0, c) + b + d }, changeBasename: function(a, b, c) { if (0 === b.indexOf(".")) return this.changeExtname(a, b); var d = a.indexOf("?"), e = ""; c = c ? this.extname(a) : ""; 0 < d && (e = a.substring(d), a = a.substring(0, d)); d = a.lastIndexOf("/"); return a.substring(0, 0 >= d ? 0 : d + 1) + b + c + e } }; cc.loader = { _jsCache: {}, _register: {}, _langPathCache: {}, _aliases: {}, resPath: "", audioPath: "", cache: {}, getXMLHttpRequest: function() { return window.XMLHttpRequest ? new window.XMLHttpRequest : new ActiveXObject("MSXML2.XMLHTTP") }, _getArgs4Js: function(a) { var b = a[0], c = a[1], d = a[2], e = ["", null, null]; if (1 === a.length) e[1] = b instanceof Array ? b : [b]; else if (2 === a.length) "function" === typeof c ? (e[1] = b instanceof Array ? b : [b], e[2] = c) : (e[0] = b || "", e[1] = c instanceof Array ? c : [c]); else if (3 === a.length) e[0] = b || "", e[1] = c instanceof Array ? c : [c], e[2] = d; else throw "arguments error to load js!"; return e }, loadJs: function(a, b, c) { var d = this, e = d._jsCache, f = d._getArgs4Js(arguments), g = f[0], h = f[1], f = f[2]; - 1 < navigator.userAgent.indexOf("Trident/5") ? d._loadJs4Dependency(g, h, 0, f) : cc.async.map(h, function(a, b, c) { a = cc.path.join(g, a); if (e[a]) return c(null); d._createScript(a, !1, c) }, f) }, loadJsWithImg: function(a, b, c) { var d = this._loadJsImg(), e = this._getArgs4Js(arguments); this.loadJs(e[0], e[1], function(a) { if (a) throw a; d.parentNode.removeChild(d); if (e[2]) e[2]() }) }, _createScript: function(a, b, c) { var d = document, e = cc.newElement("script"); e.async = b; this._jsCache[a] = !0; cc.game.config.noCache && "string" === typeof a ? this._noCacheRex.test(a) ? e.src = a + "\x26_t\x3d" + (new Date - 0) : e.src = a + "?_t\x3d" + (new Date - 0) : e.src = a; cc._addEventListener(e, "load", function() { e.parentNode.removeChild(e); this.removeEventListener("load", arguments.callee, !1); c() }, !1); cc._addEventListener(e, "error", function() { e.parentNode.removeChild(e); c("Load " + a + " failed!") }, !1); d.body.appendChild(e) }, _loadJs4Dependency: function(a, b, c, d) { if (c >= b.length) d && d(); else { var e = this; e._createScript(cc.path.join(a, b[c]), !1, function(f) { if (f) return d(f); e._loadJs4Dependency(a, b, c + 1, d) }) } }, _loadJsImg: function() { var a = document, b = a.getElementById("cocos2d_loadJsImg"); if (!b) { b = cc.newElement("img"); cc._loadingImage && (b.src = cc._loadingImage); a = a.getElementById(cc.game.config.id); a.style.backgroundColor = "black"; a.parentNode.appendChild(b); var c = getComputedStyle ? getComputedStyle(a) : a.currentStyle; c || (c = { width: a.width, height: a.height }); b.style.left = a.offsetLeft + (parseFloat(c.width) - b.width) / 2 + "px"; b.style.top = a.offsetTop + (parseFloat(c.height) - b.height) / 2 + "px"; b.style.position = "absolute" } return b }, loadTxt: function(a, b) { if (cc._isNodeJs) require("fs").readFile(a, function(a, c) { a ? b(a) : b(null, c.toString()) }); else { var c = this.getXMLHttpRequest(), d = "load " + a + " failed!"; c.open("GET", a, !0); /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent) ? (c.setRequestHeader("Accept-Charset", "utf-8"), c.onreadystatechange = function() { 4 === c.readyState && (200 === c.status ? b(null, c.responseText) : b(d)) }) : (c.overrideMimeType && c.overrideMimeType("text/plain; charset\x3dutf-8"), c.onload = function() { 4 === c.readyState && (200 === c.status ? b(null, c.responseText) : b(d)) }); c.send(null) } }, _loadTxtSync: function(a) { if (cc._isNodeJs) return require("fs").readFileSync(a).toString(); var b = this.getXMLHttpRequest(); b.open("GET", a, !1); /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent) ? b.setRequestHeader("Accept-Charset", "utf-8") : b.overrideMimeType && b.overrideMimeType("text/plain; charset\x3dutf-8"); b.send(null); return 4 === !b.readyState || 200 !== b.status ? null : b.responseText }, loadCsb: function(a, b) { var c = new XMLHttpRequest; c.open("GET", a, !0); c.responseType = "arraybuffer"; c.onload = function() { var d = c.response; d && (window.msg = d); 4 === c.readyState && (200 === c.status ? b(null, c.response) : b("load " + a + " failed!")) }; c.send(null) }, loadJson: function(a, b) { this.loadTxt(a, function(c, d) { if (c) b(c); else { try { var e = JSON.parse(d) } catch (f) { throw "parse json [" + a + "] failed : " + f; } b(null, e) } }) }, _checkIsImageURL: function(a) { return null != /(\.png)|(\.jpg)|(\.bmp)|(\.jpeg)|(\.gif)/.exec(a) }, loadImg: function(a, b, c) { var d = { isCrossOrigin: !0 }; void 0 !== c ? d.isCrossOrigin = null === b.isCrossOrigin ? d.isCrossOrigin : b.isCrossOrigin : void 0 !== b && (c = b); var e = this.getRes(a); if (e) return c && c(null, e), e; e = new Image; d.isCrossOrigin && "file://" !== location.origin && (e.crossOrigin = "Anonymous"); var f = function() { this.removeEventListener("load", f, !1); this.removeEventListener("error", h, !1); cc.loader.cache[a] = e; c && c(null, e) }, g = this, h = function() { this.removeEventListener("error", h, !1); e.crossOrigin && "anonymous" === e.crossOrigin.toLowerCase() ? (d.isCrossOrigin = !1, g.release(a), cc.loader.loadImg(a, d, c)) : "function" === typeof c && c("load image failed") }; cc._addEventListener(e, "load", f); cc._addEventListener(e, "error", h); e.src = a; return e }, _loadResIterator: function(a, b, c) { var d = this, e = null, f = a.type; f ? (f = "." + f.toLowerCase(), e = a.src ? a.src : a.name + f) : (e = a, f = cc.path.extname(e)); if (b = d.getRes(e)) return c(null, b); b = null; f && (b = d._register[f.toLowerCase()]); if (!b) return cc.error("loader for [" + f + "] not exists!"), c(); f = b.getBasePath ? b.getBasePath() : d.resPath; f = d.getUrl(f, e); cc.game.config.noCache && "string" === typeof f && (f = d._noCacheRex.test(f) ? f + ("\x26_t\x3d" + (new Date - 0)) : f + ("?_t\x3d" + (new Date - 0))); b.load(f, e, a, function(a, b) { a ? (cc.log(a), d.cache[e] = null, delete d.cache[e], c()) : (d.cache[e] = b, c(null, b)) }) }, _noCacheRex: /\?/, getUrl: function(a, b) { var c = this._langPathCache, d = cc.path; if (void 0 !== a && void 0 === b) { b = a; var e = d.extname(b), e = e ? e.toLowerCase() : ""; a = (e = this._register[e]) ? e.getBasePath ? e.getBasePath() : this.resPath : this.resPath } b = cc.path.join(a || "", b); if (b.match(/[\/(\\\\)]lang[\/(\\\\)]/i)) { if (c[b]) return c[b]; d = d.extname(b) || ""; b = c[b] = b.substring(0, b.length - d.length) + "_" + cc.sys.language + d } return b }, load: function(a, b, c) { var d = this, e = arguments.length; if (0 === e) throw "arguments error!"; 3 === e ? "function" === typeof b && (b = "function" === typeof c ? { trigger: b, cb: c } : { cb: b, cbTarget: c }) : 2 === e ? "function" === typeof b && (b = { cb: b }) : 1 === e && (b = {}); a instanceof Array || (a = [a]); e = new cc.AsyncPool(a, 0, function(a, c, e, k) { d._loadResIterator(a, c, function(a) { if (a) return e(a); var c = Array.prototype.slice.call(arguments, 1); b.trigger && b.trigger.call(b.triggerTarget, c[0], k.size, k.finishedSize); e(null, c[0]) }) }, b.cb, b.cbTarget); e.flow(); return e }, _handleAliases: function(a, b) { var c = this._aliases, d = [], e; for (e in a) { var f = a[e]; c[e] = f; d.push(f) } this.load(d, b) }, loadAliases: function(a, b) { var c = this, d = c.getRes(a); d ? c._handleAliases(d.filenames, b) : c.load(a, function(a, d) { c._handleAliases(d[0].filenames, b) }) }, register: function(a, b) { if (a && b) { if ("string" === typeof a) return this._register[a.trim().toLowerCase()] = b; for (var c = 0, d = a.length; c < d; c++) this._register["." + a[c].trim().toLowerCase()] = b } }, getRes: function(a) { return this.cache[a] || this.cache[this._aliases[a]] }, release: function(a) { var b = this.cache, c = this._aliases; delete b[a]; delete b[c[a]]; delete c[a] }, releaseAll: function() { var a = this.cache, b = this._aliases, c; for (c in a) delete a[c]; for (c in b) delete b[c] } }; cc.formatStr = function() { var a = arguments, b = a.length; if (1 > b) return ""; var c = a[0], d = !0; "object" === typeof c && (d = !1); for (var e = 1; e < b; ++e) { var f = a[e]; if (d) for (;;) { var g = null; if ("number" === typeof f && (g = c.match(/(%d)|(%s)/))) { c = c.replace(/(%d)|(%s)/, f); break } c = (g = c.match(/%s/)) ? c.replace(/%s/, f) : c + (" " + f); break } else c += " " + f } return c }; (function() { var a = window, b, c; cc.isUndefined(document.hidden) ? cc.isUndefined(document.mozHidden) ? cc.isUndefined(document.msHidden) ? cc.isUndefined(document.webkitHidden) || (b = "webkitHidden", c = "webkitvisibilitychange") : (b = "msHidden", c = "msvisibilitychange") : (b = "mozHidden", c = "mozvisibilitychange") : (b = "hidden", c = "visibilitychange"); var d = function() { cc.eventManager && cc.game._eventHide && cc.eventManager.dispatchEvent(cc.game._eventHide) }, e = function() { cc.eventManager && cc.game._eventShow && cc.eventManager.dispatchEvent(cc.game._eventShow); cc.game._intervalId && (window.cancelAnimationFrame(cc.game._intervalId), cc.game._runMainLoop()) }; b ? cc._addEventListener(document, c, function() { document[b] ? d() : e() }, !1) : (cc._addEventListener(a, "blur", d, !1), cc._addEventListener(a, "focus", e, !1)); - 1 < navigator.userAgent.indexOf("MicroMessenger") && (a.onfocus = function() { e() }); "onpageshow" in window && "onpagehide" in window && (cc._addEventListener(a, "pagehide", d, !1), cc._addEventListener(a, "pageshow", e, !1)); c = a = null })(); cc.log = cc.warn = cc.error = cc.assert = function() {}; cc.create3DContext = function(a, b) { for (var c = ["webgl", "experimental-webgl", "webkit-3d", "moz-webgl"], d = null, e = 0; e < c.length; ++e) { try { d = a.getContext(c[e], b) } catch (f) {} if (d) break } return d }; cc._initSys = function(a, b) { cc._RENDER_TYPE_CANVAS = 0; cc._RENDER_TYPE_WEBGL = 1; cc.sys = {}; var c = cc.sys; c.LANGUAGE_ENGLISH = "en"; c.LANGUAGE_CHINESE = "zh"; c.LANGUAGE_FRENCH = "fr"; c.LANGUAGE_ITALIAN = "it"; c.LANGUAGE_GERMAN = "de"; c.LANGUAGE_SPANISH = "es"; c.LANGUAGE_DUTCH = "du"; c.LANGUAGE_RUSSIAN = "ru"; c.LANGUAGE_KOREAN = "ko"; c.LANGUAGE_JAPANESE = "ja"; c.LANGUAGE_HUNGARIAN = "hu"; c.LANGUAGE_PORTUGUESE = "pt"; c.LANGUAGE_ARABIC = "ar"; c.LANGUAGE_NORWEGIAN = "no"; c.LANGUAGE_POLISH = "pl"; c.OS_IOS = "iOS"; c.OS_ANDROID = "Android"; c.OS_WINDOWS = "Windows"; c.OS_MARMALADE = "Marmalade"; c.OS_LINUX = "Linux"; c.OS_BADA = "Bada"; c.OS_BLACKBERRY = "Blackberry"; c.OS_OSX = "OS X"; c.OS_WP8 = "WP8"; c.OS_WINRT = "WINRT"; c.OS_UNKNOWN = "Unknown"; c.UNKNOWN = 0; c.IOS = 1; c.ANDROID = 2; c.WIN32 = 3; c.MARMALADE = 4; c.LINUX = 5; c.BADA = 6; c.BLACKBERRY = 7; c.MACOS = 8; c.NACL = 9; c.EMSCRIPTEN = 10; c.TIZEN = 11; c.QT5 = 12; c.WP8 = 13; c.WINRT = 14; c.MOBILE_BROWSER = 100; c.DESKTOP_BROWSER = 101; c.BROWSER_TYPE_WECHAT = "wechat"; c.BROWSER_TYPE_ANDROID = "androidbrowser"; c.BROWSER_TYPE_IE = "ie"; c.BROWSER_TYPE_QQ = "qqbrowser"; c.BROWSER_TYPE_MOBILE_QQ = "mqqbrowser"; c.BROWSER_TYPE_UC = "ucbrowser"; c.BROWSER_TYPE_360 = "360browser"; c.BROWSER_TYPE_BAIDU_APP = "baiduboxapp"; c.BROWSER_TYPE_BAIDU = "baidubrowser"; c.BROWSER_TYPE_MAXTHON = "maxthon"; c.BROWSER_TYPE_OPERA = "opera"; c.BROWSER_TYPE_OUPENG = "oupeng"; c.BROWSER_TYPE_MIUI = "miuibrowser"; c.BROWSER_TYPE_FIREFOX = "firefox"; c.BROWSER_TYPE_SAFARI = "safari"; c.BROWSER_TYPE_CHROME = "chrome"; c.BROWSER_TYPE_LIEBAO = "liebao"; c.BROWSER_TYPE_QZONE = "qzone"; c.BROWSER_TYPE_SOUGOU = "sogou"; c.BROWSER_TYPE_UNKNOWN = "unknown"; c.isNative = !1; var d = [c.BROWSER_TYPE_BAIDU, c.BROWSER_TYPE_OPERA, c.BROWSER_TYPE_FIREFOX, c.BROWSER_TYPE_CHROME, c.BROWSER_TYPE_SAFARI], e = [c.OS_IOS, c.OS_WINDOWS, c.OS_OSX, c.OS_LINUX], f = [c.BROWSER_TYPE_BAIDU, c.BROWSER_TYPE_OPERA, c.BROWSER_TYPE_FIREFOX, c.BROWSER_TYPE_CHROME, c.BROWSER_TYPE_BAIDU_APP, c.BROWSER_TYPE_SAFARI, c.BROWSER_TYPE_UC, c.BROWSER_TYPE_QQ, c.BROWSER_TYPE_MOBILE_QQ, c.BROWSER_TYPE_IE], g = window, h = g.navigator, k = document, m = k.documentElement, n = h.userAgent.toLowerCase(); c.isMobile = -1 !== n.indexOf("mobile") || -1 !== n.indexOf("android"); c.platform = c.isMobile ? c.MOBILE_BROWSER : c.DESKTOP_BROWSER; var p = h.language, p = (p = p ? p : h.browserLanguage) ? p.split("-")[0] : c.LANGUAGE_ENGLISH; c.language = p; var p = c.BROWSER_TYPE_UNKNOWN, t = n.match(/sogou|qzone|liebao|micromessenger|qqbrowser|ucbrowser|360 aphone|360browser|baiduboxapp|baidubrowser|maxthon|trident|oupeng|opera|miuibrowser|firefox/i) || n.match(/chrome|safari/i); t && 0 < t.length ? (p = t[0], "micromessenger" === p ? p = c.BROWSER_TYPE_WECHAT : "safari" === p && n.match(/android.*applewebkit/) ? p = c.BROWSER_TYPE_ANDROID : "trident" === p ? p = c.BROWSER_TYPE_IE : "360 aphone" === p && (p = c.BROWSER_TYPE_360)) : n.indexOf("iphone") && n.indexOf("mobile") && (p = "safari"); c.browserType = p; p = n.match(/(iPad|iPhone|iPod)/i) ? !0 : !1; n = n.match(/android/i) || h.platform.match(/android/i) ? !0 : !1; t = c.OS_UNKNOWN; - 1 !== h.appVersion.indexOf("Win") ? t = c.OS_WINDOWS : p ? t = c.OS_IOS : -1 !== h.appVersion.indexOf("Mac") ? t = c.OS_OSX : -1 !== h.appVersion.indexOf("X11") && -1 === h.appVersion.indexOf("Linux") ? t = c.OS_UNIX : n ? t = c.OS_ANDROID : -1 !== h.appVersion.indexOf("Linux") && (t = c.OS_LINUX); c.os = t; c._supportMultipleAudio = -1 < f.indexOf(c.browserType); var f = parseInt(a[b.renderMode]), n = cc._RENDER_TYPE_WEBGL, t = cc.newElement("Canvas"), r = cc._supportRender = !0, r = p ? !window.WebGLRenderingContext || -1 === e.indexOf(c.os) : !window.WebGLRenderingContext || -1 === d.indexOf(c.browserType) || -1 === e.indexOf(c.os); if (1 === f || 0 === f && r || "file://" === location.origin) n = cc._RENDER_TYPE_CANVAS; c._canUseCanvasNewBlendModes = function() { var a = document.createElement("canvas"); a.width = 1; a.height = 1; a = a.getContext("2d"); a.fillStyle = "#000"; a.fillRect(0, 0, 1, 1); a.globalCompositeOperation = "multiply"; var b = document.createElement("canvas"); b.width = 1; b.height = 1; var c = b.getContext("2d"); c.fillStyle = "#fff"; c.fillRect(0, 0, 1, 1); a.drawImage(b, 0, 0, 1, 1); return 0 === a.getImageData(0, 0, 1, 1).data[0] }; c._supportCanvasNewBlendModes = c._canUseCanvasNewBlendModes(); n !== cc._RENDER_TYPE_WEBGL || g.WebGLRenderingContext && cc.create3DContext(t, { stencil: !0, preserveDrawingBuffer: !0 }) || (0 === f ? n = cc._RENDER_TYPE_CANVAS : cc._supportRender = !1); if (n === cc._RENDER_TYPE_CANVAS) try { t.getContext("2d") } catch (u) { cc._supportRender = !1 } cc._renderType = n; try { c._supportWebAudio = !!(g.AudioContext || g.webkitAudioContext || g.mozAudioContext) } catch (s) { c._supportWebAudio = !1 } try { var v = c.localStorage = g.localStorage; v.setItem("storage", ""); v.removeItem("storage"); v = null } catch (x) { "SECURITY_ERR" !== x.name && "QuotaExceededError" !== x.name || cc.warn("Warning: localStorage isn't enabled. Please confirm browser cookie or privacy option"), c.localStorage = function() {} } d = c.capabilities = { canvas: !0 }; cc._renderType === cc._RENDER_TYPE_WEBGL && (d.opengl = !0); if (void 0 !== m.ontouchstart || void 0 !== k.ontouchstart || h.msPointerEnabled) d.touches = !0; void 0 !== m.onmouseup && (d.mouse = !0); void 0 !== m.onkeyup && (d.keyboard = !0); if (g.DeviceMotionEvent || g.DeviceOrientationEvent) d.accelerometer = !0; c.garbageCollect = function() {}; c.dumpRoot = function() {}; c.restartVM = function() {}; c.cleanScript = function(a) {}; c.dump = function() { var a; a = "" + ("isMobile : " + this.isMobile + "\r\n"); a += "language : " + this.language + "\r\n"; a += "browserType : " + this.browserType + "\r\n"; a += "capabilities : " + JSON.stringify(this.capabilities) + "\r\n"; a += "os : " + this.os + "\r\n"; a += "platform : " + this.platform + "\r\n"; cc.log(a) }; c.openURL = function(a) { window.open(a) } }; cc.ORIENTATION_PORTRAIT = 0; cc.ORIENTATION_PORTRAIT_UPSIDE_DOWN = 1; cc.ORIENTATION_LANDSCAPE_LEFT = 2; cc.ORIENTATION_LANDSCAPE_RIGHT = 3; cc._drawingUtil = null; cc._renderContext = null; cc._canvas = null; cc._gameDiv = null; cc._rendererInitialized = !1; cc._setupCalled = !1; cc._setup = function(a, b, c) { if (!cc._setupCalled) { cc._setupCalled = !0; var d = window, e = cc.$(a) || cc.$("#" + a), f; cc.game._setAnimFrame(); "CANVAS" === e.tagName ? (b = b || e.width, c = c || e.height, f = cc.container = cc.newElement("DIV"), a = cc._canvas = e, a.parentNode.insertBefore(f, a), a.appendTo(f), f.setAttribute("id", "Cocos2dGameContainer")) : ("DIV" !== e.tagName && cc.log("Warning: target element is not a DIV or CANVAS"), b = b || e.clientWidth, c = c || e.clientHeight, f = cc.container = e, a = cc._canvas = cc.$(cc.newElement("CANVAS")), e.appendChild(a)); a.addClass("gameCanvas"); a.setAttribute("width", b || 480); a.setAttribute("height", c || 320); a.setAttribute("tabindex", 99); a.style.outline = "none"; e = f.style; e.width = (b || 480) + "px"; e.height = (c || 320) + "px"; e.margin = "0 auto"; e.position = "relative"; e.overflow = "hidden"; f.top = "100%"; cc._renderType === cc._RENDER_TYPE_WEBGL && (cc._renderContext = cc.webglContext = cc.create3DContext(a, { stencil: !0, preserveDrawingBuffer: !0, antialias: !cc.sys.isMobile, alpha: !1 })); cc._renderContext ? (d.gl = cc._renderContext, cc._drawingUtil = new cc.DrawingPrimitiveWebGL(cc._renderContext), cc._rendererInitialized = !0, cc.textureCache._initializingRenderer(), cc.shaderCache._init()) : (cc._renderContext = new cc.CanvasContextWrapper(a.getContext("2d")), cc._drawingUtil = cc.DrawingPrimitiveCanvas ? new cc.DrawingPrimitiveCanvas(cc._renderContext) : null); cc._gameDiv = f; cc.log(cc.ENGINE_VERSION); cc._setContextMenuEnable(!1); cc.sys.isMobile && (b = cc.newElement("style"), b.type = "text/css", document.body.appendChild(b), b.textContent = "body,canvas,div{ -moz-user-select: none;-webkit-user-select: none;-ms-user-select: none;-khtml-user-select: none;-webkit-tap-highlight-color:rgba(0,0,0,0);}"); cc.view = cc.EGLView._getInstance(); cc.inputManager.registerSystemEvent(cc._canvas); cc.director = cc.Director._getInstance(); cc.director.setOpenGLView && cc.director.setOpenGLView(cc.view); cc.winSize = cc.director.getWinSize(); cc.saxParser = new cc.SAXParser; cc.plistParser = new cc.PlistParser } }; cc._checkWebGLRenderMode = function() { if (cc._renderType !== cc._RENDER_TYPE_WEBGL) throw "This feature supports WebGL render mode only."; }; cc._isContextMenuEnable = !1; cc._setContextMenuEnable = function(a) { cc._isContextMenuEnable = a; cc._canvas.oncontextmenu = function() { 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, _lastTime: null, _frameTime: null, config: null, onStart: null, onStop: null, setFrameRate: function(a) { this.config[this.CONFIG_KEY.frameRate] = a; this._intervalId && window.cancelAnimationFrame(this._intervalId); this._paused = !0; this._setAnimFrame(); this._runMainLoop() }, _setAnimFrame: function() { this._lastTime = new Date; this._frameTime = 1E3 / cc.game.config[cc.game.CONFIG_KEY.frameRate]; cc.sys.os === cc.sys.OS_IOS && cc.sys.browserType === cc.sys.BROWSER_TYPE_WECHAT || 60 !== cc.game.config[cc.game.CONFIG_KEY.frameRate] ? (window.requestAnimFrame = this._stTime, window.cancelAnimationFrame = this._ctTime) : (window.requestAnimFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || this._stTime, window.cancelAnimationFrame = window.cancelAnimationFrame || window.cancelRequestAnimationFrame || window.msCancelRequestAnimationFrame || window.mozCancelRequestAnimationFrame || window.oCancelRequestAnimationFrame || window.webkitCancelRequestAnimationFrame || window.msCancelAnimationFrame || window.mozCancelAnimationFrame || window.webkitCancelAnimationFrame || window.oCancelAnimationFrame || this._ctTime) }, _stTime: function(a) { var b = (new Date).getTime(), c = Math.max(0, cc.game._frameTime - (b - cc.game._lastTime)), d = window.setTimeout(function() { a() }, c); cc.game._lastTime = b + c; return d }, _ctTime: function(a) { window.clearTimeout(a) }, _runMainLoop: function() { var a = this, b, c = cc.director; c.setDisplayStats(a.config[a.CONFIG_KEY.showFPS]); b = function() { a._paused || (c.mainLoop(), a._intervalId && window.cancelAnimationFrame(a._intervalId), a._intervalId = window.requestAnimFrame(b)) }; window.requestAnimFrame(b); a._paused = !1 }, restart: function() { cc.director.popToSceneStackLevel(0); cc.audioEngine && cc.audioEngine.end(); cc.game.onStart() }, run: function(a) { var b = this, c = function() { a && (b.config[b.CONFIG_KEY.id] = a); b._prepareCalled || b.prepare(function() { b._prepared = !0 }); cc._supportRender && (b._checkPrepare = setInterval(function() { b._prepared && (cc._setup(b.config[b.CONFIG_KEY.id]), b._runMainLoop(), b._eventHide = b._eventHide || new cc.EventCustom(b.EVENT_HIDE), b._eventHide.setUserData(b), b._eventShow = b._eventShow || new cc.EventCustom(b.EVENT_SHOW), b._eventShow.setUserData(b), b.onStart(), clearInterval(b._checkPrepare)) }, 10)) }; document.body ? c() : cc._addEventListener(window, "load", function() { this.removeEventListener("load", arguments.callee, !1); c() }, !1) }, _initConfig: function() { var a = this.CONFIG_KEY, b = function(b) { b[a.engineDir] = b[a.engineDir] || "frameworks/cocos2d-html5"; null == b[a.debugMode] && (b[a.debugMode] = 0); b[a.frameRate] = b[a.frameRate] || 60; null == b[a.renderMode] && (b[a.renderMode] = 1); return b }; if (document.ccConfig) this.config = b(document.ccConfig); else try { for (var c = document.getElementsByTagName("script"), d = 0; d < c.length; d++) { var e = c[d].getAttribute("cocos"); if ("" === e || e) break } var f, g, h; if (d < c.length) { if (f = c[d].src) h = /(.*)\//.exec(f)[0], cc.loader.resPath = h, f = cc.path.join(h, "project.json"); g = cc.loader._loadTxtSync(f) } g || (g = cc.loader._loadTxtSync("project.json")); var k = JSON.parse(g); this.config = b(k || {}) } catch (m) { cc.log("Failed to read or parse project.json"), this.config = b({}) } cc._initSys(this.config, a) }, _jsAddedCache: {}, _getJsListOfModule: function(a, b, c) { var d = this._jsAddedCache; if (d[b]) return null; c = c || ""; var e = [], f = a[b]; if (!f) throw "can not find module [" + b + "]"; b = cc.path; for (var g = 0, h = f.length; g < h; g++) { var k = f[g]; if (!d[k]) { var m = b.extname(k); m ? ".js" === m.toLowerCase() && e.push(b.join(c, k)) : (m = this._getJsListOfModule(a, k, c)) && (e = e.concat(m)); d[k] = 1 } } return e }, prepare: function(a) { var b = this, c = b.config, d = b.CONFIG_KEY, e = c[d.engineDir], f = cc.loader; if (!cc._supportRender) throw "The renderer doesn't support the renderMode " + c[d.renderMode]; b._prepareCalled = !0; var g = c[d.jsList] || []; cc.Class ? f.loadJsWithImg("", g, function(c) { if (c) throw c; b._prepared = !0; a && a() }) : (d = cc.path.join(e, "moduleConfig.json"), f.loadJson(d, function(d, f) { if (d) throw d; var m = c.modules || [], n = f.module, p = []; cc._renderType === cc._RENDER_TYPE_WEBGL ? m.splice(0, 0, "shaders") : 0 > m.indexOf("core") && m.splice(0, 0, "core"); for (var t = 0, r = m.length; t < r; t++) { var u = b._getJsListOfModule(n, m[t], e); u && (p = p.concat(u)) } p = p.concat(g); cc.loader.loadJsWithImg(p, function(c) { if (c) throw c; b._prepared = !0; a && a() }) })) } }; cc.game._initConfig(); Function.prototype.bind = Function.prototype.bind || function(a) { if (!cc.isFunction(this)) throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable"); var b = Array.prototype.slice.call(arguments, 1), c = this, d = function() {}, e = function() { return c.apply(this instanceof d && a ? this : a, b.concat(Array.prototype.slice.call(arguments))) }; d.prototype = this.prototype; e.prototype = new d; return e }; cc._LogInfos = { ActionManager_addAction: "cc.ActionManager.addAction(): action must be non-null", ActionManager_removeAction: "cocos2d: removeAction: Target not found", ActionManager_removeActionByTag: "cc.ActionManager.removeActionByTag(): an invalid tag", ActionManager_removeActionByTag_2: "cc.ActionManager.removeActionByTag(): target must be non-null", ActionManager_getActionByTag: "cc.ActionManager.getActionByTag(): an invalid tag", ActionManager_getActionByTag_2: "cocos2d : getActionByTag(tag \x3d %s): Action not found", configuration_dumpInfo: "cocos2d: **** WARNING **** CC_ENABLE_PROFILERS is defined. Disable it when you finish profiling (from ccConfig.js)", configuration_loadConfigFile: "Expected 'data' dict, but not found. Config file: %s", configuration_loadConfigFile_2: "Please load the resource first : %s", Director_resume: "cocos2d: Director: Error in gettimeofday", Director_setProjection: "cocos2d: Director: unrecognized projection", Director_popToSceneStackLevel: "cocos2d: Director: unrecognized projection", Director_popToSceneStackLevel_2: "cocos2d: Director: Error in gettimeofday", Director_popScene: "running scene should not null", Director_pushScene: "the scene should not null", arrayVerifyType: "element type is wrong!", Scheduler_scheduleCallbackForTarget: "CCSheduler#scheduleCallback. Callback already scheduled. Updating interval from:%s to %s", Scheduler_scheduleCallbackForTarget_2: "cc.scheduler.scheduleCallbackForTarget(): callback_fn should be non-null.", Scheduler_scheduleCallbackForTarget_3: "cc.scheduler.scheduleCallbackForTarget(): target should be non-null.", Scheduler_pauseTarget: "cc.Scheduler.pauseTarget():target should be non-null", Scheduler_resumeTarget: "cc.Scheduler.resumeTarget():target should be non-null", Scheduler_isTargetPaused: "cc.Scheduler.isTargetPaused():target should be non-null", Node_getZOrder: "getZOrder is deprecated. Please use getLocalZOrder instead.", Node_setZOrder: "setZOrder is deprecated. Please use setLocalZOrder instead.", Node_getRotation: "RotationX !\x3d RotationY. Don't know which one to return", Node_getScale: "ScaleX !\x3d ScaleY. Don't know which one to return", Node_addChild: "An Node can't be added as a child of itself.", Node_addChild_2: "child already added. It can't be added again", Node_addChild_3: "child must be non-null", Node_removeFromParentAndCleanup: "removeFromParentAndCleanup is deprecated. Use removeFromParent instead", Node_boundingBox: "boundingBox is deprecated. Use getBoundingBox instead", Node_removeChildByTag: "argument tag is an invalid tag", Node_removeChildByTag_2: "cocos2d: removeChildByTag(tag \x3d %s): child not found!", Node_removeAllChildrenWithCleanup: "removeAllChildrenWithCleanup is deprecated. Use removeAllChildren instead", Node_stopActionByTag: "cc.Node.stopActionBy(): argument tag an invalid tag", Node_getActionByTag: "cc.Node.getActionByTag(): argument tag is an invalid tag", Node_resumeSchedulerAndActions: "resumeSchedulerAndActions is deprecated, please use resume instead.", Node_pauseSchedulerAndActions: "pauseSchedulerAndActions is deprecated, please use pause instead.", Node__arrayMakeObjectsPerformSelector: "Unknown callback function", Node_reorderChild: "child must be non-null", Node_runAction: "cc.Node.runAction(): action must be non-null", Node_schedule: "callback function must be non-null", Node_schedule_2: "interval must be positive", Node_initWithTexture: "cocos2d: Could not initialize cc.AtlasNode. Invalid Texture.", AtlasNode_updateAtlasValues: "cc.AtlasNode.updateAtlasValues(): Shall be overridden in subclasses", AtlasNode_initWithTileFile: "", AtlasNode__initWithTexture: "cocos2d: Could not initialize cc.AtlasNode. Invalid Texture.", _EventListenerKeyboard_checkAvailable: "cc._EventListenerKeyboard.checkAvailable(): Invalid EventListenerKeyboard!", _EventListenerTouchOneByOne_checkAvailable: "cc._EventListenerTouchOneByOne.checkAvailable(): Invalid EventListenerTouchOneByOne!", _EventListenerTouchAllAtOnce_checkAvailable: "cc._EventListenerTouchAllAtOnce.checkAvailable(): Invalid EventListenerTouchAllAtOnce!", _EventListenerAcceleration_checkAvailable: "cc._EventListenerAcceleration.checkAvailable(): _onAccelerationEvent must be non-nil", EventListener_create: "Invalid parameter.", __getListenerID: "Don't call this method if the event is for touch.", eventManager__forceAddEventListener: "Invalid scene graph priority!", eventManager_addListener: "0 priority is forbidden for fixed priority since it's used for scene graph based priority.", eventManager_removeListeners: "Invalid listener type!", eventManager_setPriority: "Can't set fixed priority with scene graph based listener.", eventManager_addListener_2: "Invalid parameters.", eventManager_addListener_3: "listener must be a cc.EventListener object when adding a fixed priority listener", eventManager_addListener_4: "The listener has been registered, please don't register it again.", LayerMultiplex_initWithLayers: "parameters should not be ending with null in Javascript", LayerMultiplex_switchTo: "Invalid index in MultiplexLayer switchTo message", LayerMultiplex_switchToAndReleaseMe: "Invalid index in MultiplexLayer switchTo message", LayerMultiplex_addLayer: "cc.Layer.addLayer(): layer should be non-null", EGLView_setDesignResolutionSize: "Resolution not valid", EGLView_setDesignResolutionSize_2: "should set resolutionPolicy", inputManager_handleTouchesBegin: "The touches is more than MAX_TOUCHES, nUnusedIndex \x3d %s", swap: "cc.swap is being modified from original macro, please check usage", checkGLErrorDebug: "WebGL error %s", animationCache__addAnimationsWithDictionary: "cocos2d: cc.AnimationCache: No animations were found in provided dictionary.", animationCache__addAnimationsWithDictionary_2: "cc.AnimationCache. Invalid animation format", animationCache_addAnimations: "cc.AnimationCache.addAnimations(): File could not be found", animationCache__parseVersion1: "cocos2d: cc.AnimationCache: Animation '%s' found in dictionary without any frames - cannot add to animation cache.", animationCache__parseVersion1_2: "cocos2d: cc.AnimationCache: Animation '%s' refers to frame '%s' which is not currently in the cc.SpriteFrameCache. This frame will not be added to the animation.", animationCache__parseVersion1_3: "cocos2d: cc.AnimationCache: None of the frames for animation '%s' were found in the cc.SpriteFrameCache. Animation is not being added to the Animation Cache.", animationCache__parseVersion1_4: "cocos2d: cc.AnimationCache: An animation in your dictionary refers to a frame which is not in the cc.SpriteFrameCache. Some or all of the frames for the animation '%s' may be missing.", animationCache__parseVersion2: "cocos2d: CCAnimationCache: Animation '%s' found in dictionary without any frames - cannot add to animation cache.", animationCache__parseVersion2_2: "cocos2d: cc.AnimationCache: Animation '%s' refers to frame '%s' which is not currently in the cc.SpriteFrameCache. This frame will not be added to the animation.", animationCache_addAnimations_2: "cc.AnimationCache.addAnimations(): Invalid texture file name", Sprite_reorderChild: "cc.Sprite.reorderChild(): this child is not in children list", Sprite_ignoreAnchorPointForPosition: "cc.Sprite.ignoreAnchorPointForPosition(): it is invalid in cc.Sprite when using SpriteBatchNode", Sprite_setDisplayFrameWithAnimationName: "cc.Sprite.setDisplayFrameWithAnimationName(): Frame not found", Sprite_setDisplayFrameWithAnimationName_2: "cc.Sprite.setDisplayFrameWithAnimationName(): Invalid frame index", Sprite_setDisplayFrame: "setDisplayFrame is deprecated, please use setSpriteFrame instead.", Sprite__updateBlendFunc: "cc.Sprite._updateBlendFunc(): _updateBlendFunc doesn't work when the sprite is rendered using a cc.CCSpriteBatchNode", Sprite_initWithSpriteFrame: "cc.Sprite.initWithSpriteFrame(): spriteFrame should be non-null", Sprite_initWithSpriteFrameName: "cc.Sprite.initWithSpriteFrameName(): spriteFrameName should be non-null", Sprite_initWithSpriteFrameName1: " is null, please check.", Sprite_initWithFile: "cc.Sprite.initWithFile(): filename should be non-null", Sprite_setDisplayFrameWithAnimationName_3: "cc.Sprite.setDisplayFrameWithAnimationName(): animationName must be non-null", Sprite_reorderChild_2: "cc.Sprite.reorderChild(): child should be non-null", Sprite_addChild: "cc.Sprite.addChild(): cc.Sprite only supports cc.Sprites as children when using cc.SpriteBatchNode", Sprite_addChild_2: "cc.Sprite.addChild(): cc.Sprite only supports a sprite using same texture as children when using cc.SpriteBatchNode", Sprite_addChild_3: "cc.Sprite.addChild(): child should be non-null", Sprite_setTexture: "cc.Sprite.texture setter: Batched sprites should use the same texture as the batchnode", Sprite_updateQuadFromSprite: "cc.SpriteBatchNode.updateQuadFromSprite(): cc.SpriteBatchNode only supports cc.Sprites as children", Sprite_insertQuadFromSprite: "cc.SpriteBatchNode.insertQuadFromSprite(): cc.SpriteBatchNode only supports cc.Sprites as children", Sprite_addChild_4: "cc.SpriteBatchNode.addChild(): cc.SpriteBatchNode only supports cc.Sprites as children", Sprite_addChild_5: "cc.SpriteBatchNode.addChild(): cc.Sprite is not using the same texture", Sprite_initWithTexture: "Sprite.initWithTexture(): Argument must be non-nil ", Sprite_setSpriteFrame: "Invalid spriteFrameName", Sprite_setTexture_2: "Invalid argument: cc.Sprite.texture setter expects a CCTexture2D.", Sprite_updateQuadFromSprite_2: "cc.SpriteBatchNode.updateQuadFromSprite(): sprite should be non-null", Sprite_insertQuadFromSprite_2: "cc.SpriteBatchNode.insertQuadFromSprite(): sprite should be non-null", SpriteBatchNode_addSpriteWithoutQuad: "cc.SpriteBatchNode.addQuadFromSprite(): SpriteBatchNode only supports cc.Sprites as children", SpriteBatchNode_increaseAtlasCapacity: "cocos2d: CCSpriteBatchNode: resizing TextureAtlas capacity from %s to %s.", SpriteBatchNode_increaseAtlasCapacity_2: "cocos2d: WARNING: Not enough memory to resize the atlas", SpriteBatchNode_reorderChild: "cc.SpriteBatchNode.addChild(): Child doesn't belong to Sprite", SpriteBatchNode_removeChild: "cc.SpriteBatchNode.addChild(): sprite batch node should contain the child", SpriteBatchNode_addSpriteWithoutQuad_2: "cc.SpriteBatchNode.addQuadFromSprite(): child should be non-null", SpriteBatchNode_reorderChild_2: "cc.SpriteBatchNode.addChild(): child should be non-null", spriteFrameCache__getFrameConfig: "cocos2d: WARNING: originalWidth/Height not found on the cc.SpriteFrame. AnchorPoint won't work as expected. Regenrate the .plist", spriteFrameCache_addSpriteFrames: "cocos2d: WARNING: an alias with name %s already exists", spriteFrameCache__checkConflict: "cocos2d: WARNING: Sprite frame: %s has already been added by another source, please fix name conflit", spriteFrameCache_getSpriteFrame: "cocos2d: cc.SpriteFrameCahce: Frame %s not found", spriteFrameCache__getFrameConfig_2: "Please load the resource first : %s", spriteFrameCache_addSpriteFrames_2: "cc.SpriteFrameCache.addSpriteFrames(): plist should be non-null", spriteFrameCache_addSpriteFrames_3: "Argument must be non-nil", CCSpriteBatchNode_updateQuadFromSprite: "cc.SpriteBatchNode.updateQuadFromSprite(): cc.SpriteBatchNode only supports cc.Sprites as children", CCSpriteBatchNode_insertQuadFromSprite: "cc.SpriteBatchNode.insertQuadFromSprite(): cc.SpriteBatchNode only supports cc.Sprites as children", CCSpriteBatchNode_addChild: "cc.SpriteBatchNode.addChild(): cc.SpriteBatchNode only supports cc.Sprites as children", CCSpriteBatchNode_initWithTexture: "Sprite.initWithTexture(): Argument must be non-nil ", CCSpriteBatchNode_addChild_2: "cc.Sprite.addChild(): child should be non-null", CCSpriteBatchNode_setSpriteFrame: "Invalid spriteFrameName", CCSpriteBatchNode_setTexture: "Invalid argument: cc.Sprite texture setter expects a CCTexture2D.", CCSpriteBatchNode_updateQuadFromSprite_2: "cc.SpriteBatchNode.updateQuadFromSprite(): sprite should be non-null", CCSpriteBatchNode_insertQuadFromSprite_2: "cc.SpriteBatchNode.insertQuadFromSprite(): sprite should be non-null", CCSpriteBatchNode_addChild_3: "cc.SpriteBatchNode.addChild(): child should be non-null", TextureAtlas_initWithFile: "cocos2d: Could not open file: %s", TextureAtlas_insertQuad: "cc.TextureAtlas.insertQuad(): invalid totalQuads", TextureAtlas_initWithTexture: "cc.TextureAtlas.initWithTexture():texture should be non-null", TextureAtlas_updateQuad: "cc.TextureAtlas.updateQuad(): quad should be non-null", TextureAtlas_updateQuad_2: "cc.TextureAtlas.updateQuad(): Invalid index", TextureAtlas_insertQuad_2: "cc.TextureAtlas.insertQuad(): Invalid index", TextureAtlas_insertQuads: "cc.TextureAtlas.insertQuad(): Invalid index + amount", TextureAtlas_insertQuadFromIndex: "cc.TextureAtlas.insertQuadFromIndex(): Invalid newIndex", TextureAtlas_insertQuadFromIndex_2: "cc.TextureAtlas.insertQuadFromIndex(): Invalid fromIndex", TextureAtlas_removeQuadAtIndex: "cc.TextureAtlas.removeQuadAtIndex(): Invalid index", TextureAtlas_removeQuadsAtIndex: "cc.TextureAtlas.removeQuadsAtIndex(): index + amount out of bounds", TextureAtlas_moveQuadsFromIndex: "cc.TextureAtlas.moveQuadsFromIndex(): move is out of bounds", TextureAtlas_moveQuadsFromIndex_2: "cc.TextureAtlas.moveQuadsFromIndex(): Invalid newIndex", TextureAtlas_moveQuadsFromIndex_3: "cc.TextureAtlas.moveQuadsFromIndex(): Invalid oldIndex", textureCache_addPVRTCImage: "TextureCache:addPVRTCImage does not support on HTML5", textureCache_addETCImage: "TextureCache:addPVRTCImage does not support on HTML5", textureCache_textureForKey: "textureForKey is deprecated. Please use getTextureForKey instead.", textureCache_addPVRImage: "addPVRImage does not support on HTML5", textureCache_addUIImage: "cocos2d: Couldn't add UIImage in TextureCache", textureCache_dumpCachedTextureInfo: "cocos2d: '%s' id\x3d%s %s x %s", textureCache_dumpCachedTextureInfo_2: "cocos2d: '%s' id\x3d HTMLCanvasElement %s x %s", textureCache_dumpCachedTextureInfo_3: "cocos2d: TextureCache dumpDebugInfo: %s textures, HTMLCanvasElement for %s KB (%s MB)", textureCache_addUIImage_2: "cc.Texture.addUIImage(): image should be non-null", Texture2D_initWithETCFile: "initWithETCFile does not support on HTML5", Texture2D_initWithPVRFile: "initWithPVRFile does not support on HTML5", Texture2D_initWithPVRTCData: "initWithPVRTCData does not support on HTML5", Texture2D_addImage: "cc.Texture.addImage(): path should be non-null", Texture2D_initWithImage: "cocos2d: cc.Texture2D. Can't create Texture. UIImage is nil", Texture2D_initWithImage_2: "cocos2d: WARNING: Image (%s x %s) is bigger than the supported %s x %s", Texture2D_initWithString: "initWithString isn't supported on cocos2d-html5", Texture2D_initWithETCFile_2: "initWithETCFile does not support on HTML5", Texture2D_initWithPVRFile_2: "initWithPVRFile does not support on HTML5", Texture2D_initWithPVRTCData_2: "initWithPVRTCData does not support on HTML5", Texture2D_bitsPerPixelForFormat: "bitsPerPixelForFormat: %s, cannot give useful result, it's a illegal pixel format", Texture2D__initPremultipliedATextureWithImage: "cocos2d: cc.Texture2D: Using RGB565 texture since image has no alpha", Texture2D_addImage_2: "cc.Texture.addImage(): path should be non-null", Texture2D_initWithData: "NSInternalInconsistencyException", MissingFile: "Missing file: %s", radiansToDegress: "cc.radiansToDegress() should be called cc.radiansToDegrees()", RectWidth: "Rect width exceeds maximum margin: %s", RectHeight: "Rect height exceeds maximum margin: %s", EventManager__updateListeners: "If program goes here, there should be event in dispatch.", EventManager__updateListeners_2: "_inDispatch should be 1 here." }; cc._logToWebPage = function(a) { if (cc._canvas) { var b = cc._logList, c = document; if (!b) { var d = c.createElement("Div"), b = d.style; d.setAttribute("id", "logInfoDiv"); cc._canvas.parentNode.appendChild(d); d.setAttribute("width", "200"); d.setAttribute("height", cc._canvas.height); b.zIndex = "99999"; b.position = "absolute"; b.top = "0"; b.left = "0"; b = cc._logList = c.createElement("textarea"); c = b.style; b.setAttribute("rows", "20"); b.setAttribute("cols", "30"); b.setAttribute("disabled", !0); d.appendChild(b); c.backgroundColor = "transparent"; c.borderBottom = "1px solid #cccccc"; c.borderRightWidth = "0px"; c.borderLeftWidth = "0px"; c.borderTopWidth = "0px"; c.borderTopStyle = "none"; c.borderRightStyle = "none"; c.borderLeftStyle = "none"; c.padding = "0px"; c.margin = 0 } b.value = b.value + a + "\r\n"; b.scrollTop = b.scrollHeight } }; cc._formatString = function(a) { if (cc.isObject(a)) try { return JSON.stringify(a) } catch (b) { return "" } else return a }; cc._initDebugSetting = function(a) { var b = cc.game; if (a !== b.DEBUG_MODE_NONE) { var c; a > b.DEBUG_MODE_ERROR ? (c = cc._logToWebPage.bind(cc), cc.error = function() { c("ERROR : " + cc.formatStr.apply(cc, arguments)) }, cc.assert = function(a, b) { if (!a && b) { for (var f = 2; f < arguments.length; f++) b = b.replace(/(%s)|(%d)/, cc._formatString(arguments[f])); c("Assert: " + b) } }, a !== b.DEBUG_MODE_ERROR_FOR_WEB_PAGE && (cc.warn = function() { c("WARN : " + cc.formatStr.apply(cc, arguments)) }), a === b.DEBUG_MODE_INFO_FOR_WEB_PAGE && (cc.log = function() { c(cc.formatStr.apply(cc, arguments)) })) : console && console.log.apply && (cc.error = function() { return console.error.apply(console, arguments) }, cc.assert = function(a, b) { if (!a && b) { for (var c = 2; c < arguments.length; c++) b = b.replace(/(%s)|(%d)/, cc._formatString(arguments[c])); throw b; } }, a !== b.DEBUG_MODE_ERROR && (cc.warn = function() { return console.warn.apply(console, arguments) }), a === b.DEBUG_MODE_INFO && (cc.log = function() { return console.log.apply(console, arguments) })) } }; cc._initDebugSetting(cc.game.config[cc.game.CONFIG_KEY.debugMode]); cc.loader.loadBinary = function(a, b) { var c = this, d = this.getXMLHttpRequest(), e = "load " + a + " failed!"; d.open("GET", a, !0); /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent) ? (d.setRequestHeader("Accept-Charset", "x-user-defined"), d.onreadystatechange = function() { if (4 === d.readyState && 200 === d.status) { var a = cc._convertResponseBodyToText(d.responseBody); b(null, c._str2Uint8Array(a)) } else b(e) }) : (d.overrideMimeType && d.overrideMimeType("text/plain; charset\x3dx-user-defined"), d.onload = function() { 4 === d.readyState && 200 === d.status ? b(null, c._str2Uint8Array(d.responseText)) : b(e) }); d.send(null) }; cc.loader._str2Uint8Array = function(a) { if (!a) return null; for (var b = new Uint8Array(a.length), c = 0; c < a.length; c++) b[c] = a.charCodeAt(c) & 255; return b }; cc.loader.loadBinarySync = function(a) { var b = this.getXMLHttpRequest(), c = "load " + a + " failed!"; b.open("GET", a, !1); a = null; if (/msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent)) { b.setRequestHeader("Accept-Charset", "x-user-defined"); b.send(null); if (200 !== b.status) return cc.log(c), null; (b = cc._convertResponseBodyToText(b.responseBody)) && (a = this._str2Uint8Array(b)) } else { b.overrideMimeType && b.overrideMimeType("text/plain; charset\x3dx-user-defined"); b.send(null); if (200 !== b.status) return cc.log(c), null; a = this._str2Uint8Array(b.responseText) } return a }; var Uint8Array = Uint8Array || Array; if (/msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent)) { var IEBinaryToArray_ByteStr_Script = '\x3c!-- IEBinaryToArray_ByteStr --\x3e\r\nFunction IEBinaryToArray_ByteStr(Binary)\r\n IEBinaryToArray_ByteStr \x3d CStr(Binary)\r\nEnd Function\r\nFunction IEBinaryToArray_ByteStr_Last(Binary)\r\n Dim lastIndex\r\n lastIndex \x3d LenB(Binary)\r\n if lastIndex mod 2 Then\r\n IEBinaryToArray_ByteStr_Last \x3d Chr( AscB( MidB( Binary, lastIndex, 1 ) ) )\r\n Else\r\n IEBinaryToArray_ByteStr_Last \x3d ""\r\n End If\r\nEnd Function\r\n', myVBScript = cc.newElement("script"); myVBScript.type = "text/vbscript"; myVBScript.textContent = IEBinaryToArray_ByteStr_Script; document.body.appendChild(myVBScript); cc._convertResponseBodyToText = function(a) { for (var b = {}, c = 0; 256 > c; c++) for (var d = 0; 256 > d; d++) b[String.fromCharCode(c + 256 * d)] = String.fromCharCode(c) + String.fromCharCode(d); c = IEBinaryToArray_ByteStr(a); a = IEBinaryToArray_ByteStr_Last(a); return c.replace(/[\s\S]/g, function(a) { return b[a] }) + a } }; cc = cc || {}; cc._loadingImage = "data:image/gif;base64,R0lGODlhEAAQALMNAD8/P7+/vyoqKlVVVX9/fxUVFUBAQGBgYMDAwC8vL5CQkP///wAAAP///wAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQFAAANACwAAAAAEAAQAAAEO5DJSau9OOvNex0IMnDIsiCkiW6g6BmKYlBFkhSUEgQKlQCARG6nEBwOgl+QApMdCIRD7YZ5RjlGpCUCACH5BAUAAA0ALAAAAgAOAA4AAAQ6kLGB0JA4M7QW0hrngRllkYyhKAYqKUGguAws0ypLS8JxCLQDgXAIDg+FRKIA6v0SAECCBpXSkstMBAAh+QQFAAANACwAAAAACgAQAAAEOJDJORAac6K1kDSKYmydpASBUl0mqmRfaGTCcQgwcxDEke+9XO2WkxQSiUIuAQAkls0n7JgsWq8RACH5BAUAAA0ALAAAAAAOAA4AAAQ6kMlplDIzTxWC0oxwHALnDQgySAdBHNWFLAvCukc215JIZihVIZEogDIJACBxnCSXTcmwGK1ar1hrBAAh+QQFAAANACwAAAAAEAAKAAAEN5DJKc4RM+tDyNFTkSQF5xmKYmQJACTVpQSBwrpJNteZSGYoFWjIGCAQA2IGsVgglBOmEyoxIiMAIfkEBQAADQAsAgAAAA4ADgAABDmQSVZSKjPPBEDSGucJxyGA1XUQxAFma/tOpDlnhqIYN6MEAUXvF+zldrMBAjHoIRYLhBMqvSmZkggAIfkEBQAADQAsBgAAAAoAEAAABDeQyUmrnSWlYhMASfeFVbZdjHAcgnUQxOHCcqWylKEohqUEAYVkgEAMfkEJYrFA6HhKJsJCNFoiACH5BAUAAA0ALAIAAgAOAA4AAAQ3kMlJq704611SKloCAEk4lln3DQgyUMJxCBKyLAh1EMRR3wiDQmHY9SQslyIQUMRmlmVTIyRaIgA7"; cc._fpsImage = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAAgCAYAAAD9qabkAAAKQ2lDQ1BJQ0MgcHJvZmlsZQAAeNqdU3dYk/cWPt/3ZQ9WQtjwsZdsgQAiI6wIyBBZohCSAGGEEBJAxYWIClYUFRGcSFXEgtUKSJ2I4qAouGdBiohai1VcOO4f3Ke1fXrv7e371/u855zn/M55zw+AERImkeaiagA5UoU8Otgfj09IxMm9gAIVSOAEIBDmy8JnBcUAAPADeXh+dLA//AGvbwACAHDVLiQSx+H/g7pQJlcAIJEA4CIS5wsBkFIAyC5UyBQAyBgAsFOzZAoAlAAAbHl8QiIAqg0A7PRJPgUA2KmT3BcA2KIcqQgAjQEAmShHJAJAuwBgVYFSLALAwgCgrEAiLgTArgGAWbYyRwKAvQUAdo5YkA9AYACAmUIszAAgOAIAQx4TzQMgTAOgMNK/4KlfcIW4SAEAwMuVzZdL0jMUuJXQGnfy8ODiIeLCbLFCYRcpEGYJ5CKcl5sjE0jnA0zODAAAGvnRwf44P5Dn5uTh5mbnbO/0xaL+a/BvIj4h8d/+vIwCBAAQTs/v2l/l5dYDcMcBsHW/a6lbANpWAGjf+V0z2wmgWgrQevmLeTj8QB6eoVDIPB0cCgsL7SViob0w44s+/zPhb+CLfvb8QB7+23rwAHGaQJmtwKOD/XFhbnauUo7nywRCMW735yP+x4V//Y4p0eI0sVwsFYrxWIm4UCJNx3m5UpFEIcmV4hLpfzLxH5b9CZN3DQCshk/ATrYHtctswH7uAQKLDljSdgBAfvMtjBoLkQAQZzQyefcAAJO/+Y9AKwEAzZek4wAAvOgYXKiUF0zGCAAARKCBKrBBBwzBFKzADpzBHbzAFwJhBkRADCTAPBBCBuSAHAqhGJZBGVTAOtgEtbADGqARmuEQtMExOA3n4BJcgetwFwZgGJ7CGLyGCQRByAgTYSE6iBFijtgizggXmY4EImFINJKApCDpiBRRIsXIcqQCqUJqkV1II/ItchQ5jVxA+pDbyCAyivyKvEcxlIGyUQPUAnVAuagfGorGoHPRdDQPXYCWomvRGrQePYC2oqfRS+h1dAB9io5jgNExDmaM2WFcjIdFYIlYGibHFmPlWDVWjzVjHVg3dhUbwJ5h7wgkAouAE+wIXoQQwmyCkJBHWExYQ6gl7CO0EroIVwmDhDHCJyKTqE+0JXoS+cR4YjqxkFhGrCbuIR4hniVeJw4TX5NIJA7JkuROCiElkDJJC0lrSNtILaRTpD7SEGmcTCbrkG3J3uQIsoCsIJeRt5APkE+S+8nD5LcUOsWI4kwJoiRSpJQSSjVlP+UEpZ8yQpmgqlHNqZ7UCKqIOp9aSW2gdlAvU4epEzR1miXNmxZDy6Qto9XQmmlnafdoL+l0ugndgx5Fl9CX0mvoB+nn6YP0dwwNhg2Dx0hiKBlrGXsZpxi3GS+ZTKYF05eZyFQw1zIbmWeYD5hvVVgq9ip8FZHKEpU6lVaVfpXnqlRVc1U/1XmqC1SrVQ+rXlZ9pkZVs1DjqQnUFqvVqR1Vu6k2rs5Sd1KPUM9RX6O+X/2C+mMNsoaFRqCGSKNUY7fGGY0hFsYyZfFYQtZyVgPrLGuYTWJbsvnsTHYF+xt2L3tMU0NzqmasZpFmneZxzQEOxrHg8DnZnErOIc4NznstAy0/LbHWaq1mrX6tN9p62r7aYu1y7Rbt69rvdXCdQJ0snfU6bTr3dQm6NrpRuoW623XP6j7TY+t56Qn1yvUO6d3RR/Vt9KP1F+rv1u/RHzcwNAg2kBlsMThj8MyQY+hrmGm40fCE4agRy2i6kcRoo9FJoye4Ju6HZ+M1eBc+ZqxvHGKsNN5l3Gs8YWJpMtukxKTF5L4pzZRrmma60bTTdMzMyCzcrNisyeyOOdWca55hvtm82/yNhaVFnMVKizaLx5balnzLBZZNlvesmFY+VnlW9VbXrEnWXOss623WV2xQG1ebDJs6m8u2qK2brcR2m23fFOIUjynSKfVTbtox7PzsCuya7AbtOfZh9iX2bfbPHcwcEh3WO3Q7fHJ0dcx2bHC866ThNMOpxKnD6VdnG2ehc53zNRemS5DLEpd2lxdTbaeKp26fesuV5RruutK10/Wjm7ub3K3ZbdTdzD3Ffav7TS6bG8ldwz3vQfTw91jicczjnaebp8LzkOcvXnZeWV77vR5Ps5wmntYwbcjbxFvgvct7YDo+PWX6zukDPsY+Ap96n4e+pr4i3z2+I37Wfpl+B/ye+zv6y/2P+L/hefIW8U4FYAHBAeUBvYEagbMDawMfBJkEpQc1BY0FuwYvDD4VQgwJDVkfcpNvwBfyG/ljM9xnLJrRFcoInRVaG/owzCZMHtYRjobPCN8Qfm+m+UzpzLYIiOBHbIi4H2kZmRf5fRQpKjKqLupRtFN0cXT3LNas5Fn7Z72O8Y+pjLk722q2cnZnrGpsUmxj7Ju4gLiquIF4h/hF8ZcSdBMkCe2J5MTYxD2J43MC52yaM5zkmlSWdGOu5dyiuRfm6c7Lnnc8WTVZkHw4hZgSl7I/5YMgQlAvGE/lp25NHRPyhJuFT0W+oo2iUbG3uEo8kuadVpX2ON07fUP6aIZPRnXGMwlPUit5kRmSuSPzTVZE1t6sz9lx2S05lJyUnKNSDWmWtCvXMLcot09mKyuTDeR55m3KG5OHyvfkI/lz89sVbIVM0aO0Uq5QDhZML6greFsYW3i4SL1IWtQz32b+6vkjC4IWfL2QsFC4sLPYuHhZ8eAiv0W7FiOLUxd3LjFdUrpkeGnw0n3LaMuylv1Q4lhSVfJqedzyjlKD0qWlQyuCVzSVqZTJy26u9Fq5YxVhlWRV72qX1VtWfyoXlV+scKyorviwRrjm4ldOX9V89Xlt2treSrfK7etI66Trbqz3Wb+vSr1qQdXQhvANrRvxjeUbX21K3nShemr1js20zcrNAzVhNe1bzLas2/KhNqP2ep1/XctW/a2rt77ZJtrWv913e/MOgx0VO97vlOy8tSt4V2u9RX31btLugt2PGmIbur/mft24R3dPxZ6Pe6V7B/ZF7+tqdG9s3K+/v7IJbVI2jR5IOnDlm4Bv2pvtmne1cFoqDsJB5cEn36Z8e+NQ6KHOw9zDzd+Zf7f1COtIeSvSOr91rC2jbaA9ob3v6IyjnR1eHUe+t/9+7zHjY3XHNY9XnqCdKD3x+eSCk+OnZKeenU4/PdSZ3Hn3TPyZa11RXb1nQ8+ePxd07ky3X/fJ897nj13wvHD0Ivdi2yW3S609rj1HfnD94UivW2/rZffL7Vc8rnT0Tes70e/Tf/pqwNVz1/jXLl2feb3vxuwbt24m3Ry4Jbr1+Hb27Rd3Cu5M3F16j3iv/L7a/eoH+g/qf7T+sWXAbeD4YMBgz8NZD+8OCYee/pT/04fh0kfMR9UjRiONj50fHxsNGr3yZM6T4aeypxPPyn5W/3nrc6vn3/3i+0vPWPzY8Av5i8+/rnmp83Lvq6mvOscjxx+8znk98ab8rc7bfe+477rfx70fmSj8QP5Q89H6Y8en0E/3Pud8/vwv94Tz+4A5JREAAAAGYktHRAD/AP8A/6C9p5MAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQfcAgcQLxxUBNp/AAAQZ0lEQVR42u2be3QVVZbGv1N17829eRLyIKAEOiISEtPhJTJAYuyBDmhWjAEx4iAGBhxA4wABbVAMWUAeykMCM+HRTcBRWkNH2l5moS0LCCrQTkYeQWBQSCAIgYRXEpKbW/XNH5zS4noR7faPEeu31l0h4dSpvc+t/Z199jkFWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhY/H9D/MR9qfKnLj/00U71aqfJn9+HCkCR/Wk36ddsgyJ/1wF4fkDfqqm9/gPsUeTnVr6a2xlQfnxdI7zs0W7irzD17Ytb2WT7EeNv/r4ox1O3Quf2QP2pgt9utwfout4FQE8AVBSlnaRmfvAURQkg2RlAbwB9AThlW5L0GaiKojhJhgOIBqDa7XaPrusdPtr5kQwF0BVAAoBIABRCKDd5aFUhRDAAw57eAOwAhKIoupft3zoqhB1AqLwuHIBut9uFt02qqvqRDJR2dAEQJj/BAOjn56dqmma+xiaECAEQAWAggLsB6A6HQ2iaZggBhBAqgEAAnQB0kzaEmT4hAITT6VQ8Ho/HJAKKECJQtr8LwD1y/A1/vcdfEUIEyfZ9AcQbYvZ942Px88L2UwlJR0dH0EMPPbRj5syZPUeNGrXR7Xb/641xIwJ1XY9NSUlZm52dfW+XLl1w8uRJzJ8//+OGhoYJqqqe1TSt1Wsm9NN1PSIqKmr12rVrR5WUlHy1bdu2AQCumWc3IYRD1/UwVVXnFRQUTIuNjUVzczN2797dWFJSkq8oymZd15sAGAEnFEUJ1nX9nzIzM1dnZmZGh4SE4OTJk5g5c+Zf29vbp9pstrMej6fVOyhIhgAYU1hY+B+hoaGoqKg4XVlZea+XTULTNFdCQsLGiRMnPuR2u3UhBOV9eeDAAWXTpk095DUe6WsoyRE5OTlr0tLSAux2O/bs2cO5c+e+pijKUpIXSHaQVAGkvPLKK++6XK4OksJLCFlXV2cvKSlJBFAjhU+x2WwhHo9nUHp6+urMzMy7wsLCUF9fjxdffPHjxsbGiTab7WuPx9NiEutOuq4PyMjI+M+srKyYqKgoHD58GDNmzNjq8XhyVFU9b/q+LH7hBAEYu3PnTlZVVRFAGgCX6f/tAHoOHDjwa0p27txp/JO9e/f+QM7cipw9nfL3kQBKt2zZQpJ87rnn6mQmoHilw2EACs+cOUOSrK+vZ1NTE0nyo48+IoBpxswoBcMJ4Ndjx471kOTFixe5d+9ekqTH42H//v13A4jyzpAURfEH0H/OnDnthu1z5sw558MmFUCPWbNmnaMP3nrrLZoyDmP8Hl68eDFJ8siRI9/Yc+zYMQKYKdtAztrTrl27xptRXV1NAKMAOAyBBBA/Y8aMdpLs6Ojgxx9//E37+++//29yvFXppwvAwMcee8xjtDHsuXLlCqOjo//ia3wsfpkoALqFhoZuIckJEyackimm3dQmEMDUmpoakmRISMhhAHOHDx/eQJIbN24kgKEyMAHAFRMTs2XXrl1saWkhSZ0kp0+ffhrAr3wEW/S8efOukORLL72kA1gKYMPWrVtJkk899dRJAHeYrgsEsIQkjx8/TgDvAPjd448/3kaSb7zxBmUa7vC6z53BwcFbSHL9+vU6Sc6aNes8gF5ewWAH0PfVV18lSQL4DMBGIcQ6AKtcLleBFC2jXtFt8ODBe0iyoqKCAJYByC8qKmJDQwOzsrK+MAmqo1OnTveHhoa+GRkZ+XZkZOSWiIiIvzgcjk9mzpypkWRmZuZpmbYbGV4AgPnNzc1sa2sjgN0A5iQmJtaSZHl5OQHcb/K3s81mW0uSTU1NBFAFYFbfvn1Pk+Tbb79NAA8IIVzW42/hByA+Pz/fLR/2ZXIda05NI/z9/TeR5J49ewhgqlxTrtI0jY2NjQQw3zTLuWJiYjaUlJToS5Ys6fjkk080kwDEeAmADcA9GzZsIElGRUW9CyAWwLApU6Y0kOSKFSsog9QICGdERMTGsrIyZmVlEcC9AB4IDw/fTpLbtm0jgN94CUAnAJmVlZVcs2aNZ/LkyRdJcvbs2b4EwAkgZfPmzTxw4AABFAN4BkC6vFeUSewcAO5duXIlSTIhIaEawGMAxgKYAmAGgCS73e5vrKVk/yGythANYEhCQsIhkly+fDkBpKqqGmL6DgIALDKN/3yZpVWQZGVlJQE8aPI3KiMjo5okV61aRQAjAPQBMPfIkSN0u90EUCBtsPiFEwpgbn19PdetW2fM5N4zQ9ekpKQqkty0aRMBpMjiWM6JEydIkoqirJUFJ6iq6pAPVy8A6cZMehMBUACEuVyuFwG8HBwcPEIWx367ZMkSjSQXLVrUJouTRorrkAHdA8BdQogsAOsKCwtJkmPGjDkvMw2bDDo/ADEjRoz4XylyFbm5uY0mAbjLyyZ/AOOrq6tZVlbWsWDBgo69e/eyoqKCgwcPPg4gSQaoIRbp27dvN7KF+tLSUr28vJwFBQXtMpvpYRIM7+wrAkDeqVOnePbsWQIoNKfzpiXPg8uXLydJJicnNwF4f+nSpW6STEtLq5fjYwhk1wkTJtSQ5Ouvv04AqTKj+N2xY8dIkgEBAW/Ie1v8wncRegwZMmQvSfbr12+3Ua33WqPfOWbMmP0kWVpaSgCDZAqcfejQIWNZsEGKgvnh9gfQb9myZd8nAEJVVZtMkUNk8CcNHTq0liR1XWdYWNhmH1mJIme80OnTp18x1rp5eXkEsNJms92Fb7e/IgEsvHz5Mp999tkmAI/l5uZeMC0B7vEqqAYAyL106RJJsra2lpWVld+sucePH38ZQG+5NncBeOrgwYMkqbe3t/Po0aOsra011wAWyl0H7x0JJ4DE+fPnu0kyPT29DsDdUrBuyNKEEAkAdpw/f/6GeoEM8GUmfwEgPCIiopwkGxsbabPZPgOw6L777vvm4p49e26VGYjFLxUhhD+ApLKyMp44ccIoVnXybgbgzkcfffRzklyzZg0BDJYCMMmoCwQFBXkLgLGWvvcWAgBToSsKwNPTp09vMR7UuLi4rwH0lgU8c/Db5ezbeeTIkRWzZ8++aMxu+fn5BPCADBwHgP4LFy701NXVEUAJgAnPP/98kyxMNgHo53A4zH77BQQETMvPz7+Um5vbBuAlAFMSExPPmdbVL0qh8Acw8fDhw5SCchVAEYAVb775JknyhRdeaJYztHfxMwLAaqNwCGC2FArv8x0hAHKNLGPKlCme5OTk/Zs3bzb7O0wKiiG8KXl5ed8IxenTp0mSR48e1UmyW7duWywBuD2xyQcgFECgoih+8H1gyJgZV5Lkyy+/3CbTRIePtl2HDBmyw1QBHyGDdXZdXR1JUghRKkXBjOMHCoBdpr0L3nvvPZLkF198wejo6O0A4lVVDTb74HQ6AwD8Wq7Jh8rgGgDgQ13XjVR8qaxJuADMbmlpYXl5uV5UVNRWUFDgfv/993Vj/ZydnU1c37eHXML4S3viAcQqitJD2l104cIFY8lTKsXSBWBMVVWVcd9yed2A1NTUQ6Zl00CvLMMOoHdubm6zFIlWOf5+PsY/Kj09vdrU11QAwwGsv3jxIk21m2DZr10I0RXAuAcffPBgaWkpV69eTYfDcdiwUxY0w6xw+flX8L1xApjevXv3lREREaW6rofB93aPDUDQpEmTMgHgtddeqwBwEd/utZvpqK6uPgEAcXFxkA94NwB9unfvjrNnz4LklwDcf08iIqv66Zs2bXrl4YcfxooVKxAbG7uqrq5uAYA2TdOEqqpGYIi2tjbl6aeffu/YsWPv5uTk7JaC1wHg4Pnz542MwoVvTx+21dbWYvjw4WLixIl+2dnZ9lGjRgmSTE1NRUpKCkwFTGiaxtTU1OXTpk3707Bhw/6g67pDipnT4biuj7qut+Lbk3Vf1tTUXI9qu91Pjq1QFEUBgJaWFgBo8yGOQ8eNGxcAAOvXr/8QwBUfYygAKL169eoCABcuXACAWtn2hOGv0+kMNO1KiPDw8F4A4rZv3/7R1KlTR0+bNu1ht9u9r1+/fqitrQXJgwDarRC6/QjPzs4+QJIffPCB9/aQmSAA43ft2mW0e1QGoi8CAPyLsZccExNTC2BlRkbGRdOyYJCP2csBIN6UAZzCd7cBbQCijYp/dXU1ExMTz6SmptaMHj36f9LS0vYlJCRsl6mxIWSdu3fv/g5J7t+/nwC2AShMTk6+SJKff/45AWRLYbD7+fndAeDf5BJnLoCCyZMnt5JkdnZ2C4B/F0KEm1Pu+Pj4rST55ZdfEsBWAK+mpaVdMo3raDn7KwDuSEpK+m+S3LBhAwG8DuCtHTt2UBbpjgC408vvcFVV15HkuXPnjMp+p5uMf0RcXNyHJNnQ0EBVVfcCWBQXF3fG+Jv0yxABPwB5LS0tRmFxN4BlTzzxxGWSXLx4sS5F3GGFy+1Hp5SUlJq6ujoWFxdTpsZ2H+0iIyMj/0iSWVlZX5mr5jfJFroPGzasxlhTnjp1iiTZ3NxMl8tlrCd9pfa9SkpKSJI5OTmnZOageLUZZqxvfVFWVkZcPwdgNwnSCKPqb17jkmR8fPzfZMDZ5CRsFBmNI7h95s2b1yhT7/MAYmStwCx4vy0uLqa3v5qmEcCfvSr1QQAeXb16NY3Cm3HQ55133iGAp+SxZTNhKSkpfzUddkrFjYevzAQCeGjp0qXfsYckY2NjTwD4leGDLCL2HTdunNtoY+zWSHFcIHdsFCtcfuZ1vO9Eqs3m7/F47sb1k2qX/f3997W2tl7BjWfpBYDOzzzzzIVJkyZh0KBBCwEsB3AJvl9AETabLcDj8dwRFRW1ctasWb8JCgpSzp07d62wsPC/Wltb8xRFadR1/ZqPXYbgAQMGbI2Pjw/+6quv9ldVVT0r01ezuPRJSUn5Y9euXXVd11WzDaqq6kePHm3+7LPPRgO4KlNuxWazhXo8nuTk5OSXMjIyEl0uFxoaGtqKior+dPXq1VdUVT0jj7r68ieoT58+vx8yZMjdx48fP1JVVTVF9m20VW02WyfZf97YsWPjXS4X6urqWvPy8jYCWCyEuEDS8FdVFKWzruv//OSTTy5OTk7uqWkaPv3007qysrJ8RVH+LI8ym8/rB3Tu3HnRI488knLo0KG2ffv2ZQI4C98vP6mqqoZqmpaclpa2cOTIkX39/f3R0NDQUVxc/G5TU9PLqqrWa5rWLH1QVFUN0TStX1JSUvH48eP7BwYG4uDBg1cKCgpeBbBe2u+2Qug2EwD5N5sMPuNtMe8XP4TT6Qxoa2sbIGeXvUKIK7d4IISiKC5d1wPljOfA9bPwzYqiXNV13dd6Uqiq6qdpml2mpe02m63d4/G4vcTF5fF47LJf71nJA6BZVVW3pmntuPHlmAD5wk6Q9NnbHp9vHaqq6tA0zU/64PZhk1FfCZB9G/23ALiqKEqzD39tpvbGUqoFwFUhRLP3yzpCCDtJpxyXDulfG27+pqRR3DXsUWVd4Yq0x/taVQjhIhksC8L+ABpM9ljBf5sKwI8pIBr75L5E4vvu+UNeG/a+hv+AL7yFH8qPtOfHjtOP6V/Bja8D6z/B2Nys/1u9Xv33tLf4GfF/LC4GCJwByWIAAAAASUVORK5CYII\x3d"; cc._loaderImage = "data:image/jpeg;base64,/9j/4QAYRXhpZgAASUkqAAgAAAAAAAAAAAAAAP/sABFEdWNreQABAAQAAAAlAAD/4QMpaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLwA8P3hwYWNrZXQgYmVnaW49Iu+7vyIgaWQ9Ilc1TTBNcENlaGlIenJlU3pOVGN6a2M5ZCI/PiA8eDp4bXBtZXRhIHhtbG5zOng9ImFkb2JlOm5zOm1ldGEvIiB4OnhtcHRrPSJBZG9iZSBYTVAgQ29yZSA1LjAtYzA2MCA2MS4xMzQ3NzcsIDIwMTAvMDIvMTItMTc6MzI6MDAgICAgICAgICI+IDxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+IDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiIHhtbG5zOnhtcE1NPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvbW0vIiB4bWxuczpzdFJlZj0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL3NUeXBlL1Jlc291cmNlUmVmIyIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bXBNTTpEb2N1bWVudElEPSJ4bXAuZGlkOjM4MDBEMDY2QTU1MjExRTFBQTAzQjEzMUNFNzMxRkQwIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOjM4MDBEMDY1QTU1MjExRTFBQTAzQjEzMUNFNzMxRkQwIiB4bXA6Q3JlYXRvclRvb2w9IkFkb2JlIFBob3Rvc2hvcCBDUzUgV2luZG93cyI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkU2RTk0OEM4OERCNDExRTE5NEUyRkE3M0M3QkE1NTlEIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkU2RTk0OEM5OERCNDExRTE5NEUyRkE3M0M3QkE1NTlEIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+/+4ADkFkb2JlAGTAAAAAAf/bAIQADQkJCQoJDQoKDRMMCwwTFhENDREWGhUVFhUVGhkUFhUVFhQZGR0fIB8dGScnKionJzk4ODg5QEBAQEBAQEBAQAEODAwOEA4RDw8RFA4RDhQVERISERUfFRUXFRUfKB0ZGRkZHSgjJiAgICYjLCwoKCwsNzc1NzdAQEBAQEBAQEBA/8AAEQgAyACgAwEiAAIRAQMRAf/EALAAAAEFAQEAAAAAAAAAAAAAAAQAAgMFBgcBAQEAAwEBAAAAAAAAAAAAAAAAAQMEAgUQAAIBAgIEBwoLBgQGAwAAAAECAwAEEQUhMRIGQVFxsTITFGGBwdEiQlKSMzWRoeFicqKyI1NzFYJjJDQWB9KjVCbxwkNkJWXik3QRAAIBAgMFBQcDBQEAAAAAAAABAhEDIRIEMUFRcTJhwVIUBZGhsSJyEzOB0ULhYpIjUxX/2gAMAwEAAhEDEQA/AMJSpUqAVKlXuFAeUq9wpUB5XuFe4V6ooDzZHDox0CnGMinzwl7Z8NajaHeoO3vmTBZBtp9YUIqTEV5ROxHKnWRnaU8VRMhFBUjpV7hSoSeUq9pUB5Sr2lhQHlKvcK8oBV7hSFSRrtaKAZs07YNPM1pG2xJIAw1jSeandry/8X4m8VCKkWwaWwam7Xl/4v1W8VLtmX/i/VbxUoKkWwakSM407tmX/i/VbxUmzGwjQsjdY41IARie/U0IbZO0kNtCXnOCkEBeFu4KI3Bs7DNb27ya+jDx3kJeEnpJJEcQVbWDsk17u5urd591ucZkWhym2Vnd9RkCDEpFxDRpbw0bunu5mlp2De2FMLYXOD2wB2xbOeraUcYGJ72mlSUiqzzdzMd3Z3mixltA2yzcK/NlHM1DQyRXce1HocdNOEfJXZ88y9ZojOqhiBszIRiHQ8Y4cK5TvHuzLljHNMqxNoDjLFraHHnjPxcNCGVbxEUzYNTx5jZSxhpW6qTzlwJ+DCvO2Zf+L9VvFSgqyHYNLYNTdssPxfibxUu15f8Ai/VPiqCakOwa82DU/a8v/F+JvFTDdWPBL8R8VKCvYRYV5UzoMAy6QdIIqI0B4KJtxiRQwou16QoGUkntH5Tz0RbZbmF2hktraSVBo2lUkY8tDye0flPPXTslVUyiyVRsjqUOA4yMT8dW2ram2m6UVTNq9S7EIyUVJydMTn/6DnP+im9Wl+g5z/opvVrpteEhQWY4AaSTwAVf5WPiZh/9S5/zj7zltzlmYWkfWXNvJDGTgGcYDHirR7i7mSbwXParsFMrgb7w6jKw/wCmnc9I14kF3vpvCljbMyWMOJL4aEiB8qU/ObUK7HYWVrl1pFZWiCOCBQqKOLjPGTrNZZqKbUXVHq2nNwTuJRk1VpbgXN8s7Rk5ym0UQQzhIG2NAjhxHWbI+gCBVjBBFbwxwQqEiiUJGg1BVGAFe7dV28WYLYZFmF2Th1UD7JGjymGyn1iK5OyzIBGB1HgrLZhamzumQAGJwSqnSCh1q3GOCodxt4cxurdcpzuN4cyhiWaF5Bg09udUmnWw1H/jV9nFuJ7Quo+8h8peThFA+047vduyMtk7fYqTl07YFdfUufMPzT5p71UdtlmYXaGS2t3mQHAsgxANdadYJopLe4QS2867EsZ4QfCNYrCFbjdDPmgkYyWFxgVf04ifJf6ScNdRUW1XBb6FU5TjF5EpSSrGu/s5lN+g5z/opvVpfoOc/wCim9WtdHnatvObJXDW7xLGhB8nrPaY9/HCr+tEdPCVaSeDoYLnqF63lzW4/PFSW3ecxbI84VSzWUwUaSdg0DXXK5nvAipnd6qgKvWnQO7pri9ZUEmm3Vl2j1kr8pRlFRyquBNZjGxQ/S56Y1S2fu9OVueon11Szahoou06QoQUXadIVCD2FJJ7R+U89dMydv8Axdn+TH9muZye0flPPXQstlK5Tbka1gUjlC1q0vVLkeb6r+O3Tx9xcY1nt8c0NrZCyiOE1108NYjGv1joo7Js1jzKyScYLIvkzL6LDwHXVJksH9Sb49dKNq0tj1jA6uriOCL+02FWX7iVtZX1/AzaHTyeoauKn2MX9W79zebiZCuR5MjSrhfXuEtwTrUeZH+yNfdrRNcxI6IzhXlJEak6WIGJ2Rw4ChWnChndtlVBLMdQA0k1gbXNMzzDfDLs6mjaPKppJbWwJ1bOwwxw43OnHh71YT3DpfWUJmFlb5jHHDdeXBHIsrRea5TSqvxqG04cNN62vetoCS4tre5mgnkGE9q+3DKOkuI2WX6LDQRRHWDh1UCtwj7QRg2wdl8Djgw1qe7XvW0BQ3kfZ7mSLgU+T9E6RVbnuVrnWVSWqj+Lt8ZbRuHEdKPkYVcZ2MJY5fSGyeVar45+rkWQHAqccalPE5km1htWK5nK4Wnt5FuUBUwOMG4nGkA/BXUrW4S6torlOjMgcd/xVn7rLo7zKs0uEjCNeSvdwoBhgsZxX1l2j36k3Lu+uyprdj5Vs5A+i/lD48a0aaVJOPi7jB6lbzWozpjB48pf1NDXNN4vfl7+Z4BXS65pvF78vfzPAK71XTHmZ/S/yT+jvJ7L3fHytz1E+upbL+Qj5W56jfXWRnsIYKLtekKEFGWvSFQgyjk9o/Keet3YthlMP/5x9msJJ7R+U89biyb/AMXEv7gD6tadL1T+kwepRrC39ZkLDMbiwMvUHRPG0bjlGg8ore/23sxBldxfMPLupNhT8yL/AORNZbdzJ484scytxgLqJY5LZj6Q2sV5G1Vud1mjjyG0ij0NEGSZToKyhjtqw4waztuiXA3qKTbSxltfGhbZlE95ZtZqxVbgiOZhrER9ph3Svk9+pJILZ4Y4DGBFCUMKjRsGPobPFhUfW0NJmljE2xJcIrcI2vFUEln1lRXd6lrazXT9GCNpD+yNqoI7mOVduNw6nzlOIoPOUa6yye1XXcbMR5GdQ3xY0BSbj31/FcTQZirJ+q431q7anbHCTZ72Bw7lbPrKBMcBWNNgbMBBh+bsjBdni0VJ1lARZs6yWiupxCuMDy6KpS2IwOo6DTr3Mre3e5tZZVUM4ZBjqOOJoWO4jkXajcOOMHGgDISvWIrdAkKR80+TzVl908bPPL3LzxOuHdifxVfiTAg92qI/w+/8gGgSyN/mR7XPVlp0lF/3L3mbVKtu5Hjbk/8AHE2Fc03i9+Xv5ngFdKNc13i9+Xv5ngFaNV0x5nn+l/kn9HeEWXu+PlbnqJ9dS2Xu9OVueon11kZ7CGCjLXpCgxRlr0hUIPYUcntH5Tz1s8vb+Bt1/dqPirGSe0flPPWusG/g4Py15q06XqlyMWvVYQ+ruI9xJOqzO9hOto/sP8tbGOFIrmWeM7IuMDMnAXXQJOUjQeOsJk0nY96ip0CYunrjaHx1t+srPJUbXBm2LrFPikwTOb+T+VhbZxGMrDXp83x1QSy2tucJpUjPETp+Cn5/ftaRvKvtp3Kx48HG3erHMzOxZiWZtLMdJNQSbbL71Vk6yynViOkqnEEfOWtPbXi3EQkGg6mXiNckjeSJxJGxR10qw0GtxuxmvbImD4CZMFlA4fRfv0BqesqqzTMZNMEDbIHtHH2QeCiZJSqMQdOGiue53mz3czQwsRbIcNHnkec3c4qAMuriz68gTIToxwOOnlp0MjxMJYW741Gs3RVldtbygE/dMcHX/moDaxTiWNZB53B3arb8/wC+4SOF4sf/AKxU9kcBsfOGHfoUHtG/RbzY5Die5HHhXdvavqiZ9Q8Jdlq4/gbKua7xe/L38zwCuhpf2Uk/Zo50kmwJKIdogDjw1VzzeL35e/meAVp1LTgqY4nn+mRauzqmqwrjzCLL3fHytz1E+upLL+Qj5W56jfXWRnroYKLtekKEFF2vSFQg9hSSe0flPPWosm/hIfoLzVl5PaPynnrRWb/w0X0F5q06XqlyM2sVYx5gmbFre/t71NY2T+0h8VbSO5SWNJUOKSAMp7jDGspmMPaLRlXS6eWve1/FRO7WYdbZm1Y/eW/R7qHxHRXGojlm3ulid6aVbaW+OALvgCLq2Hm9WxHKWqjhj6xsK1e8dm15l4niG1LZkswGsxtrPeOmsvayBJA1VItlWjptLuTdPMo7LtjRDq9naK4+WF9IrUW7BaHOljGqVHB7w2hzVoZt87d8vaNYSLl02CcRsDEbJbj71Uu7UBkvJ7/D7q2QoDxySaAO8MTXdxRVMpRp5XZOWdF/ms7R5XdyKfKWJsO/5PhrG5XlNxmEywW6bTnTxAAcJNbGSMXkM1pjgbiNo1PziPJ+Os7u7m/6ReM00ZOgxSpqYYHT3wRXMKN4ll9zUG4bQfNshu8sZVuEA2hirA4qe/VOwwrVbzbww5mI44UKRRYkbWG0S3JWctbd7u5WFfOOLHiUdJqmaipfLsIsObhWe001lMkMVvJNjhghIALMcBxCs7fxXQmkupx1bXDswGPlaTidVaEyKNXkoo4eBV+Sq7L7Vs9zcBgeyQ4GQ/MB1crmoim2orezqcowTuSeEY48jQ7oZX2PLzdyLhNd6RjrEY6I7+uspvH78vfzPAK6UAAAFGAGgAcArmu8Xvy9/M8ArTfio24RW5nnaG67uou3H/KPuqT2X8hHytz1G+upLL3enK3PUb66ys9RDBRdr0hQgou06QqEGUkntH5Tz1e238vF9BeaqKT2j8p56vbb+Xi+gvNWjTdUuRn1XTHmTh8KrJTJlt8t1CPIY44cGnpJVjTJYkmjaN9Ib4u7V923njTethRauZJV3PaW1rfLIiXEDYg6R4VYc9CXW7thfOZbKdbGZtLW8uPVY/u3GrkNUkM9zlcxUjbhfWOA90cRq4gv4LhdqN+VToNYWmnRm9NNVWNTyHc6VWBv8wt4YeHqm6xyPmroq1Z7WGFLSxTq7WLSuPSdjrkfumq5yHXDUeA92oO2SKpVumNAaoJLMXH3myp0rpJ4uKhc3tbDM5BMri1zAj79j7KTiY8TcdBpcsith0286o+sPCagEX9Pzg4zXUCp6QYse8oouCG3tk6m1BYv05W6T+IdyolxbHDAAa2OgDlNCz3ryN2WxBd5PJMg1t81eId2ukqnLlTBbfcuY+9uJLiRcvtPvHdsHK+cfRHcHDWsyawjyy0WBcDI3lTP6TeIcFV+S5OmXx9bJg1048o8Cj0V8Jq2DVu09nL80up7OxHi+oal3P8AXB/IsZS8T/YOV65zvCcc7vfzPAK3ivWCz445zeH954BXOr6I8yfSfyz+jvCLP3fHytz1G+upLP3fHytz1E+usbPaQ0UXadIUIKLtekKhB7Ckk9o/Keer22/l4/oLzVRSe0flPPV7b/y8X0F5q0abqlyM+q6Y8yQsBTDMor1o8aiaE1pbluMqS3sbLLHIhSRQyngqukhaJ9uBjo+H5aOa3ao2t34qouRlLajTalGP8v0IY8ylXQ+PKPFU/bYXOLPge6CKia0LaxTOxHu1Q7cuBd9yPEJ7TbjXKO8CajbMIF6CNIeNvJHjqIWJ7tSpYkalqVblwIdyG+RGXur0hXYJFxal+Dhq5y3slkv3Y2pD0pTr+QUClpJRUdo9XW4OLrTHtM16cZLLWkeC7y4jvlNEpcRtw1Ux27Ci448NZrTFy3nn3IQWxlgGrDZ3pza7/M8ArZo+ArF5171uvp+CqdV0R5l/psUrs2vB3hdl7vTlbnqJ9dS2Xu+PlbnqJ9dY2eshooq16QoQUXa9IVCD2FLJ7RuU89WNtmUSQqkgYMgw0accKrpPaPynnrZWG4Vi+VWmY5tnMWXG+XrIYnA0rhj0mdcTgdNdwnKDqjmduM1SRR/qlr8/4KX6pa8T/BVzDuLZXudRZblmbxXcPUNPc3KqCIwrbOzgrHEnHjoyD+3eSXkht7DeKG4umDGOJVUklfouThXfmbnZ7Cvy1vt9pmv1W1+d8FL9VteJvgq5yrcOGfLmzHN80iyyETPbptAEFo2ZG8pmUa1OFNn3Ky6W/sbDKM5hv5bx2WTZA+7RF2y52WOPJTzE+z2Dy1vt9pT/AKpacTerS/U7Tib1a04/t7kDXPY03jhN0W6sQ7K7W3q2dnrMccaDy/8At80kuZfqWYxWNtlcvUPPhiGYhWDeUy7IwYU8xPs9g8tb7faUn6pacTerTxm9oOBvVq3v9z927aynuId44LiWKNnjhAXF2UYhRg516qpsryjLr21665zFLSTaK9U2GOA87SwqY37knRU+BzOzags0s1Oyr+BKM6sxwP6tSDPLMen6vy0rvdm3Sxlu7K/S7WDDrFUDUTxgnTU826eXW7KlxmqQuwDBXUKcD+1Xee/wXuKX5XDGWLapSVcOyhEM/seJ/V+WnjeGx4pPV+Wkm6kKZlFay3Jlt7iFpYZY8ASVK6DjtDDA0f8A0Tl340/1f8Ndx8xJVWXB0KbktFFpNzdVXAC/qOwA0CQni2flrO3Vwbm5lnI2TKxbDirX/wBE5d+NcfV/wVR7xZPa5U9utvI8nWhmbbw0YEAYYAVxfhfy5rlKR4Fulu6X7mW1mzT8S4Yis/5CPlbnqJ9dSWfu9OVueon11mZvQ2i7XpChKKtekKhBlNJ7R+U89bDfGTb3a3ZX0Lcj6kdY+T2j8p560288m1kWQr6MJ+ylSAr+2cnV5renjs3H1loX+3j9XvbbtxLN9lqW4UnV5jdnjtXHxihtyZNjeSBu5J9k1BJe7xy7W5CJ/wCzuD/mTVTf2+fq97LJuLrPsNRueS7W6aJ/38x+vLVXuY+xvHaNxbf2GoCezf8A36j/APsSf8w1sLnqczTefJluYoLm5uo5F61sBshItP1cNFYe1f8A3ir/APfE/wCZUe9bB94r5jwuPsrQFhmG4l/Z2M17HdW90tuu3IkTHaCjWdIw0VVZdks9/C06yJFEp2dp+E1bbqybGTZ8vpQD7L1XRv8A7blT96Oda7tpNuuNE37Cq9KSisjyuUoxrStKllHbLlWTXsMs8chuSuwEPDqwoLe5y+YRE/gLzmqRekvKKtd4327yM/ulHxmrHJStySWVRyrjxKI2XC/CTlnlPPKTpTdFbP0L1bgrf5Lp0G3dPhQHwV0S1lzBsns3sESR8Crh9WAJGjSOKuU3E+zdZQ3oJh8IArdZXFDmOTpHa3i2+YrI2KtKy4ricBsBuHHgFXSo440+Wa2qqxjvM9uMoy+WvzWpLCWWWE28HxL6e43ojgkeSCBY1Ri5BGIUDT51cl3vm276BBqSEH4WbxV0tlkyXJcxTMb+OW6uY9mGHrCzDQwwAbTp2uKuTZ9N1uYsfRRR8WPhrm419mSSjRyiqxVK7y23B/ftuTm2oSdJyzNVw3BFn7vTlbnqF9dS2fu9OVueon11lZuQ2iLdsGFD05H2dNQGV0ntG5Tz1dWm9N1b2kVq8EVwsI2UaQaQOKhmitZGLOmk68DhSFvY+gfWNSAg7z3Qvo7yKCKIohiaNR5LKxx8qpxvjcqS0VpbxvwOAcRQPZ7D0G9Y0uz2HoH1jUCpLY7zXlpbm3eKO5QuzjrBqZji3x17PvNcyT288VvDBJbMWUovS2hslW7mFQ9nsPQPrGl2ew9A+saCod/WNxtbYsrfb17WBxx5ddD2281xC88klvDcSXEnWuzrqOGGC9zRUPZ7D0G9Y0uzWHoH1jQVCLreq6ntZbaO3it1mGy7RjTs1X2mYy20ZiCq8ZOODcdEdmsPQb1jS7PYegfWNdJuLqnQiSUlRqpFLmryxtH1Ma7Qw2gNNPOdSt0oI27p007s9h6B9Y0uz2HoH1jXX3Z+I4+1b8IJdX89xLHKQFMXQUahpxoiPN5P+onfU+A0/s9h6DesaXZ7D0D6xpG7OLbUtu0StW5JJx2bBsmbtiSiEk+cxoCWWSaVpZOk2vDVo0VYdnsPQb1jSNvZcCH1jSd2c+p1XAmFqEOmOPEfaH+BQd1ueo211IzrgFUYKNAAqI1WztCpUqVCRUqVKgFSpUqAVKlSoBUqVKgFSpUqAVKlSoBUqVKgFSpUqAVKlSoD/9k\x3d"; var cc = cc || {}, ClassManager = { id: 0 | 998 * Math.random(), instanceId: 0 | 998 * Math.random(), compileSuper: function(a, b, c) { a = a.toString(); var d = a.indexOf("("), e = a.indexOf(")"), d = a.substring(d + 1, e), d = d.trim(), e = a.indexOf("{"), f = a.lastIndexOf("}"); for (a = a.substring(e + 1, f); - 1 !== a.indexOf("this._super");) { var e = a.indexOf("this._super"), f = a.indexOf("(", e), g = a.indexOf(")", f), g = a.substring(f + 1, g), g = (g = g.trim()) ? "," : ""; a = a.substring(0, e) + "ClassManager[" + c + "]." + b + ".call(this" + g + a.substring(f + 1) } return Function(d, a) }, getNewID: function() { return this.id++ }, getNewInstanceId: function() { return this.instanceId++ } }; ClassManager.compileSuper.ClassManager = ClassManager; (function() { var a = /\b_super\b/, b = cc.game.config[cc.game.CONFIG_KEY.classReleaseMode]; b && console.log("release Mode"); cc.Class = function() {}; cc.Class.extend = function(c) { function d() { this.__instanceId = ClassManager.getNewInstanceId(); this.ctor && this.ctor.apply(this, arguments) } var e = this.prototype, f = Object.create(e), g = ClassManager.getNewID(); ClassManager[g] = e; var h = { writable: !0, enumerable: !1, configurable: !0 }; f.__instanceId = null; d.id = g; h.value = g; Object.defineProperty(f, "__pid", h); d.prototype = f; h.value = d; Object.defineProperty(d.prototype, "constructor", h); this.__getters__ && (d.__getters__ = cc.clone(this.__getters__)); this.__setters__ && (d.__setters__ = cc.clone(this.__setters__)); for (var k = 0, m = arguments.length; k < m; ++k) { var n = arguments[k], p; for (p in n) { var t = "function" === typeof n[p], r = "function" === typeof e[p], u = a.test(n[p]); b && t && r && u ? (h.value = ClassManager.compileSuper(n[p], p, g), Object.defineProperty(f, p, h)) : t && r && u ? (h.value = function(a, b) { return function() { var c = this._super; this._super = e[a]; var d = b.apply(this, arguments); this._super = c; return d } }(p, n[p]), Object.defineProperty(f, p, h)) : t ? (h.value = n[p], Object.defineProperty(f, p, h)) : f[p] = n[p]; if (t) { var s, v; if (this.__getters__ && this.__getters__[p]) { var t = this.__getters__[p], x; for (x in this.__setters__) if (this.__setters__[x] === t) { v = x; break } cc.defineGetterSetter(f, t, n[p], n[v] ? n[v] : f[v], p, v) } if (this.__setters__ && this.__setters__[p]) { t = this.__setters__[p]; for (x in this.__getters__) if (this.__getters__[x] === t) { s = x; break } cc.defineGetterSetter(f, t, n[s] ? n[s] : f[s], n[p], s, p) } } } } d.extend = cc.Class.extend; d.implement = function(a) { for (var b in a) f[b] = a[b] }; return d } })(); cc.defineGetterSetter = function(a, b, c, d, e, f) { if (a.__defineGetter__) c && a.__defineGetter__(b, c), d && a.__defineSetter__(b, d); else if (Object.defineProperty) { var g = { enumerable: !1, configurable: !0 }; c && (g.get = c); d && (g.set = d); Object.defineProperty(a, b, g) } else throw Error("browser does not support getters"); if (!e && !f) for (var g = null != c, h = void 0 != d, k = Object.getOwnPropertyNames(a), m = 0; m < k.length; m++) { var n = k[m]; if ((a.__lookupGetter__ ? !a.__lookupGetter__(n) : !Object.getOwnPropertyDescriptor(a, n)) && "function" === typeof a[n]) { var p = a[n]; if (g && p === c && (e = n, !h || f)) break; if (h && p === d && (f = n, !g || e)) break } } a = a.constructor; e && (a.__getters__ || (a.__getters__ = {}), a.__getters__[e] = b); f && (a.__setters__ || (a.__setters__ = {}), a.__setters__[f] = b) }; cc.clone = function(a) { var b = a.constructor ? new a.constructor : {}, c; for (c in a) { var d = a[c]; b[c] = "object" !== typeof d || !d || d instanceof cc.Node || d instanceof HTMLElement ? d : cc.clone(d) } return b }; cc.inject = function(a, b) { for (var c in a) b[c] = a[c] }; cc = cc || {}; cc._tmp = cc._tmp || {}; cc.associateWithNative = function(a, b) {}; cc.KEY = { none: 0, back: 6, menu: 18, backspace: 8, tab: 9, enter: 13, shift: 16, ctrl: 17, alt: 18, pause: 19, capslock: 20, escape: 27, space: 32, pageup: 33, pagedown: 34, end: 35, home: 36, left: 37, up: 38, right: 39, down: 40, select: 41, insert: 45, Delete: 46, 0: 48, 1: 49, 2: 50, 3: 51, 4: 52, 5: 53, 6: 54, 7: 55, 8: 56, 9: 57, a: 65, b: 66, c: 67, d: 68, e: 69, f: 70, g: 71, h: 72, i: 73, j: 74, k: 75, l: 76, m: 77, n: 78, o: 79, p: 80, q: 81, r: 82, s: 83, t: 84, u: 85, v: 86, w: 87, x: 88, y: 89, z: 90, num0: 96, num1: 97, num2: 98, num3: 99, num4: 100, num5: 101, num6: 102, num7: 103, num8: 104, num9: 105, "*": 106, "+": 107, "-": 109, numdel: 110, "/": 111, f1: 112, f2: 113, f3: 114, f4: 115, f5: 116, f6: 117, f7: 118, f8: 119, f9: 120, f10: 121, f11: 122, f12: 123, numlock: 144, scrolllock: 145, ";": 186, semicolon: 186, equal: 187, "\x3d": 187, ",": 188, comma: 188, dash: 189, ".": 190, period: 190, forwardslash: 191, grave: 192, "[": 219, openbracket: 219, backslash: 220, "]": 221, closebracket: 221, quote: 222, dpadLeft: 1E3, dpadRight: 1001, dpadUp: 1003, dpadDown: 1004, dpadCenter: 1005 }; cc.FMT_JPG = 0; cc.FMT_PNG = 1; cc.FMT_TIFF = 2; cc.FMT_RAWDATA = 3; cc.FMT_WEBP = 4; cc.FMT_UNKNOWN = 5; cc.getImageFormatByData = function(a) { return 8 < a.length && 137 === a[0] && 80 === a[1] && 78 === a[2] && 71 === a[3] && 13 === a[4] && 10 === a[5] && 26 === a[6] && 10 === a[7] ? cc.FMT_PNG : 2 < a.length && (73 === a[0] && 73 === a[1] || 77 === a[0] && 77 === a[1] || 255 === a[0] && 216 === a[1]) ? cc.FMT_TIFF : cc.FMT_UNKNOWN }; cc.inherits = function(a, b) { function c() {} c.prototype = b.prototype; a.superClass_ = b.prototype; a.prototype = new c; a.prototype.constructor = a }; cc.base = function(a, b, c) { var d = arguments.callee.caller; if (d.superClass_) return ret = d.superClass_.constructor.apply(a, Array.prototype.slice.call(arguments, 1)); for (var e = Array.prototype.slice.call(arguments, 2), f = !1, g = a.constructor; g; g = g.superClass_ && g.superClass_.constructor) if (g.prototype[b] === d) f = !0; else if (f) return g.prototype[b].apply(a, e); if (a[b] === d) return a.constructor.prototype[b].apply(a, e); throw Error("cc.base called from a method of one name to a method of a different name"); }; cc.Point = function(a, b) { this.x = a || 0; this.y = b || 0 }; cc.p = function(a, b) { return void 0 === a ? { x: 0, y: 0 } : void 0 === b ? { x: a.x, y: a.y } : { x: a, y: b } }; cc.pointEqualToPoint = function(a, b) { return a && b && a.x === b.x && a.y === b.y }; cc.Size = function(a, b) { this.width = a || 0; this.height = b || 0 }; cc.size = function(a, b) { return void 0 === a ? { width: 0, height: 0 } : void 0 === b ? { width: a.width, height: a.height } : { width: a, height: b } }; cc.sizeEqualToSize = function(a, b) { return a && b && a.width === b.width && a.height === b.height }; cc.Rect = function(a, b, c, d) { this.x = a || 0; this.y = b || 0; this.width = c || 0; this.height = d || 0 }; cc.rect = function(a, b, c, d) { return void 0 === a ? { x: 0, y: 0, width: 0, height: 0 } : void 0 === b ? { x: a.x, y: a.y, width: a.width, height: a.height } : { x: a, y: b, width: c, height: d } }; cc.rectEqualToRect = function(a, b) { return a && b && a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height }; cc._rectEqualToZero = function(a) { return a && 0 === a.x && 0 === a.y && 0 === a.width && 0 === a.height }; cc.rectContainsRect = function(a, b) { return a && b ? !(a.x >= b.x || a.y >= b.y || a.x + a.width <= b.x + b.width || a.y + a.height <= b.y + b.height) : !1 }; cc.rectGetMaxX = function(a) { return a.x + a.width }; cc.rectGetMidX = function(a) { return a.x + a.width / 2 }; cc.rectGetMinX = function(a) { return a.x }; cc.rectGetMaxY = function(a) { return a.y + a.height }; cc.rectGetMidY = function(a) { return a.y + a.height / 2 }; cc.rectGetMinY = function(a) { return a.y }; cc.rectContainsPoint = function(a, b) { return b.x >= cc.rectGetMinX(a) && b.x <= cc.rectGetMaxX(a) && b.y >= cc.rectGetMinY(a) && b.y <= cc.rectGetMaxY(a) }; cc.rectIntersectsRect = function(a, b) { var c = a.y + a.height, d = b.x + b.width, e = b.y + b.height; return !(a.x + a.width < b.x || d < a.x || c < b.y || e < a.y) }; cc.rectOverlapsRect = function(a, b) { return !(a.x + a.width < b.x || b.x + b.width < a.x || a.y + a.height < b.y || b.y + b.height < a.y) }; cc.rectUnion = function(a, b) { var c = cc.rect(0, 0, 0, 0); c.x = Math.min(a.x, b.x); c.y = Math.min(a.y, b.y); c.width = Math.max(a.x + a.width, b.x + b.width) - c.x; c.height = Math.max(a.y + a.height, b.y + b.height) - c.y; return c }; cc.rectIntersection = function(a, b) { var c = cc.rect(Math.max(cc.rectGetMinX(a), cc.rectGetMinX(b)), Math.max(cc.rectGetMinY(a), cc.rectGetMinY(b)), 0, 0); c.width = Math.min(cc.rectGetMaxX(a), cc.rectGetMaxX(b)) - cc.rectGetMinX(c); c.height = Math.min(cc.rectGetMaxY(a), cc.rectGetMaxY(b)) - cc.rectGetMinY(c); return c }; cc.SAXParser = cc.Class.extend({ _parser: null, _isSupportDOMParser: null, ctor: function() { window.DOMParser ? (this._isSupportDOMParser = !0, this._parser = new DOMParser) : this._isSupportDOMParser = !1 }, parse: function(a) { return this._parseXML(a) }, _parseXML: function(a) { var b; this._isSupportDOMParser ? b = this._parser.parseFromString(a, "text/xml") : (b = new ActiveXObject("Microsoft.XMLDOM"), b.async = "false", b.loadXML(a)); return b } }); cc.PlistParser = cc.SAXParser.extend({ parse: function(a) { a = this._parseXML(a).documentElement; if ("plist" !== a.tagName) throw "Not a plist file!"; for (var b = null, c = 0, d = a.childNodes.length; c < d && (b = a.childNodes[c], 1 !== b.nodeType); c++); return this._parseNode(b) }, _parseNode: function(a) { var b = null, c = a.tagName; if ("dict" === c) b = this._parseDict(a); else if ("array" === c) b = this._parseArray(a); else if ("string" === c) if (1 === a.childNodes.length) b = a.firstChild.nodeValue; else for (b = "", c = 0; c < a.childNodes.length; c++) b += a.childNodes[c].nodeValue; else "false" === c ? b = !1 : "true" === c ? b = !0 : "real" === c ? b = parseFloat(a.firstChild.nodeValue) : "integer" === c && (b = parseInt(a.firstChild.nodeValue, 10)); return b }, _parseArray: function(a) { for (var b = [], c = 0, d = a.childNodes.length; c < d; c++) { var e = a.childNodes[c]; 1 === e.nodeType && b.push(this._parseNode(e)) } return b }, _parseDict: function(a) { for (var b = {}, c = null, d = 0, e = a.childNodes.length; d < e; d++) { var f = a.childNodes[d]; 1 === f.nodeType && ("key" === f.tagName ? c = f.firstChild.nodeValue : b[c] = this._parseNode(f)) } return b } }); cc._txtLoader = { load: function(a, b, c, d) { cc.loader.loadTxt(a, d) } }; cc.loader.register(["txt", "xml", "vsh", "fsh", "atlas"], cc._txtLoader); cc._jsonLoader = { load: function(a, b, c, d) { cc.loader.loadJson(a, d) } }; cc.loader.register(["json", "ExportJson"], cc._jsonLoader); cc._jsLoader = { load: function(a, b, c, d) { cc.loader.loadJs(a, d) } }; cc.loader.register(["js"], cc._jsLoader); cc._imgLoader = { load: function(a, b, c, d) { cc.loader.cache[b] = cc.loader.loadImg(a, function(a, c) { if (a) return d(a); cc.textureCache.handleLoadedTexture(b); d(null, c) }) } }; cc.loader.register("png jpg bmp jpeg gif ico".split(" "), cc._imgLoader); cc._serverImgLoader = { load: function(a, b, c, d) { cc.loader.cache[b] = cc.loader.loadImg(c.src, function(a, c) { if (a) return d(a); cc.textureCache.handleLoadedTexture(b); d(null, c) }) } }; cc.loader.register(["serverImg"], cc._serverImgLoader); cc._plistLoader = { load: function(a, b, c, d) { cc.loader.loadTxt(a, function(a, b) { if (a) return d(a); d(null, cc.plistParser.parse(b)) }) } }; cc.loader.register(["plist"], cc._plistLoader); cc._fontLoader = { TYPE: { ".eot": "embedded-opentype", ".ttf": "truetype", ".woff": "woff", ".svg": "svg" }, _loadFont: function(a, b, c) { var d = document, e = cc.path, f = this.TYPE, g = cc.newElement("style"); g.type = "text/css"; d.body.appendChild(g); var h = "@font-face { font-family:" + a + "; src:"; if (b instanceof Array) for (var k = 0, m = b.length; k < m; k++) c = e.extname(b[k]).toLowerCase(), h += "url('" + b[k] + "') format('" + f[c] + "')", h += k === m - 1 ? ";" : ","; else h += "url('" + b + "') format('" + f[c] + "');"; g.textContent += h + "};"; b = cc.newElement("div"); c = b.style; c.fontFamily = a; b.innerHTML = "."; c.position = "absolute"; c.left = "-100px"; c.top = "-100px"; d.body.appendChild(b) }, load: function(a, b, c, d) { b = c.type; a = c.name; b = c.srcs; cc.isString(c) ? (b = cc.path.extname(c), a = cc.path.basename(c, b), this._loadFont(a, c, b)) : this._loadFont(a, b); d(null, !0) } }; cc.loader.register(["font", "eot", "ttf", "woff", "svg"], cc._fontLoader); cc._binaryLoader = { load: function(a, b, c, d) { cc.loader.loadBinary(a, d) } }; cc._csbLoader = { load: function(a, b, c, d) { cc.loader.loadCsb(a, d) } }; cc.loader.register(["csb"], cc._csbLoader); window.CocosEngine = cc.ENGINE_VERSION = "Cocos2d-JS v3.5"; cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL = 0; cc.DIRECTOR_STATS_POSITION = cc.p(0, 0); cc.DIRECTOR_FPS_INTERVAL = 0.5; cc.COCOSNODE_RENDER_SUBPIXEL = 1; cc.SPRITEBATCHNODE_RENDER_SUBPIXEL = 1; cc.OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA = 0; cc.TEXTURE_ATLAS_USE_TRIANGLE_STRIP = 0; cc.TEXTURE_ATLAS_USE_VAO = 0; cc.TEXTURE_NPOT_SUPPORT = 0; cc.RETINA_DISPLAY_SUPPORT = 1; cc.RETINA_DISPLAY_FILENAME_SUFFIX = "-hd"; cc.USE_LA88_LABELS = 1; cc.SPRITE_DEBUG_DRAW = 0; cc.SPRITEBATCHNODE_DEBUG_DRAW = 0; cc.LABELBMFONT_DEBUG_DRAW = 0; cc.LABELATLAS_DEBUG_DRAW = 0; cc.IS_RETINA_DISPLAY_SUPPORTED = 1; cc.DEFAULT_ENGINE = cc.ENGINE_VERSION + "-canvas"; cc.ENABLE_STACKABLE_ACTIONS = 1; cc.ENABLE_GL_STATE_CACHE = 1; cc.$ = function(a) { var b = this === cc ? document : this; if (a = a instanceof HTMLElement ? a : b.querySelector(a)) a.find = a.find || cc.$, a.hasClass = a.hasClass || function(a) { return this.className.match(RegExp("(\\s|^)" + a + "(\\s|$)")) }, a.addClass = a.addClass || function(a) { this.hasClass(a) || (this.className && (this.className += " "), this.className += a); return this }, a.removeClass = a.removeClass || function(a) { this.hasClass(a) && (this.className = this.className.replace(a, "")); return this }, a.remove = a.remove || function() { this.parentNode && this.parentNode.removeChild(this); return this }, a.appendTo = a.appendTo || function(a) { a.appendChild(this); return this }, a.prependTo = a.prependTo || function(a) { a.childNodes[0] ? a.insertBefore(this, a.childNodes[0]) : a.appendChild(this); return this }, a.transforms = a.transforms || function() { this.style[cc.$.trans] = cc.$.translate(this.position) + cc.$.rotate(this.rotation) + cc.$.scale(this.scale) + cc.$.skew(this.skew); return this }, a.position = a.position || { x: 0, y: 0 }, a.rotation = a.rotation || 0, a.scale = a.scale || { x: 1, y: 1 }, a.skew = a.skew || { x: 0, y: 0 }, a.translates = function(a, b) { this.position.x = a; this.position.y = b; this.transforms(); return this }, a.rotate = function(a) { this.rotation = a; this.transforms(); return this }, a.resize = function(a, b) { this.scale.x = a; this.scale.y = b; this.transforms(); return this }, a.setSkew = function(a, b) { this.skew.x = a; this.skew.y = b; this.transforms(); return this }; return a }; switch (cc.sys.browserType) { case cc.sys.BROWSER_TYPE_FIREFOX: cc.$.pfx = "Moz"; cc.$.hd = !0; break; case cc.sys.BROWSER_TYPE_CHROME: case cc.sys.BROWSER_TYPE_SAFARI: cc.$.pfx = "webkit"; cc.$.hd = !0; break; case cc.sys.BROWSER_TYPE_OPERA: cc.$.pfx = "O"; cc.$.hd = !1; break; case cc.sys.BROWSER_TYPE_IE: cc.$.pfx = "ms"; cc.$.hd = !1; break; default: cc.$.pfx = "webkit", cc.$.hd = !0 } cc.$.trans = cc.$.pfx + "Transform"; cc.$.translate = cc.$.hd ? function(a) { return "translate3d(" + a.x + "px, " + a.y + "px, 0) " } : function(a) { return "translate(" + a.x + "px, " + a.y + "px) " }; cc.$.rotate = cc.$.hd ? function(a) { return "rotateZ(" + a + "deg) " } : function(a) { return "rotate(" + a + "deg) " }; cc.$.scale = function(a) { return "scale(" + a.x + ", " + a.y + ") " }; cc.$.skew = function(a) { return "skewX(" + -a.x + "deg) skewY(" + a.y + "deg)" }; cc.$new = function(a) { return cc.$(document.createElement(a)) }; cc.$.findpos = function(a) { var b = 0, c = 0; do b += a.offsetLeft, c += a.offsetTop; while (a = a.offsetParent); return { x: b, y: c } }; cc.INVALID_INDEX = -1; cc.PI = Math.PI; cc.FLT_MAX = parseFloat("3.402823466e+38F"); cc.FLT_MIN = parseFloat("1.175494351e-38F"); cc.RAD = cc.PI / 180; cc.DEG = 180 / cc.PI; cc.UINT_MAX = 4294967295; cc.swap = function(a, b, c) { if (!cc.isObject(c) || cc.isUndefined(c.x) || cc.isUndefined(c.y)) cc.log(cc._LogInfos.swap); else { var d = c[a]; c[a] = c[b]; c[b] = d } }; cc.lerp = function(a, b, c) { return a + (b - a) * c }; cc.rand = function() { return 16777215 * Math.random() }; cc.randomMinus1To1 = function() { return 2 * (Math.random() - 0.5) }; cc.random0To1 = Math.random; cc.degreesToRadians = function(a) { return a * cc.RAD }; cc.radiansToDegrees = function(a) { return a * cc.DEG }; cc.radiansToDegress = function(a) { cc.log(cc._LogInfos.radiansToDegress); return a * cc.DEG }; cc.REPEAT_FOREVER = Number.MAX_VALUE - 1; cc.BLEND_SRC = cc.OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA ? 1 : 770; cc.BLEND_DST = 771; cc.nodeDrawSetup = function(a) { a._shaderProgram && (a._shaderProgram.use(), a._shaderProgram.setUniformForModelViewAndProjectionMatrixWithMat4()) }; cc.enableDefaultGLStates = function() {}; cc.disableDefaultGLStates = function() {}; cc.incrementGLDraws = function(a) { cc.g_NumberOfDraws += a }; cc.FLT_EPSILON = 1.192092896E-7; cc.contentScaleFactor = cc.IS_RETINA_DISPLAY_SUPPORTED ? function() { return cc.director.getContentScaleFactor() } : function() { return 1 }; cc.pointPointsToPixels = function(a) { var b = cc.contentScaleFactor(); return cc.p(a.x * b, a.y * b) }; cc.pointPixelsToPoints = function(a) { var b = cc.contentScaleFactor(); return cc.p(a.x / b, a.y / b) }; cc._pointPixelsToPointsOut = function(a, b) { var c = cc.contentScaleFactor(); b.x = a.x / c; b.y = a.y / c }; cc.sizePointsToPixels = function(a) { var b = cc.contentScaleFactor(); return cc.size(a.width * b, a.height * b) }; cc.sizePixelsToPoints = function(a) { var b = cc.contentScaleFactor(); return cc.size(a.width / b, a.height / b) }; cc._sizePixelsToPointsOut = function(a, b) { var c = cc.contentScaleFactor(); b.width = a.width / c; b.height = a.height / c }; cc.rectPixelsToPoints = cc.IS_RETINA_DISPLAY_SUPPORTED ? function(a) { var b = cc.contentScaleFactor(); return cc.rect(a.x / b, a.y / b, a.width / b, a.height / b) } : function(a) { return a }; cc.rectPointsToPixels = cc.IS_RETINA_DISPLAY_SUPPORTED ? function(a) { var b = cc.contentScaleFactor(); return cc.rect(a.x * b, a.y * b, a.width * b, a.height * b) } : function(a) { return a }; cc.ONE = 1; cc.ZERO = 0; cc.SRC_ALPHA = 770; cc.SRC_ALPHA_SATURATE = 776; cc.SRC_COLOR = 768; cc.DST_ALPHA = 772; cc.DST_COLOR = 774; cc.ONE_MINUS_SRC_ALPHA = 771; cc.ONE_MINUS_SRC_COLOR = 769; cc.ONE_MINUS_DST_ALPHA = 773; cc.ONE_MINUS_DST_COLOR = 775; cc.ONE_MINUS_CONSTANT_ALPHA = 32772; cc.ONE_MINUS_CONSTANT_COLOR = 32770; cc.LINEAR = 9729; cc.REPEAT = 10497; cc.CLAMP_TO_EDGE = 33071; cc.MIRRORED_REPEAT = 33648; cc.checkGLErrorDebug = function() { if (cc.renderMode === cc._RENDER_TYPE_WEBGL) { var a = cc._renderContext.getError(); a && cc.log(cc._LogInfos.checkGLErrorDebug, a) } }; cc.DEVICE_ORIENTATION_PORTRAIT = 0; cc.DEVICE_ORIENTATION_LANDSCAPE_LEFT = 1; cc.DEVICE_ORIENTATION_PORTRAIT_UPSIDE_DOWN = 2; cc.DEVICE_ORIENTATION_LANDSCAPE_RIGHT = 3; cc.DEVICE_MAX_ORIENTATIONS = 2; cc.VERTEX_ATTRIB_FLAG_NONE = 0; cc.VERTEX_ATTRIB_FLAG_POSITION = 1; cc.VERTEX_ATTRIB_FLAG_COLOR = 2; cc.VERTEX_ATTRIB_FLAG_TEX_COORDS = 4; cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX = cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_COLOR | cc.VERTEX_ATTRIB_FLAG_TEX_COORDS; cc.GL_ALL = 0; cc.VERTEX_ATTRIB_POSITION = 0; cc.VERTEX_ATTRIB_COLOR = 1; cc.VERTEX_ATTRIB_TEX_COORDS = 2; cc.VERTEX_ATTRIB_MAX = 3; cc.UNIFORM_PMATRIX = 0; cc.UNIFORM_MVMATRIX = 1; cc.UNIFORM_MVPMATRIX = 2; cc.UNIFORM_TIME = 3; cc.UNIFORM_SINTIME = 4; cc.UNIFORM_COSTIME = 5; cc.UNIFORM_RANDOM01 = 6; cc.UNIFORM_SAMPLER = 7; cc.UNIFORM_MAX = 8; cc.SHADER_POSITION_TEXTURECOLOR = "ShaderPositionTextureColor"; cc.SHADER_POSITION_TEXTURECOLORALPHATEST = "ShaderPositionTextureColorAlphaTest"; cc.SHADER_POSITION_COLOR = "ShaderPositionColor"; cc.SHADER_POSITION_TEXTURE = "ShaderPositionTexture"; cc.SHADER_POSITION_TEXTURE_UCOLOR = "ShaderPositionTexture_uColor"; cc.SHADER_POSITION_TEXTUREA8COLOR = "ShaderPositionTextureA8Color"; cc.SHADER_POSITION_UCOLOR = "ShaderPosition_uColor"; cc.SHADER_POSITION_LENGTHTEXTURECOLOR = "ShaderPositionLengthTextureColor"; cc.UNIFORM_PMATRIX_S = "CC_PMatrix"; cc.UNIFORM_MVMATRIX_S = "CC_MVMatrix"; cc.UNIFORM_MVPMATRIX_S = "CC_MVPMatrix"; cc.UNIFORM_TIME_S = "CC_Time"; cc.UNIFORM_SINTIME_S = "CC_SinTime"; cc.UNIFORM_COSTIME_S = "CC_CosTime"; cc.UNIFORM_RANDOM01_S = "CC_Random01"; cc.UNIFORM_SAMPLER_S = "CC_Texture0"; cc.UNIFORM_ALPHA_TEST_VALUE_S = "CC_alpha_value"; cc.ATTRIBUTE_NAME_COLOR = "a_color"; cc.ATTRIBUTE_NAME_POSITION = "a_position"; cc.ATTRIBUTE_NAME_TEX_COORD = "a_texCoord"; cc.ITEM_SIZE = 32; cc.CURRENT_ITEM = 3233828865; cc.ZOOM_ACTION_TAG = 3233828866; cc.NORMAL_TAG = 8801; cc.SELECTED_TAG = 8802; cc.DISABLE_TAG = 8803; cc.arrayVerifyType = function(a, b) { if (a && 0 < a.length) for (var c = 0; c < a.length; c++) if (!(a[c] instanceof b)) return cc.log("element type is wrong!"), !1; return !0 }; cc.arrayRemoveObject = function(a, b) { for (var c = 0, d = a.length; c < d; c++) if (a[c] === b) { a.splice(c, 1); break } }; cc.arrayRemoveArray = function(a, b) { for (var c = 0, d = b.length; c < d; c++) cc.arrayRemoveObject(a, b[c]) }; cc.arrayAppendObjectsToIndex = function(a, b, c) { a.splice.apply(a, [c, 0].concat(b)); return a }; cc.copyArray = function(a) { var b, c = a.length, d = Array(c); for (b = 0; b < c; b += 1) d[b] = a[b]; return d }; cc = cc || {}; cc._tmp = cc._tmp || {}; cc._tmp.WebGLColor = function() { cc.color = function(a, c, d, e, f, g) { return void 0 === a ? new cc.Color(0, 0, 0, 255, f, g) : cc.isString(a) ? (a = cc.hexToColor(a), new cc.Color(a.r, a.g, a.b, a.a)) : cc.isObject(a) ? new cc.Color(a.r, a.g, a.b, a.a, a.arrayBuffer, a.offset) : new cc.Color(a, c, d, e, f, g) }; cc.Color = function(a, c, d, e, f, g) { this._arrayBuffer = f || new ArrayBuffer(cc.Color.BYTES_PER_ELEMENT); this._offset = g || 0; f = this._arrayBuffer; g = this._offset; var h = Uint8Array.BYTES_PER_ELEMENT; this._rU8 = new Uint8Array(f, g, 1); this._gU8 = new Uint8Array(f, g + h, 1); this._bU8 = new Uint8Array(f, g + 2 * h, 1); this._aU8 = new Uint8Array(f, g + 3 * h, 1); this._rU8[0] = a || 0; this._gU8[0] = c || 0; this._bU8[0] = d || 0; this._aU8[0] = null == e ? 255 : e; void 0 === e && (this.a_undefined = !0) }; cc.Color.BYTES_PER_ELEMENT = 4; var a = cc.Color.prototype; a._getR = function() { return this._rU8[0] }; a._setR = function(a) { this._rU8[0] = 0 > a ? 0 : a }; a._getG = function() { return this._gU8[0] }; a._setG = function(a) { this._gU8[0] = 0 > a ? 0 : a }; a._getB = function() { return this._bU8[0] }; a._setB = function(a) { this._bU8[0] = 0 > a ? 0 : a }; a._getA = function() { return this._aU8[0] }; a._setA = function(a) { this._aU8[0] = 0 > a ? 0 : a }; cc.defineGetterSetter(a, "r", a._getR, a._setR); cc.defineGetterSetter(a, "g", a._getG, a._setG); cc.defineGetterSetter(a, "b", a._getB, a._setB); cc.defineGetterSetter(a, "a", a._getA, a._setA); cc.Vertex2F = function(a, c, d, e) { this._arrayBuffer = d || new ArrayBuffer(cc.Vertex2F.BYTES_PER_ELEMENT); this._offset = e || 0; this._xF32 = new Float32Array(this._arrayBuffer, this._offset, 1); this._yF32 = new Float32Array(this._arrayBuffer, this._offset + 4, 1); this._xF32[0] = a || 0; this._yF32[0] = c || 0 }; cc.Vertex2F.BYTES_PER_ELEMENT = 8; a = cc.Vertex2F.prototype; a._getX = function() { return this._xF32[0] }; a._setX = function(a) { this._xF32[0] = a }; a._getY = function() { return this._yF32[0] }; a._setY = function(a) { this._yF32[0] = a }; cc.defineGetterSetter(a, "x", a._getX, a._setX); cc.defineGetterSetter(a, "y", a._getY, a._setY); cc.Vertex3F = function(a, c, d, e, f) { this._arrayBuffer = e || new ArrayBuffer(cc.Vertex3F.BYTES_PER_ELEMENT); this._offset = f || 0; e = this._arrayBuffer; f = this._offset; this._xF32 = new Float32Array(e, f, 1); this._xF32[0] = a || 0; this._yF32 = new Float32Array(e, f + Float32Array.BYTES_PER_ELEMENT, 1); this._yF32[0] = c || 0; this._zF32 = new Float32Array(e, f + 2 * Float32Array.BYTES_PER_ELEMENT, 1); this._zF32[0] = d || 0 }; cc.Vertex3F.BYTES_PER_ELEMENT = 12; a = cc.Vertex3F.prototype; a._getX = function() { return this._xF32[0] }; a._setX = function(a) { this._xF32[0] = a }; a._getY = function() { return this._yF32[0] }; a._setY = function(a) { this._yF32[0] = a }; a._getZ = function() { return this._zF32[0] }; a._setZ = function(a) { this._zF32[0] = a }; cc.defineGetterSetter(a, "x", a._getX, a._setX); cc.defineGetterSetter(a, "y", a._getY, a._setY); cc.defineGetterSetter(a, "z", a._getZ, a._setZ); cc.Tex2F = function(a, c, d, e) { this._arrayBuffer = d || new ArrayBuffer(cc.Tex2F.BYTES_PER_ELEMENT); this._offset = e || 0; this._uF32 = new Float32Array(this._arrayBuffer, this._offset, 1); this._vF32 = new Float32Array(this._arrayBuffer, this._offset + 4, 1); this._uF32[0] = a || 0; this._vF32[0] = c || 0 }; cc.Tex2F.BYTES_PER_ELEMENT = 8; a = cc.Tex2F.prototype; a._getU = function() { return this._uF32[0] }; a._setU = function(a) { this._uF32[0] = a }; a._getV = function() { return this._vF32[0] }; a._setV = function(a) { this._vF32[0] = a }; cc.defineGetterSetter(a, "u", a._getU, a._setU); cc.defineGetterSetter(a, "v", a._getV, a._setV); cc.Quad2 = function(a, c, d, e, f, g) { this._arrayBuffer = f || new ArrayBuffer(cc.Quad2.BYTES_PER_ELEMENT); this._offset = g || 0; f = this._arrayBuffer; g = cc.Vertex2F.BYTES_PER_ELEMENT; this._tl = a ? new cc.Vertex2F(a.x, a.y, f, 0) : new cc.Vertex2F(0, 0, f, 0); this._tr = c ? new cc.Vertex2F(c.x, c.y, f, g) : new cc.Vertex2F(0, 0, f, g); this._bl = d ? new cc.Vertex2F(d.x, d.y, f, 2 * g) : new cc.Vertex2F(0, 0, f, 2 * g); this._br = e ? new cc.Vertex2F(e.x, e.y, f, 3 * g) : new cc.Vertex2F(0, 0, f, 3 * g) }; cc.Quad2.BYTES_PER_ELEMENT = 32; a = cc.Quad2.prototype; a._getTL = function() { return this._tl }; a._setTL = function(a) { this._tl.x = a.x; this._tl.y = a.y }; a._getTR = function() { return this._tr }; a._setTR = function(a) { this._tr.x = a.x; this._tr.y = a.y }; a._getBL = function() { return this._bl }; a._setBL = function(a) { this._bl.x = a.x; this._bl.y = a.y }; a._getBR = function() { return this._br }; a._setBR = function(a) { this._br.x = a.x; this._br.y = a.y }; cc.defineGetterSetter(a, "tl", a._getTL, a._setTL); cc.defineGetterSetter(a, "tr", a._getTR, a._setTR); cc.defineGetterSetter(a, "bl", a._getBL, a._setBL); cc.defineGetterSetter(a, "br", a._getBR, a._setBR); cc.Quad3 = function(a, c, d, e) { this.bl = a || new cc.Vertex3F(0, 0, 0); this.br = c || new cc.Vertex3F(0, 0, 0); this.tl = d || new cc.Vertex3F(0, 0, 0); this.tr = e || new cc.Vertex3F(0, 0, 0) }; cc.V3F_C4B_T2F = function(a, c, d, e, f) { this._arrayBuffer = e || new ArrayBuffer(cc.V3F_C4B_T2F.BYTES_PER_ELEMENT); this._offset = f || 0; e = this._arrayBuffer; f = this._offset; var g = cc.Vertex3F.BYTES_PER_ELEMENT; this._vertices = a ? new cc.Vertex3F(a.x, a.y, a.z, e, f) : new cc.Vertex3F(0, 0, 0, e, f); this._colors = c ? cc.color(c.r, c.g, c.b, c.a, e, f + g) : cc.color(0, 0, 0, 0, e, f + g); this._texCoords = d ? new cc.Tex2F(d.u, d.v, e, f + g + cc.Color.BYTES_PER_ELEMENT) : new cc.Tex2F(0, 0, e, f + g + cc.Color.BYTES_PER_ELEMENT) }; cc.V3F_C4B_T2F.BYTES_PER_ELEMENT = 24; a = cc.V3F_C4B_T2F.prototype; a._getVertices = function() { return this._vertices }; a._setVertices = function(a) { var c = this._vertices; c.x = a.x; c.y = a.y; c.z = a.z }; a._getColor = function() { return this._colors }; a._setColor = function(a) { var c = this._colors; c.r = a.r; c.g = a.g; c.b = a.b; c.a = a.a }; a._getTexCoords = function() { return this._texCoords }; a._setTexCoords = function(a) { this._texCoords.u = a.u; this._texCoords.v = a.v }; cc.defineGetterSetter(a, "vertices", a._getVertices, a._setVertices); cc.defineGetterSetter(a, "colors", a._getColor, a._setColor); cc.defineGetterSetter(a, "texCoords", a._getTexCoords, a._setTexCoords); cc.V3F_C4B_T2F_Quad = function(a, c, d, e, f, g) { this._arrayBuffer = f || new ArrayBuffer(cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT); this._offset = g || 0; f = this._arrayBuffer; g = this._offset; var h = cc.V3F_C4B_T2F.BYTES_PER_ELEMENT; this._tl = a ? new cc.V3F_C4B_T2F(a.vertices, a.colors, a.texCoords, f, g) : new cc.V3F_C4B_T2F(null, null, null, f, g); this._bl = c ? new cc.V3F_C4B_T2F(c.vertices, c.colors, c.texCoords, f, g + h) : new cc.V3F_C4B_T2F(null, null, null, f, g + h); this._tr = d ? new cc.V3F_C4B_T2F(d.vertices, d.colors, d.texCoords, f, g + 2 * h) : new cc.V3F_C4B_T2F(null, null, null, f, g + 2 * h); this._br = e ? new cc.V3F_C4B_T2F(e.vertices, e.colors, e.texCoords, f, g + 3 * h) : new cc.V3F_C4B_T2F(null, null, null, f, g + 3 * h) }; cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT = 96; a = cc.V3F_C4B_T2F_Quad.prototype; a._getTL = function() { return this._tl }; a._setTL = function(a) { var c = this._tl; c.vertices = a.vertices; c.colors = a.colors; c.texCoords = a.texCoords }; a._getBL = function() { return this._bl }; a._setBL = function(a) { var c = this._bl; c.vertices = a.vertices; c.colors = a.colors; c.texCoords = a.texCoords }; a._getTR = function() { return this._tr }; a._setTR = function(a) { var c = this._tr; c.vertices = a.vertices; c.colors = a.colors; c.texCoords = a.texCoords }; a._getBR = function() { return this._br }; a._setBR = function(a) { var c = this._br; c.vertices = a.vertices; c.colors = a.colors; c.texCoords = a.texCoords }; a._getArrayBuffer = function() { return this._arrayBuffer }; cc.defineGetterSetter(a, "tl", a._getTL, a._setTL); cc.defineGetterSetter(a, "tr", a._getTR, a._setTR); cc.defineGetterSetter(a, "bl", a._getBL, a._setBL); cc.defineGetterSetter(a, "br", a._getBR, a._setBR); cc.defineGetterSetter(a, "arrayBuffer", a._getArrayBuffer, null); cc.V3F_C4B_T2F_QuadZero = function() { return new cc.V3F_C4B_T2F_Quad }; cc.V3F_C4B_T2F_QuadCopy = function(a) { if (!a) return cc.V3F_C4B_T2F_QuadZero(); var c = a.tl, d = a.bl, e = a.tr; a = a.br; return { tl: { vertices: { x: c.vertices.x, y: c.vertices.y, z: c.vertices.z }, colors: { r: c.colors.r, g: c.colors.g, b: c.colors.b, a: c.colors.a }, texCoords: { u: c.texCoords.u, v: c.texCoords.v } }, bl: { vertices: { x: d.vertices.x, y: d.vertices.y, z: d.vertices.z }, colors: { r: d.colors.r, g: d.colors.g, b: d.colors.b, a: d.colors.a }, texCoords: { u: d.texCoords.u, v: d.texCoords.v } }, tr: { vertices: { x: e.vertices.x, y: e.vertices.y, z: e.vertices.z }, colors: { r: e.colors.r, g: e.colors.g, b: e.colors.b, a: e.colors.a }, texCoords: { u: e.texCoords.u, v: e.texCoords.v } }, br: { vertices: { x: a.vertices.x, y: a.vertices.y, z: a.vertices.z }, colors: { r: a.colors.r, g: a.colors.g, b: a.colors.b, a: a.colors.a }, texCoords: { u: a.texCoords.u, v: a.texCoords.v } } } }; cc.V3F_C4B_T2F_QuadsCopy = function(a) { if (!a) return []; for (var c = [], d = 0; d < a.length; d++) c.push(cc.V3F_C4B_T2F_QuadCopy(a[d])); return c }; cc.V2F_C4B_T2F = function(a, c, d, e, f) { this._arrayBuffer = e || new ArrayBuffer(cc.V2F_C4B_T2F.BYTES_PER_ELEMENT); this._offset = f || 0; e = this._arrayBuffer; f = this._offset; var g = cc.Vertex2F.BYTES_PER_ELEMENT; this._vertices = a ? new cc.Vertex2F(a.x, a.y, e, f) : new cc.Vertex2F(0, 0, e, f); this._colors = c ? cc.color(c.r, c.g, c.b, c.a, e, f + g) : cc.color(0, 0, 0, 0, e, f + g); this._texCoords = d ? new cc.Tex2F(d.u, d.v, e, f + g + cc.Color.BYTES_PER_ELEMENT) : new cc.Tex2F(0, 0, e, f + g + cc.Color.BYTES_PER_ELEMENT) }; cc.V2F_C4B_T2F.BYTES_PER_ELEMENT = 20; a = cc.V2F_C4B_T2F.prototype; a._getVertices = function() { return this._vertices }; a._setVertices = function(a) { this._vertices.x = a.x; this._vertices.y = a.y }; a._getColor = function() { return this._colors }; a._setColor = function(a) { var c = this._colors; c.r = a.r; c.g = a.g; c.b = a.b; c.a = a.a }; a._getTexCoords = function() { return this._texCoords }; a._setTexCoords = function(a) { this._texCoords.u = a.u; this._texCoords.v = a.v }; cc.defineGetterSetter(a, "vertices", a._getVertices, a._setVertices); cc.defineGetterSetter(a, "colors", a._getColor, a._setColor); cc.defineGetterSetter(a, "texCoords", a._getTexCoords, a._setTexCoords); cc.V2F_C4B_T2F_Triangle = function(a, c, d, e, f) { this._arrayBuffer = e || new ArrayBuffer(cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT); this._offset = f || 0; e = this._arrayBuffer; f = this._offset; var g = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT; this._a = a ? new cc.V2F_C4B_T2F(a.vertices, a.colors, a.texCoords, e, f) : new cc.V2F_C4B_T2F(null, null, null, e, f); this._b = c ? new cc.V2F_C4B_T2F(c.vertices, c.colors, c.texCoords, e, f + g) : new cc.V2F_C4B_T2F(null, null, null, e, f + g); this._c = d ? new cc.V2F_C4B_T2F(d.vertices, d.colors, d.texCoords, e, f + 2 * g) : new cc.V2F_C4B_T2F(null, null, null, e, f + 2 * g) }; cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT = 60; a = cc.V2F_C4B_T2F_Triangle.prototype; a._getA = function() { return this._a }; a._setA = function(a) { var c = this._a; c.vertices = a.vertices; c.colors = a.colors; c.texCoords = a.texCoords }; a._getB = function() { return this._b }; a._setB = function(a) { var c = this._b; c.vertices = a.vertices; c.colors = a.colors; c.texCoords = a.texCoords }; a._getC = function() { return this._c }; a._setC = function(a) { var c = this._c; c.vertices = a.vertices; c.colors = a.colors; c.texCoords = a.texCoords }; cc.defineGetterSetter(a, "a", a._getA, a._setA); cc.defineGetterSetter(a, "b", a._getB, a._setB); cc.defineGetterSetter(a, "c", a._getC, a._setC) }; cc._tmp.PrototypeColor = function() { var a = cc.color; a._getWhite = function() { return a(255, 255, 255) }; a._getYellow = function() { return a(255, 255, 0) }; a._getBlue = function() { return a(0, 0, 255) }; a._getGreen = function() { return a(0, 255, 0) }; a._getRed = function() { return a(255, 0, 0) }; a._getMagenta = function() { return a(255, 0, 255) }; a._getBlack = function() { return a(0, 0, 0) }; a._getOrange = function() { return a(255, 127, 0) }; a._getGray = function() { return a(166, 166, 166) }; cc.defineGetterSetter(a, "WHITE", a._getWhite); cc.defineGetterSetter(a, "YELLOW", a._getYellow); cc.defineGetterSetter(a, "BLUE", a._getBlue); cc.defineGetterSetter(a, "GREEN", a._getGreen); cc.defineGetterSetter(a, "RED", a._getRed); cc.defineGetterSetter(a, "MAGENTA", a._getMagenta); cc.defineGetterSetter(a, "BLACK", a._getBlack); cc.defineGetterSetter(a, "ORANGE", a._getOrange); cc.defineGetterSetter(a, "GRAY", a._getGray); cc.BlendFunc._disable = function() { return new cc.BlendFunc(cc.ONE, cc.ZERO) }; cc.BlendFunc._alphaPremultiplied = function() { return new cc.BlendFunc(cc.ONE, cc.ONE_MINUS_SRC_ALPHA) }; cc.BlendFunc._alphaNonPremultiplied = function() { return new cc.BlendFunc(cc.SRC_ALPHA, cc.ONE_MINUS_SRC_ALPHA) }; cc.BlendFunc._additive = function() { return new cc.BlendFunc(cc.SRC_ALPHA, cc.ONE) }; cc.defineGetterSetter(cc.BlendFunc, "DISABLE", cc.BlendFunc._disable); cc.defineGetterSetter(cc.BlendFunc, "ALPHA_PREMULTIPLIED", cc.BlendFunc._alphaPremultiplied); cc.defineGetterSetter(cc.BlendFunc, "ALPHA_NON_PREMULTIPLIED", cc.BlendFunc._alphaNonPremultiplied); cc.defineGetterSetter(cc.BlendFunc, "ADDITIVE", cc.BlendFunc._additive) }; cc.Color = function(a, b, c, d) { this.r = a || 0; this.g = b || 0; this.b = c || 0; this.a = null == d ? 255 : d }; cc.color = function(a, b, c, d) { return void 0 === a ? { r: 0, g: 0, b: 0, a: 255 } : cc.isString(a) ? cc.hexToColor(a) : cc.isObject(a) ? { r: a.r, g: a.g, b: a.b, a: null == a.a ? 255 : a.a } : { r: a, g: b, b: c, a: null == d ? 255 : d } }; cc.colorEqual = function(a, b) { return a.r === b.r && a.g === b.g && a.b === b.b }; cc.Acceleration = function(a, b, c, d) { this.x = a || 0; this.y = b || 0; this.z = c || 0; this.timestamp = d || 0 }; cc.Vertex2F = function(a, b) { this.x = a || 0; this.y = b || 0 }; cc.vertex2 = function(a, b) { return new cc.Vertex2F(a, b) }; cc.Vertex3F = function(a, b, c) { this.x = a || 0; this.y = b || 0; this.z = c || 0 }; cc.vertex3 = function(a, b, c) { return new cc.Vertex3F(a, b, c) }; cc.Tex2F = function(a, b) { this.u = a || 0; this.v = b || 0 }; cc.tex2 = function(a, b) { return new cc.Tex2F(a, b) }; cc.BlendFunc = function(a, b) { this.src = a; this.dst = b }; cc.blendFuncDisable = function() { return new cc.BlendFunc(cc.ONE, cc.ZERO) }; cc.hexToColor = function(a) { a = a.replace(/^#?/, "0x"); a = parseInt(a); return cc.color(a >> 16, (a >> 8) % 256, a % 256) }; cc.colorToHex = function(a) { var b = a.r.toString(16), c = a.g.toString(16), d = a.b.toString(16); return "#" + (16 > a.r ? "0" + b : b) + (16 > a.g ? "0" + c : c) + (16 > a.b ? "0" + d : d) }; cc.TEXT_ALIGNMENT_LEFT = 0; cc.TEXT_ALIGNMENT_CENTER = 1; cc.TEXT_ALIGNMENT_RIGHT = 2; cc.VERTICAL_TEXT_ALIGNMENT_TOP = 0; cc.VERTICAL_TEXT_ALIGNMENT_CENTER = 1; cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM = 2; cc._Dictionary = cc.Class.extend({ _keyMapTb: null, _valueMapTb: null, __currId: 0, ctor: function() { this._keyMapTb = {}; this._valueMapTb = {}; this.__currId = 2 << (0 | 10 * Math.random()) }, __getKey: function() { this.__currId++; return "key_" + this.__currId }, setObject: function(a, b) { if (null != b) { var c = this.__getKey(); this._keyMapTb[c] = b; this._valueMapTb[c] = a } }, objectForKey: function(a) { if (null == a) return null; var b = this._keyMapTb, c; for (c in b) if (b[c] === a) return this._valueMapTb[c]; return null }, valueForKey: function(a) { return this.objectForKey(a) }, removeObjectForKey: function(a) { if (null != a) { var b = this._keyMapTb, c; for (c in b) if (b[c] === a) { delete this._valueMapTb[c]; delete b[c]; break } } }, removeObjectsForKeys: function(a) { if (null != a) for (var b = 0; b < a.length; b++) this.removeObjectForKey(a[b]) }, allKeys: function() { var a = [], b = this._keyMapTb, c; for (c in b) a.push(b[c]); return a }, removeAllObjects: function() { this._keyMapTb = {}; this._valueMapTb = {} }, count: function() { return this.allKeys().length } }); cc.FontDefinition = function(a) { this.fontName = "Arial"; this.fontSize = 12; this.textAlign = cc.TEXT_ALIGNMENT_CENTER; this.verticalAlign = cc.VERTICAL_TEXT_ALIGNMENT_TOP; this.fillStyle = cc.color(255, 255, 255, 255); this.boundingHeight = this.boundingWidth = 0; this.strokeEnabled = !1; this.strokeStyle = cc.color(255, 255, 255, 255); this.lineWidth = 1; this.fontWeight = this.fontStyle = this.lineHeight = "normal"; this.shadowEnabled = !1; this.shadowBlur = this.shadowOffsetY = this.shadowOffsetX = 0; this.shadowOpacity = 1; if (a && a instanceof Object) for (var b in a) this[b] = a[b] }; cc.FontDefinition.prototype._getCanvasFontStr = function() { return this.fontStyle + " " + this.fontWeight + " " + this.fontSize + "px/" + (this.lineHeight.charAt ? this.lineHeight : this.lineHeight + "px") + " '" + this.fontName + "'" }; cc._renderType === cc._RENDER_TYPE_WEBGL && (cc.assert(cc.isFunction(cc._tmp.WebGLColor), cc._LogInfos.MissingFile, "CCTypesWebGL.js"), cc._tmp.WebGLColor(), delete cc._tmp.WebGLColor); cc.assert(cc.isFunction(cc._tmp.PrototypeColor), cc._LogInfos.MissingFile, "CCTypesPropertyDefine.js"); cc._tmp.PrototypeColor(); delete cc._tmp.PrototypeColor; cc.Touches = []; cc.TouchesIntergerDict = {}; cc.DENSITYDPI_DEVICE = "device-dpi"; cc.DENSITYDPI_HIGH = "high-dpi"; cc.DENSITYDPI_MEDIUM = "medium-dpi"; cc.DENSITYDPI_LOW = "low-dpi"; cc.__BrowserGetter = { init: function() { this.html = document.getElementsByTagName("html")[0] }, availWidth: function(a) { return a && a !== this.html ? a.clientWidth : window.innerWidth }, availHeight: function(a) { return a && a !== this.html ? a.clientHeight : window.innerHeight }, meta: { width: "device-width", "user-scalable": "no" }, adaptationType: cc.sys.browserType }; - 1 < window.navigator.userAgent.indexOf("OS 8_1_") && (cc.__BrowserGetter.adaptationType = cc.sys.BROWSER_TYPE_MIUI); switch (cc.__BrowserGetter.adaptationType) { case cc.sys.BROWSER_TYPE_SAFARI: cc.__BrowserGetter.meta["minimal-ui"] = "true"; cc.__BrowserGetter.availWidth = function(a) { return a.clientWidth }; cc.__BrowserGetter.availHeight = function(a) { return a.clientHeight }; break; case cc.sys.BROWSER_TYPE_CHROME: cc.__BrowserGetter.__defineGetter__("target-densitydpi", function() { return cc.view._targetDensityDPI }); case cc.sys.BROWSER_TYPE_SOUGOU: case cc.sys.BROWSER_TYPE_UC: cc.__BrowserGetter.availWidth = function(a) { return a.clientWidth }; cc.__BrowserGetter.availHeight = function(a) { return a.clientHeight }; break; case cc.sys.BROWSER_TYPE_MIUI: cc.__BrowserGetter.init = function(a) { if (!a.__resizeWithBrowserSize) { var b = function() { a.setDesignResolutionSize(a._designResolutionSize.width, a._designResolutionSize.height, a._resolutionPolicy); window.removeEventListener("resize", b, !1) }; window.addEventListener("resize", b, !1) } } } cc.EGLView = cc.Class.extend({ _delegate: null, _frameSize: null, _designResolutionSize: null, _originalDesignResolutionSize: null, _viewPortRect: null, _visibleRect: null, _retinaEnabled: !1, _autoFullScreen: !0, _devicePixelRatio: 1, _viewName: "", _resizeCallback: null, _scaleX: 1, _originalScaleX: 1, _scaleY: 1, _originalScaleY: 1, _indexBitsUsed: 0, _maxTouches: 5, _resolutionPolicy: null, _rpExactFit: null, _rpShowAll: null, _rpNoBorder: null, _rpFixedHeight: null, _rpFixedWidth: null, _initialized: !1, _captured: !1, _wnd: null, _hDC: null, _hRC: null, _supportTouch: !1, _contentTranslateLeftTop: null, _frame: null, _frameZoomFactor: 1, __resizeWithBrowserSize: !1, _isAdjustViewPort: !0, _targetDensityDPI: null, ctor: function() { var a = document, b = cc.ContainerStrategy, c = cc.ContentStrategy; cc.__BrowserGetter.init(this); this._frame = cc.container.parentNode === a.body ? a.documentElement : cc.container.parentNode; this._frameSize = cc.size(0, 0); this._initFrameSize(); var a = cc._canvas.width, d = cc._canvas.height; this._designResolutionSize = cc.size(a, d); this._originalDesignResolutionSize = cc.size(a, d); this._viewPortRect = cc.rect(0, 0, a, d); this._visibleRect = cc.rect(0, 0, a, d); this._contentTranslateLeftTop = { left: 0, top: 0 }; this._viewName = "Cocos2dHTML5"; a = cc.sys; this.enableRetina(a.os === a.OS_IOS || a.os === a.OS_OSX); cc.visibleRect && cc.visibleRect.init(this._visibleRect); this._rpExactFit = new cc.ResolutionPolicy(b.EQUAL_TO_FRAME, c.EXACT_FIT); this._rpShowAll = new cc.ResolutionPolicy(b.PROPORTION_TO_FRAME, c.SHOW_ALL); this._rpNoBorder = new cc.ResolutionPolicy(b.EQUAL_TO_FRAME, c.NO_BORDER); this._rpFixedHeight = new cc.ResolutionPolicy(b.EQUAL_TO_FRAME, c.FIXED_HEIGHT); this._rpFixedWidth = new cc.ResolutionPolicy(b.EQUAL_TO_FRAME, c.FIXED_WIDTH); this._hDC = cc._canvas; this._hRC = cc._renderContext; this._targetDensityDPI = cc.DENSITYDPI_HIGH }, _resizeEvent: function() { var a; a = this.setDesignResolutionSize ? this : cc.view; var b = a._frameSize.width, c = a._frameSize.height; a._initFrameSize(); if (a._frameSize.width !== b || a._frameSize.height !== c) a._resizeCallback && a._resizeCallback.call(), b = a._originalDesignResolutionSize.width, c = a._originalDesignResolutionSize.height, 0 < b && a.setDesignResolutionSize(b, c, a._resolutionPolicy) }, setTargetDensityDPI: function(a) { this._targetDensityDPI = a; this._setViewPortMeta() }, getTargetDensityDPI: function() { return this._targetDensityDPI }, resizeWithBrowserSize: function(a) { a ? this.__resizeWithBrowserSize || (this.__resizeWithBrowserSize = !0, cc._addEventListener(window, "resize", this._resizeEvent), cc._addEventListener(window, "orientationchange", this._resizeEvent)) : this.__resizeWithBrowserSize && (this.__resizeWithBrowserSize = !1, window.removeEventListener("resize", this._resizeEvent), window.removeEventListener("orientationchange", this._resizeEvent)) }, setResizeCallback: function(a) { if (cc.isFunction(a) || null == a) this._resizeCallback = a }, _initFrameSize: function() { var a = this._frameSize; a.width = cc.__BrowserGetter.availWidth(this._frame); a.height = cc.__BrowserGetter.availHeight(this._frame) }, _adjustSizeKeepCanvasSize: function() { var a = this._originalDesignResolutionSize.width, b = this._originalDesignResolutionSize.height; 0 < a && this.setDesignResolutionSize(a, b, this._resolutionPolicy) }, _setViewPortMeta: function() { if (this._isAdjustViewPort) { var a = document.getElementById("cocosMetaElement"); a && document.head.removeChild(a); var b, c = (a = document.getElementsByName("viewport")) ? a[0] : null, d, a = cc.newElement("meta"); a.id = "cocosMetaElement"; a.name = "viewport"; a.content = ""; b = cc.__BrowserGetter.meta; d = c ? c.content : ""; for (var e in b) RegExp(e).test(d) || (d += "," + e + "\x3d" + b[e]); /^,/.test(d) && (d = d.substr(1)); a.content = d; c && (c.content = d); document.head.appendChild(a) } }, _setScaleXYForRenderTexture: function() { var a = cc.contentScaleFactor(); this._scaleY = this._scaleX = a }, _resetScale: function() { this._scaleX = this._originalScaleX; this._scaleY = this._originalScaleY }, _adjustSizeToBrowser: function() {}, initialize: function() { this._initialized = !0 }, adjustViewPort: function(a) { this._isAdjustViewPort = a }, enableRetina: function(a) { this._retinaEnabled = a ? !0 : !1 }, isRetinaEnabled: function() { return this._retinaEnabled }, enableAutoFullScreen: function(a) { this._autoFullScreen = a ? !0 : !1 }, isAutoFullScreenEnabled: function() { return this._autoFullScreen }, end: function() {}, isOpenGLReady: function() { return null !== this._hDC && null !== this._hRC }, setFrameZoomFactor: function(a) { this._frameZoomFactor = a; this.centerWindow(); cc.director.setProjection(cc.director.getProjection()) }, swapBuffers: function() {}, setIMEKeyboardState: function(a) {}, setContentTranslateLeftTop: function(a, b) { this._contentTranslateLeftTop = { left: a, top: b } }, getContentTranslateLeftTop: function() { return this._contentTranslateLeftTop }, getFrameSize: function() { return cc.size(this._frameSize.width, this._frameSize.height) }, setFrameSize: function(a, b) { this._frameSize.width = a; this._frameSize.height = b; this._frame.style.width = a + "px"; this._frame.style.height = b + "px"; this._resizeEvent(); cc.director.setProjection(cc.director.getProjection()) }, centerWindow: function() {}, getVisibleSize: function() { return cc.size(this._visibleRect.width, this._visibleRect.height) }, getVisibleOrigin: function() { return cc.p(this._visibleRect.x, this._visibleRect.y) }, canSetContentScaleFactor: function() { return !0 }, getResolutionPolicy: function() { return this._resolutionPolicy }, setResolutionPolicy: function(a) { if (a instanceof cc.ResolutionPolicy) this._resolutionPolicy = a; else { var b = cc.ResolutionPolicy; a === b.EXACT_FIT && (this._resolutionPolicy = this._rpExactFit); a === b.SHOW_ALL && (this._resolutionPolicy = this._rpShowAll); a === b.NO_BORDER && (this._resolutionPolicy = this._rpNoBorder); a === b.FIXED_HEIGHT && (this._resolutionPolicy = this._rpFixedHeight); a === b.FIXED_WIDTH && (this._resolutionPolicy = this._rpFixedWidth) } }, setDesignResolutionSize: function(a, b, c) { if (0 < a || 0 < b) if (this.setResolutionPolicy(c), c = this._resolutionPolicy) { c.preApply(this); cc.sys.isMobile && this._setViewPortMeta(); this._initFrameSize(); this._originalDesignResolutionSize.width = this._designResolutionSize.width = a; this._originalDesignResolutionSize.height = this._designResolutionSize.height = b; var d = c.apply(this, this._designResolutionSize); d.scale && 2 === d.scale.length && (this._scaleX = d.scale[0], this._scaleY = d.scale[1]); d.viewport && (a = this._viewPortRect, b = this._visibleRect, d = d.viewport, a.x = d.x, a.y = d.y, a.width = d.width, a.height = d.height, b.x = -a.x / this._scaleX, b.y = -a.y / this._scaleY, b.width = cc._canvas.width / this._scaleX, b.height = cc._canvas.height / this._scaleY, cc._renderContext.setOffset && cc._renderContext.setOffset(a.x, -a.y)); a = cc.director; a._winSizeInPoints.width = this._designResolutionSize.width; a._winSizeInPoints.height = this._designResolutionSize.height; c.postApply(this); cc.winSize.width = a._winSizeInPoints.width; cc.winSize.height = a._winSizeInPoints.height; cc._renderType === cc._RENDER_TYPE_WEBGL && (a._createStatsLabel(), a.setGLDefaultValues()); this._originalScaleX = this._scaleX; this._originalScaleY = this._scaleY; cc.DOM && cc.DOM._resetEGLViewDiv(); cc.visibleRect && cc.visibleRect.init(this._visibleRect) } else cc.log(cc._LogInfos.EGLView_setDesignResolutionSize_2); else cc.log(cc._LogInfos.EGLView_setDesignResolutionSize) }, getDesignResolutionSize: function() { return cc.size(this._designResolutionSize.width, this._designResolutionSize.height) }, setViewPortInPoints: function(a, b, c, d) { var e = this._frameZoomFactor, f = this._scaleX, g = this._scaleY; cc._renderContext.viewport(a * f * e + this._viewPortRect.x * e, b * g * e + this._viewPortRect.y * e, c * f * e, d * g * e) }, setScissorInPoints: function(a, b, c, d) { var e = this._frameZoomFactor, f = this._scaleX, g = this._scaleY; cc._renderContext.scissor(a * f * e + this._viewPortRect.x * e, b * g * e + this._viewPortRect.y * e, c * f * e, d * g * e) }, isScissorEnabled: function() { var a = cc._renderContext; return a.isEnabled(a.SCISSOR_TEST) }, getScissorRect: function() { var a = cc._renderContext, b = this._scaleX, c = this._scaleY, a = a.getParameter(a.SCISSOR_BOX); return cc.rect((a[0] - this._viewPortRect.x) / b, (a[1] - this._viewPortRect.y) / c, a[2] / b, a[3] / c) }, setViewName: function(a) { null != a && 0 < a.length && (this._viewName = a) }, getViewName: function() { return this._viewName }, getViewPortRect: function() { return this._viewPortRect }, getScaleX: function() { return this._scaleX }, getScaleY: function() { return this._scaleY }, getDevicePixelRatio: function() { return this._devicePixelRatio }, convertToLocationInView: function(a, b, c) { return { x: this._devicePixelRatio * (a - c.left), y: this._devicePixelRatio * (c.top + c.height - b) } }, _convertMouseToLocationInView: function(a, b) { var c = this._viewPortRect; a.x = (this._devicePixelRatio * (a.x - b.left) - c.x) / this._scaleX; a.y = (this._devicePixelRatio * (b.top + b.height - a.y) - c.y) / this._scaleY }, _convertTouchesWithScale: function(a) { for (var b = this._viewPortRect, c = this._scaleX, d = this._scaleY, e, f, g, h = 0; h < a.length; h++) e = a[h], f = e._point, g = e._prevPoint, e._setPoint((f.x - b.x) / c, (f.y - b.y) / d), e._setPrevPoint((g.x - b.x) / c, (g.y - b.y) / d) } }); cc.EGLView._getInstance = function() { this._instance || (this._instance = this._instance || new cc.EGLView, this._instance.initialize()); return this._instance }; cc.ContainerStrategy = cc.Class.extend({ preApply: function(a) {}, apply: function(a, b) {}, postApply: function(a) {}, _setupContainer: function(a, b, c) { var d = a._frame; cc.view._autoFullScreen && cc.sys.isMobile && d === document.documentElement && cc.screen.autoFullScreen(d); var d = cc._canvas, e = cc.container; e.style.width = d.style.width = b + "px"; e.style.height = d.style.height = c + "px"; e = a._devicePixelRatio = 1; a.isRetinaEnabled() && (e = a._devicePixelRatio = window.devicePixelRatio || 1); d.width = b * e; d.height = c * e; cc._renderContext.resetCache && cc._renderContext.resetCache(); a = document.body; var f; a && (f = a.style) && (f.paddingTop = f.paddingTop || "0px", f.paddingRight = f.paddingRight || "0px", f.paddingBottom = f.paddingBottom || "0px", f.paddingLeft = f.paddingLeft || "0px", f.borderTop = f.borderTop || "0px", f.borderRight = f.borderRight || "0px", f.borderBottom = f.borderBottom || "0px", f.borderLeft = f.borderLeft || "0px", f.marginTop = f.marginTop || "0px", f.marginRight = f.marginRight || "0px", f.marginBottom = f.marginBottom || "0px", f.marginLeft = f.marginLeft || "0px") }, _fixContainer: function() { document.body.insertBefore(cc.container, document.body.firstChild); var a = document.body.style; a.width = window.innerWidth + "px"; a.height = window.innerHeight + "px"; a.overflow = "hidden"; a = cc.container.style; a.position = "fixed"; a.left = a.top = "0px"; document.body.scrollTop = 0 } }); cc.ContentStrategy = cc.Class.extend({ _result: { scale: [1, 1], viewport: null }, _buildResult: function(a, b, c, d, e, f) { 2 > Math.abs(a - c) && (c = a); 2 > Math.abs(b - d) && (d = b); a = cc.rect(Math.round((a - c) / 2), Math.round((b - d) / 2), c, d); this._result.scale = [e, f]; this._result.viewport = a; return this._result }, preApply: function(a) {}, apply: function(a, b) { return { scale: [1, 1] } }, postApply: function(a) {} }); (function() { var a = cc.ContainerStrategy.extend({ apply: function(a) { this._setupContainer(a, a._frameSize.width, a._frameSize.height) } }), b = cc.ContainerStrategy.extend({ apply: function(a, b) { var c = a._frameSize.width, d = a._frameSize.height, e = cc.container.style, n = b.width, p = b.height, t = c / n, r = d / p, u, s; t < r ? (u = c, s = p * t) : (u = n * r, s = d); n = Math.round((c - u) / 2); s = Math.round((d - s) / 2); this._setupContainer(a, c - 2 * n, d - 2 * s); e.marginLeft = n + "px"; e.marginRight = n + "px"; e.marginTop = s + "px"; e.marginBottom = s + "px" } }); a.extend({ preApply: function(a) { this._super(a); a._frame = document.documentElement }, apply: function(a) { this._super(a); this._fixContainer() } }); b.extend({ preApply: function(a) { this._super(a); a._frame = document.documentElement }, apply: function(a, b) { this._super(a, b); this._fixContainer() } }); var c = cc.ContainerStrategy.extend({ apply: function(a) { this._setupContainer(a, cc._canvas.width, cc._canvas.height) } }); cc.ContainerStrategy.EQUAL_TO_FRAME = new a; cc.ContainerStrategy.PROPORTION_TO_FRAME = new b; cc.ContainerStrategy.ORIGINAL_CONTAINER = new c; var a = cc.ContentStrategy.extend({ apply: function(a, b) { var c = cc._canvas.width, d = cc._canvas.height; return this._buildResult(c, d, c, d, c / b.width, d / b.height) } }), b = cc.ContentStrategy.extend({ apply: function(a, b) { var c = cc._canvas.width, d = cc._canvas.height, e = b.width, n = b.height, p = c / e, t = d / n, r = 0, u, s; p < t ? (r = p, u = c, s = n * r) : (r = t, u = e * r, s = d); return this._buildResult(c, d, u, s, r, r) } }), c = cc.ContentStrategy.extend({ apply: function(a, b) { var c = cc._canvas.width, d = cc._canvas.height, e = b.width, n = b.height, p = c / e, t = d / n, r, u, s; p < t ? (r = t, u = e * r, s = d) : (r = p, u = c, s = n * r); return this._buildResult(c, d, u, s, r, r) } }), d = cc.ContentStrategy.extend({ apply: function(a, b) { var c = cc._canvas.width, d = cc._canvas.height, e = d / b.height; return this._buildResult(c, d, c, d, e, e) }, postApply: function(a) { cc.director._winSizeInPoints = a.getVisibleSize() } }), e = cc.ContentStrategy.extend({ apply: function(a, b) { var c = cc._canvas.width, d = cc._canvas.height, e = c / b.width; return this._buildResult(c, d, c, d, e, e) }, postApply: function(a) { cc.director._winSizeInPoints = a.getVisibleSize() } }); cc.ContentStrategy.EXACT_FIT = new a; cc.ContentStrategy.SHOW_ALL = new b; cc.ContentStrategy.NO_BORDER = new c; cc.ContentStrategy.FIXED_HEIGHT = new d; cc.ContentStrategy.FIXED_WIDTH = new e })(); cc.ResolutionPolicy = cc.Class.extend({ _containerStrategy: null, _contentStrategy: null, ctor: function(a, b) { this.setContainerStrategy(a); this.setContentStrategy(b) }, preApply: function(a) { this._containerStrategy.preApply(a); this._contentStrategy.preApply(a) }, apply: function(a, b) { this._containerStrategy.apply(a, b); return this._contentStrategy.apply(a, b) }, postApply: function(a) { this._containerStrategy.postApply(a); this._contentStrategy.postApply(a) }, setContainerStrategy: function(a) { a instanceof cc.ContainerStrategy && (this._containerStrategy = a) }, setContentStrategy: function(a) { a instanceof cc.ContentStrategy && (this._contentStrategy = a) } }); cc.ResolutionPolicy.EXACT_FIT = 0; cc.ResolutionPolicy.NO_BORDER = 1; cc.ResolutionPolicy.SHOW_ALL = 2; cc.ResolutionPolicy.FIXED_HEIGHT = 3; cc.ResolutionPolicy.FIXED_WIDTH = 4; cc.ResolutionPolicy.UNKNOWN = 5; cc.screen = { _supportsFullScreen: !1, _preOnFullScreenChange: null, _touchEvent: "", _fn: null, _fnMap: [ ["requestFullscreen", "exitFullscreen", "fullscreenchange", "fullscreenEnabled", "fullscreenElement"], ["requestFullScreen", "exitFullScreen", "fullScreenchange", "fullScreenEnabled", "fullScreenElement"], ["webkitRequestFullScreen", "webkitCancelFullScreen", "webkitfullscreenchange", "webkitIsFullScreen", "webkitCurrentFullScreenElement"], ["mozRequestFullScreen", "mozCancelFullScreen", "mozfullscreenchange", "mozFullScreen", "mozFullScreenElement" ], ["msRequestFullscreen", "msExitFullscreen", "MSFullscreenChange", "msFullscreenEnabled", "msFullscreenElement"] ], init: function() { this._fn = {}; var a, b, c = this._fnMap, d; a = 0; for (l = c.length; a < l; a++) if ((b = c[a]) && b[1] in document) { a = 0; for (d = b.length; a < d; a++) this._fn[c[0][a]] = b[a]; break } this._supportsFullScreen = "undefined" !== typeof this._fn.requestFullscreen; this._touchEvent = "ontouchstart" in window ? "touchstart" : "mousedown" }, fullScreen: function() { return this._supportsFullScreen && document[this._fn.fullscreenElement] }, requestFullScreen: function(a, b) { if (this._supportsFullScreen) { a = a || document.documentElement; if (b) { var c = this._fn.fullscreenchange; this._preOnFullScreenChange && document.removeEventListener(c, this._preOnFullScreenChange); this._preOnFullScreenChange = b; cc._addEventListener(document, c, b, !1) } return a[this._fn.requestFullscreen]() } }, exitFullScreen: function() { return this._supportsFullScreen ? document[this._fn.exitFullscreen]() : !0 }, autoFullScreen: function(a, b) { function c() { e.requestFullScreen(a, b); d.removeEventListener(e._touchEvent, c) } a = a || document.body; var d = cc._canvas || a, e = this; this.requestFullScreen(a, b); cc._addEventListener(d, this._touchEvent, c) } }; cc.screen.init(); cc.visibleRect = { topLeft: cc.p(0, 0), topRight: cc.p(0, 0), top: cc.p(0, 0), bottomLeft: cc.p(0, 0), bottomRight: cc.p(0, 0), bottom: cc.p(0, 0), center: cc.p(0, 0), left: cc.p(0, 0), right: cc.p(0, 0), width: 0, height: 0, init: function(a) { var b = this.width = a.width, c = this.height = a.height, d = a.x; a = a.y; var e = a + c, f = d + b; this.topLeft.x = d; this.topLeft.y = e; this.topRight.x = f; this.topRight.y = e; this.top.x = d + b / 2; this.top.y = e; this.bottomLeft.x = d; this.bottomLeft.y = a; this.bottomRight.x = f; this.bottomRight.y = a; this.bottom.x = d + b / 2; this.bottom.y = a; this.center.x = d + b / 2; this.center.y = a + c / 2; this.left.x = d; this.left.y = a + c / 2; this.right.x = f; this.right.y = a + c / 2 } }; cc.UIInterfaceOrientationLandscapeLeft = -90; cc.UIInterfaceOrientationLandscapeRight = 90; cc.UIInterfaceOrientationPortraitUpsideDown = 180; cc.UIInterfaceOrientationPortrait = 0; cc.inputManager = { _mousePressed: !1, _isRegisterEvent: !1, _preTouchPoint: cc.p(0, 0), _prevMousePoint: cc.p(0, 0), _preTouchPool: [], _preTouchPoolPointer: 0, _touches: [], _touchesIntegerDict: {}, _indexBitsUsed: 0, _maxTouches: 5, _accelEnabled: !1, _accelInterval: 1 / 30, _accelMinus: 1, _accelCurTime: 0, _acceleration: null, _accelDeviceEvent: null, _getUnUsedIndex: function() { for (var a = this._indexBitsUsed, b = 0; b < this._maxTouches; b++) { if (!(a & 1)) return this._indexBitsUsed |= 1 << b, b; a >>= 1 } return -1 }, _removeUsedIndexBit: function(a) { 0 > a || a >= this._maxTouches || (a = ~(1 << a), this._indexBitsUsed &= a) }, _glView: null, handleTouchesBegin: function(a) { for (var b, c, d, e = [], f = this._touchesIntegerDict, g = 0, h = a.length; g < h; g++) if (b = a[g], d = b.getID(), c = f[d], null == c) { var k = this._getUnUsedIndex(); - 1 === k ? cc.log(cc._LogInfos.inputManager_handleTouchesBegin, k) : (c = this._touches[k] = new cc.Touch(b._point.x, b._point.y, b.getID()), c._setPrevPoint(b._prevPoint), f[d] = k, e.push(c)) } 0 < e.length && (this._glView._convertTouchesWithScale(e), a = new cc.EventTouch(e), a._eventCode = cc.EventTouch.EventCode.BEGAN, cc.eventManager.dispatchEvent(a)) }, handleTouchesMove: function(a) { for (var b, c, d = [], e = this._touches, f = 0, g = a.length; f < g; f++) b = a[f], c = b.getID(), c = this._touchesIntegerDict[c], null != c && e[c] && (e[c]._setPoint(b._point), e[c]._setPrevPoint(b._prevPoint), d.push(e[c])); 0 < d.length && (this._glView._convertTouchesWithScale(d), a = new cc.EventTouch(d), a._eventCode = cc.EventTouch.EventCode.MOVED, cc.eventManager.dispatchEvent(a)) }, handleTouchesEnd: function(a) { a = this.getSetOfTouchesEndOrCancel(a); 0 < a.length && (this._glView._convertTouchesWithScale(a), a = new cc.EventTouch(a), a._eventCode = cc.EventTouch.EventCode.ENDED, cc.eventManager.dispatchEvent(a)) }, handleTouchesCancel: function(a) { a = this.getSetOfTouchesEndOrCancel(a); 0 < a.length && (this._glView._convertTouchesWithScale(a), a = new cc.EventTouch(a), a._eventCode = cc.EventTouch.EventCode.CANCELLED, cc.eventManager.dispatchEvent(a)) }, getSetOfTouchesEndOrCancel: function(a) { for (var b, c, d, e = [], f = this._touches, g = this._touchesIntegerDict, h = 0, k = a.length; h < k; h++) b = a[h], d = b.getID(), c = g[d], null != c && f[c] && (f[c]._setPoint(b._point), f[c]._setPrevPoint(b._prevPoint), e.push(f[c]), this._removeUsedIndexBit(c), delete g[d]); return e }, getHTMLElementPosition: function(a) { var b = document.documentElement, c = window, d = null, d = cc.isFunction(a.getBoundingClientRect) ? a.getBoundingClientRect() : a instanceof HTMLCanvasElement ? { left: 0, top: 0, width: a.width, height: a.height } : { left: 0, top: 0, width: parseInt(a.style.width), height: parseInt(a.style.height) }; return { left: d.left + c.pageXOffset - b.clientLeft, top: d.top + c.pageYOffset - b.clientTop, width: d.width, height: d.height } }, getPreTouch: function(a) { for (var b = null, c = this._preTouchPool, d = a.getID(), e = c.length - 1; 0 <= e; e--) if (c[e].getID() === d) { b = c[e]; break } b || (b = a); return b }, setPreTouch: function(a) { for (var b = !1, c = this._preTouchPool, d = a.getID(), e = c.length - 1; 0 <= e; e--) if (c[e].getID() === d) { c[e] = a; b = !0; break } b || (50 >= c.length ? c.push(a) : (c[this._preTouchPoolPointer] = a, this._preTouchPoolPointer = (this._preTouchPoolPointer + 1) % 50)) }, getTouchByXY: function(a, b, c) { var d = this._preTouchPoint; a = this._glView.convertToLocationInView(a, b, c); b = new cc.Touch(a.x, a.y); b._setPrevPoint(d.x, d.y); d.x = a.x; d.y = a.y; return b }, getMouseEvent: function(a, b, c) { var d = this._prevMousePoint; this._glView._convertMouseToLocationInView(a, b); b = new cc.EventMouse(c); b.setLocation(a.x, a.y); b._setPrevCursor(d.x, d.y); d.x = a.x; d.y = a.y; return b }, getPointByEvent: function(a, b) { if (null != a.pageX) return { x: a.pageX, y: a.pageY }; b.left -= document.body.scrollLeft; b.top -= document.body.scrollTop; return { x: a.clientX, y: a.clientY } }, getTouchesByEvent: function(a, b) { for (var c = [], d = this._glView, e, f, g = this._preTouchPoint, h = a.changedTouches.length, k = 0; k < h; k++) if (e = a.changedTouches[k]) { var m; m = cc.sys.BROWSER_TYPE_FIREFOX === cc.sys.browserType ? d.convertToLocationInView(e.pageX, e.pageY, b) : d.convertToLocationInView(e.clientX, e.clientY, b); null != e.identifier ? (e = new cc.Touch(m.x, m.y, e.identifier), f = this.getPreTouch(e).getLocation(), e._setPrevPoint(f.x, f.y), this.setPreTouch(e)) : (e = new cc.Touch(m.x, m.y), e._setPrevPoint(g.x, g.y)); g.x = m.x; g.y = m.y; c.push(e) } return c }, registerSystemEvent: function(a) { if (!this._isRegisterEvent) { this._glView = cc.view; var b = this, c = "mouse" in cc.sys.capabilities, d = "touches" in cc.sys.capabilities, e = !1; cc.sys.isMobile && (e = !0); c && (cc._addEventListener(window, "mousedown", function() { b._mousePressed = !0 }, !1), cc._addEventListener(window, "mouseup", function(c) { if (!e) { var d = b._mousePressed; b._mousePressed = !1; if (d) { var d = b.getHTMLElementPosition(a), f = b.getPointByEvent(c, d); cc.rectContainsPoint(new cc.Rect(d.left, d.top, d.width, d.height), f) || (b.handleTouchesEnd([b.getTouchByXY(f.x, f.y, d)]), d = b.getMouseEvent(f, d, cc.EventMouse.UP), d.setButton(c.button), cc.eventManager.dispatchEvent(d)) } } }, !1), cc._addEventListener(a, "mousedown", function(c) { if (!e) { b._mousePressed = !0; var d = b.getHTMLElementPosition(a), f = b.getPointByEvent(c, d); b.handleTouchesBegin([b.getTouchByXY(f.x, f.y, d)]); d = b.getMouseEvent(f, d, cc.EventMouse.DOWN); d.setButton(c.button); cc.eventManager.dispatchEvent(d); c.stopPropagation(); c.preventDefault(); a.focus() } }, !1), cc._addEventListener(a, "mouseup", function(c) { if (!e) { b._mousePressed = !1; var d = b.getHTMLElementPosition(a), f = b.getPointByEvent(c, d); b.handleTouchesEnd([b.getTouchByXY(f.x, f.y, d)]); d = b.getMouseEvent(f, d, cc.EventMouse.UP); d.setButton(c.button); cc.eventManager.dispatchEvent(d); c.stopPropagation(); c.preventDefault() } }, !1), cc._addEventListener(a, "mousemove", function(c) { if (!e) { var d = b.getHTMLElementPosition(a), f = b.getPointByEvent(c, d); b.handleTouchesMove([b.getTouchByXY(f.x, f.y, d)]); d = b.getMouseEvent(f, d, cc.EventMouse.MOVE); b._mousePressed ? d.setButton(c.button) : d.setButton(null); cc.eventManager.dispatchEvent(d); c.stopPropagation(); c.preventDefault() } }, !1), cc._addEventListener(a, "mousewheel", function(c) { var d = b.getHTMLElementPosition(a), e = b.getPointByEvent(c, d), d = b.getMouseEvent(e, d, cc.EventMouse.SCROLL); d.setButton(c.button); d.setScrollData(0, c.wheelDelta); cc.eventManager.dispatchEvent(d); c.stopPropagation(); c.preventDefault() }, !1), cc._addEventListener(a, "DOMMouseScroll", function(c) { var d = b.getHTMLElementPosition(a), e = b.getPointByEvent(c, d), d = b.getMouseEvent(e, d, cc.EventMouse.SCROLL); d.setButton(c.button); d.setScrollData(0, -120 * c.detail); cc.eventManager.dispatchEvent(d); c.stopPropagation(); c.preventDefault() }, !1)); if (window.navigator.msPointerEnabled) { var c = { MSPointerDown: b.handleTouchesBegin, MSPointerMove: b.handleTouchesMove, MSPointerUp: b.handleTouchesEnd, MSPointerCancel: b.handleTouchesCancel }, f; for (f in c)(function(c, d) { cc._addEventListener(a, c, function(c) { var e = b.getHTMLElementPosition(a); e.left -= document.documentElement.scrollLeft; e.top -= document.documentElement.scrollTop; d.call(b, [b.getTouchByXY(c.clientX, c.clientY, e)]); c.stopPropagation() }, !1) })(f, c[f]) } d && (cc._addEventListener(a, "touchstart", function(c) { if (c.changedTouches) { var d = b.getHTMLElementPosition(a); d.left -= document.body.scrollLeft; d.top -= document.body.scrollTop; b.handleTouchesBegin(b.getTouchesByEvent(c, d)); c.stopPropagation(); c.preventDefault(); a.focus() } }, !1), cc._addEventListener(a, "touchmove", function(c) { if (c.changedTouches) { var d = b.getHTMLElementPosition(a); d.left -= document.body.scrollLeft; d.top -= document.body.scrollTop; b.handleTouchesMove(b.getTouchesByEvent(c, d)); c.stopPropagation(); c.preventDefault() } }, !1), cc._addEventListener(a, "touchend", function(c) { if (c.changedTouches) { var d = b.getHTMLElementPosition(a); d.left -= document.body.scrollLeft; d.top -= document.body.scrollTop; b.handleTouchesEnd(b.getTouchesByEvent(c, d)); c.stopPropagation(); c.preventDefault() } }, !1), cc._addEventListener(a, "touchcancel", function(c) { if (c.changedTouches) { var d = b.getHTMLElementPosition(a); d.left -= document.body.scrollLeft; d.top -= document.body.scrollTop; b.handleTouchesCancel(b.getTouchesByEvent(c, d)); c.stopPropagation(); c.preventDefault() } }, !1)); this._registerKeyboardEvent(); this._registerAccelerometerEvent(); this._isRegisterEvent = !0 } }, _registerKeyboardEvent: function() {}, _registerAccelerometerEvent: function() {}, update: function(a) { this._accelCurTime > this._accelInterval && (this._accelCurTime -= this._accelInterval, cc.eventManager.dispatchEvent(new cc.EventAcceleration(this._acceleration))); this._accelCurTime += a } }; var _p = cc.inputManager; _p.setAccelerometerEnabled = function(a) { this._accelEnabled !== a && (this._accelEnabled = a, a = cc.director.getScheduler(), this._accelCurTime = 0, a.scheduleUpdate(this)) }; _p.setAccelerometerInterval = function(a) { this._accelInterval !== a && (this._accelInterval = a) }; _p._registerKeyboardEvent = function() { cc._addEventListener(cc._canvas, "keydown", function(a) { cc.eventManager.dispatchEvent(new cc.EventKeyboard(a.keyCode, !0)); a.stopPropagation(); a.preventDefault() }, !1); cc._addEventListener(cc._canvas, "keyup", function(a) { cc.eventManager.dispatchEvent(new cc.EventKeyboard(a.keyCode, !1)); a.stopPropagation(); a.preventDefault() }, !1) }; _p._registerAccelerometerEvent = function() { var a = window; this._acceleration = new cc.Acceleration; this._accelDeviceEvent = a.DeviceMotionEvent || a.DeviceOrientationEvent; cc.sys.browserType === cc.sys.BROWSER_TYPE_MOBILE_QQ && (this._accelDeviceEvent = window.DeviceOrientationEvent); var b = this._accelDeviceEvent === a.DeviceMotionEvent ? "devicemotion" : "deviceorientation", c = navigator.userAgent; if (/Android/.test(c) || /Adr/.test(c) && cc.sys.browserType === cc.BROWSER_TYPE_UC) this._minus = -1; cc._addEventListener(a, b, this.didAccelerate.bind(this), !1) }; _p.didAccelerate = function(a) { var b = window; if (this._accelEnabled) { var c = this._acceleration, d, e, f; this._accelDeviceEvent === window.DeviceMotionEvent ? (f = a.accelerationIncludingGravity, d = this._accelMinus * f.x * 0.1, e = this._accelMinus * f.y * 0.1, f = 0.1 * f.z) : (d = a.gamma / 90 * 0.981, e = 0.981 * -(a.beta / 90), f = a.alpha / 90 * 0.981); cc.sys.os === cc.sys.OS_ANDROID ? (c.x = -d, c.y = -e) : (c.x = d, c.y = e); c.z = f; c.timestamp = a.timeStamp || Date.now(); a = c.x; b.orientation === cc.UIInterfaceOrientationLandscapeRight ? (c.x = -c.y, c.y = a) : b.orientation === cc.UIInterfaceOrientationLandscapeLeft ? (c.x = c.y, c.y = -a) : b.orientation === cc.UIInterfaceOrientationPortraitUpsideDown && (c.x = -c.x, c.y = -c.y) } }; delete _p; cc.AffineTransform = function(a, b, c, d, e, f) { this.a = a; this.b = b; this.c = c; this.d = d; this.tx = e; this.ty = f }; cc.affineTransformMake = function(a, b, c, d, e, f) { return { a: a, b: b, c: c, d: d, tx: e, ty: f } }; cc.pointApplyAffineTransform = function(a, b, c) { var d; void 0 === c ? (c = b, d = a.x, a = a.y) : (d = a, a = b); return { x: c.a * d + c.c * a + c.tx, y: c.b * d + c.d * a + c.ty } }; cc._pointApplyAffineTransform = function(a, b, c) { return cc.pointApplyAffineTransform(a, b, c) }; cc.sizeApplyAffineTransform = function(a, b) { return { width: b.a * a.width + b.c * a.height, height: b.b * a.width + b.d * a.height } }; cc.affineTransformMakeIdentity = function() { return { a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0 } }; cc.affineTransformIdentity = function() { return { a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0 } }; cc.rectApplyAffineTransform = function(a, b) { var c = cc.rectGetMinY(a), d = cc.rectGetMinX(a), e = cc.rectGetMaxX(a), f = cc.rectGetMaxY(a), g = cc.pointApplyAffineTransform(d, c, b), c = cc.pointApplyAffineTransform(e, c, b), d = cc.pointApplyAffineTransform(d, f, b), h = cc.pointApplyAffineTransform(e, f, b), e = Math.min(g.x, c.x, d.x, h.x), f = Math.max(g.x, c.x, d.x, h.x), k = Math.min(g.y, c.y, d.y, h.y), g = Math.max(g.y, c.y, d.y, h.y); return cc.rect(e, k, f - e, g - k) }; cc._rectApplyAffineTransformIn = function(a, b) { var c = cc.rectGetMinY(a), d = cc.rectGetMinX(a), e = cc.rectGetMaxX(a), f = cc.rectGetMaxY(a), g = cc.pointApplyAffineTransform(d, c, b), c = cc.pointApplyAffineTransform(e, c, b), d = cc.pointApplyAffineTransform(d, f, b), h = cc.pointApplyAffineTransform(e, f, b), e = Math.min(g.x, c.x, d.x, h.x), f = Math.max(g.x, c.x, d.x, h.x), k = Math.min(g.y, c.y, d.y, h.y), g = Math.max(g.y, c.y, d.y, h.y); a.x = e; a.y = k; a.width = f - e; a.height = g - k; return a }; cc.affineTransformTranslate = function(a, b, c) { return { a: a.a, b: a.b, c: a.c, d: a.d, tx: a.tx + a.a * b + a.c * c, ty: a.ty + a.b * b + a.d * c } }; cc.affineTransformScale = function(a, b, c) { return { a: a.a * b, b: a.b * b, c: a.c * c, d: a.d * c, tx: a.tx, ty: a.ty } }; cc.affineTransformRotate = function(a, b) { var c = Math.sin(b), d = Math.cos(b); return { a: a.a * d + a.c * c, b: a.b * d + a.d * c, c: a.c * d - a.a * c, d: a.d * d - a.b * c, tx: a.tx, ty: a.ty } }; cc.affineTransformConcat = function(a, b) { return { a: a.a * b.a + a.b * b.c, b: a.a * b.b + a.b * b.d, c: a.c * b.a + a.d * b.c, d: a.c * b.b + a.d * b.d, tx: a.tx * b.a + a.ty * b.c + b.tx, ty: a.tx * b.b + a.ty * b.d + b.ty } }; cc.affineTransformEqualToTransform = function(a, b) { return a.a === b.a && a.b === b.b && a.c === b.c && a.d === b.d && a.tx === b.tx && a.ty === b.ty }; cc.affineTransformInvert = function(a) { var b = 1 / (a.a * a.d - a.b * a.c); return { a: b * a.d, b: -b * a.b, c: -b * a.c, d: b * a.a, tx: b * (a.c * a.ty - a.d * a.tx), ty: b * (a.b * a.tx - a.a * a.ty) } }; cc.POINT_EPSILON = parseFloat("1.192092896e-07F"); cc.pNeg = function(a) { return cc.p(-a.x, -a.y) }; cc.pAdd = function(a, b) { return cc.p(a.x + b.x, a.y + b.y) }; cc.pSub = function(a, b) { return cc.p(a.x - b.x, a.y - b.y) }; cc.pMult = function(a, b) { return cc.p(a.x * b, a.y * b) }; cc.pMidpoint = function(a, b) { return cc.pMult(cc.pAdd(a, b), 0.5) }; cc.pDot = function(a, b) { return a.x * b.x + a.y * b.y }; cc.pCross = function(a, b) { return a.x * b.y - a.y * b.x }; cc.pPerp = function(a) { return cc.p(-a.y, a.x) }; cc.pRPerp = function(a) { return cc.p(a.y, -a.x) }; cc.pProject = function(a, b) { return cc.pMult(b, cc.pDot(a, b) / cc.pDot(b, b)) }; cc.pRotate = function(a, b) { return cc.p(a.x * b.x - a.y * b.y, a.x * b.y + a.y * b.x) }; cc.pUnrotate = function(a, b) { return cc.p(a.x * b.x + a.y * b.y, a.y * b.x - a.x * b.y) }; cc.pLengthSQ = function(a) { return cc.pDot(a, a) }; cc.pDistanceSQ = function(a, b) { return cc.pLengthSQ(cc.pSub(a, b)) }; cc.pLength = function(a) { return Math.sqrt(cc.pLengthSQ(a)) }; cc.pDistance = function(a, b) { return cc.pLength(cc.pSub(a, b)) }; cc.pNormalize = function(a) { var b = cc.pLength(a); return 0 === b ? cc.p(a) : cc.pMult(a, 1 / b) }; cc.pForAngle = function(a) { return cc.p(Math.cos(a), Math.sin(a)) }; cc.pToAngle = function(a) { return Math.atan2(a.y, a.x) }; cc.clampf = function(a, b, c) { if (b > c) { var d = b; b = c; c = d } return a < b ? b : a < c ? a : c }; cc.pClamp = function(a, b, c) { return cc.p(cc.clampf(a.x, b.x, c.x), cc.clampf(a.y, b.y, c.y)) }; cc.pFromSize = function(a) { return cc.p(a.width, a.height) }; cc.pCompOp = function(a, b) { return cc.p(b(a.x), b(a.y)) }; cc.pLerp = function(a, b, c) { return cc.pAdd(cc.pMult(a, 1 - c), cc.pMult(b, c)) }; cc.pFuzzyEqual = function(a, b, c) { return a.x - c <= b.x && b.x <= a.x + c && a.y - c <= b.y && b.y <= a.y + c ? !0 : !1 }; cc.pCompMult = function(a, b) { return cc.p(a.x * b.x, a.y * b.y) }; cc.pAngleSigned = function(a, b) { var c = cc.pNormalize(a), d = cc.pNormalize(b), c = Math.atan2(c.x * d.y - c.y * d.x, cc.pDot(c, d)); return Math.abs(c) < cc.POINT_EPSILON ? 0 : c }; cc.pAngle = function(a, b) { var c = Math.acos(cc.pDot(cc.pNormalize(a), cc.pNormalize(b))); return Math.abs(c) < cc.POINT_EPSILON ? 0 : c }; cc.pRotateByAngle = function(a, b, c) { a = cc.pSub(a, b); var d = Math.cos(c); c = Math.sin(c); var e = a.x; a.x = e * d - a.y * c + b.x; a.y = e * c + a.y * d + b.y; return a }; cc.pLineIntersect = function(a, b, c, d, e) { if (a.x === b.x && a.y === b.y || c.x === d.x && c.y === d.y) return !1; var f = b.x - a.x; b = b.y - a.y; var g = d.x - c.x; d = d.y - c.y; var h = a.x - c.x; a = a.y - c.y; c = d * f - g * b; e.x = g * a - d * h; e.y = f * a - b * h; if (0 === c) return 0 === e.x || 0 === e.y ? !0 : !1; e.x /= c; e.y /= c; return !0 }; cc.pSegmentIntersect = function(a, b, c, d) { var e = cc.p(0, 0); return cc.pLineIntersect(a, b, c, d, e) && 0 <= e.x && 1 >= e.x && 0 <= e.y && 1 >= e.y ? !0 : !1 }; cc.pIntersectPoint = function(a, b, c, d) { var e = cc.p(0, 0); return cc.pLineIntersect(a, b, c, d, e) ? (c = cc.p(0, 0), c.x = a.x + e.x * (b.x - a.x), c.y = a.y + e.x * (b.y - a.y), c) : cc.p(0, 0) }; cc.pSameAs = function(a, b) { return null != a && null != b ? a.x === b.x && a.y === b.y : !1 }; cc.pZeroIn = function(a) { a.x = 0; a.y = 0 }; cc.pIn = function(a, b) { a.x = b.x; a.y = b.y }; cc.pMultIn = function(a, b) { a.x *= b; a.y *= b }; cc.pSubIn = function(a, b) { a.x -= b.x; a.y -= b.y }; cc.pAddIn = function(a, b) { a.x += b.x; a.y += b.y }; cc.pNormalizeIn = function(a) { cc.pMultIn(a, 1 / Math.sqrt(a.x * a.x + a.y * a.y)) }; cc.vertexLineToPolygon = function(a, b, c, d, e) { e += d; if (!(1 >= e)) { b *= 0.5; for (var f, g = e - 1, h = d; h < e; h++) { f = 2 * h; var k = cc.p(a[2 * h], a[2 * h + 1]), m; if (0 === h) m = cc.pPerp(cc.pNormalize(cc.pSub(k, cc.p(a[2 * (h + 1)], a[2 * (h + 1) + 1])))); else if (h === g) m = cc.pPerp(cc.pNormalize(cc.pSub(cc.p(a[2 * (h - 1)], a[2 * (h - 1) + 1]), k))); else { m = cc.p(a[2 * (h - 1)], a[2 * (h - 1) + 1]); var n = cc.p(a[2 * (h + 1)], a[2 * (h + 1) + 1]), p = cc.pNormalize(cc.pSub(n, k)), t = cc.pNormalize(cc.pSub(m, k)), r = Math.acos(cc.pDot(p, t)); m = r < cc.degreesToRadians(70) ? cc.pPerp(cc.pNormalize(cc.pMidpoint(p, t))) : r < cc.degreesToRadians(170) ? cc.pNormalize(cc.pMidpoint(p, t)) : cc.pPerp(cc.pNormalize(cc.pSub(n, m))) } m = cc.pMult(m, b); c[2 * f] = k.x + m.x; c[2 * f + 1] = k.y + m.y; c[2 * (f + 1)] = k.x - m.x; c[2 * (f + 1) + 1] = k.y - m.y } for (h = 0 === d ? 0 : d - 1; h < g; h++) f = 2 * h, a = f + 2, b = cc.vertex2(c[2 * f], c[2 * f + 1]), e = cc.vertex2(c[2 * (f + 1)], c[2 * (f + 1) + 1]), f = cc.vertex2(c[2 * a], c[2 * a]), d = cc.vertex2(c[2 * (a + 1)], c[2 * (a + 1) + 1]), b = !cc.vertexLineIntersect(b.x, b.y, d.x, d.y, e.x, e.y, f.x, f.y), !b.isSuccess && (0 > b.value || 1 < b.value) && (b.isSuccess = !0), b.isSuccess && (c[2 * a] = d.x, c[2 * a + 1] = d.y, c[2 * (a + 1)] = f.x, c[2 * (a + 1) + 1] = f.y) } }; cc.vertexLineIntersect = function(a, b, c, d, e, f, g, h) { if (a === c && b === d || e === g && f === h) return { isSuccess: !1, value: 0 }; c -= a; d -= b; e -= a; f -= b; g -= a; h -= b; a = Math.sqrt(c * c + d * d); c /= a; d /= a; b = e * c + f * d; f = f * c - e * d; e = b; b = g * c + h * d; h = h * c - g * d; g = b; return f === h ? { isSuccess: !1, value: 0 } : { isSuccess: !0, value: (g + (e - g) * h / (h - f)) / a } }; cc.vertexListIsClockwise = function(a) { for (var b = 0, c = a.length; b < c; b++) { var d = a[(b + 1) % c], e = a[(b + 2) % c]; if (0 < cc.pCross(cc.pSub(d, a[b]), cc.pSub(e, d))) return !1 } return !0 }; cc.CGAffineToGL = function(a, b) { b[2] = b[3] = b[6] = b[7] = b[8] = b[9] = b[11] = b[14] = 0; b[10] = b[15] = 1; b[0] = a.a; b[4] = a.c; b[12] = a.tx; b[1] = a.b; b[5] = a.d; b[13] = a.ty }; cc.GLToCGAffine = function(a, b) { b.a = a[0]; b.c = a[4]; b.tx = a[12]; b.b = a[1]; b.d = a[5]; b.ty = a[13] }; cc.Touch = cc.Class.extend({ _point: null, _prevPoint: null, _id: 0, _startPointCaptured: !1, _startPoint: null, ctor: function(a, b, c) { this._point = cc.p(a || 0, b || 0); this._id = c || 0 }, getLocation: function() { return { x: this._point.x, y: this._point.y } }, getLocationX: function() { return this._point.x }, getLocationY: function() { return this._point.y }, getPreviousLocation: function() { return { x: this._prevPoint.x, y: this._prevPoint.y } }, getStartLocation: function() { return { x: this._startPoint.x, y: this._startPoint.y } }, getDelta: function() { return cc.pSub(this._point, this._prevPoint) }, getLocationInView: function() { return { x: this._point.x, y: this._point.y } }, getPreviousLocationInView: function() { return { x: this._prevPoint.x, y: this._prevPoint.y } }, getStartLocationInView: function() { return { x: this._startPoint.x, y: this._startPoint.y } }, getID: function() { return this._id }, getId: function() { cc.log("getId is deprecated. Please use getID instead."); return this._id }, setTouchInfo: function(a, b, c) { this._prevPoint = this._point; this._point = cc.p(b || 0, c || 0); this._id = a; this._startPointCaptured || (this._startPoint = cc.p(this._point), this._startPointCaptured = !0) }, _setPoint: function(a, b) { void 0 === b ? (this._point.x = a.x, this._point.y = a.y) : (this._point.x = a, this._point.y = b) }, _setPrevPoint: function(a, b) { this._prevPoint = void 0 === b ? cc.p(a.x, a.y) : cc.p(a || 0, b || 0) } }); cc.Event = cc.Class.extend({ _type: 0, _isStopped: !1, _currentTarget: null, _setCurrentTarget: function(a) { this._currentTarget = a }, ctor: function(a) { this._type = a }, getType: function() { return this._type }, stopPropagation: function() { this._isStopped = !0 }, isStopped: function() { return this._isStopped }, getCurrentTarget: function() { return this._currentTarget } }); cc.Event.TOUCH = 0; cc.Event.KEYBOARD = 1; cc.Event.ACCELERATION = 2; cc.Event.MOUSE = 3; cc.Event.FOCUS = 4; cc.Event.CUSTOM = 6; cc.EventCustom = cc.Event.extend({ _eventName: null, _userData: null, ctor: function(a) { cc.Event.prototype.ctor.call(this, cc.Event.CUSTOM); this._eventName = a }, setUserData: function(a) { this._userData = a }, getUserData: function() { return this._userData }, getEventName: function() { return this._eventName } }); cc.EventMouse = cc.Event.extend({ _eventType: 0, _button: 0, _x: 0, _y: 0, _prevX: 0, _prevY: 0, _scrollX: 0, _scrollY: 0, ctor: function(a) { cc.Event.prototype.ctor.call(this, cc.Event.MOUSE); this._eventType = a }, setScrollData: function(a, b) { this._scrollX = a; this._scrollY = b }, getScrollX: function() { return this._scrollX }, getScrollY: function() { return this._scrollY }, setLocation: function(a, b) { this._x = a; this._y = b }, getLocation: function() { return { x: this._x, y: this._y } }, getLocationInView: function() { return { x: this._x, y: cc.view._designResolutionSize.height - this._y } }, _setPrevCursor: function(a, b) { this._prevX = a; this._prevY = b }, getDelta: function() { return { x: this._x - this._prevX, y: this._y - this._prevY } }, getDeltaX: function() { return this._x - this._prevX }, getDeltaY: function() { return this._y - this._prevY }, setButton: function(a) { this._button = a }, getButton: function() { return this._button }, getLocationX: function() { return this._x }, getLocationY: function() { return this._y } }); cc.EventMouse.NONE = 0; cc.EventMouse.DOWN = 1; cc.EventMouse.UP = 2; cc.EventMouse.MOVE = 3; cc.EventMouse.SCROLL = 4; cc.EventMouse.BUTTON_LEFT = 0; cc.EventMouse.BUTTON_RIGHT = 2; cc.EventMouse.BUTTON_MIDDLE = 1; cc.EventMouse.BUTTON_4 = 3; cc.EventMouse.BUTTON_5 = 4; cc.EventMouse.BUTTON_6 = 5; cc.EventMouse.BUTTON_7 = 6; cc.EventMouse.BUTTON_8 = 7; cc.EventTouch = cc.Event.extend({ _eventCode: 0, _touches: null, ctor: function(a) { cc.Event.prototype.ctor.call(this, cc.Event.TOUCH); this._touches = a || [] }, getEventCode: function() { return this._eventCode }, getTouches: function() { return this._touches }, _setEventCode: function(a) { this._eventCode = a }, _setTouches: function(a) { this._touches = a } }); cc.EventTouch.MAX_TOUCHES = 5; cc.EventTouch.EventCode = { BEGAN: 0, MOVED: 1, ENDED: 2, CANCELLED: 3 }; cc.EventFocus = cc.Event.extend({ _widgetGetFocus: null, _widgetLoseFocus: null, ctor: function(a, b) { cc.Event.prototype.ctor.call(this, cc.Event.FOCUS); this._widgetGetFocus = b; this._widgetLoseFocus = a } }); cc.EventListener = cc.Class.extend({ _onEvent: null, _type: 0, _listenerID: null, _registered: !1, _fixedPriority: 0, _node: null, _paused: !0, _isEnabled: !0, ctor: function(a, b, c) { this._onEvent = c; this._type = a || 0; this._listenerID = b || "" }, _setPaused: function(a) { this._paused = a }, _isPaused: function() { return this._paused }, _setRegistered: function(a) { this._registered = a }, _isRegistered: function() { return this._registered }, _getType: function() { return this._type }, _getListenerID: function() { return this._listenerID }, _setFixedPriority: function(a) { this._fixedPriority = a }, _getFixedPriority: function() { return this._fixedPriority }, _setSceneGraphPriority: function(a) { this._node = a }, _getSceneGraphPriority: function() { return this._node }, checkAvailable: function() { return null !== this._onEvent }, clone: function() { return null }, setEnabled: function(a) { this._isEnabled = a }, isEnabled: function() { return this._isEnabled }, retain: function() {}, release: function() {} }); cc.EventListener.UNKNOWN = 0; cc.EventListener.TOUCH_ONE_BY_ONE = 1; cc.EventListener.TOUCH_ALL_AT_ONCE = 2; cc.EventListener.KEYBOARD = 3; cc.EventListener.MOUSE = 4; cc.EventListener.ACCELERATION = 5; cc.EventListener.ACCELERATION = 6; cc.EventListener.CUSTOM = 8; cc.EventListener.FOCUS = 7; cc._EventListenerCustom = cc.EventListener.extend({ _onCustomEvent: null, ctor: function(a, b) { this._onCustomEvent = b; var c = this; cc.EventListener.prototype.ctor.call(this, cc.EventListener.CUSTOM, a, function(a) { null !== c._onCustomEvent && c._onCustomEvent(a) }) }, checkAvailable: function() { return cc.EventListener.prototype.checkAvailable.call(this) && null !== this._onCustomEvent }, clone: function() { return new cc._EventListenerCustom(this._listenerID, this._onCustomEvent) } }); cc._EventListenerCustom.create = function(a, b) { return new cc._EventListenerCustom(a, b) }; cc._EventListenerMouse = cc.EventListener.extend({ onMouseDown: null, onMouseUp: null, onMouseMove: null, onMouseScroll: null, ctor: function() { var a = this; cc.EventListener.prototype.ctor.call(this, cc.EventListener.MOUSE, cc._EventListenerMouse.LISTENER_ID, function(b) { var c = cc.EventMouse; switch (b._eventType) { case c.DOWN: if (a.onMouseDown) a.onMouseDown(b); break; case c.UP: if (a.onMouseUp) a.onMouseUp(b); break; case c.MOVE: if (a.onMouseMove) a.onMouseMove(b); break; case c.SCROLL: if (a.onMouseScroll) a.onMouseScroll(b) } }) }, clone: function() { var a = new cc._EventListenerMouse; a.onMouseDown = this.onMouseDown; a.onMouseUp = this.onMouseUp; a.onMouseMove = this.onMouseMove; a.onMouseScroll = this.onMouseScroll; return a }, checkAvailable: function() { return !0 } }); cc._EventListenerMouse.LISTENER_ID = "__cc_mouse"; cc._EventListenerMouse.create = function() { return new cc._EventListenerMouse }; cc._EventListenerTouchOneByOne = cc.EventListener.extend({ _claimedTouches: null, swallowTouches: !1, onTouchBegan: null, onTouchMoved: null, onTouchEnded: null, onTouchCancelled: null, ctor: function() { cc.EventListener.prototype.ctor.call(this, cc.EventListener.TOUCH_ONE_BY_ONE, cc._EventListenerTouchOneByOne.LISTENER_ID, null); this._claimedTouches = [] }, setSwallowTouches: function(a) { this.swallowTouches = a }, isSwallowTouches: function() { return this.swallowTouches }, clone: function() { var a = new cc._EventListenerTouchOneByOne; a.onTouchBegan = this.onTouchBegan; a.onTouchMoved = this.onTouchMoved; a.onTouchEnded = this.onTouchEnded; a.onTouchCancelled = this.onTouchCancelled; a.swallowTouches = this.swallowTouches; return a }, checkAvailable: function() { return this.onTouchBegan ? !0 : (cc.log(cc._LogInfos._EventListenerTouchOneByOne_checkAvailable), !1) } }); cc._EventListenerTouchOneByOne.LISTENER_ID = "__cc_touch_one_by_one"; cc._EventListenerTouchOneByOne.create = function() { return new cc._EventListenerTouchOneByOne }; cc._EventListenerTouchAllAtOnce = cc.EventListener.extend({ onTouchesBegan: null, onTouchesMoved: null, onTouchesEnded: null, onTouchesCancelled: null, ctor: function() { cc.EventListener.prototype.ctor.call(this, cc.EventListener.TOUCH_ALL_AT_ONCE, cc._EventListenerTouchAllAtOnce.LISTENER_ID, null) }, clone: function() { var a = new cc._EventListenerTouchAllAtOnce; a.onTouchesBegan = this.onTouchesBegan; a.onTouchesMoved = this.onTouchesMoved; a.onTouchesEnded = this.onTouchesEnded; a.onTouchesCancelled = this.onTouchesCancelled; return a }, checkAvailable: function() { return null === this.onTouchesBegan && null === this.onTouchesMoved && null === this.onTouchesEnded && null === this.onTouchesCancelled ? (cc.log(cc._LogInfos._EventListenerTouchAllAtOnce_checkAvailable), !1) : !0 } }); cc._EventListenerTouchAllAtOnce.LISTENER_ID = "__cc_touch_all_at_once"; cc._EventListenerTouchAllAtOnce.create = function() { return new cc._EventListenerTouchAllAtOnce }; cc.EventListener.create = function(a) { cc.assert(a && a.event, cc._LogInfos.EventListener_create); var b = a.event; delete a.event; var c = null; b === cc.EventListener.TOUCH_ONE_BY_ONE ? c = new cc._EventListenerTouchOneByOne : b === cc.EventListener.TOUCH_ALL_AT_ONCE ? c = new cc._EventListenerTouchAllAtOnce : b === cc.EventListener.MOUSE ? c = new cc._EventListenerMouse : b === cc.EventListener.CUSTOM ? (c = new cc._EventListenerCustom(a.eventName, a.callback), delete a.eventName, delete a.callback) : b === cc.EventListener.KEYBOARD ? c = new cc._EventListenerKeyboard : b === cc.EventListener.ACCELERATION ? (c = new cc._EventListenerAcceleration(a.callback), delete a.callback) : b === cc.EventListener.FOCUS && (c = new cc._EventListenerFocus); for (var d in a) c[d] = a[d]; return c }; cc._EventListenerFocus = cc.EventListener.extend({ clone: function() { var a = new cc._EventListenerFocus; a.onFocusChanged = this.onFocusChanged; return a }, checkAvailable: function() { return this.onFocusChanged ? !0 : (cc.log("Invalid EventListenerFocus!"), !1) }, onFocusChanged: null, ctor: function() { cc.EventListener.prototype.ctor.call(this, cc.EventListener.FOCUS, cc._EventListenerFocus.LISTENER_ID, function(a) { if (this.onFocusChanged) this.onFocusChanged(a._widgetLoseFocus, a._widgetGetFocus) }) } }); cc._EventListenerFocus.LISTENER_ID = "__cc_focus_event"; cc._EventListenerVector = cc.Class.extend({ _fixedListeners: null, _sceneGraphListeners: null, gt0Index: 0, ctor: function() { this._fixedListeners = []; this._sceneGraphListeners = [] }, size: function() { return this._fixedListeners.length + this._sceneGraphListeners.length }, empty: function() { return 0 === this._fixedListeners.length && 0 === this._sceneGraphListeners.length }, push: function(a) { 0 === a._getFixedPriority() ? this._sceneGraphListeners.push(a) : this._fixedListeners.push(a) }, clearSceneGraphListeners: function() { this._sceneGraphListeners.length = 0 }, clearFixedListeners: function() { this._fixedListeners.length = 0 }, clear: function() { this._sceneGraphListeners.length = 0; this._fixedListeners.length = 0 }, getFixedPriorityListeners: function() { return this._fixedListeners }, getSceneGraphPriorityListeners: function() { return this._sceneGraphListeners } }); cc.__getListenerID = function(a) { var b = cc.Event, c = a.getType(); if (c === b.ACCELERATION) return cc._EventListenerAcceleration.LISTENER_ID; if (c === b.CUSTOM) return a.getEventName(); if (c === b.KEYBOARD) return cc._EventListenerKeyboard.LISTENER_ID; if (c === b.MOUSE) return cc._EventListenerMouse.LISTENER_ID; if (c === b.FOCUS) return cc._EventListenerFocus.LISTENER_ID; c === b.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(a) { null != this._nodeListenersMap[a.__instanceId] && this._dirtyNodes.push(a); a = a.getChildren(); for (var b = 0, c = a.length; b < c; b++) this._setDirtyForNode(a[b]) }, pauseTarget: function(a, b) { var c = this._nodeListenersMap[a.__instanceId], d, e; if (c) for (d = 0, e = c.length; d < e; d++) c[d]._setPaused(!0); if (!0 === b) for (c = a.getChildren(), d = 0, e = c.length; d < e; d++) this.pauseTarget(c[d], !0) }, resumeTarget: function(a, b) { var c = this._nodeListenersMap[a.__instanceId], d, e; if (c) for (d = 0, e = c.length; d < e; d++) c[d]._setPaused(!1); this._setDirtyForNode(a); if (!0 === b) for (c = a.getChildren(), d = 0, e = c.length; d < e; d++) this.resumeTarget(c[d], !0) }, _addListener: function(a) { 0 === this._inDispatch ? this._forceAddEventListener(a) : this._toAddedListeners.push(a) }, _forceAddEventListener: function(a) { var b = a._getListenerID(), c = this._listenersMap[b]; c || (c = new cc._EventListenerVector, this._listenersMap[b] = c); c.push(a); 0 === a._getFixedPriority() ? (this._setDirty(b, this.DIRTY_SCENE_GRAPH_PRIORITY), b = a._getSceneGraphPriority(), null === b && cc.log(cc._LogInfos.eventManager__forceAddEventListener), this._associateNodeAndEventListener(b, a), b.isRunning() && this.resumeTarget(b)) : this._setDirty(b, this.DIRTY_FIXED_PRIORITY) }, _getListeners: function(a) { return this._listenersMap[a] }, _updateDirtyFlagForSceneGraph: function() { if (0 !== this._dirtyNodes.length) { for (var a = this._dirtyNodes, b, c, d = this._nodeListenersMap, e = 0, f = a.length; e < f; e++) if (b = d[a[e].__instanceId]) for (var g = 0, h = b.length; g < h; g++)(c = b[g]) && this._setDirty(c._getListenerID(), this.DIRTY_SCENE_GRAPH_PRIORITY); this._dirtyNodes.length = 0 } }, _removeAllListenersInVector: function(a) { if (a) for (var b, c = 0; c < a.length;) b = a[c], b._setRegistered(!1), null != b._getSceneGraphPriority() && (this._dissociateNodeAndEventListener(b._getSceneGraphPriority(), b), b._setSceneGraphPriority(null)), 0 === this._inDispatch ? cc.arrayRemoveObject(a, b) : ++c }, _removeListenersForListenerID: function(a) { var b = this._listenersMap[a]; if (b) { var c = b.getFixedPriorityListeners(), d = b.getSceneGraphPriorityListeners(); this._removeAllListenersInVector(d); this._removeAllListenersInVector(c); delete this._priorityDirtyFlagMap[a]; this._inDispatch || (b.clear(), delete this._listenersMap[a]) } c = this._toAddedListeners; for (b = 0; b < c.length;)(d = c[b]) && d._getListenerID() === a ? cc.arrayRemoveObject(c, d) : ++b }, _sortEventListeners: function(a) { var b = this.DIRTY_NONE, c = this._priorityDirtyFlagMap; c[a] && (b = c[a]); b !== this.DIRTY_NONE && (c[a] = this.DIRTY_NONE, b & this.DIRTY_FIXED_PRIORITY && this._sortListenersOfFixedPriority(a), b & this.DIRTY_SCENE_GRAPH_PRIORITY && ((b = cc.director.getRunningScene()) ? this._sortListenersOfSceneGraphPriority(a, b) : c[a] = this.DIRTY_SCENE_GRAPH_PRIORITY)) }, _sortListenersOfSceneGraphPriority: function(a, b) { var c = this._getListeners(a); if (c) { var d = c.getSceneGraphPriorityListeners(); d && 0 !== d.length && (this._nodePriorityIndex = 0, this._nodePriorityMap = {}, this._visitTarget(b, !0), c.getSceneGraphPriorityListeners().sort(this._sortEventListenersOfSceneGraphPriorityDes)) } }, _sortEventListenersOfSceneGraphPriorityDes: function(a, b) { var c = cc.eventManager._nodePriorityMap; return a && b && a._getSceneGraphPriority() && b._getSceneGraphPriority() ? c[b._getSceneGraphPriority().__instanceId] - c[a._getSceneGraphPriority().__instanceId] : -1 }, _sortListenersOfFixedPriority: function(a) { if (a = this._listenersMap[a]) { var b = a.getFixedPriorityListeners(); if (b && 0 !== b.length) { b.sort(this._sortListenersOfFixedPriorityAsc); for (var c = 0, d = b.length; c < d && !(0 <= b[c]._getFixedPriority());)++c; a.gt0Index = c } } }, _sortListenersOfFixedPriorityAsc: function(a, b) { return a._getFixedPriority() - b._getFixedPriority() }, _onUpdateListeners: function(a) { if (a = this._listenersMap[a]) { var b = a.getFixedPriorityListeners(), c = a.getSceneGraphPriorityListeners(), d, e; if (c) for (d = 0; d < c.length;) e = c[d], e._isRegistered() ? ++d : cc.arrayRemoveObject(c, e); if (b) for (d = 0; d < b.length;) e = b[d], e._isRegistered() ? ++d : cc.arrayRemoveObject(b, e); c && 0 === c.length && a.clearSceneGraphListeners(); b && 0 === b.length && a.clearFixedListeners() } }, _updateListeners: function(a) { var b = this._inDispatch; cc.assert(0 < b, cc._LogInfos.EventManager__updateListeners); if (!(1 < b)) { a.getType() === cc.Event.TOUCH ? (this._onUpdateListeners(cc._EventListenerTouchOneByOne.LISTENER_ID), this._onUpdateListeners(cc._EventListenerTouchAllAtOnce.LISTENER_ID)) : this._onUpdateListeners(cc.__getListenerID(a)); cc.assert(1 === b, cc._LogInfos.EventManager__updateListeners_2); a = this._listenersMap; var b = this._priorityDirtyFlagMap, c; for (c in a) a[c].empty() && (delete b[c], delete a[c]); c = this._toAddedListeners; if (0 !== c.length) { a = 0; for (b = c.length; a < b; a++) this._forceAddEventListener(c[a]); this._toAddedListeners.length = 0 } } }, _onTouchEventCallback: function(a, b) { if (!a._isRegistered) return !1; var c = b.event, d = b.selTouch; c._setCurrentTarget(a._node); var e = !1, f, g = c.getEventCode(), h = cc.EventTouch.EventCode; if (g === h.BEGAN) a.onTouchBegan && (e = a.onTouchBegan(d, c)) && a._registered && a._claimedTouches.push(d); else if (0 < a._claimedTouches.length && -1 !== (f = a._claimedTouches.indexOf(d))) if (e = !0, g === h.MOVED && a.onTouchMoved) a.onTouchMoved(d, c); else if (g === h.ENDED) { if (a.onTouchEnded) a.onTouchEnded(d, c); a._registered && a._claimedTouches.splice(f, 1) } else if (g === h.CANCELLED) { if (a.onTouchCancelled) a.onTouchCancelled(d, c); a._registered && a._claimedTouches.splice(f, 1) } return c.isStopped() ? (cc.eventManager._updateListeners(c), !0) : e && a._registered && a.swallowTouches ? (b.needsMutableSet && b.touches.splice(d, 1), !0) : !1 }, _dispatchTouchEvent: function(a) { this._sortEventListeners(cc._EventListenerTouchOneByOne.LISTENER_ID); this._sortEventListeners(cc._EventListenerTouchAllAtOnce.LISTENER_ID); var b = this._getListeners(cc._EventListenerTouchOneByOne.LISTENER_ID), c = this._getListeners(cc._EventListenerTouchAllAtOnce.LISTENER_ID); if (null !== b || null !== c) { var d = a.getTouches(), e = cc.copyArray(d), f = { event: a, needsMutableSet: b && c, touches: e, selTouch: null }; if (b) for (var g = 0; g < d.length; g++) if (f.selTouch = d[g], this._dispatchEventToListeners(b, this._onTouchEventCallback, f), a.isStopped()) return; if (c && 0 < e.length && (this._dispatchEventToListeners(c, this._onTouchesEventCallback, { event: a, touches: e }), a.isStopped())) return; this._updateListeners(a) } }, _onTouchesEventCallback: function(a, b) { if (!a._registered) return !1; var c = cc.EventTouch.EventCode, d = b.event, e = b.touches, f = d.getEventCode(); d._setCurrentTarget(a._node); if (f === c.BEGAN && a.onTouchesBegan) a.onTouchesBegan(e, d); else if (f === c.MOVED && a.onTouchesMoved) a.onTouchesMoved(e, d); else if (f === c.ENDED && a.onTouchesEnded) a.onTouchesEnded(e, d); else if (f === c.CANCELLED && a.onTouchesCancelled) a.onTouchesCancelled(e, d); return d.isStopped() ? (cc.eventManager._updateListeners(d), !0) : !1 }, _associateNodeAndEventListener: function(a, b) { var c = this._nodeListenersMap[a.__instanceId]; c || (c = [], this._nodeListenersMap[a.__instanceId] = c); c.push(b) }, _dissociateNodeAndEventListener: function(a, b) { var c = this._nodeListenersMap[a.__instanceId]; c && (cc.arrayRemoveObject(c, b), 0 === c.length && delete this._nodeListenersMap[a.__instanceId]) }, _dispatchEventToListeners: function(a, b, c) { var d = !1, e = a.getFixedPriorityListeners(), f = a.getSceneGraphPriorityListeners(), g = 0, h; if (e && 0 !== e.length) for (; g < a.gt0Index; ++g) if (h = e[g], h.isEnabled() && !h._isPaused() && h._isRegistered() && b(h, c)) { d = !0; break } if (f && !d) for (a = 0; a < f.length; a++) if (h = f[a], h.isEnabled() && !h._isPaused() && h._isRegistered() && b(h, c)) { d = !0; break } if (e && !d) for (; g < e.length && (h = e[g], !h.isEnabled() || h._isPaused() || !h._isRegistered() || !b(h, c)); ++g); }, _setDirty: function(a, b) { var c = this._priorityDirtyFlagMap; c[a] = null == c[a] ? b : b | c[a] }, _visitTarget: function(a, b) { var c = a.getChildren(), d = 0, e = c.length, f = this._globalZOrderNodeMap, g = this._nodeListenersMap; if (0 < e) { for (var h; d < e; d++) if ((h = c[d]) && 0 > h.getLocalZOrder()) this._visitTarget(h, !1); else break; null != g[a.__instanceId] && (f[a.getGlobalZOrder()] || (f[a.getGlobalZOrder()] = []), f[a.getGlobalZOrder()].push(a.__instanceId)); for (; d < e; d++)(h = c[d]) && this._visitTarget(h, !1) } else null != g[a.__instanceId] && (f[a.getGlobalZOrder()] || (f[a.getGlobalZOrder()] = []), f[a.getGlobalZOrder()].push(a.__instanceId)); if (b) { var c = [], k; for (k in f) c.push(k); c.sort(this._sortNumberAsc); k = c.length; h = this._nodePriorityMap; for (d = 0; d < k; d++) for (e = f[c[d]], g = 0; g < e.length; g++) h[e[g]] = ++this._nodePriorityIndex; this._globalZOrderNodeMap = {} } }, _sortNumberAsc: function(a, b) { return a - b }, addListener: function(a, b) { cc.assert(a && b, cc._LogInfos.eventManager_addListener_2); if (!(a instanceof cc.EventListener)) cc.assert(!cc.isNumber(b), cc._LogInfos.eventManager_addListener_3), a = cc.EventListener.create(a); else if (a._isRegistered()) { cc.log(cc._LogInfos.eventManager_addListener_4); return } if (a.checkAvailable()) { if (cc.isNumber(b)) { if (0 === b) { cc.log(cc._LogInfos.eventManager_addListener); return } a._setSceneGraphPriority(null); a._setFixedPriority(b); a._setRegistered(!0); a._setPaused(!1) } else a._setSceneGraphPriority(b), a._setFixedPriority(0), a._setRegistered(!0); this._addListener(a); return a } }, addCustomListener: function(a, b) { var c = new cc._EventListenerCustom(a, b); this.addListener(c, 1); return c }, removeListener: function(a) { if (null != a) { var b, c = this._listenersMap, d; for (d in c) { var e = c[d], f = e.getFixedPriorityListeners(); b = e.getSceneGraphPriorityListeners(); (b = this._removeListenerInVector(b, a)) ? this._setDirty(a._getListenerID(), this.DIRTY_SCENE_GRAPH_PRIORITY): (b = this._removeListenerInVector(f, a)) && this._setDirty(a._getListenerID(), this.DIRTY_FIXED_PRIORITY); e.empty() && (delete this._priorityDirtyFlagMap[a._getListenerID()], delete c[d]); if (b) break } if (!b) for (c = this._toAddedListeners, d = 0, e = c.length; d < e; d++) if (f = c[d], f === a) { cc.arrayRemoveObject(c, f); f._setRegistered(!1); break } } }, _removeListenerInVector: function(a, b) { if (null == a) return !1; for (var c = 0, d = a.length; c < d; c++) { var e = a[c]; if (e === b) return e._setRegistered(!1), null != e._getSceneGraphPriority() && (this._dissociateNodeAndEventListener(e._getSceneGraphPriority(), e), e._setSceneGraphPriority(null)), 0 === this._inDispatch && cc.arrayRemoveObject(a, e), !0 } return !1 }, removeListeners: function(a, b) { if (a instanceof cc.Node) { delete this._nodePriorityMap[a.__instanceId]; cc.arrayRemoveObject(this._dirtyNodes, a); var c = this._nodeListenersMap[a.__instanceId]; if (c) { for (var d = cc.copyArray(c), c = 0; c < d.length; c++) this.removeListener(d[c]); d.length = 0 } d = this._toAddedListeners; for (c = 0; c < d.length;) { var e = d[c]; e._getSceneGraphPriority() === a ? (e._setSceneGraphPriority(null), e._setRegistered(!1), d.splice(c, 1)) : ++c } if (!0 === b) for (d = a.getChildren(), c = 0, e = d.length; c < e; c++) this.removeListeners(d[c], !0) } else a === cc.EventListener.TOUCH_ONE_BY_ONE ? this._removeListenersForListenerID(cc._EventListenerTouchOneByOne.LISTENER_ID) : a === cc.EventListener.TOUCH_ALL_AT_ONCE ? this._removeListenersForListenerID(cc._EventListenerTouchAllAtOnce.LISTENER_ID) : a === cc.EventListener.MOUSE ? this._removeListenersForListenerID(cc._EventListenerMouse.LISTENER_ID) : a === cc.EventListener.ACCELERATION ? this._removeListenersForListenerID(cc._EventListenerAcceleration.LISTENER_ID) : a === cc.EventListener.KEYBOARD ? this._removeListenersForListenerID(cc._EventListenerKeyboard.LISTENER_ID) : cc.log(cc._LogInfos.eventManager_removeListeners) }, removeCustomListeners: function(a) { this._removeListenersForListenerID(a) }, removeAllListeners: function() { var a = this._listenersMap, b = this._internalCustomListenerIDs, c; for (c in a) - 1 === b.indexOf(c) && this._removeListenersForListenerID(c) }, setPriority: function(a, b) { if (null != a) { var c = this._listenersMap, d; for (d in c) { var e = c[d].getFixedPriorityListeners(); if (e && -1 !== e.indexOf(a)) { null != a._getSceneGraphPriority() && cc.log(cc._LogInfos.eventManager_setPriority); a._getFixedPriority() !== b && (a._setFixedPriority(b), this._setDirty(a._getListenerID(), this.DIRTY_FIXED_PRIORITY)); break } } } }, setEnabled: function(a) { this._isEnabled = a }, isEnabled: function() { return this._isEnabled }, dispatchEvent: function(a) { if (this._isEnabled) { this._updateDirtyFlagForSceneGraph(); this._inDispatch++; if (!a || !a.getType) throw "event is undefined"; if (a.getType() === cc.Event.TOUCH) this._dispatchTouchEvent(a); else { var b = cc.__getListenerID(a); this._sortEventListeners(b); b = this._listenersMap[b]; null != b && this._dispatchEventToListeners(b, this._onListenerCallback, a); this._updateListeners(a) } this._inDispatch-- } }, _onListenerCallback: function(a, b) { b._setCurrentTarget(a._getSceneGraphPriority()); a._onEvent(b); return b.isStopped() }, dispatchCustomEvent: function(a, b) { var c = new cc.EventCustom(a); c.setUserData(b); this.dispatchEvent(c) } }; cc.EventHelper = function() {}; cc.EventHelper.prototype = { constructor: cc.EventHelper, apply: function(a) { a.addEventListener = cc.EventHelper.prototype.addEventListener; a.hasEventListener = cc.EventHelper.prototype.hasEventListener; a.removeEventListener = cc.EventHelper.prototype.removeEventListener; a.dispatchEvent = cc.EventHelper.prototype.dispatchEvent }, addEventListener: function(a, b, c) { if ("load" === a && this._textureLoaded) setTimeout(function() { b.call(c) }, 0); else { void 0 === this._listeners && (this._listeners = {}); var d = this._listeners; void 0 === d[a] && (d[a] = []); this.hasEventListener(a, b, c) || d[a].push({ callback: b, eventTarget: c }) } }, hasEventListener: function(a, b, c) { if (void 0 === this._listeners) return !1; var d = this._listeners; if (void 0 !== d[a]) { a = 0; for (var e = d.length; a < e; a++) { var f = d[a]; if (f.callback === b && f.eventTarget === c) return !0 } } return !1 }, removeEventListener: function(a, b) { if (void 0 !== this._listeners) { var c = this._listeners[a]; if (void 0 !== c) for (var d = 0; d < c.length;) c[d].eventTarget === b ? c.splice(d, 1) : d++ } }, dispatchEvent: function(a, b) { if (void 0 !== this._listeners) { null == b && (b = !0); var c = this._listeners[a]; if (void 0 !== c) { for (var d = [], e = c.length, f = 0; f < e; f++) d[f] = c[f]; for (f = 0; f < e; f++) d[f].callback.call(d[f].eventTarget, this); b && (c.length = 0) } } } }; cc.EventAcceleration = cc.Event.extend({ _acc: null, ctor: function(a) { cc.Event.prototype.ctor.call(this, cc.Event.ACCELERATION); this._acc = a } }); cc.EventKeyboard = cc.Event.extend({ _keyCode: 0, _isPressed: !1, ctor: function(a, b) { cc.Event.prototype.ctor.call(this, cc.Event.KEYBOARD); this._keyCode = a; this._isPressed = b } }); cc._EventListenerAcceleration = cc.EventListener.extend({ _onAccelerationEvent: null, ctor: function(a) { this._onAccelerationEvent = a; var b = this; cc.EventListener.prototype.ctor.call(this, cc.EventListener.ACCELERATION, cc._EventListenerAcceleration.LISTENER_ID, function(a) { b._onAccelerationEvent(a._acc, a) }) }, checkAvailable: function() { cc.assert(this._onAccelerationEvent, cc._LogInfos._EventListenerAcceleration_checkAvailable); return !0 }, clone: function() { return new cc._EventListenerAcceleration(this._onAccelerationEvent) } }); cc._EventListenerAcceleration.LISTENER_ID = "__cc_acceleration"; cc._EventListenerAcceleration.create = function(a) { return new cc._EventListenerAcceleration(a) }; cc._EventListenerKeyboard = cc.EventListener.extend({ onKeyPressed: null, onKeyReleased: null, ctor: function() { var a = this; cc.EventListener.prototype.ctor.call(this, cc.EventListener.KEYBOARD, cc._EventListenerKeyboard.LISTENER_ID, function(b) { if (b._isPressed) { if (a.onKeyPressed) a.onKeyPressed(b._keyCode, b) } else if (a.onKeyReleased) a.onKeyReleased(b._keyCode, b) }) }, clone: function() { var a = new cc._EventListenerKeyboard; a.onKeyPressed = this.onKeyPressed; a.onKeyReleased = this.onKeyReleased; return a }, checkAvailable: function() { return null === this.onKeyPressed && null === this.onKeyReleased ? (cc.log(cc._LogInfos._EventListenerKeyboard_checkAvailable), !1) : !0 } }); cc._EventListenerKeyboard.LISTENER_ID = "__cc_keyboard"; cc._EventListenerKeyboard.create = function() { return new cc._EventListenerKeyboard }; cc.rendererCanvas = { childrenOrderDirty: !0, _transformNodePool: [], _renderCmds: [], _isCacheToCanvasOn: !1, _cacheToCanvasCmds: {}, _cacheInstanceIds: [], _currentID: 0, getRenderCmd: function(a) { return a._createRenderCmd() }, rendering: function(a) { var b = this._renderCmds, c, d = cc.view.getScaleX(), e = cc.view.getScaleY(), f = a || cc._renderContext; f.computeRealOffsetY(); a = 0; for (c = b.length; a < c; a++) b[a].rendering(f, d, e) }, _renderingToCacheCanvas: function(a, b, c, d) { a || cc.log("The context of RenderTexture is invalid."); c = cc.isUndefined(c) ? 1 : c; d = cc.isUndefined(d) ? 1 : d; b = b || this._currentID; var e = this._cacheToCanvasCmds[b], f, g; a.computeRealOffsetY(); f = 0; for (g = e.length; f < g; f++) e[f].rendering(a, c, d); e.length = 0; a = this._cacheInstanceIds; delete this._cacheToCanvasCmds[b]; cc.arrayRemoveObject(a, b); 0 === a.length ? this._isCacheToCanvasOn = !1 : this._currentID = a[a.length - 1] }, _turnToCacheMode: function(a) { this._isCacheToCanvasOn = !0; a = a || 0; this._cacheToCanvasCmds[a] = []; - 1 === this._cacheInstanceIds.indexOf(a) && this._cacheInstanceIds.push(a); this._currentID = a }, _turnToNormalMode: function() { this._isCacheToCanvasOn = !1 }, resetFlag: function() { this.childrenOrderDirty = !1; this._transformNodePool.length = 0 }, transform: function() { var a = this._transformNodePool; a.sort(this._sortNodeByLevelAsc); for (var b = 0, c = a.length; b < c; b++) 0 !== a[b]._dirtyFlag && a[b].updateStatus(); a.length = 0 }, transformDirty: function() { return 0 < this._transformNodePool.length }, _sortNodeByLevelAsc: function(a, b) { return a._curLevel - b._curLevel }, pushDirtyNode: function(a) { this._transformNodePool.push(a) }, clearRenderCommands: function() { this._renderCmds.length = 0 }, pushRenderCommand: function(a) { if (a._needDraw) if (this._isCacheToCanvasOn) { var b = this._cacheToCanvasCmds[this._currentID]; - 1 === b.indexOf(a) && b.push(a) } else -1 === this._renderCmds.indexOf(a) && this._renderCmds.push(a) } }; cc._renderType === cc._RENDER_TYPE_CANVAS && (cc.renderer = cc.rendererCanvas); (function() { cc.CanvasContextWrapper = function(a) { this._context = a; this._saveCount = 0; this._currentAlpha = a.globalAlpha; this._currentCompositeOperation = a.globalCompositeOperation; this._currentFillStyle = a.fillStyle; this._currentStrokeStyle = a.strokeStyle; this._offsetY = this._offsetX = 0; this._realOffsetY = this.height; this._armatureMode = 0 }; var a = cc.CanvasContextWrapper.prototype; a.resetCache = function() { var a = this._context; this._currentAlpha = a.globalAlpha; this._currentCompositeOperation = a.globalCompositeOperation; this._currentFillStyle = a.fillStyle; this._currentStrokeStyle = a.strokeStyle; this._realOffsetY = this._context.canvas.height + this._offsetY }; a.setOffset = function(a, c) { this._offsetX = a; this._offsetY = c; this._realOffsetY = this._context.canvas.height + this._offsetY }; a.computeRealOffsetY = function() { this._realOffsetY = this._context.canvas.height + this._offsetY }; a.setViewScale = function(a, c) { this._scaleX = a; this._scaleY = c }; a.getContext = function() { return this._context }; a.save = function() { this._context.save(); this._saveCount++ }; a.restore = function() { this._context.restore(); this._saveCount-- }; a.setGlobalAlpha = function(a) { 0 < this._saveCount ? this._context.globalAlpha = a : this._currentAlpha !== a && (this._currentAlpha = a, this._context.globalAlpha = a) }; a.setCompositeOperation = function(a) { 0 < this._saveCount ? this._context.globalCompositeOperation = a : this._currentCompositeOperation !== a && (this._currentCompositeOperation = a, this._context.globalCompositeOperation = a) }; a.setFillStyle = function(a) { 0 < this._saveCount ? this._context.fillStyle = a : this._currentFillStyle !== a && (this._currentFillStyle = a, this._context.fillStyle = a) }; a.setStrokeStyle = function(a) { 0 < this._saveCount ? this._context.strokeStyle = a : this._currentStrokeStyle !== a && (this._currentStrokeStyle = a, this._context.strokeStyle = a) }; a.setTransform = function(a, c, d) { 0 < this._armatureMode ? (this.restore(), this.save(), this._context.transform(a.a, -a.b, -a.c, a.d, a.tx * c, -(a.ty * d))) : this._context.setTransform(a.a, -a.b, -a.c, a.d, this._offsetX + a.tx * c, this._realOffsetY - a.ty * d) }; a._switchToArmatureMode = function(a, c, d, e) { a ? (this._armatureMode++, this._context.setTransform(c.a, c.c, c.b, c.d, this._offsetX + c.tx * d, this._realOffsetY - c.ty * e), this.save()) : (this._armatureMode--, this.restore()) } })(); cc.rendererWebGL = { childrenOrderDirty: !0, _transformNodePool: [], _renderCmds: [], _isCacheToBufferOn: !1, _cacheToBufferCmds: {}, _cacheInstanceIds: [], _currentID: 0, getRenderCmd: function(a) { return a._createRenderCmd() }, rendering: function(a) { var b = this._renderCmds, c, d = a || cc._renderContext; a = 0; for (c = b.length; a < c; a++) b[a].rendering(d) }, _turnToCacheMode: function(a) { this._isCacheToBufferOn = !0; a = a || 0; this._cacheToBufferCmds[a] = []; this._cacheInstanceIds.push(a); this._currentID = a }, _turnToNormalMode: function() { this._isCacheToBufferOn = !1 }, _renderingToBuffer: function(a) { a = a || this._currentID; var b = this._cacheToBufferCmds[a], c, d, e = cc._renderContext, f = this._cacheInstanceIds; c = 0; for (d = b.length; c < d; c++) b[c].rendering(e); b.length = 0; delete this._cacheToBufferCmds[a]; cc.arrayRemoveObject(f, a); 0 === f.length ? this._isCacheToBufferOn = !1 : this._currentID = f[f.length - 1] }, resetFlag: function() { this.childrenOrderDirty = !1; this._transformNodePool.length = 0 }, transform: function() { var a = this._transformNodePool; a.sort(this._sortNodeByLevelAsc); for (var b = 0, c = a.length; b < c; b++) a[b].updateStatus(); a.length = 0 }, transformDirty: function() { return 0 < this._transformNodePool.length }, _sortNodeByLevelAsc: function(a, b) { return a._curLevel - b._curLevel }, pushDirtyNode: function(a) { this._transformNodePool.push(a) }, clearRenderCommands: function() { this._renderCmds.length = 0 }, pushRenderCommand: function(a) { if (a._needDraw) if (this._isCacheToBufferOn) { var b = this._cacheToBufferCmds[this._currentID]; - 1 === b.indexOf(a) && b.push(a) } else -1 === this._renderCmds.indexOf(a) && this._renderCmds.push(a) } }; cc._renderType === cc._RENDER_TYPE_WEBGL && (cc.renderer = cc.rendererWebGL); cc._tmp.PrototypeCCNode = function() { var a = cc.Node.prototype; cc.defineGetterSetter(a, "x", a.getPositionX, a.setPositionX); cc.defineGetterSetter(a, "y", a.getPositionY, a.setPositionY); cc.defineGetterSetter(a, "width", a._getWidth, a._setWidth); cc.defineGetterSetter(a, "height", a._getHeight, a._setHeight); cc.defineGetterSetter(a, "anchorX", a._getAnchorX, a._setAnchorX); cc.defineGetterSetter(a, "anchorY", a._getAnchorY, a._setAnchorY); cc.defineGetterSetter(a, "skewX", a.getSkewX, a.setSkewX); cc.defineGetterSetter(a, "skewY", a.getSkewY, a.setSkewY); cc.defineGetterSetter(a, "zIndex", a.getLocalZOrder, a.setLocalZOrder); cc.defineGetterSetter(a, "vertexZ", a.getVertexZ, a.setVertexZ); cc.defineGetterSetter(a, "rotation", a.getRotation, a.setRotation); cc.defineGetterSetter(a, "rotationX", a.getRotationX, a.setRotationX); cc.defineGetterSetter(a, "rotationY", a.getRotationY, a.setRotationY); cc.defineGetterSetter(a, "scale", a.getScale, a.setScale); cc.defineGetterSetter(a, "scaleX", a.getScaleX, a.setScaleX); cc.defineGetterSetter(a, "scaleY", a.getScaleY, a.setScaleY); cc.defineGetterSetter(a, "children", a.getChildren); cc.defineGetterSetter(a, "childrenCount", a.getChildrenCount); cc.defineGetterSetter(a, "parent", a.getParent, a.setParent); cc.defineGetterSetter(a, "visible", a.isVisible, a.setVisible); cc.defineGetterSetter(a, "running", a.isRunning); cc.defineGetterSetter(a, "ignoreAnchor", a.isIgnoreAnchorPointForPosition, a.ignoreAnchorPointForPosition); cc.defineGetterSetter(a, "actionManager", a.getActionManager, a.setActionManager); cc.defineGetterSetter(a, "scheduler", a.getScheduler, a.setScheduler); cc.defineGetterSetter(a, "shaderProgram", a.getShaderProgram, a.setShaderProgram); cc.defineGetterSetter(a, "opacity", a.getOpacity, a.setOpacity); cc.defineGetterSetter(a, "opacityModifyRGB", a.isOpacityModifyRGB); cc.defineGetterSetter(a, "cascadeOpacity", a.isCascadeOpacityEnabled, a.setCascadeOpacityEnabled); cc.defineGetterSetter(a, "color", a.getColor, a.setColor); cc.defineGetterSetter(a, "cascadeColor", a.isCascadeColorEnabled, a.setCascadeColorEnabled) }; cc.NODE_TAG_INVALID = -1; cc.s_globalOrderOfArrival = 1; cc.Node = cc.Class.extend({ _localZOrder: 0, _globalZOrder: 0, _vertexZ: 0, _rotationX: 0, _rotationY: 0, _scaleX: 1, _scaleY: 1, _position: null, _normalizedPosition: null, _usingNormalizedPosition: !1, _normalizedPositionDirty: !1, _skewX: 0, _skewY: 0, _children: null, _visible: !0, _anchorPoint: null, _contentSize: null, _running: !1, _parent: null, _ignoreAnchorPointForPosition: !1, tag: cc.NODE_TAG_INVALID, userData: null, userObject: null, _reorderChildDirty: !1, _shaderProgram: null, arrivalOrder: 0, _actionManager: null, _scheduler: null, _eventDispatcher: null, _additionalTransformDirty: !1, _additionalTransform: null, _componentContainer: null, _isTransitionFinished: !1, _className: "Node", _showNode: !1, _name: "", _realOpacity: 255, _realColor: null, _cascadeColorEnabled: !1, _cascadeOpacityEnabled: !1, _renderCmd: null, _camera: null, ctor: function() { this._initNode(); this._initRendererCmd() }, _initNode: function() { this._anchorPoint = cc.p(0, 0); this._contentSize = cc.size(0, 0); this._position = cc.p(0, 0); this._normalizedPosition = cc.p(0, 0); this._children = []; var a = cc.director; this._actionManager = a.getActionManager(); this._scheduler = a.getScheduler(); this._additionalTransform = cc.affineTransformMakeIdentity(); cc.ComponentContainer && (this._componentContainer = new cc.ComponentContainer(this)); this._realOpacity = 255; this._realColor = cc.color(255, 255, 255, 255); this._cascadeOpacityEnabled = this._cascadeColorEnabled = !1 }, init: function() { return !0 }, _arrayMakeObjectsPerformSelector: function(a, b) { if (a && 0 !== a.length) { var c, d = a.length, e; c = cc.Node._stateCallbackType; switch (b) { case c.onEnter: for (c = 0; c < d; c++) if (e = a[c]) e.onEnter(); break; case c.onExit: for (c = 0; c < d; c++) if (e = a[c]) e.onExit(); break; case c.onEnterTransitionDidFinish: for (c = 0; c < d; c++) if (e = a[c]) e.onEnterTransitionDidFinish(); break; case c.cleanup: for (c = 0; c < d; c++)(e = a[c]) && e.cleanup(); break; case c.updateTransform: for (c = 0; c < d; c++)(e = a[c]) && e.updateTransform(); break; case c.onExitTransitionDidStart: for (c = 0; c < d; c++) if (e = a[c]) e.onExitTransitionDidStart(); break; case c.sortAllChildren: for (c = 0; c < d; c++)(e = a[c]) && e.sortAllChildren(); break; default: cc.assert(0, cc._LogInfos.Node__arrayMakeObjectsPerformSelector) } } }, attr: function(a) { for (var b in a) this[b] = a[b] }, getSkewX: function() { return this._skewX }, setSkewX: function(a) { this._skewX = a; this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty) }, getSkewY: function() { return this._skewY }, setSkewY: function(a) { this._skewY = a; this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty) }, setLocalZOrder: function(a) { this._localZOrder = a; this._parent && this._parent.reorderChild(this, a); cc.eventManager._setDirtyForNode(this) }, _setLocalZOrder: function(a) { this._localZOrder = a }, getLocalZOrder: function() { return this._localZOrder }, getZOrder: function() { cc.log(cc._LogInfos.Node_getZOrder); return this.getLocalZOrder() }, setZOrder: function(a) { cc.log(cc._LogInfos.Node_setZOrder); this.setLocalZOrder(a) }, setGlobalZOrder: function(a) { this._globalZOrder !== a && (this._globalZOrder = a, cc.eventManager._setDirtyForNode(this)) }, getGlobalZOrder: function() { return this._globalZOrder }, getVertexZ: function() { return this._vertexZ }, setVertexZ: function(a) { this._vertexZ = a }, getRotation: function() { this._rotationX !== this._rotationY && cc.log(cc._LogInfos.Node_getRotation); return this._rotationX }, setRotation: function(a) { this._rotationX = this._rotationY = a; this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty) }, getRotationX: function() { return this._rotationX }, setRotationX: function(a) { this._rotationX = a; this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty) }, getRotationY: function() { return this._rotationY }, setRotationY: function(a) { this._rotationY = a; this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty) }, getScale: function() { this._scaleX !== this._scaleY && cc.log(cc._LogInfos.Node_getScale); return this._scaleX }, setScale: function(a, b) { this._scaleX = a; this._scaleY = b || 0 === b ? b : a; this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty) }, getScaleX: function() { return this._scaleX }, setScaleX: function(a) { this._scaleX = a; this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty) }, getScaleY: function() { return this._scaleY }, setScaleY: function(a) { this._scaleY = a; this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty) }, setPosition: function(a, b) { var c = this._position; if (void 0 === b) { if (c.x === a.x && c.y === a.y) return; c.x = a.x; c.y = a.y } else { if (c.x === a.x && c.y === b) return; c.x = a; c.y = b } this._usingNormalizedPosition = !1; this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty) }, setNormalizedPosition: function(a, b) { var c = this._normalizedPosition; void 0 === b ? (c.x = a.x, c.y = a.y) : (c.x = a, c.y = b); this._normalizedPositionDirty = this._usingNormalizedPosition = !0; this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty) }, getPosition: function() { return cc.p(this._position) }, getNormalizedPosition: function() { return cc.p(this._normalizedPosition) }, getPositionX: function() { return this._position.x }, setPositionX: function(a) { this._position.x = a; this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty) }, getPositionY: function() { return this._position.y }, setPositionY: function(a) { this._position.y = a; this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty) }, getChildrenCount: function() { return this._children.length }, getChildren: function() { return this._children }, isVisible: function() { return this._visible }, setVisible: function(a) { this._visible !== a && (this._visible = a, this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty), cc.renderer.childrenOrderDirty = !0) }, getAnchorPoint: function() { return cc.p(this._anchorPoint) }, setAnchorPoint: function(a, b) { var c = this._anchorPoint; if (void 0 === b) { if (a.x === c.x && a.y === c.y) return; c.x = a.x; c.y = a.y } else { if (a === c.x && b === c.y) return; c.x = a; c.y = b } this._renderCmd._updateAnchorPointInPoint() }, _getAnchorX: function() { return this._anchorPoint.x }, _setAnchorX: function(a) { this._anchorPoint.x !== a && (this._anchorPoint.x = a, this._renderCmd._updateAnchorPointInPoint()) }, _getAnchorY: function() { return this._anchorPoint.y }, _setAnchorY: function(a) { this._anchorPoint.y !== a && (this._anchorPoint.y = a, this._renderCmd._updateAnchorPointInPoint()) }, getAnchorPointInPoints: function() { return this._renderCmd.getAnchorPointInPoints() }, _getWidth: function() { return this._contentSize.width }, _setWidth: function(a) { this._contentSize.width = a; this._renderCmd._updateAnchorPointInPoint() }, _getHeight: function() { return this._contentSize.height }, _setHeight: function(a) { this._contentSize.height = a; this._renderCmd._updateAnchorPointInPoint() }, getContentSize: function() { return cc.size(this._contentSize) }, setContentSize: function(a, b) { var c = this._contentSize; if (void 0 === b) { if (a.width === c.width && a.height === c.height) return; c.width = a.width; c.height = a.height } else { if (a === c.width && b === c.height) return; c.width = a; c.height = b } this._renderCmd._updateAnchorPointInPoint() }, isRunning: function() { return this._running }, getParent: function() { return this._parent }, setParent: function(a) { this._parent = a }, isIgnoreAnchorPointForPosition: function() { return this._ignoreAnchorPointForPosition }, ignoreAnchorPointForPosition: function(a) { a !== this._ignoreAnchorPointForPosition && (this._ignoreAnchorPointForPosition = a, this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)) }, getTag: function() { return this.tag }, setTag: function(a) { this.tag = a }, setName: function(a) { this._name = a }, getName: function() { return this._name }, getUserData: function() { return this.userData }, setUserData: function(a) { this.userData = a }, getUserObject: function() { return this.userObject }, setUserObject: function(a) { this.userObject !== a && (this.userObject = a) }, getOrderOfArrival: function() { return this.arrivalOrder }, setOrderOfArrival: function(a) { this.arrivalOrder = a }, getActionManager: function() { this._actionManager || (this._actionManager = cc.director.getActionManager()); return this._actionManager }, setActionManager: function(a) { this._actionManager !== a && (this.stopAllActions(), this._actionManager = a) }, getScheduler: function() { this._scheduler || (this._scheduler = cc.director.getScheduler()); return this._scheduler }, setScheduler: function(a) { this._scheduler !== a && (this.unscheduleAllCallbacks(), this._scheduler = a) }, boundingBox: function() { cc.log(cc._LogInfos.Node_boundingBox); return this.getBoundingBox() }, getBoundingBox: function() { var a = cc.rect(0, 0, this._contentSize.width, this._contentSize.height); return cc._rectApplyAffineTransformIn(a, this.getNodeToParentTransform()) }, cleanup: function() { this.stopAllActions(); this.unscheduleAllCallbacks(); cc.eventManager.removeListeners(this); this._arrayMakeObjectsPerformSelector(this._children, cc.Node._stateCallbackType.cleanup) }, getChildByTag: function(a) { var b = this._children; if (null !== b) for (var c = 0; c < b.length; c++) { var d = b[c]; if (d && d.tag === a) return d } return null }, getChildByName: function(a) { if (!a) return cc.log("Invalid name"), null; for (var b = this._children, c = 0, d = b.length; c < d; c++) if (b[c]._name === a) return b[c]; return null }, addChild: function(a, b, c) { b = void 0 === b ? a._localZOrder : b; var d, e = !1; cc.isUndefined(c) ? (c = void 0, d = a._name) : cc.isString(c) ? (d = c, c = void 0) : cc.isNumber(c) && (e = !0, d = ""); cc.assert(a, cc._LogInfos.Node_addChild_3); cc.assert(null === a._parent, "child already added. It can't be added again"); this._addChildHelper(a, b, c, d, e) }, _addChildHelper: function(a, b, c, d, e) { this._children || (this._children = []); this._insertChild(a, b); e ? a.setTag(c) : a.setName(d); a.setParent(this); a.setOrderOfArrival(cc.s_globalOrderOfArrival++); if (this._running && (a.onEnter(), this._isTransitionFinished)) a.onEnterTransitionDidFinish(); this._cascadeColorEnabled && a._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.colorDirty); this._cascadeOpacityEnabled && a._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.opacityDirty) }, removeFromParent: function(a) { this._parent && (null == a && (a = !0), this._parent.removeChild(this, a)) }, removeFromParentAndCleanup: function(a) { cc.log(cc._LogInfos.Node_removeFromParentAndCleanup); this.removeFromParent(a) }, removeChild: function(a, b) { 0 !== this._children.length && (null == b && (b = !0), -1 < this._children.indexOf(a) && this._detachChild(a, b), cc.renderer.childrenOrderDirty = !0) }, removeChildByTag: function(a, b) { a === cc.NODE_TAG_INVALID && cc.log(cc._LogInfos.Node_removeChildByTag); var c = this.getChildByTag(a); null == c ? cc.log(cc._LogInfos.Node_removeChildByTag_2, a) : this.removeChild(c, b) }, removeAllChildrenWithCleanup: function(a) { this.removeAllChildren(a) }, removeAllChildren: function(a) { var b = this._children; if (null !== b) { null == a && (a = !0); for (var c = 0; c < b.length; c++) { var d = b[c]; d && (this._running && (d.onExitTransitionDidStart(), d.onExit()), a && d.cleanup(), d.parent = null) } this._children.length = 0 } }, _detachChild: function(a, b) { this._running && (a.onExitTransitionDidStart(), a.onExit()); b && a.cleanup(); a.parent = null; a._renderCmd.detachFromParent(); cc.arrayRemoveObject(this._children, a) }, _insertChild: function(a, b) { cc.renderer.childrenOrderDirty = this._reorderChildDirty = !0; this._children.push(a); a._setLocalZOrder(b) }, setNodeDirty: function() { this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty) }, reorderChild: function(a, b) { cc.assert(a, cc._LogInfos.Node_reorderChild); cc.renderer.childrenOrderDirty = this._reorderChildDirty = !0; a.arrivalOrder = cc.s_globalOrderOfArrival; cc.s_globalOrderOfArrival++; a._setLocalZOrder(b) }, sortAllChildren: function() { if (this._reorderChildDirty) { var a = this._children, b = a.length, c, d, e; for (c = 1; c < b; c++) { e = a[c]; for (d = c - 1; 0 <= d;) { if (e._localZOrder < a[d]._localZOrder) a[d + 1] = a[d]; else if (e._localZOrder === a[d]._localZOrder && e.arrivalOrder < a[d].arrivalOrder) a[d + 1] = a[d]; else break; d-- } a[d + 1] = e } this._reorderChildDirty = !1 } }, draw: function(a) {}, transformAncestors: function() { null !== this._parent && (this._parent.transformAncestors(), this._parent.transform()) }, onEnter: function() { this._isTransitionFinished = !1; this._running = !0; this._arrayMakeObjectsPerformSelector(this._children, cc.Node._stateCallbackType.onEnter); this.resume() }, onEnterTransitionDidFinish: function() { this._isTransitionFinished = !0; this._arrayMakeObjectsPerformSelector(this._children, cc.Node._stateCallbackType.onEnterTransitionDidFinish) }, onExitTransitionDidStart: function() { this._arrayMakeObjectsPerformSelector(this._children, cc.Node._stateCallbackType.onExitTransitionDidStart) }, onExit: function() { this._running = !1; this.pause(); this._arrayMakeObjectsPerformSelector(this._children, cc.Node._stateCallbackType.onExit); this.removeAllComponents() }, runAction: function(a) { cc.assert(a, cc._LogInfos.Node_runAction); this.actionManager.addAction(a, this, !this._running); return a }, stopAllActions: function() { this.actionManager && this.actionManager.removeAllActionsFromTarget(this) }, stopAction: function(a) { this.actionManager.removeAction(a) }, stopActionByTag: function(a) { a === cc.ACTION_TAG_INVALID ? cc.log(cc._LogInfos.Node_stopActionByTag) : this.actionManager.removeActionByTag(a, this) }, getActionByTag: function(a) { return a === cc.ACTION_TAG_INVALID ? (cc.log(cc._LogInfos.Node_getActionByTag), null) : this.actionManager.getActionByTag(a, this) }, getNumberOfRunningActions: function() { return this.actionManager.numberOfRunningActionsInTarget(this) }, scheduleUpdate: function() { this.scheduleUpdateWithPriority(0) }, scheduleUpdateWithPriority: function(a) { this.scheduler.scheduleUpdate(this, a, !this._running) }, unscheduleUpdate: function() { this.scheduler.unscheduleUpdate(this) }, schedule: function(a, b, c, d, e) { var f = arguments.length; "function" === typeof a ? 1 === f ? (b = 0, c = cc.REPEAT_FOREVER, d = 0, e = this.__instanceId) : 2 === f ? "number" === typeof b ? (c = cc.REPEAT_FOREVER, d = 0, e = this.__instanceId) : (e = b, b = 0, c = cc.REPEAT_FOREVER, d = 0) : 3 === f ? ("string" === typeof c ? (e = c, c = cc.REPEAT_FOREVER) : e = this.__instanceId, d = 0) : 4 === f && (e = this.__instanceId) : 1 === f ? (b = 0, c = cc.REPEAT_FOREVER, d = 0) : 2 === f && (c = cc.REPEAT_FOREVER, d = 0); cc.assert(a, cc._LogInfos.Node_schedule); cc.assert(0 <= b, cc._LogInfos.Node_schedule_2); c = null == c ? cc.REPEAT_FOREVER : c; this.scheduler.schedule(a, this, b || 0, c, d || 0, !this._running, e) }, scheduleOnce: function(a, b, c) { void 0 === c && (c = this.__instanceId); this.schedule(a, 0, 0, b, c) }, unschedule: function(a) { a && this.scheduler.unschedule(a, this) }, unscheduleAllCallbacks: function() { this.scheduler.unscheduleAllForTarget(this) }, resumeSchedulerAndActions: function() { cc.log(cc._LogInfos.Node_resumeSchedulerAndActions); this.resume() }, resume: function() { this.scheduler.resumeTarget(this); this.actionManager && this.actionManager.resumeTarget(this); cc.eventManager.resumeTarget(this) }, pauseSchedulerAndActions: function() { cc.log(cc._LogInfos.Node_pauseSchedulerAndActions); this.pause() }, pause: function() { this.scheduler.pauseTarget(this); this.actionManager && this.actionManager.pauseTarget(this); cc.eventManager.pauseTarget(this) }, setAdditionalTransform: function(a) { if (null == a) return this._additionalTransformDirty = !1; this._additionalTransform = a; this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty); this._additionalTransformDirty = !0 }, getParentToNodeTransform: function() { this._renderCmd.getParentToNodeTransform() }, parentToNodeTransform: function() { return this.getParentToNodeTransform() }, getNodeToWorldTransform: function() { for (var a = this.getNodeToParentTransform(), b = this._parent; null !== b; b = b.parent) a = cc.affineTransformConcat(a, b.getNodeToParentTransform()); return a }, nodeToWorldTransform: function() { return this.getNodeToWorldTransform() }, getWorldToNodeTransform: function() { return cc.affineTransformInvert(this.getNodeToWorldTransform()) }, worldToNodeTransform: function() { return this.getWorldToNodeTransform() }, convertToNodeSpace: function(a) { return cc.pointApplyAffineTransform(a, this.getWorldToNodeTransform()) }, convertToWorldSpace: function(a) { a = a || cc.p(0, 0); return cc.pointApplyAffineTransform(a, this.getNodeToWorldTransform()) }, convertToNodeSpaceAR: function(a) { return cc.pSub(this.convertToNodeSpace(a), this._renderCmd.getAnchorPointInPoints()) }, convertToWorldSpaceAR: function(a) { a = a || cc.p(0, 0); a = cc.pAdd(a, this._renderCmd.getAnchorPointInPoints()); return this.convertToWorldSpace(a) }, _convertToWindowSpace: function(a) { a = this.convertToWorldSpace(a); return cc.director.convertToUI(a) }, convertTouchToNodeSpace: function(a) { a = a.getLocation(); return this.convertToNodeSpace(a) }, convertTouchToNodeSpaceAR: function(a) { a = cc.director.convertToGL(a.getLocation()); return this.convertToNodeSpaceAR(a) }, update: function(a) { this._componentContainer && !this._componentContainer.isEmpty() && this._componentContainer.visit(a) }, updateTransform: function() { this._arrayMakeObjectsPerformSelector(this._children, cc.Node._stateCallbackType.updateTransform) }, retain: function() {}, release: function() {}, getComponent: function(a) { return this._componentContainer ? this._componentContainer.getComponent(a) : null }, addComponent: function(a) { this._componentContainer && this._componentContainer.add(a) }, removeComponent: function(a) { return this._componentContainer ? this._componentContainer.remove(a) : !1 }, removeAllComponents: function() { this._componentContainer && this._componentContainer.removeAll() }, grid: null, visit: function(a) { this._renderCmd.visit(a) }, transform: function(a, b) { this._renderCmd.transform(a, b) }, nodeToParentTransform: function() { return this.getNodeToParentTransform() }, getNodeToParentTransform: function() { return this._renderCmd.getNodeToParentTransform() }, getCamera: function() { this._camera || (this._camera = new cc.Camera); return this._camera }, getGrid: function() { return this.grid }, setGrid: function(a) { this.grid = a }, getShaderProgram: function() { return this._renderCmd.getShaderProgram() }, setShaderProgram: function(a) { this._renderCmd.setShaderProgram(a) }, getGLServerState: function() { return 0 }, setGLServerState: function(a) {}, getBoundingBoxToWorld: function() { var a = cc.rect(0, 0, this._contentSize.width, this._contentSize.height), b = this.getNodeToWorldTransform(), a = cc.rectApplyAffineTransform(a, b); if (!this._children) return a; for (var c = this._children, d = 0; d < c.length; d++) { var e = c[d]; e && e._visible && (e = e._getBoundingBoxToCurrentNode(b)) && (a = cc.rectUnion(a, e)) } return a }, _getBoundingBoxToCurrentNode: function(a) { var b = cc.rect(0, 0, this._contentSize.width, this._contentSize.height); a = null == a ? this.getNodeToParentTransform() : cc.affineTransformConcat(this.getNodeToParentTransform(), a); b = cc.rectApplyAffineTransform(b, a); if (!this._children) return b; for (var c = this._children, d = 0; d < c.length; d++) { var e = c[d]; e && e._visible && (e = e._getBoundingBoxToCurrentNode(a)) && (b = cc.rectUnion(b, e)) } return b }, getOpacity: function() { return this._realOpacity }, getDisplayedOpacity: function() { return this._renderCmd.getDisplayedOpacity() }, setOpacity: function(a) { this._realOpacity = a; this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.opacityDirty) }, updateDisplayedOpacity: function(a) { this._renderCmd._updateDisplayOpacity(a) }, isCascadeOpacityEnabled: function() { return this._cascadeOpacityEnabled }, setCascadeOpacityEnabled: function(a) { this._cascadeOpacityEnabled !== a && (this._cascadeOpacityEnabled = a, this._renderCmd.setCascadeOpacityEnabledDirty()) }, getColor: function() { var a = this._realColor; return cc.color(a.r, a.g, a.b, a.a) }, getDisplayedColor: function() { return this._renderCmd.getDisplayedColor() }, setColor: function(a) { var b = this._realColor; b.r = a.r; b.g = a.g; b.b = a.b; this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.colorDirty) }, updateDisplayedColor: function(a) { this._renderCmd._updateDisplayColor(a) }, isCascadeColorEnabled: function() { return this._cascadeColorEnabled }, setCascadeColorEnabled: function(a) { this._cascadeColorEnabled !== a && (this._cascadeColorEnabled = a, this._renderCmd.setCascadeColorEnabledDirty()) }, setOpacityModifyRGB: function(a) {}, isOpacityModifyRGB: function() { return !1 }, _initRendererCmd: function() { this._renderCmd = cc.renderer.getRenderCmd(this) }, _createRenderCmd: function() { return cc._renderType === cc._RENDER_TYPE_CANVAS ? new cc.Node.CanvasRenderCmd(this) : new cc.Node.WebGLRenderCmd(this) } }); cc.Node.create = function() { return new cc.Node }; cc.Node._stateCallbackType = { onEnter: 1, onExit: 2, cleanup: 3, onEnterTransitionDidFinish: 4, updateTransform: 5, onExitTransitionDidStart: 6, sortAllChildren: 7 }; cc.assert(cc.isFunction(cc._tmp.PrototypeCCNode), cc._LogInfos.MissingFile, "BaseNodesPropertyDefine.js"); cc._tmp.PrototypeCCNode(); delete cc._tmp.PrototypeCCNode; cc.CustomRenderCmd = function(a, b) { this._needDraw = !0; this._target = a; this._callback = b; this.rendering = function(a, b, e) { this._callback && this._callback.call(this._target, a, b, e) } }; cc.Node._dirtyFlags = { transformDirty: 1, visibleDirty: 2, colorDirty: 4, opacityDirty: 8, cacheDirty: 16, orderDirty: 32, textDirty: 64, gradientDirty: 128, all: 255 }; cc.Node.RenderCmd = function(a) { this._dirtyFlag = 1; this._node = a; this._needDraw = !1; this._anchorPointInPoints = new cc.Point(0, 0); this._transform = { a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0 }; this._worldTransform = { a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0 }; this._inverse = { a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0 }; this._displayedOpacity = 255; this._displayedColor = cc.color(255, 255, 255, 255); this._cascadeOpacityEnabledDirty = this._cascadeColorEnabledDirty = !1; this._curLevel = -1 }; cc.Node.RenderCmd.prototype = { constructor: cc.Node.RenderCmd, getAnchorPointInPoints: function() { return cc.p(this._anchorPointInPoints) }, getDisplayedColor: function() { var a = this._displayedColor; return cc.color(a.r, a.g, a.b, a.a) }, getDisplayedOpacity: function() { return this._displayedOpacity }, setCascadeColorEnabledDirty: function() { this._cascadeColorEnabledDirty = !0; this.setDirtyFlag(cc.Node._dirtyFlags.colorDirty) }, setCascadeOpacityEnabledDirty: function() { this._cascadeOpacityEnabledDirty = !0; this.setDirtyFlag(cc.Node._dirtyFlags.opacityDirty) }, getParentToNodeTransform: function() { this._dirtyFlag & cc.Node._dirtyFlags.transformDirty && (this._inverse = cc.affineTransformInvert(this.getNodeToParentTransform())); return this._inverse }, detachFromParent: function() {}, _updateAnchorPointInPoint: function() { var a = this._anchorPointInPoints, b = this._node._contentSize, c = this._node._anchorPoint; a.x = b.width * c.x; a.y = b.height * c.y; this.setDirtyFlag(cc.Node._dirtyFlags.transformDirty) }, setDirtyFlag: function(a) { 0 === this._dirtyFlag && 0 !== a && cc.renderer.pushDirtyNode(this); this._dirtyFlag |= a }, getParentRenderCmd: function() { return this._node && this._node._parent && this._node._parent._renderCmd ? this._node._parent._renderCmd : null }, _updateDisplayColor: function(a) { var b = this._node, c = this._displayedColor, d = b._realColor, e; if (this._cascadeColorEnabledDirty && !b._cascadeColorEnabled) { c.r = d.r; c.g = d.g; c.b = d.b; c = new cc.Color(255, 255, 255, 255); a = b._children; b = 0; for (d = a.length; b < d; b++)(e = a[b]) && e._renderCmd && e._renderCmd._updateDisplayColor(c); this._cascadeColorEnabledDirty = !1 } else if (void 0 === a && (a = (a = b._parent) && a._cascadeColorEnabled ? a.getDisplayedColor() : cc.color.WHITE), c.r = 0 | d.r * a.r / 255, c.g = 0 | d.g * a.g / 255, c.b = 0 | d.b * a.b / 255, b._cascadeColorEnabled) for (a = b._children, b = 0, d = a.length; b < d; b++)(e = a[b]) && e._renderCmd && (e._renderCmd._updateDisplayColor(c), e._renderCmd._updateColor()); this._dirtyFlag ^= this._dirtyFlag & cc.Node._dirtyFlags.colorDirty }, _updateDisplayOpacity: function(a) { var b = this._node, c, d; if (this._cascadeOpacityEnabledDirty && !b._cascadeOpacityEnabled) { this._displayedOpacity = b._realOpacity; c = b._children; a = 0; for (b = c.length; a < b; a++)(d = c[a]) && d._renderCmd && d._renderCmd._updateDisplayOpacity(255); this._cascadeOpacityEnabledDirty = !1 } else if (void 0 === a && (c = b._parent, a = 255, c && c._cascadeOpacityEnabled && (a = c.getDisplayedOpacity())), this._displayedOpacity = b._realOpacity * a / 255, b._cascadeOpacityEnabled) for (c = b._children, a = 0, b = c.length; a < b; a++)(d = c[a]) && d._renderCmd && (d._renderCmd._updateDisplayOpacity(this._displayedOpacity), d._renderCmd._updateColor()); this._dirtyFlag ^= this._dirtyFlag & cc.Node._dirtyFlags.opacityDirty }, _syncDisplayColor: function(a) { var b = this._node, c = this._displayedColor, d = b._realColor; void 0 === a && (a = (a = b._parent) && a._cascadeColorEnabled ? a.getDisplayedColor() : cc.color.WHITE); c.r = 0 | d.r * a.r / 255; c.g = 0 | d.g * a.g / 255; c.b = 0 | d.b * a.b / 255 }, _syncDisplayOpacity: function(a) { var b = this._node; if (void 0 === a) { var c = b._parent; a = 255; c && c._cascadeOpacityEnabled && (a = c.getDisplayedOpacity()) } this._displayedOpacity = b._realOpacity * a / 255 }, _updateColor: function() {}, updateStatus: function() { var a = cc.Node._dirtyFlags, b = this._dirtyFlag, c = b & a.colorDirty, d = b & a.opacityDirty; c && this._updateDisplayColor(); d && this._updateDisplayOpacity(); (c || d) && this._updateColor(); b & a.transformDirty && (this.transform(this.getParentRenderCmd(), !0), this._dirtyFlag ^= this._dirtyFlag & cc.Node._dirtyFlags.transformDirty) } }; (function() { cc.Node.CanvasRenderCmd = function(a) { cc.Node.RenderCmd.call(this, a); this._cachedParent = null; this._cacheDirty = !1 }; var a = cc.Node.CanvasRenderCmd.prototype = Object.create(cc.Node.RenderCmd.prototype); a.constructor = cc.Node.CanvasRenderCmd; a.transform = function(a, c) { var d = this.getNodeToParentTransform(), e = this._worldTransform; this._cacheDirty = !0; if (a) { var f = a._worldTransform; e.a = d.a * f.a + d.b * f.c; e.b = d.a * f.b + d.b * f.d; e.c = d.c * f.a + d.d * f.c; e.d = d.c * f.b + d.d * f.d; e.tx = f.a * d.tx + f.c * d.ty + f.tx; e.ty = f.d * d.ty + f.ty + f.b * d.tx } else e.a = d.a, e.b = d.b, e.c = d.c, e.d = d.d, e.tx = d.tx, e.ty = d.ty; if (c && (d = this._node._children) && 0 !== d.length) for (e = 0, f = d.length; e < f; e++) d[e]._renderCmd.transform(this, c) }; a.getNodeToParentTransform = function() { var a = this._node, c = !1; a._usingNormalizedPosition && a._parent && (c = a._parent._contentSize, a._position.x = a._normalizedPosition.x * c.width, a._position.y = a._normalizedPosition.y * c.height, a._normalizedPositionDirty = !1, c = !0); if (c || this._dirtyFlag & cc.Node._dirtyFlags.transformDirty) { c = this._transform; c.tx = a._position.x; c.ty = a._position.y; var d = 1, e = 0, f = 0, g = 1; a._rotationX && (g = 0.017453292519943295 * a._rotationX, f = Math.sin(g), g = Math.cos(g)); a._rotationY && (e = 0.017453292519943295 * a._rotationY, d = Math.cos(e), e = -Math.sin(e)); c.a = d; c.b = e; c.c = f; c.d = g; var h = a._scaleX, k = a._scaleY, m = this._anchorPointInPoints.x, n = this._anchorPointInPoints.y, p = 1E-6 > h && -1E-6 < h ? 1E-6 : h, t = 1E-6 > k && -1E-6 < k ? 1E-6 : k; if (1 !== h || 1 !== k) d = c.a *= p, e = c.b *= p, f = c.c *= t, g = c.d *= t; if (a._skewX || a._skewY) h = Math.tan(-a._skewX * Math.PI / 180), k = Math.tan(-a._skewY * Math.PI / 180), Infinity === h && (h = 99999999), Infinity === k && (k = 99999999), p = n * h, t = m * k, c.a = d - f * k, c.b = e - g * k, c.c = f - d * h, c.d = g - e * h, c.tx += d * p + f * t, c.ty += e * p + g * t; c.tx -= d * m + f * n; c.ty -= e * m + g * n; a._ignoreAnchorPointForPosition && (c.tx += m, c.ty += n); a._additionalTransformDirty && (this._transform = cc.affineTransformConcat(c, a._additionalTransform)) } return this._transform }; a.visit = function(a) { var c = this._node; if (c._visible) { if (a = a || this.getParentRenderCmd()) this._curLevel = a._curLevel + 1; var d = c._children, e; this._syncStatus(a); a = d.length; if (0 < a) { c.sortAllChildren(); for (c = 0; c < a; c++) if (e = d[c], 0 > e._localZOrder) e._renderCmd.visit(this); else break; for (cc.renderer.pushRenderCommand(this); c < a; c++) d[c]._renderCmd.visit(this) } else cc.renderer.pushRenderCommand(this); this._dirtyFlag = 0 } }; a._syncStatus = function(a) { var c = cc.Node._dirtyFlags, d = this._dirtyFlag, e = a ? a._node : null; e && e._cascadeColorEnabled && a._dirtyFlag & c.colorDirty && (d |= c.colorDirty); e && e._cascadeOpacityEnabled && a._dirtyFlag & c.opacityDirty && (d |= c.opacityDirty); a && a._dirtyFlag & c.transformDirty && (d |= c.transformDirty); var e = d & c.colorDirty, f = d & c.opacityDirty, c = d & c.transformDirty; this._dirtyFlag = d; e && this._syncDisplayColor(); f && this._syncDisplayOpacity(); e && this._updateColor(); c && this.transform(a) }; a.setDirtyFlag = function(a) { cc.Node.RenderCmd.prototype.setDirtyFlag.call(this, a); this._setCacheDirty(); this._cachedParent && this._cachedParent.setDirtyFlag(a) }; a._setCacheDirty = function() { if (!1 === this._cacheDirty) { this._cacheDirty = !0; var a = this._cachedParent; a && a !== this && a._setNodeDirtyForCache && a._setNodeDirtyForCache() } }; a._setCachedParent = function(a) { if (this._cachedParent !== a) { this._cachedParent = a; for (var c = this._node._children, d = 0, e = c.length; d < e; d++) c[d]._renderCmd._setCachedParent(a) } }; a.detachFromParent = function() { this._cachedParent = null; for (var a = this._node._children, c, d = 0, e = a.length; d < e; d++)(c = a[d]) && c._renderCmd && c._renderCmd.detachFromParent() }; a.setShaderProgram = function(a) {}; a.getShaderProgram = function() { return null }; cc.Node.CanvasRenderCmd._getCompositeOperationByBlendFunc = function(a) { return a ? a.src === cc.SRC_ALPHA && a.dst === cc.ONE || a.src === cc.ONE && a.dst === cc.ONE ? "lighter" : a.src === cc.ZERO && a.dst === cc.SRC_ALPHA ? "destination-in" : a.src === cc.ZERO && a.dst === cc.ONE_MINUS_SRC_ALPHA ? "destination-out" : "source-over" : "source-over" } })(); (function() { cc.Node.WebGLRenderCmd = function(a) { cc.Node.RenderCmd.call(this, a); a = new cc.math.Matrix4; var c = a.mat; c[2] = c[3] = c[6] = c[7] = c[8] = c[9] = c[11] = c[14] = 0; c[10] = c[15] = 1; this._transform4x4 = a; this._stackMatrix = new cc.math.Matrix4; this._camera = this._shaderProgram = null }; var a = cc.Node.WebGLRenderCmd.prototype = Object.create(cc.Node.RenderCmd.prototype); a.constructor = cc.Node.WebGLRenderCmd; a.getNodeToParentTransform = function() { var a = this._node; if (a._usingNormalizedPosition && a._parent) { var c = a._parent._contentSize; a._position.x = a._normalizedPosition.x * c.width; a._position.y = a._normalizedPosition.y * c.height; a._normalizedPositionDirty = !1 } if (this._dirtyFlag & cc.Node._dirtyFlags.transformDirty) { var c = a._position.x, d = a._position.y, e = this._anchorPointInPoints.x, f = -e, g = this._anchorPointInPoints.y, h = -g, k = a._scaleX, m = a._scaleY, n = 0.017453292519943295 * a._rotationX, p = 0.017453292519943295 * a._rotationY; a._ignoreAnchorPointForPosition && (c += e, d += g); var t = 1, r = 0, u = 1, s = 0; if (0 !== a._rotationX || 0 !== a._rotationY) t = Math.cos(-n), r = Math.sin(-n), u = Math.cos(-p), s = Math.sin(-p); n = a._skewX || a._skewY; n || 0 === e && 0 === g || (c += u * f * k + -r * h * m, d += s * f * k + t * h * m); p = this._transform; p.a = u * k; p.b = s * k; p.c = -r * m; p.d = t * m; p.tx = c; p.ty = d; n && (p = cc.affineTransformConcat({ a: 1, b: Math.tan(cc.degreesToRadians(a._skewY)), c: Math.tan(cc.degreesToRadians(a._skewX)), d: 1, tx: 0, ty: 0 }, p), 0 !== e || 0 !== g) && (p = cc.affineTransformTranslate(p, f, h)); a._additionalTransformDirty && (p = cc.affineTransformConcat(p, a._additionalTransform), a._additionalTransformDirty = !1); this._transform = p } return this._transform }; a._syncStatus = function(a) { var c = cc.Node._dirtyFlags, d = this._dirtyFlag, e = a ? a._node : null; e && e._cascadeColorEnabled && a._dirtyFlag & c.colorDirty && (d |= c.colorDirty); e && e._cascadeOpacityEnabled && a._dirtyFlag & c.opacityDirty && (d |= c.opacityDirty); a && a._dirtyFlag & c.transformDirty && (d |= c.transformDirty); e = d & c.colorDirty; c = d & c.opacityDirty; this._dirtyFlag = d; e && this._syncDisplayColor(); c && this._syncDisplayOpacity(); (e || c) && this._updateColor(); this.transform(a) }; a._updateColor = function() {}; a.visit = function(a) { var c = this._node; if (c._visible) { a = a || this.getParentRenderCmd(); c._parent && c._parent._renderCmd && (this._curLevel = c._parent._renderCmd._curLevel + 1); var d = cc.current_stack; d.stack.push(d.top); this._syncStatus(a); d.top = this._stackMatrix; if ((a = c._children) && 0 < a.length) { var e = a.length; c.sortAllChildren(); for (c = 0; c < e; c++) if (a[c] && 0 > a[c]._localZOrder) a[c]._renderCmd.visit(this); else break; for (cc.renderer.pushRenderCommand(this); c < e; c++) a[c] && a[c]._renderCmd.visit(this) } else cc.renderer.pushRenderCommand(this); this._dirtyFlag = 0; d.top = d.stack.pop() } }; a.transform = function(a, c) { var d = this._transform4x4, e = this._stackMatrix, f = this._node, g = (a = a || this.getParentRenderCmd()) ? a._stackMatrix : cc.current_stack.top, h = this.getNodeToParentTransform(); this._dirtyFlag ^= this._dirtyFlag & cc.Node._dirtyFlags.transformDirty; var k = d.mat; k[0] = h.a; k[4] = h.c; k[12] = h.tx; k[1] = h.b; k[5] = h.d; k[13] = h.ty; k[14] = f._vertexZ; cc.kmMat4Multiply(e, g, d); null === f._camera || null !== f.grid && f.grid.isActive() || (g = this._anchorPointInPoints.x, h = this._anchorPointInPoints.y, 0 !== g || 0 !== h ? (cc.SPRITEBATCHNODE_RENDER_SUBPIXEL || (g |= 0, h |= 0), k = cc.math.Matrix4.createByTranslation(g, h, 0, d), e.multiply(k), f._camera._locateForRenderer(e), k = cc.math.Matrix4.createByTranslation(-g, -h, 0, k), e.multiply(k), d.identity()) : f._camera._locateForRenderer(e)); if (c && f._children && 0 !== f._children.length) for (f = f._children, d = 0, e = f.length; d < e; d++) f[d]._renderCmd.transform(this, c) }; a.setShaderProgram = function(a) { this._shaderProgram = a }; a.getShaderProgram = function() { return this._shaderProgram } })(); cc.AtlasNode = cc.Node.extend({ textureAtlas: null, quadsToDraw: 0, _itemsPerRow: 0, _itemsPerColumn: 0, _itemWidth: 0, _itemHeight: 0, _opacityModifyRGB: !1, _blendFunc: null, _ignoreContentScaleFactor: !1, _className: "AtlasNode", _textureForCanvas: null, ctor: function(a, b, c, d) { cc.Node.prototype.ctor.call(this); this._blendFunc = { src: cc.BLEND_SRC, dst: cc.BLEND_DST }; this._ignoreContentScaleFactor = !1; void 0 !== d && this.initWithTileFile(a, b, c, d) }, _createRenderCmd: function() { this._renderCmd = cc._renderType === cc._RENDER_TYPE_CANVAS ? new cc.AtlasNode.CanvasRenderCmd(this) : new cc.AtlasNode.WebGLRenderCmd(this) }, updateAtlasValues: function() { cc.log(cc._LogInfos.AtlasNode_updateAtlasValues) }, getColor: function() { return this._opacityModifyRGB ? this._renderCmd._colorUnmodified : cc.Node.prototype.getColor.call(this) }, setOpacityModifyRGB: function(a) { var b = this.color; this._opacityModifyRGB = a; this.setColor(b) }, isOpacityModifyRGB: function() { return this._opacityModifyRGB }, getBlendFunc: function() { return this._blendFunc }, setBlendFunc: function(a, b) { this._blendFunc = void 0 === b ? a : { src: a, dst: b } }, setTextureAtlas: function(a) { this.textureAtlas = a }, getTextureAtlas: function() { return this.textureAtlas }, getQuadsToDraw: function() { return this.quadsToDraw }, setQuadsToDraw: function(a) { this.quadsToDraw = a }, initWithTileFile: function(a, b, c, d) { if (!a) throw "cc.AtlasNode.initWithTileFile(): title should not be null"; a = cc.textureCache.addImage(a); return this.initWithTexture(a, b, c, d) }, initWithTexture: function(a, b, c, d) { return this._renderCmd.initWithTexture(a, b, c, d) }, setColor: function(a) { this._renderCmd.setColor(a) }, setOpacity: function(a) { this._renderCmd.setOpacity(a) }, getTexture: function() { return this._renderCmd.getTexture() }, setTexture: function(a) { this._renderCmd.setTexture(a) }, _setIgnoreContentScaleFactor: function(a) { this._ignoreContentScaleFactor = a } }); _p = cc.AtlasNode.prototype; cc.defineGetterSetter(_p, "opacity", _p.getOpacity, _p.setOpacity); cc.defineGetterSetter(_p, "color", _p.getColor, _p.setColor); cc.defineGetterSetter(_p, "texture", _p.getTexture, _p.setTexture); cc.EventHelper.prototype.apply(_p); cc.AtlasNode.create = function(a, b, c, d) { return new cc.AtlasNode(a, b, c, d) }; (function() { cc.AtlasNode.CanvasRenderCmd = function(a) { cc.Node.CanvasRenderCmd.call(this, a); this._needDraw = !1; this._colorUnmodified = cc.color.WHITE; this._texture = this._originalTexture = null }; var a = cc.AtlasNode.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); a.constructor = cc.AtlasNode.CanvasRenderCmd; a.initWithTexture = function(a, c, d, e) { var f = this._node; f._itemWidth = c; f._itemHeight = d; f._opacityModifyRGB = !0; this._originalTexture = a; if (!this._originalTexture) return cc.log(cc._LogInfos.AtlasNode__initWithTexture), !1; this._texture = this._originalTexture; this._calculateMaxItems(); f.quadsToDraw = e; return !0 }; a.setColor = function(a) { var c = this._node._realColor; if (c.r !== a.r || c.g !== a.g || c.b !== a.b) this._colorUnmodified = a, this._changeTextureColor() }; a._changeTextureColor = cc.sys._supportCanvasNewBlendModes ? function() { var a = this._node, c = a.getTexture(); if (c && this._originalTexture) { var d = this._originalTexture.getHtmlElementObj(); if (d) { var e = c.getHtmlElementObj(), c = cc.rect(0, 0, d.width, d.height); e instanceof HTMLCanvasElement ? cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(d, this._colorUnmodified, c, e) : (e = cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(d, this._colorUnmodified, c), c = new cc.Texture2D, c.initWithElement(e), c.handleLoadedTexture(), a.setTexture(c)) } } } : function() { var a = this._node, c, d = a.getTexture(); if (d && this._originalTexture && (c = d.getHtmlElementObj())) { var e = this._originalTexture.getHtmlElementObj(); if (d = cc.textureCache.getTextureColors(e)) e = cc.rect(0, 0, e.width, e.height), c instanceof HTMLCanvasElement ? cc.Sprite.CanvasRenderCmd._generateTintImage(c, d, this._displayedColor, e, c) : (c = cc.Sprite.CanvasRenderCmd._generateTintImage(c, d, this._displayedColor, e), d = new cc.Texture2D, d.initWithElement(c), d.handleLoadedTexture(), a.setTexture(d)) } }; a.setOpacity = function(a) { cc.Node.prototype.setOpacity.call(this._node, a) }; a.getTexture = function() { return this._texture }; a.setTexture = function(a) { this._texture = a }; a._calculateMaxItems = function() { var a = this._node, c = this._texture.getContentSize(); a._itemsPerColumn = 0 | c.height / a._itemHeight; a._itemsPerRow = 0 | c.width / a._itemWidth } })(); (function() { cc.AtlasNode.WebGLRenderCmd = function(a) { cc.Node.WebGLRenderCmd.call(this, a); this._needDraw = !0; this._textureAtlas = null; this._colorUnmodified = cc.color.WHITE; this._uniformColor = this._colorF32Array = null; this._shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURE_UCOLOR); this._uniformColor = cc._renderContext.getUniformLocation(this._shaderProgram.getProgram(), "u_color") }; var a = cc.AtlasNode.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); a.constructor = cc.AtlasNode.WebGLRenderCmd; a._updateBlendFunc = function() { var a = this._node; this._textureAtlas.texture.hasPremultipliedAlpha() || (a._blendFunc.src = cc.SRC_ALPHA, a._blendFunc.dst = cc.ONE_MINUS_SRC_ALPHA) }; a._updateOpacityModifyRGB = function() { this._node._opacityModifyRGB = this._textureAtlas.texture.hasPremultipliedAlpha() }; a.rendering = function(a) { a = a || cc._renderContext; var c = this._node; this._shaderProgram.use(); this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix); cc.glBlendFunc(c._blendFunc.src, c._blendFunc.dst); this._uniformColor && this._colorF32Array && (a.uniform4fv(this._uniformColor, this._colorF32Array), this._textureAtlas.drawNumberOfQuads(c.quadsToDraw, 0)) }; a.initWithTexture = function(a, c, d, e) { var f = this._node; f._itemWidth = c; f._itemHeight = d; this._colorUnmodified = cc.color.WHITE; f._opacityModifyRGB = !0; f._blendFunc.src = cc.BLEND_SRC; f._blendFunc.dst = cc.BLEND_DST; c = f._realColor; this._colorF32Array = new Float32Array([c.r / 255, c.g / 255, c.b / 255, f._realOpacity / 255]); this._textureAtlas = new cc.TextureAtlas; this._textureAtlas.initWithTexture(a, e); if (!this._textureAtlas) return cc.log(cc._LogInfos.AtlasNode__initWithTexture), !1; this._updateBlendFunc(); this._updateOpacityModifyRGB(); this._calculateMaxItems(); f.quadsToDraw = e; return !0 }; a.setColor = function(a) { var c = cc.color(a.r, a.g, a.b), d = this._node; this._colorUnmodified = a; a = this._displayedOpacity; d._opacityModifyRGB && (c.r = c.r * a / 255, c.g = c.g * a / 255, c.b = c.b * a / 255); cc.Node.prototype.setColor.call(d, c) }; a.setOpacity = function(a) { var c = this._node; cc.Node.prototype.setOpacity.call(c, a); c._opacityModifyRGB && (c.color = this._colorUnmodified) }; a._updateColor = function() { var a = this._displayedColor; this._colorF32Array = new Float32Array([a.r / 255, a.g / 255, a.b / 255, this._displayedOpacity / 255]) }; a.getTexture = function() { return this._textureAtlas.texture }; a.setTexture = function(a) { this._textureAtlas.texture = a; this._updateBlendFunc(); this._updateOpacityModifyRGB() }; a._calculateMaxItems = function() { var a = this._node, c = this._textureAtlas.texture, d = c.getContentSize(); a._ignoreContentScaleFactor && (d = c.getContentSizeInPixels()); a._itemsPerColumn = 0 | d.height / a._itemHeight; a._itemsPerRow = 0 | d.width / a._itemWidth } })(); cc._tmp.WebGLTexture2D = function() { cc.Texture2D = cc.Class.extend({ _pVRHaveAlphaPremultiplied: !0, _pixelFormat: null, _pixelsWide: 0, _pixelsHigh: 0, _name: "", _contentSize: null, maxS: 0, maxT: 0, _hasPremultipliedAlpha: !1, _hasMipmaps: !1, shaderProgram: null, _textureLoaded: !1, _htmlElementObj: null, _webTextureObj: null, url: null, ctor: function() { this._contentSize = cc.size(0, 0); this._pixelFormat = cc.Texture2D.defaultPixelFormat }, releaseTexture: function() { this._webTextureObj && cc._renderContext.deleteTexture(this._webTextureObj); cc.loader.release(this.url) }, getPixelFormat: function() { return this._pixelFormat }, getPixelsWide: function() { return this._pixelsWide }, getPixelsHigh: function() { return this._pixelsHigh }, getName: function() { return this._webTextureObj }, getContentSize: function() { return cc.size(this._contentSize.width / cc.contentScaleFactor(), this._contentSize.height / cc.contentScaleFactor()) }, _getWidth: function() { return this._contentSize.width / cc.contentScaleFactor() }, _getHeight: function() { return this._contentSize.height / cc.contentScaleFactor() }, getContentSizeInPixels: function() { return this._contentSize }, getMaxS: function() { return this.maxS }, setMaxS: function(a) { this.maxS = a }, getMaxT: function() { return this.maxT }, setMaxT: function(a) { this.maxT = a }, getShaderProgram: function() { return this.shaderProgram }, setShaderProgram: function(a) { this.shaderProgram = a }, hasPremultipliedAlpha: function() { return this._hasPremultipliedAlpha }, hasMipmaps: function() { return this._hasMipmaps }, description: function() { return "\x3ccc.Texture2D | Name \x3d " + this._name + " | Dimensions \x3d " + this._pixelsWide + " x " + this._pixelsHigh + " | Coordinates \x3d (" + this.maxS + ", " + this.maxT + ")\x3e" }, releaseData: function(a) {}, keepData: function(a, b) { return a }, initWithData: function(a, b, c, d, e) { var f = cc.Texture2D, g = cc._renderContext, h = g.RGBA, k = g.UNSIGNED_BYTE, m = c * cc.Texture2D._B[b] / 8; 0 === m % 8 ? g.pixelStorei(g.UNPACK_ALIGNMENT, 8) : 0 === m % 4 ? g.pixelStorei(g.UNPACK_ALIGNMENT, 4) : 0 === m % 2 ? g.pixelStorei(g.UNPACK_ALIGNMENT, 2) : g.pixelStorei(g.UNPACK_ALIGNMENT, 1); this._webTextureObj = g.createTexture(); cc.glBindTexture2D(this); g.texParameteri(g.TEXTURE_2D, g.TEXTURE_MIN_FILTER, g.LINEAR); g.texParameteri(g.TEXTURE_2D, g.TEXTURE_MAG_FILTER, g.LINEAR); g.texParameteri(g.TEXTURE_2D, g.TEXTURE_WRAP_S, g.CLAMP_TO_EDGE); g.texParameteri(g.TEXTURE_2D, g.TEXTURE_WRAP_T, g.CLAMP_TO_EDGE); switch (b) { case f.PIXEL_FORMAT_RGBA8888: h = g.RGBA; break; case f.PIXEL_FORMAT_RGB888: h = g.RGB; break; case f.PIXEL_FORMAT_RGBA4444: k = g.UNSIGNED_SHORT_4_4_4_4; break; case f.PIXEL_FORMAT_RGB5A1: k = g.UNSIGNED_SHORT_5_5_5_1; break; case f.PIXEL_FORMAT_RGB565: k = g.UNSIGNED_SHORT_5_6_5; break; case f.PIXEL_FORMAT_AI88: h = g.LUMINANCE_ALPHA; break; case f.PIXEL_FORMAT_A8: h = g.ALPHA; break; case f.PIXEL_FORMAT_I8: h = g.LUMINANCE; break; default: cc.assert(0, cc._LogInfos.Texture2D_initWithData) } g.texImage2D(g.TEXTURE_2D, 0, h, c, d, 0, h, k, a); this._contentSize.width = e.width; this._contentSize.height = e.height; this._pixelsWide = c; this._pixelsHigh = d; this._pixelFormat = b; this.maxS = e.width / c; this.maxT = e.height / d; this._hasMipmaps = this._hasPremultipliedAlpha = !1; this.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURE); return this._textureLoaded = !0 }, drawAtPoint: function(a) { var b = [0, this.maxT, this.maxS, this.maxT, 0, 0, this.maxS, 0], c = this._pixelsWide * this.maxS, d = this._pixelsHigh * this.maxT; a = [a.x, a.y, 0, c + a.x, a.y, 0, a.x, d + a.y, 0, c + a.x, d + a.y, 0]; cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_TEX_COORDS); this._shaderProgram.use(); this._shaderProgram.setUniformsForBuiltins(); cc.glBindTexture2D(this); c = cc._renderContext; c.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, c.FLOAT, !1, 0, a); c.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, c.FLOAT, !1, 0, b); c.drawArrays(c.TRIANGLE_STRIP, 0, 4) }, drawInRect: function(a) { var b = [0, this.maxT, this.maxS, this.maxT, 0, 0, this.maxS, 0]; a = [a.x, a.y, a.x + a.width, a.y, a.x, a.y + a.height, a.x + a.width, a.y + a.height]; cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_TEX_COORDS); this._shaderProgram.use(); this._shaderProgram.setUniformsForBuiltins(); cc.glBindTexture2D(this); var c = cc._renderContext; c.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, c.FLOAT, !1, 0, a); c.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, c.FLOAT, !1, 0, b); c.drawArrays(c.TRIANGLE_STRIP, 0, 4) }, initWithImage: function(a) { if (null == a) return cc.log(cc._LogInfos.Texture2D_initWithImage), !1; var b = a.getWidth(), c = a.getHeight(), d = cc.configuration.getMaxTextureSize(); if (b > d || c > d) return cc.log(cc._LogInfos.Texture2D_initWithImage_2, b, c, d, d), !1; this._textureLoaded = !0; return this._initPremultipliedATextureWithImage(a, b, c) }, initWithElement: function(a) { a && (this._webTextureObj = cc._renderContext.createTexture(), this._htmlElementObj = a, this._textureLoaded = !0) }, getHtmlElementObj: function() { return this._htmlElementObj }, isLoaded: function() { return this._textureLoaded }, handleLoadedTexture: function(a) { a = void 0 === a ? !1 : a; if (cc._rendererInitialized) { if (!this._htmlElementObj) { var b = cc.loader.getRes(this.url); if (!b) return; this.initWithElement(b) } this._htmlElementObj.width && this._htmlElementObj.height && (b = cc._renderContext, cc.glBindTexture2D(this), b.pixelStorei(b.UNPACK_ALIGNMENT, 4), a && b.pixelStorei(b.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 1), b.texImage2D(b.TEXTURE_2D, 0, b.RGBA, b.RGBA, b.UNSIGNED_BYTE, this._htmlElementObj), b.texParameteri(b.TEXTURE_2D, b.TEXTURE_MIN_FILTER, b.LINEAR), b.texParameteri(b.TEXTURE_2D, b.TEXTURE_MAG_FILTER, b.LINEAR), b.texParameteri(b.TEXTURE_2D, b.TEXTURE_WRAP_S, b.CLAMP_TO_EDGE), b.texParameteri(b.TEXTURE_2D, b.TEXTURE_WRAP_T, b.CLAMP_TO_EDGE), this.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURE), cc.glBindTexture2D(null), a && b.pixelStorei(b.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0), b = this._htmlElementObj.height, this._pixelsWide = this._contentSize.width = this._htmlElementObj.width, this._pixelsHigh = this._contentSize.height = b, this._pixelFormat = cc.Texture2D.PIXEL_FORMAT_RGBA8888, this.maxT = this.maxS = 1, this._hasPremultipliedAlpha = a, this._hasMipmaps = !1, this.dispatchEvent("load")) } }, initWithString: function(a, b, c, d, e, f) { cc.log(cc._LogInfos.Texture2D_initWithString); return null }, initWithETCFile: function(a) { cc.log(cc._LogInfos.Texture2D_initWithETCFile_2); return !1 }, initWithPVRFile: function(a) { cc.log(cc._LogInfos.Texture2D_initWithPVRFile_2); return !1 }, initWithPVRTCData: function(a, b, c, d, e, f) { cc.log(cc._LogInfos.Texture2D_initWithPVRTCData_2); return !1 }, setTexParameters: function(a, b, c, d) { var e = cc._renderContext; void 0 !== b && (a = { minFilter: a, magFilter: b, wrapS: c, wrapT: d }); cc.assert(this._pixelsWide === cc.NextPOT(this._pixelsWide) && this._pixelsHigh === cc.NextPOT(this._pixelsHigh) || a.wrapS === e.CLAMP_TO_EDGE && a.wrapT === e.CLAMP_TO_EDGE, "WebGLRenderingContext.CLAMP_TO_EDGE should be used in NPOT textures"); cc.glBindTexture2D(this); e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MIN_FILTER, a.minFilter); e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MAG_FILTER, a.magFilter); e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_S, a.wrapS); e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_T, a.wrapT) }, setAntiAliasTexParameters: function() { var a = cc._renderContext; cc.glBindTexture2D(this); this._hasMipmaps ? a.texParameteri(a.TEXTURE_2D, a.TEXTURE_MIN_FILTER, a.LINEAR_MIPMAP_NEAREST) : a.texParameteri(a.TEXTURE_2D, a.TEXTURE_MIN_FILTER, a.LINEAR); a.texParameteri(a.TEXTURE_2D, a.TEXTURE_MAG_FILTER, a.LINEAR) }, setAliasTexParameters: function() { var a = cc._renderContext; cc.glBindTexture2D(this); this._hasMipmaps ? a.texParameteri(a.TEXTURE_2D, a.TEXTURE_MIN_FILTER, a.NEAREST_MIPMAP_NEAREST) : a.texParameteri(a.TEXTURE_2D, a.TEXTURE_MIN_FILTER, a.NEAREST); a.texParameteri(a.TEXTURE_2D, a.TEXTURE_MAG_FILTER, a.NEAREST) }, generateMipmap: function() { cc.assert(this._pixelsWide === cc.NextPOT(this._pixelsWide) && this._pixelsHigh === cc.NextPOT(this._pixelsHigh), "Mimpap texture only works in POT textures"); cc.glBindTexture2D(this); cc._renderContext.generateMipmap(cc._renderContext.TEXTURE_2D); this._hasMipmaps = !0 }, stringForFormat: function() { return cc.Texture2D._M[this._pixelFormat] }, bitsPerPixelForFormat: function(a) { a = a || this._pixelFormat; var b = cc.Texture2D._B[a]; if (null != b) return b; cc.log(cc._LogInfos.Texture2D_bitsPerPixelForFormat, a); return -1 }, _initPremultipliedATextureWithImage: function(a, b, c) { var d = cc.Texture2D, e = a.getData(), f = null, f = null, g = a.hasAlpha(), h = cc.size(a.getWidth(), a.getHeight()), k = d.defaultPixelFormat, m = a.getBitsPerComponent(); g || (8 <= m ? k = d.PIXEL_FORMAT_RGB888 : (cc.log(cc._LogInfos.Texture2D__initPremultipliedATextureWithImage), k = d.PIXEL_FORMAT_RGB565)); var n = b * c; if (k === d.PIXEL_FORMAT_RGB565) if (g) for (e = new Uint16Array(b * c), f = a.getData(), m = 0; m < n; ++m) e[m] = (f[m] >> 0 & 255) >> 3 << 11 | (f[m] >> 8 & 255) >> 2 << 5 | (f[m] >> 16 & 255) >> 3 << 0; else for (e = new Uint16Array(b * c), f = a.getData(), m = 0; m < n; ++m) e[m] = (f[m] & 255) >> 3 << 11 | (f[m] & 255) >> 2 << 5 | (f[m] & 255) >> 3 << 0; else if (k === d.PIXEL_FORMAT_RGBA4444) for (e = new Uint16Array(b * c), f = a.getData(), m = 0; m < n; ++m) e[m] = (f[m] >> 0 & 255) >> 4 << 12 | (f[m] >> 8 & 255) >> 4 << 8 | (f[m] >> 16 & 255) >> 4 << 4 | (f[m] >> 24 & 255) >> 4 << 0; else if (k === d.PIXEL_FORMAT_RGB5A1) for (e = new Uint16Array(b * c), f = a.getData(), m = 0; m < n; ++m) e[m] = (f[m] >> 0 & 255) >> 3 << 11 | (f[m] >> 8 & 255) >> 3 << 6 | (f[m] >> 16 & 255) >> 3 << 1 | (f[m] >> 24 & 255) >> 7 << 0; else if (k === d.PIXEL_FORMAT_A8) for (e = new Uint8Array(b * c), f = a.getData(), m = 0; m < n; ++m) e[m] = f >> 24 & 255; if (g && k === d.PIXEL_FORMAT_RGB888) for (f = a.getData(), e = new Uint8Array(b * c * 3), m = 0; m < n; ++m) e[3 * m] = f >> 0 & 255, e[3 * m + 1] = f >> 8 & 255, e[3 * m + 2] = f >> 16 & 255; this.initWithData(e, k, b, c, h); a.getData(); this._hasPremultipliedAlpha = a.isPremultipliedAlpha(); return !0 }, addLoadedEventListener: function(a, b) { this.addEventListener("load", a, b) }, removeLoadedEventListener: function(a) { this.removeEventListener("load", a) } }) }; cc._tmp.WebGLTextureAtlas = function() { var a = cc.TextureAtlas.prototype; a._setupVBO = function() { var a = cc._renderContext; this._buffersVBO[0] = a.createBuffer(); this._buffersVBO[1] = a.createBuffer(); this._quadsWebBuffer = a.createBuffer(); this._mapBuffers() }; a._mapBuffers = function() { var a = cc._renderContext; a.bindBuffer(a.ARRAY_BUFFER, this._quadsWebBuffer); a.bufferData(a.ARRAY_BUFFER, this._quadsArrayBuffer, a.DYNAMIC_DRAW); a.bindBuffer(a.ELEMENT_ARRAY_BUFFER, this._buffersVBO[1]); a.bufferData(a.ELEMENT_ARRAY_BUFFER, this._indices, a.STATIC_DRAW) }; a.drawNumberOfQuads = function(a, c) { c = c || 0; if (0 !== a && this.texture && this.texture.isLoaded()) { var d = cc._renderContext; cc.glBindTexture2D(this.texture); cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); d.bindBuffer(d.ARRAY_BUFFER, this._quadsWebBuffer); this.dirty && (d.bufferData(d.ARRAY_BUFFER, this._quadsArrayBuffer, d.DYNAMIC_DRAW), this.dirty = !1); d.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 3, d.FLOAT, !1, 24, 0); d.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, d.UNSIGNED_BYTE, !0, 24, 12); d.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, d.FLOAT, !1, 24, 16); d.bindBuffer(d.ELEMENT_ARRAY_BUFFER, this._buffersVBO[1]); cc.TEXTURE_ATLAS_USE_TRIANGLE_STRIP ? d.drawElements(d.TRIANGLE_STRIP, 6 * a, d.UNSIGNED_SHORT, 6 * c * this._indices.BYTES_PER_ELEMENT) : d.drawElements(d.TRIANGLES, 6 * a, d.UNSIGNED_SHORT, 6 * c * this._indices.BYTES_PER_ELEMENT); cc.g_NumberOfDraws++ } } }; cc._tmp.WebGLTextureCache = function() { var a = cc.textureCache; a.handleLoadedTexture = function(a) { var c = this._textures; cc._rendererInitialized || (c = this._loadedTexturesBefore); var d = c[a]; d || (d = c[a] = new cc.Texture2D, d.url = a); d.handleLoadedTexture() }; a.addImage = function(a, c, d) { cc.assert(a, cc._LogInfos.Texture2D_addImage_2); var e = this._textures; cc._rendererInitialized || (e = this._loadedTexturesBefore); var f = e[a] || e[cc.loader._aliases[a]]; if (f) return c && c.call(d, f), f; f = e[a] = new cc.Texture2D; f.url = a; (cc.loader._checkIsImageURL(a) ? cc.loader.load : cc.loader.loadImg).call(cc.loader, a, function(f, h) { if (f) return c && c.call(d, f); cc.textureCache.handleLoadedTexture(a); var k = e[a]; c && c.call(d, k) }); return f }; a.addImageAsync = a.addImage; a = null }; cc._tmp.PrototypeTexture2D = function() { var a = cc.Texture2D; a.PVRImagesHavePremultipliedAlpha = function(a) { cc.PVRHaveAlphaPremultiplied_ = a }; a.PIXEL_FORMAT_RGBA8888 = 2; a.PIXEL_FORMAT_RGB888 = 3; a.PIXEL_FORMAT_RGB565 = 4; a.PIXEL_FORMAT_A8 = 5; a.PIXEL_FORMAT_I8 = 6; a.PIXEL_FORMAT_AI88 = 7; a.PIXEL_FORMAT_RGBA4444 = 8; a.PIXEL_FORMAT_RGB5A1 = 7; a.PIXEL_FORMAT_PVRTC4 = 9; a.PIXEL_FORMAT_PVRTC2 = 10; a.PIXEL_FORMAT_DEFAULT = a.PIXEL_FORMAT_RGBA8888; var b = cc.Texture2D._M = {}; b[a.PIXEL_FORMAT_RGBA8888] = "RGBA8888"; b[a.PIXEL_FORMAT_RGB888] = "RGB888"; b[a.PIXEL_FORMAT_RGB565] = "RGB565"; b[a.PIXEL_FORMAT_A8] = "A8"; b[a.PIXEL_FORMAT_I8] = "I8"; b[a.PIXEL_FORMAT_AI88] = "AI88"; b[a.PIXEL_FORMAT_RGBA4444] = "RGBA4444"; b[a.PIXEL_FORMAT_RGB5A1] = "RGB5A1"; b[a.PIXEL_FORMAT_PVRTC4] = "PVRTC4"; b[a.PIXEL_FORMAT_PVRTC2] = "PVRTC2"; b = cc.Texture2D._B = {}; b[a.PIXEL_FORMAT_RGBA8888] = 32; b[a.PIXEL_FORMAT_RGB888] = 24; b[a.PIXEL_FORMAT_RGB565] = 16; b[a.PIXEL_FORMAT_A8] = 8; b[a.PIXEL_FORMAT_I8] = 8; b[a.PIXEL_FORMAT_AI88] = 16; b[a.PIXEL_FORMAT_RGBA4444] = 16; b[a.PIXEL_FORMAT_RGB5A1] = 16; b[a.PIXEL_FORMAT_PVRTC4] = 4; b[a.PIXEL_FORMAT_PVRTC2] = 3; b = cc.Texture2D.prototype; cc.defineGetterSetter(b, "name", b.getName); cc.defineGetterSetter(b, "pixelFormat", b.getPixelFormat); cc.defineGetterSetter(b, "pixelsWidth", b.getPixelsWide); cc.defineGetterSetter(b, "pixelsHeight", b.getPixelsHigh); cc.defineGetterSetter(b, "width", b._getWidth); cc.defineGetterSetter(b, "height", b._getHeight); a.defaultPixelFormat = a.PIXEL_FORMAT_DEFAULT }; cc._tmp.PrototypeTextureAtlas = function() { var a = cc.TextureAtlas.prototype; cc.defineGetterSetter(a, "totalQuads", a.getTotalQuads); cc.defineGetterSetter(a, "capacity", a.getCapacity); cc.defineGetterSetter(a, "quads", a.getQuads, a.setQuads) }; cc.ALIGN_CENTER = 51; cc.ALIGN_TOP = 19; cc.ALIGN_TOP_RIGHT = 18; cc.ALIGN_RIGHT = 50; cc.ALIGN_BOTTOM_RIGHT = 34; cc.ALIGN_BOTTOM = 35; cc.ALIGN_BOTTOM_LEFT = 33; cc.ALIGN_LEFT = 49; cc.ALIGN_TOP_LEFT = 17; cc.PVRHaveAlphaPremultiplied_ = !1; cc._renderType === cc._RENDER_TYPE_CANVAS ? (cc.Texture2D = cc.Class.extend({ _contentSize: null, _textureLoaded: !1, _htmlElementObj: null, url: null, _pattern: null, ctor: function() { this._contentSize = cc.size(0, 0); this._textureLoaded = !1; this._htmlElementObj = null; this._pattern = "" }, getPixelsWide: function() { return this._contentSize.width }, getPixelsHigh: function() { return this._contentSize.height }, getContentSize: function() { var a = cc.contentScaleFactor(); return cc.size(this._contentSize.width / a, this._contentSize.height / a) }, _getWidth: function() { return this._contentSize.width / cc.contentScaleFactor() }, _getHeight: function() { return this._contentSize.height / cc.contentScaleFactor() }, getContentSizeInPixels: function() { return this._contentSize }, initWithElement: function(a) { a && (this._htmlElementObj = a, this._contentSize.width = a.width, this._contentSize.height = a.height, this._textureLoaded = !0) }, getHtmlElementObj: function() { return this._htmlElementObj }, isLoaded: function() { return this._textureLoaded }, handleLoadedTexture: function() { if (!this._textureLoaded) { if (!this._htmlElementObj) { var a = cc.loader.getRes(this.url); if (!a) return; this.initWithElement(a) } a = this._htmlElementObj; this._contentSize.width = a.width; this._contentSize.height = a.height; this.dispatchEvent("load") } }, description: function() { return "\x3ccc.Texture2D | width \x3d " + this._contentSize.width + " height " + this._contentSize.height + "\x3e" }, initWithData: function(a, b, c, d, e) { return !1 }, initWithImage: function(a) { return !1 }, initWithString: function(a, b, c, d, e, f) { return !1 }, releaseTexture: function() { cc.loader.release(this.url) }, getName: function() { return null }, getMaxS: function() { return 1 }, setMaxS: function(a) {}, getMaxT: function() { return 1 }, setMaxT: function(a) {}, getPixelFormat: function() { return null }, getShaderProgram: function() { return null }, setShaderProgram: function(a) {}, hasPremultipliedAlpha: function() { return !1 }, hasMipmaps: function() { return !1 }, releaseData: function(a) {}, keepData: function(a, b) { return a }, drawAtPoint: function(a) {}, drawInRect: function(a) {}, initWithETCFile: function(a) { cc.log(cc._LogInfos.Texture2D_initWithETCFile); return !1 }, initWithPVRFile: function(a) { cc.log(cc._LogInfos.Texture2D_initWithPVRFile); return !1 }, initWithPVRTCData: function(a, b, c, d, e, f) { cc.log(cc._LogInfos.Texture2D_initWithPVRTCData); return !1 }, setTexParameters: function(a, b, c, d) { void 0 !== b && (a = { minFilter: a, magFilter: b, wrapS: c, wrapT: d }); this._pattern = a.wrapS === cc.REPEAT && a.wrapT === cc.REPEAT ? "repeat" : a.wrapS === cc.REPEAT ? "repeat-x" : a.wrapT === cc.REPEAT ? "repeat-y" : "" }, setAntiAliasTexParameters: function() {}, setAliasTexParameters: function() {}, generateMipmap: function() {}, stringForFormat: function() { return "" }, bitsPerPixelForFormat: function(a) { return -1 }, addLoadedEventListener: function(a, b) { this.addEventListener("load", a, b) }, removeLoadedEventListener: function(a) { this.removeEventListener("load", a) }, _grayElementObj: null, _backupElement: null, _isGray: !1, _switchToGray: function(a) { this._textureLoaded && this._isGray !== a && ((this._isGray = a) ? (this._backupElement = this._htmlElementObj, this._grayElementObj || (this._grayElementObj = cc.Texture2D._generateGrayTexture(this._htmlElementObj)), this._htmlElementObj = this._grayElementObj) : null !== this._backupElement && (this._htmlElementObj = this._backupElement)) } }), cc.Texture2D._generateGrayTexture = function(a, b, c) { if (null === a) return null; c = c || cc.newElement("canvas"); b = b || cc.rect(0, 0, a.width, a.height); c.width = b.width; c.height = b.height; var d = c.getContext("2d"); d.drawImage(a, b.x, b.y, b.width, b.height, 0, 0, b.width, b.height); a = d.getImageData(0, 0, b.width, b.height); b = a.data; for (var e = 0, f = b.length; e < f; e += 4) b[e] = b[e + 1] = b[e + 2] = 0.34 * b[e] + 0.5 * b[e + 1] + 0.16 * b[e + 2]; d.putImageData(a, 0, 0); return c }) : (cc.assert(cc.isFunction(cc._tmp.WebGLTexture2D), cc._LogInfos.MissingFile, "TexturesWebGL.js"), cc._tmp.WebGLTexture2D(), delete cc._tmp.WebGLTexture2D); cc.EventHelper.prototype.apply(cc.Texture2D.prototype); cc.assert(cc.isFunction(cc._tmp.PrototypeTexture2D), cc._LogInfos.MissingFile, "TexturesPropertyDefine.js"); cc._tmp.PrototypeTexture2D(); delete cc._tmp.PrototypeTexture2D; cc.textureCache = { _textures: {}, _textureColorsCache: {}, _textureKeySeq: 0 | 1E3 * Math.random(), _loadedTexturesBefore: {}, _initializingRenderer: function() { var a, b = this._loadedTexturesBefore, c = this._textures; for (a in b) { var d = b[a]; d.handleLoadedTexture(); c[a] = d } this._loadedTexturesBefore = {} }, addPVRTCImage: function(a) { cc.log(cc._LogInfos.textureCache_addPVRTCImage) }, addETCImage: function(a) { cc.log(cc._LogInfos.textureCache_addETCImage) }, description: function() { return "\x3cTextureCache | Number of textures \x3d " + this._textures.length + "\x3e" }, textureForKey: function(a) { cc.log(cc._LogInfos.textureCache_textureForKey); return this.getTextureForKey(a) }, getTextureForKey: function(a) { return this._textures[a] || this._textures[cc.loader._aliases[a]] }, getKeyByTexture: function(a) { for (var b in this._textures) if (this._textures[b] === a) return b; return null }, _generalTextureKey: function() { this._textureKeySeq++; return "_textureKey_" + this._textureKeySeq }, getTextureColors: function(a) { var b = this.getKeyByTexture(a); b || (b = a instanceof HTMLImageElement ? a.src : this._generalTextureKey()); this._textureColorsCache[b] || (this._textureColorsCache[b] = cc.Sprite.CanvasRenderCmd._generateTextureCacheForColor(a)); return this._textureColorsCache[b] }, addPVRImage: function(a) { cc.log(cc._LogInfos.textureCache_addPVRImage) }, removeAllTextures: function() { var a = this._textures, b; for (b in a) a[b] && a[b].releaseTexture(); this._textures = {} }, removeTexture: function(a) { if (a) { var b = this._textures, c; for (c in b) b[c] === a && (b[c].releaseTexture(), delete b[c]) } }, removeTextureForKey: function(a) { null != a && this._textures[a] && delete this._textures[a] }, cacheImage: function(a, b) { if (b instanceof cc.Texture2D) this._textures[a] = b; else { var c = new cc.Texture2D; c.initWithElement(b); c.handleLoadedTexture(); this._textures[a] = c } }, addUIImage: function(a, b) { cc.assert(a, cc._LogInfos.textureCache_addUIImage_2); if (b && this._textures[b]) return this._textures[b]; var c = new cc.Texture2D; c.initWithImage(a); null != b ? this._textures[b] = c : cc.log(cc._LogInfos.textureCache_addUIImage); return c }, dumpCachedTextureInfo: function() { var a = 0, b = 0, c = this._textures, d; for (d in c) { var e = c[d]; a++; e.getHtmlElementObj() instanceof HTMLImageElement ? cc.log(cc._LogInfos.textureCache_dumpCachedTextureInfo, d, e.getHtmlElementObj().src, e.pixelsWidth, e.pixelsHeight) : cc.log(cc._LogInfos.textureCache_dumpCachedTextureInfo_2, d, e.pixelsWidth, e.pixelsHeight); b += e.pixelsWidth * e.pixelsHeight * 4 } c = this._textureColorsCache; for (d in c) { var e = c[d], f; for (f in e) { var g = e[f]; a++; cc.log(cc._LogInfos.textureCache_dumpCachedTextureInfo_2, d, g.width, g.height); b += g.width * g.height * 4 } } cc.log(cc._LogInfos.textureCache_dumpCachedTextureInfo_3, a, b / 1024, (b / 1048576).toFixed(2)) }, _clear: function() { this._textures = {}; this._textureColorsCache = {}; this._textureKeySeq = 0 | 1E3 * Math.random(); this._loadedTexturesBefore = {} } }; cc._renderType === cc._RENDER_TYPE_CANVAS ? (_p = cc.textureCache, _p.handleLoadedTexture = function(a) { var b = this._textures, c = b[a]; c || (c = b[a] = new cc.Texture2D, c.url = a); c.handleLoadedTexture() }, _p.addImage = function(a, b, c) { cc.assert(a, cc._LogInfos.Texture2D_addImage); var d = this._textures, e = d[a] || d[cc.loader._aliases[a]]; if (e) return b && b.call(c, e), e; e = d[a] = new cc.Texture2D; e.url = a; (cc.loader._checkIsImageURL(a) ? cc.loader.load : cc.loader.loadImg).call(cc.loader, a, function(e, g) { if (e) return b && b.call(c, e); cc.textureCache.handleLoadedTexture(a); var h = d[a]; b && b.call(c, h) }); return e }, _p.addImageAsync = _p.addImage, _p = null) : (cc.assert(cc.isFunction(cc._tmp.WebGLTextureCache), cc._LogInfos.MissingFile, "TexturesWebGL.js"), cc._tmp.WebGLTextureCache(), delete cc._tmp.WebGLTextureCache); cc.TextureAtlas = cc.Class.extend({ dirty: !1, texture: null, _indices: null, _buffersVBO: null, _capacity: 0, _quads: null, _quadsArrayBuffer: null, _quadsWebBuffer: null, _quadsReader: null, ctor: function(a, b) { this._buffersVBO = []; cc.isString(a) ? this.initWithFile(a, b) : a instanceof cc.Texture2D && this.initWithTexture(a, b) }, getTotalQuads: function() { return this._totalQuads }, getCapacity: function() { return this._capacity }, getTexture: function() { return this.texture }, setTexture: function(a) { this.texture = a }, setDirty: function(a) { this.dirty = a }, isDirty: function() { return this.dirty }, getQuads: function() { return this._quads }, setQuads: function(a) { this._quads = a }, _copyQuadsToTextureAtlas: function(a, b) { if (a) for (var c = 0; c < a.length; c++) this._setQuadToArray(a[c], b + c) }, _setQuadToArray: function(a, b) { var c = this._quads; c[b] ? (c[b].bl = a.bl, c[b].br = a.br, c[b].tl = a.tl, c[b].tr = a.tr) : c[b] = new cc.V3F_C4B_T2F_Quad(a.tl, a.bl, a.tr, a.br, this._quadsArrayBuffer, b * cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT) }, description: function() { return "\x3ccc.TextureAtlas | totalQuads \x3d" + this._totalQuads + "\x3e" }, _setupIndices: function() { if (0 !== this._capacity) for (var a = this._indices, b = this._capacity, c = 0; c < b; c++) cc.TEXTURE_ATLAS_USE_TRIANGLE_STRIP ? (a[6 * c + 0] = 4 * c + 0, a[6 * c + 1] = 4 * c + 0, a[6 * c + 2] = 4 * c + 2, a[6 * c + 3] = 4 * c + 1, a[6 * c + 4] = 4 * c + 3, a[6 * c + 5] = 4 * c + 3) : (a[6 * c + 0] = 4 * c + 0, a[6 * c + 1] = 4 * c + 1, a[6 * c + 2] = 4 * c + 2, a[6 * c + 3] = 4 * c + 3, a[6 * c + 4] = 4 * c + 2, a[6 * c + 5] = 4 * c + 1) }, _setupVBO: function() { var a = cc._renderContext; this._buffersVBO[0] = a.createBuffer(); this._buffersVBO[1] = a.createBuffer(); this._quadsWebBuffer = a.createBuffer(); this._mapBuffers() }, _mapBuffers: function() { var a = cc._renderContext; a.bindBuffer(a.ARRAY_BUFFER, this._quadsWebBuffer); a.bufferData(a.ARRAY_BUFFER, this._quadsArrayBuffer, a.DYNAMIC_DRAW); a.bindBuffer(a.ELEMENT_ARRAY_BUFFER, this._buffersVBO[1]); a.bufferData(a.ELEMENT_ARRAY_BUFFER, this._indices, a.STATIC_DRAW) }, initWithFile: function(a, b) { var c = cc.textureCache.addImage(a); if (c) return this.initWithTexture(c, b); cc.log(cc._LogInfos.TextureAtlas_initWithFile, a); return !1 }, initWithTexture: function(a, b) { cc.assert(a, cc._LogInfos.TextureAtlas_initWithTexture); this._capacity = b |= 0; this._totalQuads = 0; this.texture = a; this._quads = []; this._indices = new Uint16Array(6 * b); var c = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT; this._quadsArrayBuffer = new ArrayBuffer(c * b); this._quadsReader = new Uint8Array(this._quadsArrayBuffer); if ((!this._quads || !this._indices) && 0 < b) return !1; for (var d = this._quads, e = 0; e < b; e++) d[e] = new cc.V3F_C4B_T2F_Quad(null, null, null, null, this._quadsArrayBuffer, e * c); this._setupIndices(); this._setupVBO(); return this.dirty = !0 }, updateQuad: function(a, b) { cc.assert(a, cc._LogInfos.TextureAtlas_updateQuad); cc.assert(0 <= b && b < this._capacity, cc._LogInfos.TextureAtlas_updateQuad_2); this._totalQuads = Math.max(b + 1, this._totalQuads); this._setQuadToArray(a, b); this.dirty = !0 }, insertQuad: function(a, b) { cc.assert(b < this._capacity, cc._LogInfos.TextureAtlas_insertQuad_2); this._totalQuads++; if (this._totalQuads > this._capacity) cc.log(cc._LogInfos.TextureAtlas_insertQuad); else { var c = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT, d = b * c, e = (this._totalQuads - 1 - b) * c; this._quads[this._totalQuads - 1] = new cc.V3F_C4B_T2F_Quad(null, null, null, null, this._quadsArrayBuffer, (this._totalQuads - 1) * c); this._quadsReader.set(this._quadsReader.subarray(d, d + e), d + c); this._setQuadToArray(a, b); this.dirty = !0 } }, insertQuads: function(a, b, c) { c = c || a.length; cc.assert(b + c <= this._capacity, cc._LogInfos.TextureAtlas_insertQuads); var d = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT; this._totalQuads += c; if (this._totalQuads > this._capacity) cc.log(cc._LogInfos.TextureAtlas_insertQuad); else { var e = b * d, f = (this._totalQuads - 1 - b - c) * d, g = this._totalQuads - 1 - c, h; for (h = 0; h < c; h++) this._quads[g + h] = new cc.V3F_C4B_T2F_Quad(null, null, null, null, this._quadsArrayBuffer, (this._totalQuads - 1) * d); this._quadsReader.set(this._quadsReader.subarray(e, e + f), e + d * c); for (h = 0; h < c; h++) this._setQuadToArray(a[h], b + h); this.dirty = !0 } }, insertQuadFromIndex: function(a, b) { if (a !== b) { cc.assert(0 <= b || b < this._totalQuads, cc._LogInfos.TextureAtlas_insertQuadFromIndex); cc.assert(0 <= a || a < this._totalQuads, cc._LogInfos.TextureAtlas_insertQuadFromIndex_2); var c = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT, d = this._quadsReader, e = d.subarray(a * c, c), f; a > b ? (f = b * c, d.set(d.subarray(f, f + (a - b) * c), f + c), d.set(e, f)) : (f = (a + 1) * c, d.set(d.subarray(f, f + (b - a) * c), f - c), d.set(e, b * c)); this.dirty = !0 } }, removeQuadAtIndex: function(a) { cc.assert(a < this._totalQuads, cc._LogInfos.TextureAtlas_removeQuadAtIndex); var b = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT; this._totalQuads--; this._quads.length = this._totalQuads; if (a !== this._totalQuads) { var c = (a + 1) * b; this._quadsReader.set(this._quadsReader.subarray(c, c + (this._totalQuads - a) * b), c - b) } this.dirty = !0 }, removeQuadsAtIndex: function(a, b) { cc.assert(a + b <= this._totalQuads, cc._LogInfos.TextureAtlas_removeQuadsAtIndex); this._totalQuads -= b; if (a !== this._totalQuads) { var c = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT, d = (a + b) * c, e = a * c; this._quadsReader.set(this._quadsReader.subarray(d, d + (this._totalQuads - a) * c), e) } this.dirty = !0 }, removeAllQuads: function() { this._totalQuads = this._quads.length = 0 }, _setDirty: function(a) { this.dirty = a }, resizeCapacity: function(a) { if (a === this._capacity) return !0; var b = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT, c = this._capacity; this._totalQuads = Math.min(this._totalQuads, a); var d = this._capacity = 0 | a, e = this._totalQuads; if (null === this._quads) for (this._quads = [], this._quadsArrayBuffer = new ArrayBuffer(b * d), this._quadsReader = new Uint8Array(this._quadsArrayBuffer), a = 0; a < d; a++) this._quads = new cc.V3F_C4B_T2F_Quad(null, null, null, null, this._quadsArrayBuffer, a * b); else { var f, g, h = this._quads; if (d > c) { f = []; g = new ArrayBuffer(b * d); for (a = 0; a < e; a++) f[a] = new cc.V3F_C4B_T2F_Quad(h[a].tl, h[a].bl, h[a].tr, h[a].br, g, a * b); for (; a < d; a++) f[a] = new cc.V3F_C4B_T2F_Quad(null, null, null, null, g, a * b) } else for (e = Math.max(e, d), f = [], g = new ArrayBuffer(b * d), a = 0; a < e; a++) f[a] = new cc.V3F_C4B_T2F_Quad(h[a].tl, h[a].bl, h[a].tr, h[a].br, g, a * b); this._quadsReader = new Uint8Array(g); this._quads = f; this._quadsArrayBuffer = g } null === this._indices ? this._indices = new Uint16Array(6 * d) : d > c ? (b = new Uint16Array(6 * d), b.set(this._indices, 0), this._indices = b) : this._indices = this._indices.subarray(0, 6 * d); this._setupIndices(); this._mapBuffers(); return this.dirty = !0 }, increaseTotalQuadsWith: function(a) { this._totalQuads += a }, moveQuadsFromIndex: function(a, b, c) { if (void 0 === c) { if (c = b, b = this._totalQuads - a, cc.assert(c + (this._totalQuads - a) <= this._capacity, cc._LogInfos.TextureAtlas_moveQuadsFromIndex), 0 === b) return } else if (cc.assert(c + b <= this._totalQuads, cc._LogInfos.TextureAtlas_moveQuadsFromIndex_2), cc.assert(a < this._totalQuads, cc._LogInfos.TextureAtlas_moveQuadsFromIndex_3), a === c) return; var d = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT, e = a * d, f = b * d, g = this._quadsReader, h = g.subarray(e, e + f), k = c * d; c < a ? (b = c * d, g.set(g.subarray(b, b + (a - c) * d), b + f)) : (b = (a + b) * d, g.set(g.subarray(b, b + (c - a) * d), e)); g.set(h, k); this.dirty = !0 }, fillWithEmptyQuadsFromIndex: function(a, b) { for (var c = b * cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT, d = new Uint8Array(this._quadsArrayBuffer, a * cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT, c), e = 0; e < c; e++) d[e] = 0 }, drawQuads: function() { this.drawNumberOfQuads(this._totalQuads, 0) }, _releaseBuffer: function() { var a = cc._renderContext; this._buffersVBO && (this._buffersVBO[0] && a.deleteBuffer(this._buffersVBO[0]), this._buffersVBO[1] && a.deleteBuffer(this._buffersVBO[1])); this._quadsWebBuffer && a.deleteBuffer(this._quadsWebBuffer) } }); _p = cc.TextureAtlas.prototype; cc.defineGetterSetter(_p, "totalQuads", _p.getTotalQuads); cc.defineGetterSetter(_p, "capacity", _p.getCapacity); cc.defineGetterSetter(_p, "quads", _p.getQuads, _p.setQuads); cc.TextureAtlas.create = function(a, b) { return new cc.TextureAtlas(a, b) }; cc.TextureAtlas.createWithTexture = cc.TextureAtlas.create; cc._renderType === cc._RENDER_TYPE_WEBGL && (cc.assert(cc.isFunction(cc._tmp.WebGLTextureAtlas), cc._LogInfos.MissingFile, "TexturesWebGL.js"), cc._tmp.WebGLTextureAtlas(), delete cc._tmp.WebGLTextureAtlas); cc.assert(cc.isFunction(cc._tmp.PrototypeTextureAtlas), cc._LogInfos.MissingFile, "TexturesPropertyDefine.js"); cc._tmp.PrototypeTextureAtlas(); delete cc._tmp.PrototypeTextureAtlas; cc.Scene = cc.Node.extend({ _className: "Scene", ctor: function() { cc.Node.prototype.ctor.call(this); this._ignoreAnchorPointForPosition = !0; this.setAnchorPoint(0.5, 0.5); this.setContentSize(cc.director.getWinSize()) } }); cc.Scene.create = function() { return new cc.Scene }; cc.LoaderScene = cc.Scene.extend({ _interval: null, _label: null, _className: "LoaderScene", init: function() { var a = this, b = 200, c = a._bgLayer = new cc.LayerColor(cc.color(32, 32, 32, 255)); a.addChild(c, 0); var d = 24, e = -b / 2 + 100; cc._loaderImage && (cc.loader.loadImg(cc._loaderImage, { isCrossOrigin: !1 }, function(c, d) { b = d.height; a._initStage(d, cc.visibleRect.center) }), d = 14, e = -b / 2 - 10); d = a._label = new cc.LabelTTF("Loading... 0%", "Arial", d); d.setPosition(cc.pAdd(cc.visibleRect.center, cc.p(0, e))); d.setColor(cc.color(180, 180, 180)); c.addChild(this._label, 10); return !0 }, _initStage: function(a, b) { var c = this._texture2d = new cc.Texture2D; c.initWithElement(a); c.handleLoadedTexture(); c = this._logo = new cc.Sprite(c); c.setScale(cc.contentScaleFactor()); c.x = b.x; c.y = b.y; this._bgLayer.addChild(c, 10) }, onEnter: function() { cc.Node.prototype.onEnter.call(this); this.schedule(this._startLoading, 0.3) }, onExit: function() { cc.Node.prototype.onExit.call(this); this._label.setString("Loading... 0%") }, initWithResources: function(a, b) { cc.isString(a) && (a = [a]); this.resources = a || []; this.cb = b }, _startLoading: function() { var a = this; a.unschedule(a._startLoading); cc.loader.load(a.resources, function(b, c, d) { b = Math.min(d / c * 100 | 0, 100); a._label.setString("Loading... " + b + "%") }, function() { a.cb && a.cb() }) } }); cc.LoaderScene.preload = function(a, b) { var c = cc; c.loaderScene || (c.loaderScene = new cc.LoaderScene, c.loaderScene.init()); c.loaderScene.initWithResources(a, b); cc.director.runScene(c.loaderScene); return c.loaderScene }; cc.Layer = cc.Node.extend({ _className: "Layer", ctor: function() { var a = cc.Node.prototype; a.ctor.call(this); this._ignoreAnchorPointForPosition = !0; a.setAnchorPoint.call(this, 0.5, 0.5); a.setContentSize.call(this, cc.winSize) }, init: function() { this._ignoreAnchorPointForPosition = !0; this.setAnchorPoint(0.5, 0.5); this.setContentSize(cc.winSize); this._cascadeOpacityEnabled = this._cascadeColorEnabled = !1; return !0 }, bake: function() { this._renderCmd.bake() }, unbake: function() { this._renderCmd.unbake() }, isBaked: function() { return this._isBaked }, addChild: function(a, b, c) { cc.Node.prototype.addChild.call(this, a, b, c); this._renderCmd._bakeForAddChild(a) }, _createRenderCmd: function() { return cc._renderType === cc._RENDER_TYPE_CANVAS ? new cc.Layer.CanvasRenderCmd(this) : new cc.Layer.WebGLRenderCmd(this) } }); cc.Layer.create = function() { return new cc.Layer }; cc.LayerColor = cc.Layer.extend({ _blendFunc: null, _className: "LayerColor", getBlendFunc: function() { return this._blendFunc }, changeWidthAndHeight: function(a, b) { this.width = a; this.height = b }, changeWidth: function(a) { this.width = a }, changeHeight: function(a) { this.height = a }, setOpacityModifyRGB: function(a) {}, isOpacityModifyRGB: function() { return !1 }, ctor: function(a, b, c) { cc.Layer.prototype.ctor.call(this); this._blendFunc = new cc.BlendFunc(cc.BLEND_SRC, cc.BLEND_DST); cc.LayerColor.prototype.init.call(this, a, b, c) }, init: function(a, b, c) { cc._renderType !== cc._RENDER_TYPE_CANVAS && (this.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_COLOR)); var d = cc.director.getWinSize(); a = a || cc.color(0, 0, 0, 255); b = void 0 === b ? d.width : b; c = void 0 === c ? d.height : c; d = this._realColor; d.r = a.r; d.g = a.g; d.b = a.b; this._realOpacity = a.a; this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.colorDirty | cc.Node._dirtyFlags.opacityDirty); cc.LayerColor.prototype.setContentSize.call(this, b, c); return !0 }, setBlendFunc: function(a, b) { var c = this._blendFunc; void 0 === b ? (c.src = a.src, c.dst = a.dst) : (c.src = a, c.dst = b); this._renderCmd.updateBlendFunc(c) }, _setWidth: function(a) { cc.Node.prototype._setWidth.call(this, a); this._renderCmd._updateSquareVerticesWidth(a) }, _setHeight: function(a) { cc.Node.prototype._setHeight.call(this, a); this._renderCmd._updateSquareVerticesHeight(a) }, setContentSize: function(a, b) { cc.Layer.prototype.setContentSize.call(this, a, b); this._renderCmd._updateSquareVertices(a, b) }, _createRenderCmd: function() { return cc._renderType === cc._RENDER_TYPE_CANVAS ? new cc.LayerColor.CanvasRenderCmd(this) : new cc.LayerColor.WebGLRenderCmd(this) } }); cc.LayerColor.create = function(a, b, c) { return new cc.LayerColor(a, b, c) }; (function() { var a = cc.LayerColor.prototype; cc.defineGetterSetter(a, "width", a._getWidth, a._setWidth); cc.defineGetterSetter(a, "height", a._getHeight, a._setHeight) })(); cc.LayerGradient = cc.LayerColor.extend({ _endColor: null, _startOpacity: 255, _endOpacity: 255, _alongVector: null, _compressedInterpolation: !1, _className: "LayerGradient", _colorStops: [], ctor: function(a, b, c, d) { cc.LayerColor.prototype.ctor.call(this); this._endColor = cc.color(0, 0, 0, 255); this._alongVector = cc.p(0, -1); this._endOpacity = this._startOpacity = 255; d && d instanceof Array ? (this._colorStops = d, d.splice(0, 0, { p: 0, color: a || cc.color.BLACK }), d.push({ p: 1, color: b || cc.color.BLACK })) : this._colorStops = [{ p: 0, color: a || cc.color.BLACK }, { p: 1, color: b || cc.color.BLACK }]; cc.LayerGradient.prototype.init.call(this, a, b, c, d) }, init: function(a, b, c, d) { a = a || cc.color(0, 0, 0, 255); b = b || cc.color(0, 0, 0, 255); c = c || cc.p(0, -1); d = this._endColor; this._startOpacity = a.a; d.r = b.r; d.g = b.g; d.b = b.b; this._endOpacity = b.a; this._alongVector = c; this._compressedInterpolation = !0; cc.LayerColor.prototype.init.call(this, cc.color(a.r, a.g, a.b, 255)); this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.colorDirty | cc.Node._dirtyFlags.opacityDirty | cc.Node._dirtyFlags.gradientDirty); return !0 }, setContentSize: function(a, b) { cc.LayerColor.prototype.setContentSize.call(this, a, b); this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.gradientDirty) }, _setWidth: function(a) { cc.LayerColor.prototype._setWidth.call(this, a); this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.gradientDirty) }, _setHeight: function(a) { cc.LayerColor.prototype._setHeight.call(this, a); this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.gradientDirty) }, getStartColor: function() { return cc.color(this._realColor) }, setStartColor: function(a) { this.color = a; var b = this._colorStops; b && 0 < b.length && (b = b[0].color, b.r = a.r, b.g = a.g, b.b = a.b) }, setEndColor: function(a) { var b = this._endColor; b.r = a.r; b.g = a.g; b.b = a.b; (b = this._colorStops) && 0 < b.length && (b = b[b.length - 1].color, b.r = a.r, b.g = a.g, b.b = a.b); this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.colorDirty) }, getEndColor: function() { return cc.color(this._endColor) }, setStartOpacity: function(a) { this._startOpacity = a; var b = this._colorStops; b && 0 < b.length && (b[0].color.a = a); this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.opacityDirty) }, getStartOpacity: function() { return this._startOpacity }, setEndOpacity: function(a) { this._endOpacity = a; var b = this._colorStops; b && 0 < b.length && (b[b.length - 1].color.a = a); this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.opacityDirty) }, getEndOpacity: function() { return this._endOpacity }, setVector: function(a) { this._alongVector.x = a.x; this._alongVector.y = a.y; this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.gradientDirty) }, getVector: function() { return cc.p(this._alongVector.x, this._alongVector.y) }, isCompressedInterpolation: function() { return this._compressedInterpolation }, setCompressedInterpolation: function(a) { this._compressedInterpolation = a; this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.gradientDirty) }, getColorStops: function() { return this._colorStops }, setColorStops: function(a) { this._colorStops = a; this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.colorDirty | cc.Node._dirtyFlags.opacityDirty | cc.Node._dirtyFlags.gradientDirty) }, _createRenderCmd: function() { return cc._renderType === cc._RENDER_TYPE_CANVAS ? new cc.LayerGradient.CanvasRenderCmd(this) : new cc.LayerGradient.WebGLRenderCmd(this) } }); cc.LayerGradient.create = function(a, b, c, d) { return new cc.LayerGradient(a, b, c, d) }; (function() { var a = cc.LayerGradient.prototype; cc.defineGetterSetter(a, "startColor", a.getStartColor, a.setStartColor); cc.defineGetterSetter(a, "endColor", a.getEndColor, a.setEndColor); cc.defineGetterSetter(a, "startOpacity", a.getStartOpacity, a.setStartOpacity); cc.defineGetterSetter(a, "endOpacity", a.getEndOpacity, a.setEndOpacity); cc.defineGetterSetter(a, "vector", a.getVector, a.setVector); cc.defineGetterSetter(a, "colorStops", a.getColorStops, a.setColorStops) })(); cc.LayerMultiplex = cc.Layer.extend({ _enabledLayer: 0, _layers: null, _className: "LayerMultiplex", ctor: function(a) { cc.Layer.prototype.ctor.call(this); a instanceof Array ? cc.LayerMultiplex.prototype.initWithLayers.call(this, a) : cc.LayerMultiplex.prototype.initWithLayers.call(this, Array.prototype.slice.call(arguments)) }, initWithLayers: function(a) { 0 < a.length && null == a[a.length - 1] && cc.log(cc._LogInfos.LayerMultiplex_initWithLayers); this._layers = a; this._enabledLayer = 0; this.addChild(this._layers[this._enabledLayer]); return !0 }, switchTo: function(a) { a >= this._layers.length ? cc.log(cc._LogInfos.LayerMultiplex_switchTo) : (this.removeChild(this._layers[this._enabledLayer], !0), this._enabledLayer = a, this.addChild(this._layers[a])) }, switchToAndReleaseMe: function(a) { a >= this._layers.length ? cc.log(cc._LogInfos.LayerMultiplex_switchToAndReleaseMe) : (this.removeChild(this._layers[this._enabledLayer], !0), this._layers[this._enabledLayer] = null, this._enabledLayer = a, this.addChild(this._layers[a])) }, addLayer: function(a) { a ? this._layers.push(a) : cc.log(cc._LogInfos.LayerMultiplex_addLayer) } }); cc.LayerMultiplex.create = function() { return new cc.LayerMultiplex(Array.prototype.slice.call(arguments)) }; (function() { cc.Layer.CanvasRenderCmd = function(a) { cc.Node.CanvasRenderCmd.call(this, a); this._isBaked = !1; this._bakeSprite = null }; var a = cc.Layer.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); a.constructor = cc.Layer.CanvasRenderCmd; a.bake = function() { if (!this._isBaked) { this._needDraw = !0; this._isBaked = this._cacheDirty = cc.renderer.childrenOrderDirty = !0; for (var a = this._node._children, c = 0, d = a.length; c < d; c++) a[c]._renderCmd._setCachedParent(this); this._bakeSprite || (this._bakeSprite = new cc.BakeSprite, this._bakeSprite.setAnchorPoint(0, 0)) } }; a.unbake = function() { if (this._isBaked) { cc.renderer.childrenOrderDirty = !0; this._isBaked = this._needDraw = !1; this._cacheDirty = !0; for (var a = this._node._children, c = 0, d = a.length; c < d; c++) a[c]._renderCmd._setCachedParent(null) } }; a.isBaked = function() { return this._isBaked }; a.rendering = function() { if (this._cacheDirty) { var a = this._node, c = a._children, d = this._bakeSprite; this.transform(this.getParentRenderCmd(), !0); var e = this._getBoundingBoxForBake(); e.width = 0 | e.width + 0.5; e.height = 0 | e.height + 0.5; var f = d.getCacheContext(), g = f.getContext(); d.resetCanvasSize(e.width, e.height); f.setOffset(0 - e.x, g.canvas.height - e.height + e.y); d.setPosition(e.x, e.y); a.sortAllChildren(); cc.renderer._turnToCacheMode(this.__instanceId); a = 0; for (e = c.length; a < e; a++) c[a].visit(this); cc.renderer._renderingToCacheCanvas(f, this.__instanceId); d.transform(); this._cacheDirty = !1 } }; a.visit = function(a) { if (this._isBaked) { var c = this._node, d = c._children.length; c._visible && 0 !== d && (this._syncStatus(a), cc.renderer.pushRenderCommand(this), this._bakeSprite.visit(this), this._dirtyFlag = 0) } else cc.Node.CanvasRenderCmd.prototype.visit.call(this, a) }; a._bakeForAddChild = function(a) { a._parent === this._node && this._isBaked && a._renderCmd._setCachedParent(this) }; a._getBoundingBoxForBake = function() { var a = null, c = this._node; if (!c._children || 0 === c._children.length) return cc.rect(0, 0, 10, 10); for (var d = c.getNodeToWorldTransform(), c = c._children, e = 0, f = c.length; e < f; e++) { var g = c[e]; g && g._visible && (a ? (g = g._getBoundingBoxToCurrentNode(d)) && (a = cc.rectUnion(a, g)) : a = g._getBoundingBoxToCurrentNode(d)) } return a } })(); (function() { cc.LayerColor.CanvasRenderCmd = function(a) { cc.Layer.CanvasRenderCmd.call(this, a); this._needDraw = !0; this._blendFuncStr = "source-over"; this._bakeRenderCmd = new cc.CustomRenderCmd(this, this._bakeRendering) }; var a = cc.LayerColor.CanvasRenderCmd.prototype = Object.create(cc.Layer.CanvasRenderCmd.prototype); a.constructor = cc.LayerColor.CanvasRenderCmd; a.unbake = function() { cc.Layer.CanvasRenderCmd.prototype.unbake.call(this); this._needDraw = !0 }; a.rendering = function(a, c, d) { a = a || cc._renderContext; var e = a.getContext(), f = this._node, g = this._displayedColor, h = this._displayedOpacity / 255, k = f._contentSize.width, f = f._contentSize.height; 0 !== h && (a.setCompositeOperation(this._blendFuncStr), a.setGlobalAlpha(h), a.setFillStyle("rgba(" + (0 | g.r) + "," + (0 | g.g) + "," + (0 | g.b) + ", 1)"), a.setTransform(this._worldTransform, c, d), e.fillRect(0, 0, k * c, -f * d), cc.g_NumberOfDraws++) }; a.updateBlendFunc = function(a) { this._blendFuncStr = cc.Node.CanvasRenderCmd._getCompositeOperationByBlendFunc(a) }; a._updateSquareVertices = a._updateSquareVerticesWidth = a._updateSquareVerticesHeight = function() {}; a._bakeRendering = function() { if (this._cacheDirty) { var a = this._node, c = this._bakeSprite, d = a._children, e = d.length; this.transform(this.getParentRenderCmd(), !0); var f = this._getBoundingBoxForBake(); f.width = 0 | f.width + 0.5; f.height = 0 | f.height + 0.5; var g = c.getCacheContext(), h = g.getContext(); c.resetCanvasSize(f.width, f.height); g.setOffset(0 - f.x, h.canvas.height - f.height + f.y); c.setPosition(f.x, f.y); cc.renderer._turnToCacheMode(this.__instanceId); if (0 < e) { a.sortAllChildren(); for (a = 0; a < e; a++) if (f = d[a], 0 > f._localZOrder) f._renderCmd.visit(this); else break; for (cc.renderer.pushRenderCommand(this); a < e; a++) d[a]._renderCmd.visit(this) } else cc.renderer.pushRenderCommand(this); cc.renderer._renderingToCacheCanvas(g, this.__instanceId); c.transform(); this._cacheDirty = !1 } }; a.visit = function(a) { this._isBaked ? this._node._visible && (this._syncStatus(a), cc.renderer.pushRenderCommand(this._bakeRenderCmd), this._bakeSprite._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty), this._bakeSprite.visit(this), this._dirtyFlag = 0) : cc.Node.CanvasRenderCmd.prototype.visit.call(this) }; a._getBoundingBoxForBake = function() { var a = this._node, c = cc.rect(0, 0, a._contentSize.width, a._contentSize.height), d = a.getNodeToWorldTransform(), c = cc.rectApplyAffineTransform(c, a.getNodeToWorldTransform()); if (!a._children || 0 === a._children.length) return c; for (var a = a._children, e = 0; e < a.length; e++) { var f = a[e]; f && f._visible && (f = f._getBoundingBoxToCurrentNode(d), c = cc.rectUnion(c, f)) } return c } })(); (function() { cc.LayerGradient.RenderCmd = { updateStatus: function() { var a = cc.Node._dirtyFlags, b = this._dirtyFlag, c = b & a.colorDirty, d = b & a.opacityDirty; c && this._updateDisplayColor(); d && this._updateDisplayOpacity(); b & a.transformDirty && this.transform(null, !0); (c || d || b & a.gradientDirty) && this._updateColor(); this._dirtyFlag = 0 } } })(); (function() { cc.LayerGradient.CanvasRenderCmd = function(a) { cc.LayerColor.CanvasRenderCmd.call(this, a); this._needDraw = !0; this._startPoint = cc.p(0, 0); this._endPoint = cc.p(0, 0); this._endStopStr = this._startStopStr = null }; var a = cc.LayerGradient.CanvasRenderCmd.prototype = Object.create(cc.LayerColor.CanvasRenderCmd.prototype); cc.inject(cc.LayerGradient.RenderCmd, a); a.constructor = cc.LayerGradient.CanvasRenderCmd; a.rendering = function(a, c, d) { a = a || cc._renderContext; var e = a.getContext(), f = this._node, g = this._displayedOpacity / 255; if (0 !== g) { var h = f._contentSize.width, k = f._contentSize.height; a.setCompositeOperation(this._blendFuncStr); a.setGlobalAlpha(g); g = e.createLinearGradient(this._startPoint.x * c, this._startPoint.y * d, this._endPoint.x * c, this._endPoint.y * d); if (f._colorStops) for (var m = 0; m < f._colorStops.length; m++) g.addColorStop(f._colorStops[m].p, this._colorStopsStr[m]); else g.addColorStop(0, this._startStopStr), g.addColorStop(1, this._endStopStr); a.setFillStyle(g); a.setTransform(this._worldTransform, c, d); e.fillRect(0, 0, h * c, -k * d); cc.g_NumberOfDraws++ } }; a._syncStatus = function(a) { var c = cc.Node._dirtyFlags, d = this._dirtyFlag, e = a ? a._node : null; e && e._cascadeColorEnabled && a._dirtyFlag & c.colorDirty && (d |= c.colorDirty); e && e._cascadeOpacityEnabled && a._dirtyFlag & c.opacityDirty && (d |= c.opacityDirty); a && a._dirtyFlag & c.transformDirty && (d |= c.transformDirty); var e = d & c.colorDirty, f = d & c.opacityDirty; this._dirtyFlag = d; e && this._syncDisplayColor(); f && this._syncDisplayOpacity(); d & c.transformDirty && this.transform(a); (e || f || d & c.gradientDirty) && this._updateColor() }; a._updateColor = function() { var a = this._node, c = a._contentSize, d = 0.5 * c.width, c = 0.5 * c.height; this._dirtyFlag ^= this._dirtyFlag & cc.Node._dirtyFlags.gradientDirty; var e = cc.pAngleSigned(cc.p(0, -1), a._alongVector), e = cc.pRotateByAngle(cc.p(0, -1), cc.p(0, 0), e), f = Math.min(Math.abs(1 / e.x), Math.abs(1 / e.y)); this._startPoint.x = d * -e.x * f + d; this._startPoint.y = c * e.y * f - c; this._endPoint.x = d * e.x * f + d; this._endPoint.y = c * -e.y * f - c; d = this._displayedColor; c = a._endColor; e = a._startOpacity / 255; f = a._endOpacity / 255; this._startStopStr = "rgba(" + Math.round(d.r) + "," + Math.round(d.g) + "," + Math.round(d.b) + "," + e.toFixed(4) + ")"; this._endStopStr = "rgba(" + Math.round(c.r) + "," + Math.round(c.g) + "," + Math.round(c.b) + "," + f.toFixed(4) + ")"; if (a._colorStops) for (this._endOpacity = this._startOpacity = 0, this._colorStopsStr = [], d = 0; d < a._colorStops.length; d++) c = a._colorStops[d].color, e = null == c.a ? 1 : c.a / 255, this._colorStopsStr.push("rgba(" + Math.round(c.r) + "," + Math.round(c.g) + "," + Math.round(c.b) + "," + e.toFixed(4) + ")") } })(); (function() { cc.Layer.WebGLRenderCmd = function(a) { cc.Node.WebGLRenderCmd.call(this, a) }; var a = cc.Layer.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); a.constructor = cc.Layer.WebGLRenderCmd; a.bake = function() {}; a.unbake = function() {}; a._bakeForAddChild = function() {} })(); (function() { cc.LayerColor.WebGLRenderCmd = function(a) { cc.Layer.WebGLRenderCmd.call(this, a); this._needDraw = !0; this._squareVerticesAB = new ArrayBuffer(32); this._squareColorsAB = new ArrayBuffer(16); a = this._squareVerticesAB; var c = this._squareColorsAB, d = cc.Vertex2F.BYTES_PER_ELEMENT, e = cc.Color.BYTES_PER_ELEMENT; this._squareVertices = [new cc.Vertex2F(0, 0, a, 0), new cc.Vertex2F(0, 0, a, d), new cc.Vertex2F(0, 0, a, 2 * d), new cc.Vertex2F(0, 0, a, 3 * d)]; this._squareColors = [cc.color(0, 0, 0, 255, c, 0), cc.color(0, 0, 0, 255, c, e), cc.color(0, 0, 0, 255, c, 2 * e), cc.color(0, 0, 0, 255, c, 3 * e)]; this._verticesFloat32Buffer = cc._renderContext.createBuffer(); this._colorsUint8Buffer = cc._renderContext.createBuffer() }; var a = cc.LayerColor.WebGLRenderCmd.prototype = Object.create(cc.Layer.WebGLRenderCmd.prototype); a.constructor = cc.LayerColor.WebGLRenderCmd; a.rendering = function(a) { a = a || cc._renderContext; var c = this._node; this._shaderProgram.use(); this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix); cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_COLOR); cc.glBlendFunc(c._blendFunc.src, c._blendFunc.dst); a.bindBuffer(a.ARRAY_BUFFER, this._verticesFloat32Buffer); a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, a.FLOAT, !1, 0, 0); a.bindBuffer(a.ARRAY_BUFFER, this._colorsUint8Buffer); a.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, a.UNSIGNED_BYTE, !0, 0, 0); a.drawArrays(a.TRIANGLE_STRIP, 0, this._squareVertices.length) }; a._updateSquareVertices = function(a, c) { var d = this._squareVertices; void 0 === c ? (d[1].x = a.width, d[2].y = a.height, d[3].x = a.width, d[3].y = a.height) : (d[1].x = a, d[2].y = c, d[3].x = a, d[3].y = c); this._bindLayerVerticesBufferData() }; a._updateSquareVerticesWidth = function(a) { var c = this._squareVertices; c[1].x = a; c[3].x = a; this._bindLayerVerticesBufferData() }; a._updateSquareVerticesHeight = function(a) { var c = this._squareVertices; c[2].y = a; c[3].y = a; this._bindLayerVerticesBufferData() }; a._updateColor = function() { for (var a = this._displayedColor, c = this._displayedOpacity, d = this._squareColors, e = 0; 4 > e; e++) d[e].r = a.r, d[e].g = a.g, d[e].b = a.b, d[e].a = c; this._bindLayerColorsBufferData() }; a._bindLayerVerticesBufferData = function() { var a = cc._renderContext; a.bindBuffer(a.ARRAY_BUFFER, this._verticesFloat32Buffer); a.bufferData(a.ARRAY_BUFFER, this._squareVerticesAB, a.STATIC_DRAW) }; a._bindLayerColorsBufferData = function() { var a = cc._renderContext; a.bindBuffer(a.ARRAY_BUFFER, this._colorsUint8Buffer); a.bufferData(a.ARRAY_BUFFER, this._squareColorsAB, a.STATIC_DRAW) }; a.updateBlendFunc = function(a) {} })(); (function() { cc.LayerGradient.WebGLRenderCmd = function(a) { cc.LayerColor.WebGLRenderCmd.call(this, a); this._needDraw = !0; this._clipRect = new cc.Rect; this._clippingRectDirty = !1 }; var a = cc.LayerGradient.WebGLRenderCmd.prototype = Object.create(cc.LayerColor.WebGLRenderCmd.prototype); cc.inject(cc.LayerGradient.RenderCmd, a); a.constructor = cc.LayerGradient.WebGLRenderCmd; a._syncStatus = function(a) { var c = cc.Node._dirtyFlags, d = this._dirtyFlag, e = a ? a._node : null; e && e._cascadeColorEnabled && a._dirtyFlag & c.colorDirty && (d |= c.colorDirty); e && e._cascadeOpacityEnabled && a._dirtyFlag & c.opacityDirty && (d |= c.opacityDirty); a && a._dirtyFlag & c.transformDirty && (d |= c.transformDirty); var e = d & c.colorDirty, f = d & c.opacityDirty; this._dirtyFlag = d; e && this._syncDisplayColor(); f && this._syncDisplayOpacity(); this.transform(a); (e || f || d & c.gradientDirty) && this._updateColor() }; a._updateColor = function() { this._dirtyFlag ^= this._dirtyFlag & cc.Node._dirtyFlags.gradientDirty; var a = this._node, c = a._colorStops; if (c && !(2 > c.length)) { this._clippingRectDirty = !0; var d = c.length, e = 2 * d, f, g = a._contentSize; this._squareVerticesAB = new ArrayBuffer(8 * e); this._squareColorsAB = new ArrayBuffer(4 * e); var h = this._squareVertices, k = this._squareColors; h.length = 0; k.length = 0; var m = this._squareVerticesAB, n = this._squareColorsAB, p = cc.Vertex2F.BYTES_PER_ELEMENT, t = cc.Color.BYTES_PER_ELEMENT; for (f = 0; f < e; f++) h.push(new cc.Vertex2F(0, 0, m, p * f)), k.push(cc.color(0, 0, 0, 255, n, t * f)); n = Math.PI + cc.pAngleSigned(cc.p(0, -1), a._alongVector); a = cc.p(g.width / 2, g.height / 2); f = Math.round(cc.radiansToDegrees(n)); e = cc.affineTransformMake(1, 0, 0, 1, a.x, a.y); e = cc.affineTransformRotate(e, n); 90 > f ? (p = cc.p(-a.x, a.y), f = cc.p(a.x, a.y)) : 180 > f ? (p = cc.p(a.x, a.y), f = cc.p(a.x, -a.y)) : 270 > f ? (p = cc.p(a.x, -a.y), f = cc.p(-a.x, -a.y)) : (p = cc.p(-a.x, -a.y), f = cc.p(-a.x, a.y)); m = Math.sin(n); n = Math.cos(n); p = Math.abs((p.x * n - p.y * m) / a.x); f = Math.abs((f.x * m + f.y * n) / a.y); e = cc.affineTransformScale(e, p, f); for (f = 0; f < d; f++) m = c[f].p * g.height, n = cc.pointApplyAffineTransform(-a.x, m - a.y, e), h[2 * f].x = n.x, h[2 * f].y = n.y, m = cc.pointApplyAffineTransform(g.width - a.x, m - a.y, e), h[2 * f + 1].x = m.x, h[2 * f + 1].y = m.y; g = this._displayedOpacity / 255; for (f = 0; f < d; f++) h = c[f].color, a = k[2 * f], e = k[2 * f + 1], a.r = h.r, a.g = h.g, a.b = h.b, a.a = h.a * g, e.r = h.r, e.g = h.g, e.b = h.b, e.a = h.a * g; this._bindLayerVerticesBufferData(); this._bindLayerColorsBufferData() } }; a.rendering = function(a) { a = a || cc._renderContext; var c = this._node, d = this._getClippingRect(); a.enable(a.SCISSOR_TEST); cc.view.setScissorInPoints(d.x, d.y, d.width, d.height); this._shaderProgram.use(); this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix); cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_COLOR); cc.glBlendFunc(c._blendFunc.src, c._blendFunc.dst); a.bindBuffer(a.ARRAY_BUFFER, this._verticesFloat32Buffer); a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, a.FLOAT, !1, 0, 0); a.bindBuffer(a.ARRAY_BUFFER, this._colorsUint8Buffer); a.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, a.UNSIGNED_BYTE, !0, 0, 0); a.drawArrays(a.TRIANGLE_STRIP, 0, this._squareVertices.length); a.disable(a.SCISSOR_TEST) }; a._getClippingRect = function() { if (this._clippingRectDirty) { var a = this._node, c = cc.rect(0, 0, a._contentSize.width, a._contentSize.height), a = a.getNodeToWorldTransform(); this._clipRect = cc._rectApplyAffineTransformIn(c, a) } return this._clipRect } })(); cc._tmp.PrototypeSprite = function() { var a = cc.Sprite.prototype; cc.defineGetterSetter(a, "opacityModifyRGB", a.isOpacityModifyRGB, a.setOpacityModifyRGB); cc.defineGetterSetter(a, "opacity", a.getOpacity, a.setOpacity); cc.defineGetterSetter(a, "color", a.getColor, a.setColor); cc.defineGetterSetter(a, "flippedX", a.isFlippedX, a.setFlippedX); cc.defineGetterSetter(a, "flippedY", a.isFlippedY, a.setFlippedY); cc.defineGetterSetter(a, "offsetX", a._getOffsetX); cc.defineGetterSetter(a, "offsetY", a._getOffsetY); cc.defineGetterSetter(a, "texture", a.getTexture, a.setTexture); cc.defineGetterSetter(a, "textureRectRotated", a.isTextureRectRotated); cc.defineGetterSetter(a, "batchNode", a.getBatchNode, a.setBatchNode); cc.defineGetterSetter(a, "quad", a.getQuad) }; cc.Sprite = cc.Node.extend({ dirty: !1, atlasIndex: 0, textureAtlas: null, _batchNode: null, _recursiveDirty: null, _hasChildren: null, _shouldBeHidden: !1, _transformToBatch: null, _blendFunc: null, _texture: null, _rect: null, _rectRotated: !1, _offsetPosition: null, _unflippedOffsetPositionFromCenter: null, _opacityModifyRGB: !1, _flippedX: !1, _flippedY: !1, _textureLoaded: !1, _className: "Sprite", ctor: function(a, b, c) { cc.Node.prototype.ctor.call(this); this._shouldBeHidden = !1; this._offsetPosition = cc.p(0, 0); this._unflippedOffsetPositionFromCenter = cc.p(0, 0); this._blendFunc = { src: cc.BLEND_SRC, dst: cc.BLEND_DST }; this._rect = cc.rect(0, 0, 0, 0); this._softInit(a, b, c) }, textureLoaded: function() { return this._textureLoaded }, addLoadedEventListener: function(a, b) { this.addEventListener("load", a, b) }, isDirty: function() { return this.dirty }, setDirty: function(a) { this.dirty = a }, isTextureRectRotated: function() { return this._rectRotated }, getAtlasIndex: function() { return this.atlasIndex }, setAtlasIndex: function(a) { this.atlasIndex = a }, getTextureRect: function() { return cc.rect(this._rect) }, getTextureAtlas: function() { return this.textureAtlas }, setTextureAtlas: function(a) { this.textureAtlas = a }, getOffsetPosition: function() { return cc.p(this._offsetPosition) }, _getOffsetX: function() { return this._offsetPosition.x }, _getOffsetY: function() { return this._offsetPosition.y }, getBlendFunc: function() { return this._blendFunc }, initWithSpriteFrame: function(a) { cc.assert(a, cc._LogInfos.Sprite_initWithSpriteFrame); a.textureLoaded() || (this._textureLoaded = !1, a.addEventListener("load", this._renderCmd._spriteFrameLoadedCallback, this)); var b = cc._renderType === cc._RENDER_TYPE_CANVAS ? !1 : a._rotated, b = this.initWithTexture(a.getTexture(), a.getRect(), b); this.setSpriteFrame(a); return b }, initWithSpriteFrameName: function(a) { cc.assert(a, cc._LogInfos.Sprite_initWithSpriteFrameName); var b = cc.spriteFrameCache.getSpriteFrame(a); cc.assert(b, a + cc._LogInfos.Sprite_initWithSpriteFrameName1); return this.initWithSpriteFrame(b) }, useBatchNode: function(a) { this.textureAtlas = a.getTextureAtlas(); this._batchNode = a }, setVertexRect: function(a) { var b = this._rect; b.x = a.x; b.y = a.y; b.width = a.width; b.height = a.height }, sortAllChildren: function() { if (this._reorderChildDirty) { var a = this._children, b = a.length, c, d, e; for (c = 1; c < b; c++) { e = a[c]; for (d = c - 1; 0 <= d;) { if (e._localZOrder < a[d]._localZOrder) a[d + 1] = a[d]; else if (e._localZOrder === a[d]._localZOrder && e.arrivalOrder < a[d].arrivalOrder) a[d + 1] = a[d]; else break; d-- } a[d + 1] = e } this._batchNode && this._arrayMakeObjectsPerformSelector(a, cc.Node._stateCallbackType.sortAllChildren); this._reorderChildDirty = !1 } }, reorderChild: function(a, b) { cc.assert(a, cc._LogInfos.Sprite_reorderChild_2); - 1 === this._children.indexOf(a) ? cc.log(cc._LogInfos.Sprite_reorderChild) : b !== a.zIndex && (this._batchNode && !this._reorderChildDirty && (this._setReorderChildDirtyRecursively(), this._batchNode.reorderBatch(!0)), cc.Node.prototype.reorderChild.call(this, a, b)) }, removeChild: function(a, b) { this._batchNode && this._batchNode.removeSpriteFromAtlas(a); cc.Node.prototype.removeChild.call(this, a, b) }, setVisible: function(a) { cc.Node.prototype.setVisible.call(this, a); this._renderCmd.setDirtyRecursively(!0) }, removeAllChildren: function(a) { var b = this._children, c = this._batchNode; if (c && null != b) for (var d = 0, e = b.length; d < e; d++) c.removeSpriteFromAtlas(b[d]); cc.Node.prototype.removeAllChildren.call(this, a); this._hasChildren = !1 }, ignoreAnchorPointForPosition: function(a) { this._batchNode ? cc.log(cc._LogInfos.Sprite_ignoreAnchorPointForPosition) : cc.Node.prototype.ignoreAnchorPointForPosition.call(this, a) }, setFlippedX: function(a) { this._flippedX !== a && (this._flippedX = a, this.setTextureRect(this._rect, this._rectRotated, this._contentSize), this.setNodeDirty(!0)) }, setFlippedY: function(a) { this._flippedY !== a && (this._flippedY = a, this.setTextureRect(this._rect, this._rectRotated, this._contentSize), this.setNodeDirty(!0)) }, isFlippedX: function() { return this._flippedX }, isFlippedY: function() { return this._flippedY }, setOpacityModifyRGB: function(a) { this._opacityModifyRGB !== a && (this._opacityModifyRGB = a, this._renderCmd._setColorDirty()) }, isOpacityModifyRGB: function() { return this._opacityModifyRGB }, setDisplayFrameWithAnimationName: function(a, b) { cc.assert(a, cc._LogInfos.Sprite_setDisplayFrameWithAnimationName_3); var c = cc.animationCache.getAnimation(a); c ? (c = c.getFrames()[b]) ? this.setSpriteFrame(c.getSpriteFrame()) : cc.log(cc._LogInfos.Sprite_setDisplayFrameWithAnimationName_2) : cc.log(cc._LogInfos.Sprite_setDisplayFrameWithAnimationName) }, getBatchNode: function() { return this._batchNode }, _setReorderChildDirtyRecursively: function() { if (!this._reorderChildDirty) { this._reorderChildDirty = !0; for (var a = this._parent; a && a !== this._batchNode;) a._setReorderChildDirtyRecursively(), a = a.parent } }, getTexture: function() { return this._texture }, _softInit: function(a, b, c) { if (void 0 === a) cc.Sprite.prototype.init.call(this); else if (cc.isString(a)) "#" === a[0] ? (a = a.substr(1, a.length - 1), a = cc.spriteFrameCache.getSpriteFrame(a), this.initWithSpriteFrame(a)) : cc.Sprite.prototype.init.call(this, a, b); else if (cc.isObject(a)) if (a instanceof cc.Texture2D) this.initWithTexture(a, b, c); else if (a instanceof cc.SpriteFrame) this.initWithSpriteFrame(a); else if (a instanceof HTMLImageElement || a instanceof HTMLCanvasElement) b = new cc.Texture2D, b.initWithElement(a), b.handleLoadedTexture(), this.initWithTexture(b) }, getQuad: function() { return this._renderCmd.getQuad() }, setBlendFunc: function(a, b) { var c = this._blendFunc; void 0 === b ? (c.src = a.src, c.dst = a.dst) : (c.src = a, c.dst = b); this._renderCmd.updateBlendFunc(c) }, init: function() { if (0 < arguments.length) return this.initWithFile(arguments[0], arguments[1]); cc.Node.prototype.init.call(this); this.dirty = this._recursiveDirty = !1; this._blendFunc.src = cc.BLEND_SRC; this._blendFunc.dst = cc.BLEND_DST; this.texture = null; this._flippedX = this._flippedY = !1; this.anchorY = this.anchorX = 0.5; this._offsetPosition.x = 0; this._offsetPosition.y = 0; this._hasChildren = !1; this._renderCmd._init(); this.setTextureRect(cc.rect(0, 0, 0, 0), !1, cc.size(0, 0)); return !0 }, initWithFile: function(a, b) { cc.assert(a, cc._LogInfos.Sprite_initWithFile); var c = cc.textureCache.getTextureForKey(a); if (c) { if (!b) { var d = c.getContentSize(); b = cc.rect(0, 0, d.width, d.height) } return this.initWithTexture(c, b) } c = cc.textureCache.addImage(a); return this.initWithTexture(c, b || cc.rect(0, 0, c._contentSize.width, c._contentSize.height)) }, initWithTexture: function(a, b, c, d) { cc.assert(0 !== arguments.length, cc._LogInfos.CCSpriteBatchNode_initWithTexture); c = c || !1; a = this._renderCmd._handleTextureForRotatedTexture(a, b, c, d); if (!cc.Node.prototype.init.call(this)) return !1; this._batchNode = null; this.dirty = this._recursiveDirty = !1; this._opacityModifyRGB = !0; this._blendFunc.src = cc.BLEND_SRC; this._blendFunc.dst = cc.BLEND_DST; this._flippedX = this._flippedY = !1; this.setAnchorPoint(0.5, 0.5); this._offsetPosition.x = 0; this._offsetPosition.y = 0; this._hasChildren = !1; this._renderCmd._init(); var e = a.isLoaded(); this._textureLoaded = e; if (!e) return this._rectRotated = c, b && (this._rect.x = b.x, this._rect.y = b.y, this._rect.width = b.width, this._rect.height = b.height), this.texture && this.texture.removeEventListener("load", this), a.addEventListener("load", this._renderCmd._textureLoadedCallback, this), this.texture = a, !0; b || (b = cc.rect(0, 0, a.width, a.height)); this._renderCmd._checkTextureBoundary(a, b, c); this.texture = a; this.setTextureRect(b, c); this.setBatchNode(null); return !0 }, setTextureRect: function(a, b, c, d) { this._rectRotated = b || !1; this.setContentSize(c || a); this.setVertexRect(a); this._renderCmd._setTextureCoords(a, d); a = this._unflippedOffsetPositionFromCenter.x; b = this._unflippedOffsetPositionFromCenter.y; this._flippedX && (a = -a); this._flippedY && (b = -b); c = this._rect; this._offsetPosition.x = a + (this._contentSize.width - c.width) / 2; this._offsetPosition.y = b + (this._contentSize.height - c.height) / 2; this._batchNode ? this.dirty = !0 : this._renderCmd._resetForBatchNode() }, updateTransform: function() { this._renderCmd.updateTransform() }, addChild: function(a, b, c) { cc.assert(a, cc._LogInfos.CCSpriteBatchNode_addChild_2); null == b && (b = a._localZOrder); null == c && (c = a.tag); this._renderCmd._setBatchNodeForAddChild(a) && (cc.Node.prototype.addChild.call(this, a, b, c), this._hasChildren = !0) }, setSpriteFrame: function(a) { var b = this; cc.isString(a) && (a = cc.spriteFrameCache.getSpriteFrame(a), cc.assert(a, cc._LogInfos.Sprite_setSpriteFrame)); this.setNodeDirty(!0); var c = a.getOffset(); b._unflippedOffsetPositionFromCenter.x = c.x; b._unflippedOffsetPositionFromCenter.y = c.y; c = a.getTexture(); a.textureLoaded() ? (c !== b._texture && (b.texture = c), b.setTextureRect(a.getRect(), a.isRotated(), a.getOriginalSize())) : (b._textureLoaded = !1, a.addEventListener("load", function(a) { b._textureLoaded = !0; var c = a.getTexture(); c !== b._texture && (b.texture = c); b.setTextureRect(a.getRect(), a.isRotated(), a.getOriginalSize()); b.dispatchEvent("load"); b.setColor(b.color) }, b)); this._renderCmd._updateForSetSpriteFrame(c) }, setDisplayFrame: function(a) { cc.log(cc._LogInfos.Sprite_setDisplayFrame); this.setSpriteFrame(a) }, isFrameDisplayed: function(a) { return this._renderCmd.isFrameDisplayed(a) }, displayFrame: function() { return this.getSpriteFrame() }, getSpriteFrame: function() { return new cc.SpriteFrame(this._texture, cc.rectPointsToPixels(this._rect), this._rectRotated, cc.pointPointsToPixels(this._unflippedOffsetPositionFromCenter), cc.sizePointsToPixels(this._contentSize)) }, setBatchNode: function(a) { (this._batchNode = a) ? (this._transformToBatch = cc.affineTransformIdentity(), this.textureAtlas = this._batchNode.getTextureAtlas()) : (this.atlasIndex = cc.Sprite.INDEX_NOT_INITIALIZED, this.textureAtlas = null, this.dirty = this._recursiveDirty = !1, this._renderCmd._resetForBatchNode()) }, setTexture: function(a) { if (!a) return this._renderCmd._setTexture(null); cc.isString(a) ? (a = cc.textureCache.addImage(a), a._textureLoaded ? (this._renderCmd._setTexture(a), this._changeRectWithTexture(a.getContentSize()), this.setColor(this._realColor), this._textureLoaded = !0) : a.addEventListener("load", function() { this._renderCmd._setTexture(a); this._changeRectWithTexture(a.getContentSize()); this.setColor(this._realColor); this._textureLoaded = !0 }, this)) : (cc.assert(a instanceof cc.Texture2D, cc._LogInfos.Sprite_setTexture_2), this._changeRectWithTexture(a.getContentSize()), this._renderCmd._setTexture(a)) }, _changeRectWithTexture: function(a) { if (a && (a.width || a.height)) { var b = this.getTextureRect(); b.height || b.width || (a.x = a.x || 0, a.y = a.y || 0, a.width = a.width || 0, a.height = a.height || 0, this.setTextureRect(a)) } }, _createRenderCmd: function() { return cc._renderType === cc._RENDER_TYPE_CANVAS ? new cc.Sprite.CanvasRenderCmd(this) : new cc.Sprite.WebGLRenderCmd(this) } }); cc.Sprite.create = function(a, b, c) { return new cc.Sprite(a, b, c) }; cc.Sprite.createWithTexture = cc.Sprite.create; cc.Sprite.createWithSpriteFrameName = cc.Sprite.create; cc.Sprite.createWithSpriteFrame = cc.Sprite.create; cc.Sprite.INDEX_NOT_INITIALIZED = -1; cc.EventHelper.prototype.apply(cc.Sprite.prototype); cc.assert(cc.isFunction(cc._tmp.PrototypeSprite), cc._LogInfos.MissingFile, "SpritesPropertyDefine.js"); cc._tmp.PrototypeSprite(); delete cc._tmp.PrototypeSprite; (function() { cc.Sprite.CanvasRenderCmd = function(a) { cc.Node.CanvasRenderCmd.call(this, a); this._needDraw = !0; this._textureCoord = { renderX: 0, renderY: 0, x: 0, y: 0, width: 0, height: 0, validRect: !1 }; this._blendFuncStr = "source-over"; this._colorized = !1; this._originalTexture = null }; var a = cc.Sprite.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); a.constructor = cc.Sprite.CanvasRenderCmd; a._init = function() {}; a.setDirtyRecursively = function(a) {}; a._resetForBatchNode = function() {}; a._setTexture = function(a) { var c = this._node; c._texture !== a && (a ? (a.getHtmlElementObj() instanceof HTMLImageElement && (this._originalTexture = a), c._textureLoaded = a._textureLoaded) : c._textureLoaded = !1, c._texture = a) }; a._setColorDirty = function() { this.setDirtyFlag(cc.Node._dirtyFlags.colorDirty | cc.Node._dirtyFlags.opacityDirty) }; a.isFrameDisplayed = function(a) { var c = this._node; return a.getTexture() !== c._texture ? !1 : cc.rectEqualToRect(a.getRect(), c._rect) }; a.updateBlendFunc = function(a) { this._blendFuncStr = cc.Node.CanvasRenderCmd._getCompositeOperationByBlendFunc(a) }; a._setBatchNodeForAddChild = function(a) { return !0 }; a._handleTextureForRotatedTexture = function(a, c, d, e) { d && a.isLoaded() && (a = a.getHtmlElementObj(), a = cc.Sprite.CanvasRenderCmd._cutRotateImageToCanvas(a, c, e), e = new cc.Texture2D, e.initWithElement(a), e.handleLoadedTexture(), a = e, c.x = c.y = 0, this._node._rect = cc.rect(0, 0, c.width, c.height)); return a }; a._checkTextureBoundary = function(a, c, d) { a && a.url && (d = c.y + c.height, c.x + c.width > a.width && cc.error(cc._LogInfos.RectWidth, a.url), d > a.height && cc.error(cc._LogInfos.RectHeight, a.url)); this._node._originalTexture = a }; a.rendering = function(a, c, d) { var e = this._node, f = this._textureCoord, g = this._displayedOpacity / 255; if ((!e._texture || 0 !== f.width && 0 !== f.height && e._texture._textureLoaded) && 0 !== g) { a = a || cc._renderContext; var h = a.getContext(), k = e._offsetPosition.x, m = e._rect.height, n = e._rect.width, p = -e._offsetPosition.y - m; a.setTransform(this._worldTransform, c, d); a.setCompositeOperation(this._blendFuncStr); a.setGlobalAlpha(g); (e._flippedX || e._flippedY) && a.save(); e._flippedX && (k = -k - n, h.scale(-1, 1)); e._flippedY && (p = e._offsetPosition.y, h.scale(1, -1)); e._texture ? (g = e._texture._htmlElementObj, "" !== e._texture._pattern ? (a.setFillStyle(h.createPattern(g, e._texture._pattern)), h.fillRect(k * c, p * d, n * c, m * d)) : this._colorized ? h.drawImage(g, 0, 0, f.width, f.height, k * c, p * d, n * c, m * d) : h.drawImage(g, f.renderX, f.renderY, f.width, f.height, k * c, p * d, n * c, m * d)) : (g = e._contentSize, f.validRect && (f = this._displayedColor, a.setFillStyle("rgba(" + f.r + "," + f.g + "," + f.b + ",1)"), h.fillRect(k * c, p * d, g.width * c, g.height * d))); (e._flippedX || e._flippedY) && a.restore(); cc.g_NumberOfDraws++ } }; a._updateColor = cc.sys._supportCanvasNewBlendModes ? function() { var a = this._node, c = this._displayedColor; if (255 === c.r && 255 === c.g && 255 === c.b) this._colorized && (this._colorized = !1, a.texture = this._originalTexture); else { var d, e = a._texture, f = this._textureCoord; e && f.validRect && this._originalTexture && (d = e.getHtmlElementObj()) && (this._colorized = !0, d instanceof HTMLCanvasElement && !this._rectRotated && !this._newTextureWhenChangeColor && this._originalTexture._htmlElementObj !== d ? cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(this._originalTexture._htmlElementObj, c, f, d) : (d = cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(this._originalTexture._htmlElementObj, c, f), e = new cc.Texture2D, e.initWithElement(d), e.handleLoadedTexture(), a.texture = e)) } } : function() { var a = this._node, c = this._displayedColor; if (255 === c.r && 255 === c.g && 255 === c.b) this._colorized && (this._colorized = !1, a.texture = this._originalTexture); else { var d, e = a._texture, f = this._textureCoord; e && f.validRect && this._originalTexture && (d = e.getHtmlElementObj()) && (e = cc.textureCache.getTextureColors(this._originalTexture.getHtmlElementObj())) && (this._colorized = !0, d instanceof HTMLCanvasElement && !this._rectRotated && !this._newTextureWhenChangeColor ? cc.Sprite.CanvasRenderCmd._generateTintImage(d, e, c, f, d) : (d = cc.Sprite.CanvasRenderCmd._generateTintImage(d, e, c, f), e = new cc.Texture2D, e.initWithElement(d), e.handleLoadedTexture(), a.texture = e)) } }; a.getQuad = function() { return null }; a._updateForSetSpriteFrame = function(a, c) { var d = this._node; d._rectRotated && (d._originalTexture = a); this._colorized = !1; this._textureCoord.renderX = this._textureCoord.x; this._textureCoord.renderY = this._textureCoord.y; c && (d = d.getColor(), 255 === d.r && 255 === d.g && 255 === d.b || this._updateColor()) }; a.updateTransform = function() { var a = this._node; if (a.dirty) { var c = a._parent; !a._visible || c && c !== a._batchNode && c._shouldBeHidden ? a._shouldBeHidden = !0 : (a._shouldBeHidden = !1, a._transformToBatch = c && c !== a._batchNode ? cc.affineTransformConcat(this.getNodeToParentTransform(), c._transformToBatch) : this.getNodeToParentTransform()); a._recursiveDirty = !1; a.dirty = !1 } a._hasChildren && a._arrayMakeObjectsPerformSelector(a._children, cc.Node._stateCallbackType.updateTransform) }; a._updateDisplayColor = function(a) { cc.Node.CanvasRenderCmd.prototype._updateDisplayColor.call(this, a) }; a._spriteFrameLoadedCallback = function(a) { this.setTextureRect(a.getRect(), a.isRotated(), a.getOriginalSize()); this._renderCmd._updateColor(); this.dispatchEvent("load") }; a._textureLoadedCallback = function(a) { if (!this._textureLoaded) { this._textureLoaded = !0; var c = this._rect, d = this._renderCmd; c ? cc._rectEqualToZero(c) && (c.width = a.width, c.height = a.height) : c = cc.rect(0, 0, a.width, a.height); this.texture = d._originalTexture = a; this.setTextureRect(c, this._rectRotated); a = d._displayedColor; 255 === a.r && 255 === a.g && 255 === a.b || d._updateColor(); this.setBatchNode(this._batchNode); this.dispatchEvent("load") } }; a._setTextureCoords = function(a, c) { void 0 === c && (c = !0); var d = this._textureCoord, e = c ? cc.contentScaleFactor() : 1; d.renderX = d.x = 0 | a.x * e; d.renderY = d.y = 0 | a.y * e; d.width = 0 | a.width * e; d.height = 0 | a.height * e; d.validRect = !(0 === d.width || 0 === d.height || 0 > d.x || 0 > d.y); this._colorized && (this._node._texture = this._originalTexture, this._colorized = !1, this._updateColor()) }; cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply = function(a, c, d, e) { e = e || cc.newElement("canvas"); d = d || cc.rect(0, 0, a.width, a.height); var f = e.getContext("2d"); e.width !== d.width || e.height !== d.height ? (e.width = d.width, e.height = d.height) : f.globalCompositeOperation = "source-over"; f.fillStyle = "rgb(" + (0 | c.r) + "," + (0 | c.g) + "," + (0 | c.b) + ")"; f.fillRect(0, 0, d.width, d.height); f.globalCompositeOperation = "multiply"; f.drawImage(a, d.x, d.y, d.width, d.height, 0, 0, d.width, d.height); f.globalCompositeOperation = "destination-atop"; f.drawImage(a, d.x, d.y, d.width, d.height, 0, 0, d.width, d.height); return e }; cc.Sprite.CanvasRenderCmd._generateTintImage = function(a, c, d, e, f) { e || (e = cc.rect(0, 0, a.width, a.height)); a = d.r / 255; var g = d.g / 255; d = d.b / 255; var h = Math.min(e.width, c[0].width), k = Math.min(e.height, c[0].height), m; f ? (m = f.getContext("2d"), m.clearRect(0, 0, h, k)) : (f = cc.newElement("canvas"), f.width = h, f.height = k, m = f.getContext("2d")); m.save(); m.globalCompositeOperation = "lighter"; var n = m.globalAlpha; 0 < a && (m.globalAlpha = a * n, m.drawImage(c[0], e.x, e.y, h, k, 0, 0, h, k)); 0 < g && (m.globalAlpha = g * n, m.drawImage(c[1], e.x, e.y, h, k, 0, 0, h, k)); 0 < d && (m.globalAlpha = d * n, m.drawImage(c[2], e.x, e.y, h, k, 0, 0, h, k)); 1 > a + g + d && (m.globalAlpha = n, m.drawImage(c[3], e.x, e.y, h, k, 0, 0, h, k)); m.restore(); return f }; cc.Sprite.CanvasRenderCmd._generateTextureCacheForColor = function(a) { function c() { var c = cc.Sprite.CanvasRenderCmd._generateTextureCacheForColor, e = a.width, h = a.height; d[0].width = e; d[0].height = h; d[1].width = e; d[1].height = h; d[2].width = e; d[2].height = h; d[3].width = e; d[3].height = h; c.canvas.width = e; c.canvas.height = h; var k = c.canvas.getContext("2d"); k.drawImage(a, 0, 0); c.tempCanvas.width = e; c.tempCanvas.height = h; for (var k = k.getImageData(0, 0, e, h).data, m = 0; 4 > m; m++) { var n = d[m].getContext("2d"); n.getImageData(0, 0, e, h).data; c.tempCtx.drawImage(a, 0, 0); for (var p = c.tempCtx.getImageData(0, 0, e, h), t = p.data, r = 0; r < k.length; r += 4) t[r] = 0 === m ? k[r] : 0, t[r + 1] = 1 === m ? k[r + 1] : 0, t[r + 2] = 2 === m ? k[r + 2] : 0, t[r + 3] = k[r + 3]; n.putImageData(p, 0, 0) } a.onload = null } if (a.channelCache) return a.channelCache; var d = [cc.newElement("canvas"), cc.newElement("canvas"), cc.newElement("canvas"), cc.newElement("canvas")]; try { c() } catch (e) { a.onload = c } return a.channelCache = d }; cc.Sprite.CanvasRenderCmd._generateTextureCacheForColor.canvas = cc.newElement("canvas"); cc.Sprite.CanvasRenderCmd._generateTextureCacheForColor.tempCanvas = cc.newElement("canvas"); cc.Sprite.CanvasRenderCmd._generateTextureCacheForColor.tempCtx = cc.Sprite.CanvasRenderCmd._generateTextureCacheForColor.tempCanvas.getContext("2d"); cc.Sprite.CanvasRenderCmd._cutRotateImageToCanvas = function(a, c, d) { if (!a) return null; if (!c) return a; d = null == d ? !0 : d; var e = cc.newElement("canvas"); e.width = c.width; e.height = c.height; var f = e.getContext("2d"); f.translate(e.width / 2, e.height / 2); d ? f.rotate(-1.5707963267948966) : f.rotate(1.5707963267948966); f.drawImage(a, c.x, c.y, c.height, c.width, -c.height / 2, -c.width / 2, c.height, c.width); return e } })(); (function() { cc.Sprite.WebGLRenderCmd = function(a) { cc.Node.WebGLRenderCmd.call(this, a); this._needDraw = !0; this._quad = new cc.V3F_C4B_T2F_Quad; this._quadWebBuffer = cc._renderContext.createBuffer(); this._quadDirty = !0; this._recursiveDirty = this._dirty = !1 }; var a = cc.Sprite.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); a.constructor = cc.Sprite.WebGLRenderCmd; a.updateBlendFunc = function(a) {}; a.setDirtyFlag = function(a) { cc.Node.WebGLRenderCmd.prototype.setDirtyFlag.call(this, a); this._dirty = !0 }; a.setDirtyRecursively = function(a) { this._dirty = this._recursiveDirty = a; for (var c = this._node._children, d, e = c ? c.length : 0, f = 0; f < e; f++) d = c[f], d instanceof cc.Sprite && d._renderCmd.setDirtyRecursively(a) }; a._setBatchNodeForAddChild = function(a) { var c = this._node; if (c._batchNode) { if (!(a instanceof cc.Sprite)) return cc.log(cc._LogInfos.Sprite_addChild), !1; a.texture._webTextureObj !== c.textureAtlas.texture._webTextureObj && cc.log(cc._LogInfos.Sprite_addChild_2); c._batchNode.appendChild(a); c._reorderChildDirty || c._setReorderChildDirtyRecursively() } return !0 }; a._handleTextureForRotatedTexture = function(a) { return a }; a.isFrameDisplayed = function(a) { var c = this._node; return cc.rectEqualToRect(a.getRect(), c._rect) && a.getTexture().getName() === c._texture.getName() && cc.pointEqualToPoint(a.getOffset(), c._unflippedOffsetPositionFromCenter) }; a._init = function() { var a = { r: 255, g: 255, b: 255, a: 255 }, c = this._quad; c.bl.colors = a; c.br.colors = a; c.tl.colors = a; c.tr.colors = a; this._quadDirty = !0 }; a._resetForBatchNode = function() { var a = this._node, c = a._offsetPosition.x, d = a._offsetPosition.y, e = c + a._rect.width, a = d + a._rect.height, f = this._quad; f.bl.vertices = { x: c, y: d, z: 0 }; f.br.vertices = { x: e, y: d, z: 0 }; f.tl.vertices = { x: c, y: a, z: 0 }; f.tr.vertices = { x: e, y: a, z: 0 }; this._quadDirty = !0 }; a.getQuad = function() { return this._quad }; a._updateForSetSpriteFrame = function() {}; a._spriteFrameLoadedCallback = function(a) { this.setTextureRect(a.getRect(), a.isRotated(), a.getOriginalSize()); this.dispatchEvent("load") }; a._textureLoadedCallback = function(a) { var c = this._renderCmd; if (!this._textureLoaded) { this._textureLoaded = !0; var d = this._rect; d ? cc._rectEqualToZero(d) && (d.width = a.width, d.height = a.height) : d = cc.rect(0, 0, a.width, a.height); this.texture = a; this.setTextureRect(d, this._rectRotated); this.setBatchNode(this._batchNode); c._quadDirty = !0; this.dispatchEvent("load") } }; a._setTextureCoords = function(a, c) { void 0 === c && (c = !0); c && (a = cc.rectPointsToPixels(a)); var d = this._node, e = d._batchNode ? d.textureAtlas.texture : d._texture; if (e) { var f = e.pixelsWidth, g = e.pixelsHeight, h, k, m = this._quad; d._rectRotated ? (cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL ? (e = (2 * a.x + 1) / (2 * f), f = e + (2 * a.height - 2) / (2 * f), h = (2 * a.y + 1) / (2 * g), g = h + (2 * a.width - 2) / (2 * g)) : (e = a.x / f, f = (a.x + a.height) / f, h = a.y / g, g = (a.y + a.width) / g), d._flippedX && (k = h, h = g, g = k), d._flippedY && (k = e, e = f, f = k), m.bl.texCoords.u = e, m.bl.texCoords.v = h, m.br.texCoords.u = e, m.br.texCoords.v = g, m.tl.texCoords.u = f, m.tl.texCoords.v = h, m.tr.texCoords.u = f, m.tr.texCoords.v = g) : (cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL ? (e = (2 * a.x + 1) / (2 * f), f = e + (2 * a.width - 2) / (2 * f), h = (2 * a.y + 1) / (2 * g), g = h + (2 * a.height - 2) / (2 * g)) : (e = a.x / f, f = (a.x + a.width) / f, h = a.y / g, g = (a.y + a.height) / g), d._flippedX && (k = e, e = f, f = k), d._flippedY && (k = h, h = g, g = k), m.bl.texCoords.u = e, m.bl.texCoords.v = g, m.br.texCoords.u = f, m.br.texCoords.v = g, m.tl.texCoords.u = e, m.tl.texCoords.v = h, m.tr.texCoords.u = f, m.tr.texCoords.v = h); this._quadDirty = !0 } }; a.transform = function(a, c) { cc.Node.WebGLRenderCmd.prototype.transform.call(this, a, c); this._dirty = !0 }; a._setColorDirty = function() {}; a._updateColor = function() { var a = this._displayedColor, c = this._displayedOpacity, d = this._node, a = { r: a.r, g: a.g, b: a.b, a: c }; d._opacityModifyRGB && (a.r *= c / 255, a.g *= c / 255, a.b *= c / 255); c = this._quad; c.bl.colors = a; c.br.colors = a; c.tl.colors = a; c.tr.colors = a; d._batchNode && (d.atlasIndex !== cc.Sprite.INDEX_NOT_INITIALIZED ? d.textureAtlas.updateQuad(c, d.atlasIndex) : this._dirty = !0); this._quadDirty = !0 }; a._updateBlendFunc = function() { if (this._batchNode) cc.log(cc._LogInfos.Sprite__updateBlendFunc); else { var a = this._node; a._texture && a._texture.hasPremultipliedAlpha() ? (a._blendFunc.src = cc.BLEND_SRC, a._blendFunc.dst = cc.BLEND_DST, a.opacityModifyRGB = !0) : (a._blendFunc.src = cc.SRC_ALPHA, a._blendFunc.dst = cc.ONE_MINUS_SRC_ALPHA, a.opacityModifyRGB = !1) } }; a._setTexture = function(a) { var c = this._node; if (c._batchNode) { if (c._batchNode.texture !== a) { cc.log(cc._LogInfos.Sprite_setTexture); return } } else c._texture !== a && (c._textureLoaded = a ? a._textureLoaded : !1, c._texture = a, this._updateBlendFunc()); this._shaderProgram = a ? cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR) : cc.shaderCache.programForKey(cc.SHADER_POSITION_COLOR) }; a.updateTransform = function() { var a = this._node; if (this._dirty) { var c = this._quad, d = a._parent; if (!a._visible || d && d !== a._batchNode && d._shouldBeHidden) c.br.vertices = c.tl.vertices = c.tr.vertices = c.bl.vertices = { x: 0, y: 0, z: 0 }, a._shouldBeHidden = !0; else { a._shouldBeHidden = !1; 0 !== this._dirtyFlag && (this.updateStatus(), this._dirtyFlag = 0); a._transformToBatch = d && d !== a._batchNode ? cc.affineTransformConcat(this.getNodeToParentTransform(), d._transformToBatch) : this.getNodeToParentTransform(); var e = a._transformToBatch, f = a._rect, d = a._offsetPosition.x, g = a._offsetPosition.y, h = d + f.width, k = g + f.height, m = e.tx, n = e.ty, p = e.a, t = e.b, r = e.d, u = -e.c, e = d * p - g * u + m, f = d * t + g * r + n, s = h * p - g * u + m, g = h * t + g * r + n, v = h * p - k * u + m, h = h * t + k * r + n, m = d * p - k * u + m, d = d * t + k * r + n, k = a._vertexZ; cc.SPRITEBATCHNODE_RENDER_SUBPIXEL || (e |= 0, f |= 0, s |= 0, g |= 0, v |= 0, h |= 0, m |= 0, d |= 0); c.bl.vertices = { x: e, y: f, z: k }; c.br.vertices = { x: s, y: g, z: k }; c.tl.vertices = { x: m, y: d, z: k }; c.tr.vertices = { x: v, y: h, z: k } } a.textureAtlas.updateQuad(c, a.atlasIndex); this._dirty = a._recursiveDirty = !1 } a._hasChildren && a._arrayMakeObjectsPerformSelector(a._children, cc.Node._stateCallbackType.updateTransform) }; a._checkTextureBoundary = function(a, c, d) { a && a.url && (d ? (d = c.x + c.height, c = c.y + c.width) : (d = c.x + c.width, c = c.y + c.height), d > a.width && cc.error(cc._LogInfos.RectWidth, a.url), c > a.height && cc.error(cc._LogInfos.RectHeight, a.url)) }; a.rendering = function(a) { var c = this._node, d = c._texture; d && !d._textureLoaded || 0 === this._displayedOpacity || (a = a || cc._renderContext, d ? d._textureLoaded && (this._shaderProgram.use(), this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix), cc.glBlendFunc(c._blendFunc.src, c._blendFunc.dst), cc.glBindTexture2DN(0, d), cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX), a.bindBuffer(a.ARRAY_BUFFER, this._quadWebBuffer), this._quadDirty && (a.bufferData(a.ARRAY_BUFFER, this._quad.arrayBuffer, a.DYNAMIC_DRAW), this._quadDirty = !1), a.vertexAttribPointer(0, 3, a.FLOAT, !1, 24, 0), a.vertexAttribPointer(1, 4, a.UNSIGNED_BYTE, !0, 24, 12), a.vertexAttribPointer(2, 2, a.FLOAT, !1, 24, 16), a.drawArrays(a.TRIANGLE_STRIP, 0, 4)) : (this._shaderProgram.use(), this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix), cc.glBlendFunc(c._blendFunc.src, c._blendFunc.dst), cc.glBindTexture2D(null), cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_COLOR), a.bindBuffer(a.ARRAY_BUFFER, this._quadWebBuffer), this._quadDirty && (a.bufferData(a.ARRAY_BUFFER, this._quad.arrayBuffer, a.STATIC_DRAW), this._quadDirty = !1), a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 3, a.FLOAT, !1, 24, 0), a.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, a.UNSIGNED_BYTE, !0, 24, 12), a.drawArrays(a.TRIANGLE_STRIP, 0, 4)), cc.g_NumberOfDraws++, 0 === cc.SPRITE_DEBUG_DRAW && !c._showNode) || (cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW), cc.current_stack.stack.push(cc.current_stack.top), cc.current_stack.top = this._stackMatrix, 1 === cc.SPRITE_DEBUG_DRAW || c._showNode ? (c = this._quad, c = [cc.p(c.tl.vertices.x, c.tl.vertices.y), cc.p(c.bl.vertices.x, c.bl.vertices.y), cc.p(c.br.vertices.x, c.br.vertices.y), cc.p(c.tr.vertices.x, c.tr.vertices.y)], cc._drawingUtil.drawPoly(c, 4, !0)) : 2 === cc.SPRITE_DEBUG_DRAW && (d = c.getTextureRect(), c = c.getOffsetPosition(), c = [cc.p(c.x, c.y), cc.p(c.x + d.width, c.y), cc.p(c.x + d.width, c.y + d.height), cc.p(c.x, c.y + d.height)], cc._drawingUtil.drawPoly(c, 4, !0)), cc.current_stack.top = cc.current_stack.stack.pop()) } })(); cc.SpriteBatchNode = cc.Node.extend({ _blendFunc: null, _descendants: null, _className: "SpriteBatchNode", ctor: function(a, b) { cc.Node.prototype.ctor.call(this); this._descendants = []; this._blendFunc = new cc.BlendFunc(cc.BLEND_SRC, cc.BLEND_DST); var c; b = b || cc.SpriteBatchNode.DEFAULT_CAPACITY; cc.isString(a) ? (c = cc.textureCache.getTextureForKey(a)) || (c = cc.textureCache.addImage(a)) : a instanceof cc.Texture2D && (c = a); c && this.initWithTexture(c, b) }, addSpriteWithoutQuad: function(a, b, c) { cc.assert(a, cc._LogInfos.SpriteBatchNode_addSpriteWithoutQuad_2); if (!(a instanceof cc.Sprite)) return cc.log(cc._LogInfos.SpriteBatchNode_addSpriteWithoutQuad), null; a.atlasIndex = b; var d = 0, e, f = this._descendants; if (f && 0 < f.length) for (d = 0, e = f.length; d < e; d++) { var g = f[d]; if (g && g.atlasIndex >= b) break } f.splice(d, 0, a); cc.Node.prototype.addChild.call(this, a, b, c); this.reorderBatch(!1); return this }, getTextureAtlas: function() { return this._renderCmd.getTextureAtlas() }, setTextureAtlas: function(a) { this._renderCmd.getTextureAtlas(a) }, getDescendants: function() { return this._descendants }, initWithFile: function(a, b) { var c = cc.textureCache.getTextureForKey(a); c || (c = cc.textureCache.addImage(a)); return this.initWithTexture(c, b) }, _setNodeDirtyForCache: function() { this._renderCmd && this._renderCmd._setNodeDirtyForCache && this._renderCmd._setNodeDirtyForCache() }, init: function(a, b) { var c = cc.textureCache.getTextureForKey(a); c || (c = cc.textureCache.addImage(a)); return this.initWithTexture(c, b) }, increaseAtlasCapacity: function() { this._renderCmd.increaseAtlasCapacity() }, removeChildAtIndex: function(a, b) { this.removeChild(this._children[a], b) }, rebuildIndexInOrder: function(a, b) { var c = a.children; if (c && 0 < c.length) for (var d = 0; d < c.length; d++) { var e = c[d]; e && 0 > e.zIndex && (b = this.rebuildIndexInOrder(e, b)) }!a === this && (a.atlasIndex = b, b++); if (c && 0 < c.length) for (d = 0; d < c.length; d++)(e = c[d]) && 0 <= e.zIndex && (b = this.rebuildIndexInOrder(e, b)); return b }, highestAtlasIndexInChild: function(a) { var b = a.children; return b && 0 !== b.length ? this.highestAtlasIndexInChild(b[b.length - 1]) : a.atlasIndex }, lowestAtlasIndexInChild: function(a) { var b = a.children; return b && 0 !== b.length ? this.lowestAtlasIndexInChild(b[b.length - 1]) : a.atlasIndex }, atlasIndexForChild: function(a, b) { var c = a.parent, d = c.children, e = d.indexOf(a), f = null; 0 < e && e < cc.UINT_MAX && (f = d[e - 1]); return c === this ? 0 === e ? 0 : this.highestAtlasIndexInChild(f) + 1 : 0 === e ? 0 > b ? c.atlasIndex : c.atlasIndex + 1 : 0 > f.zIndex && 0 > b || 0 <= f.zIndex && 0 <= b ? this.highestAtlasIndexInChild(f) + 1 : c.atlasIndex + 1 }, reorderBatch: function(a) { this._reorderChildDirty = a }, setBlendFunc: function(a, b) { this._blendFunc = void 0 === b ? a : { src: a, dst: b } }, getBlendFunc: function() { return new cc.BlendFunc(this._blendFunc.src, this._blendFunc.dst) }, reorderChild: function(a, b) { cc.assert(a, cc._LogInfos.SpriteBatchNode_reorderChild_2); - 1 === this._children.indexOf(a) ? cc.log(cc._LogInfos.SpriteBatchNode_reorderChild) : b !== a.zIndex && cc.Node.prototype.reorderChild.call(this, a, b) }, removeChild: function(a, b) { null != a && (-1 === this._children.indexOf(a) ? cc.log(cc._LogInfos.SpriteBatchNode_removeChild) : (this.removeSpriteFromAtlas(a), cc.Node.prototype.removeChild.call(this, a, b))) }, updateQuadFromSprite: function(a, b) { cc.assert(a, cc._LogInfos.CCSpriteBatchNode_updateQuadFromSprite_2); a instanceof cc.Sprite ? (this._renderCmd.checkAtlasCapacity(), a.batchNode = this, a.atlasIndex = b, a.dirty = !0, a.updateTransform()) : cc.log(cc._LogInfos.CCSpriteBatchNode_updateQuadFromSprite) }, insertQuadFromSprite: function(a, b) { cc.assert(a, cc._LogInfos.CCSpriteBatchNode_insertQuadFromSprite_2); a instanceof cc.Sprite ? (this._renderCmd.insertQuad(a, b), a.batchNode = this, a.atlasIndex = b, a.dirty = !0, a.updateTransform(), this._renderCmd.cutting(a, b)) : cc.log(cc._LogInfos.CCSpriteBatchNode_insertQuadFromSprite) }, initWithTexture: function(a, b) { this._children.length = 0; this._descendants.length = 0; b = b || cc.SpriteBatchNode.DEFAULT_CAPACITY; this._renderCmd.initWithTexture(a, b); return !0 }, insertChild: function(a, b) { a.batchNode = this; a.atlasIndex = b; a.dirty = !0; this._renderCmd.insertQuad(a, b); this._descendants.splice(b, 0, a); var c = b + 1, d = this._descendants; if (d && 0 < d.length) for (; c < d.length; c++) d[c].atlasIndex++; var d = a.children, e, f; if (d) for (c = 0, f = d.length || 0; c < f; c++) if (e = d[c]) { var g = this.atlasIndexForChild(e, e.zIndex); this.insertChild(e, g) } }, appendChild: function(a) { this._reorderChildDirty = !0; a.batchNode = this; a.dirty = !0; this._descendants.push(a); var b = this._descendants.length - 1; a.atlasIndex = b; this._renderCmd.insertQuad(a, b); a = a.children; for (var b = 0, c = a.length || 0; b < c; b++) this.appendChild(a[b]) }, removeSpriteFromAtlas: function(a) { this._renderCmd.removeQuadAtIndex(a.atlasIndex); a.batchNode = null; var b = this._descendants, c = b.indexOf(a); if (-1 !== c) { b.splice(c, 1); for (var d = b.length; c < d; ++c) b[c].atlasIndex-- } if (a = a.children) for (b = 0, c = a.length || 0; b < c; b++) a[b] && this.removeSpriteFromAtlas(a[b]) }, getTexture: function() { return this._renderCmd.getTexture() }, setTexture: function(a) { this._renderCmd.setTexture(a) }, addChild: function(a, b, c) { cc.assert(null != a, cc._LogInfos.CCSpriteBatchNode_addChild_3); this._renderCmd.isValidChild(a) && (b = null == b ? a.zIndex : b, c = null == c ? a.tag : c, cc.Node.prototype.addChild.call(this, a, b, c), this.appendChild(a)) }, removeAllChildren: function(a) { var b = this._descendants; if (b && 0 < b.length) for (var c = 0, d = b.length; c < d; c++) b[c] && (b[c].batchNode = null); cc.Node.prototype.removeAllChildren.call(this, a); this._descendants.length = 0; this._renderCmd.removeAllQuads() }, sortAllChildren: function() { if (this._reorderChildDirty) { var a = this._children, b, c = 0, d = a.length, e; for (b = 1; b < d; b++) { var f = a[b], c = b - 1; for (e = a[c]; 0 <= c && (f._localZOrder < e._localZOrder || f._localZOrder === e._localZOrder && f.arrivalOrder < e.arrivalOrder);) a[c + 1] = e, c -= 1, e = a[c]; a[c + 1] = f } 0 < a.length && (this._arrayMakeObjectsPerformSelector(a, cc.Node._stateCallbackType.sortAllChildren), this._renderCmd.updateChildrenAtlasIndex(a)); this._reorderChildDirty = !1 } }, _createRenderCmd: function() { return cc._renderType === cc._RENDER_TYPE_CANVAS ? new cc.SpriteBatchNode.CanvasRenderCmd(this) : new cc.SpriteBatchNode.WebGLRenderCmd(this) } }); _p = cc.SpriteBatchNode.prototype; cc.defineGetterSetter(_p, "texture", _p.getTexture, _p.setTexture); cc.defineGetterSetter(_p, "textureAtlas", _p.getTextureAtlas, _p.setTextureAtlas); cc.defineGetterSetter(_p, "descendants", _p.getDescendants); cc.SpriteBatchNode.DEFAULT_CAPACITY = 29; cc.SpriteBatchNode.create = function(a, b) { return new cc.SpriteBatchNode(a, b) }; cc.SpriteBatchNode.createWithTexture = cc.SpriteBatchNode.create; (function() { cc.SpriteBatchNode.CanvasRenderCmd = function(a) { cc.Node.CanvasRenderCmd.call(this, a); this._originalTexture = this._texture = null }; var a = cc.SpriteBatchNode.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); a.constructor = cc.SpriteBatchNode.CanvasRenderCmd; a.checkAtlasCapacity = function() {}; a.isValidChild = function(a) { return a instanceof cc.Sprite ? !0 : (cc.log(cc._LogInfos.Sprite_addChild_4), !1) }; a.initWithTexture = function(a, c) { this._texture = this._originalTexture = a }; a.insertQuad = function(a, c) {}; a.increaseAtlasCapacity = function() {}; a.removeQuadAtIndex = function() {}; a.removeAllQuads = function() {}; a.getTexture = function() { return this._texture }; a.setTexture = function(a) { this._texture = a; for (var c = this._node._children, d = 0; d < c.length; d++) c[d].setTexture(a) }; a.updateChildrenAtlasIndex = function(a) { for (var c = this._node._descendants.length = 0, d = a.length; c < d; c++) this._updateAtlasIndex(a[c]) }; a._updateAtlasIndex = function(a) { var c = this._node._descendants, d = a.children, e, f = d.length; for (e = 0; e < f; e++) if (0 > d[e]._localZOrder) c.push(d[e]); else break; for (c.push(a); e < f; e++) c.push(d[e]) }; a.getTextureAtlas = function() {}; a.setTextureAtlas = function(a) {}; a.cutting = function(a, c) { this._node._children.splice(c, 0, a) } })(); (function() { cc.SpriteBatchNode.WebGLRenderCmd = function(a) { cc.Node.WebGLRenderCmd.call(this, a); this._needDraw = !0; this._textureAtlas = null }; var a = cc.SpriteBatchNode.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); a.constructor = cc.SpriteBatchNode.WebGLRenderCmd; a.isValidChild = function(a) { return a instanceof cc.Sprite ? a.texture != this.getTexture() ? (cc.log(cc._LogInfos.Sprite_addChild_5), !1) : !0 : (cc.log(cc._LogInfos.Sprite_addChild_4), !1) }; a.rendering = function() { var a = this._node; 0 !== this._textureAtlas.totalQuads && (this._shaderProgram.use(), this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix), a._arrayMakeObjectsPerformSelector(a._children, cc.Node._stateCallbackType.updateTransform), cc.glBlendFunc(a._blendFunc.src, a._blendFunc.dst), this._textureAtlas.drawQuads()) }; a.visit = function(a) { var c = this._node; if (c._visible) { c._parent && c._parent._renderCmd && (this._curLevel = c._parent._renderCmd._curLevel + 1); var d = cc.current_stack; d.stack.push(d.top); this._dirtyFlag & cc.Node._dirtyFlags.transformDirty || this.transform(a); this.updateStatus(a); d.top = this._stackMatrix; c.sortAllChildren(); cc.renderer.pushRenderCommand(this); this._dirtyFlag = 0; d.top = d.stack.pop() } }; a.checkAtlasCapacity = function(a) { for (var c = this._textureAtlas; a >= c.capacity || c.capacity === c.totalQuads;) this.increaseAtlasCapacity() }; a.increaseAtlasCapacity = function() { var a = this._textureAtlas.capacity, c = Math.floor(4 * (a + 1) / 3); cc.log(cc._LogInfos.SpriteBatchNode_increaseAtlasCapacity, a, c); this._textureAtlas.resizeCapacity(c) || cc.log(cc._LogInfos.SpriteBatchNode_increaseAtlasCapacity_2) }; a.initWithTexture = function(a, c) { this._textureAtlas = new cc.TextureAtlas; this._textureAtlas.initWithTexture(a, c); this._updateBlendFunc(); this._shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR) }; a.insertQuad = function(a, c) { var d = this._textureAtlas; d.totalQuads >= d.capacity && this.increaseAtlasCapacity(); d.insertQuad(a.quad, c) }; a.removeQuadAtIndex = function(a) { this._textureAtlas.removeQuadAtIndex(a) }; a.getTexture = function() { return this._textureAtlas.texture }; a.setTexture = function(a) { this._textureAtlas.setTexture(a); a && this._updateBlendFunc() }; a.removeAllQuads = function() { this._textureAtlas.removeAllQuads() }; a._swap = function(a, c) { var d = this._node._descendants, e = this._textureAtlas, f = e.quads, g = d[a], h = cc.V3F_C4B_T2F_QuadCopy(f[a]); d[c].atlasIndex = a; d[a] = d[c]; e.updateQuad(f[c], a); d[c] = g; e.updateQuad(h, c) }; a._updateAtlasIndex = function(a, c) { var d = 0, e = a.children; e && (d = e.length); var f = 0; if (0 === d) f = a.atlasIndex, a.atlasIndex = c, a.arrivalOrder = 0, f !== c && this._swap(f, c), c++; else { f = !0; 0 <= e[0].zIndex && (f = a.atlasIndex, a.atlasIndex = c, a.arrivalOrder = 0, f !== c && this._swap(f, c), c++, f = !1); for (d = 0; d < e.length; d++) { var g = e[d]; f && 0 <= g.zIndex && (f = a.atlasIndex, a.atlasIndex = c, a.arrivalOrder = 0, f !== c && this._swap(f, c), c++, f = !1); c = this._updateAtlasIndex(g, c) } f && (f = a.atlasIndex, a.atlasIndex = c, a.arrivalOrder = 0, f !== c && this._swap(f, c), c++) } return c }; a.updateChildrenAtlasIndex = function(a) { for (var c = 0, d = 0; d < a.length; d++) c = this._updateAtlasIndex(a[d], c) }; a._updateBlendFunc = function() { if (!this._textureAtlas.texture.hasPremultipliedAlpha()) { var a = this._node._blendFunc; a.src = cc.SRC_ALPHA; a.dst = cc.ONE_MINUS_SRC_ALPHA } }; a.getTextureAtlas = function() { return this._textureAtlas }; a.setTextureAtlas = function(a) { a !== this._textureAtlas && (this._textureAtlas = a) }; a.cutting = function() {} })(); cc.BakeSprite = cc.Sprite.extend({ _cacheCanvas: null, _cacheContext: null, ctor: function() { cc.Sprite.prototype.ctor.call(this); var a = document.createElement("canvas"); a.width = a.height = 10; this._cacheCanvas = a; this._cacheContext = new cc.CanvasContextWrapper(a.getContext("2d")); var b = new cc.Texture2D; b.initWithElement(a); b.handleLoadedTexture(); this.setTexture(b) }, getCacheContext: function() { return this._cacheContext }, getCacheCanvas: function() { return this._cacheCanvas }, resetCanvasSize: function(a, b) { void 0 === b && (b = a.height, a = a.width); var c = this._cacheCanvas; c.width = a; c.height = b; this.getTexture().handleLoadedTexture(); this.setTextureRect(cc.rect(0, 0, a, b), !1) } }); cc.AnimationFrame = cc.Class.extend({ _spriteFrame: null, _delayPerUnit: 0, _userInfo: null, ctor: function(a, b, c) { this._spriteFrame = a || null; this._delayPerUnit = b || 0; this._userInfo = c || null }, clone: function() { var a = new cc.AnimationFrame; a.initWithSpriteFrame(this._spriteFrame.clone(), this._delayPerUnit, this._userInfo); return a }, copyWithZone: function(a) { return cc.clone(this) }, copy: function(a) { a = new cc.AnimationFrame; a.initWithSpriteFrame(this._spriteFrame.clone(), this._delayPerUnit, this._userInfo); return a }, initWithSpriteFrame: function(a, b, c) { this._spriteFrame = a; this._delayPerUnit = b; this._userInfo = c; return !0 }, getSpriteFrame: function() { return this._spriteFrame }, setSpriteFrame: function(a) { this._spriteFrame = a }, getDelayUnits: function() { return this._delayPerUnit }, setDelayUnits: function(a) { this._delayPerUnit = a }, getUserInfo: function() { return this._userInfo }, setUserInfo: function(a) { this._userInfo = a } }); cc.AnimationFrame.create = function(a, b, c) { return new cc.AnimationFrame(a, b, c) }; cc.Animation = cc.Class.extend({ _frames: null, _loops: 0, _restoreOriginalFrame: !1, _duration: 0, _delayPerUnit: 0, _totalDelayUnits: 0, ctor: function(a, b, c) { this._frames = []; if (void 0 === a) this.initWithSpriteFrames(null, 0); else { var d = a[0]; d && (d instanceof cc.SpriteFrame ? this.initWithSpriteFrames(a, b, c) : d instanceof cc.AnimationFrame && this.initWithAnimationFrames(a, b, c)) } }, getFrames: function() { return this._frames }, setFrames: function(a) { this._frames = a }, addSpriteFrame: function(a) { var b = new cc.AnimationFrame; b.initWithSpriteFrame(a, 1, null); this._frames.push(b); this._totalDelayUnits++ }, addSpriteFrameWithFile: function(a) { a = cc.textureCache.addImage(a); var b = cc.rect(0, 0, 0, 0); b.width = a.width; b.height = a.height; a = new cc.SpriteFrame(a, b); this.addSpriteFrame(a) }, addSpriteFrameWithTexture: function(a, b) { var c = new cc.SpriteFrame(a, b); this.addSpriteFrame(c) }, initWithAnimationFrames: function(a, b, c) { cc.arrayVerifyType(a, cc.AnimationFrame); this._delayPerUnit = b; this._loops = void 0 === c ? 1 : c; this._totalDelayUnits = 0; b = this._frames; for (c = b.length = 0; c < a.length; c++) { var d = a[c]; b.push(d); this._totalDelayUnits += d.getDelayUnits() } return !0 }, clone: function() { var a = new cc.Animation; a.initWithAnimationFrames(this._copyFrames(), this._delayPerUnit, this._loops); a.setRestoreOriginalFrame(this._restoreOriginalFrame); return a }, copyWithZone: function(a) { a = new cc.Animation; a.initWithAnimationFrames(this._copyFrames(), this._delayPerUnit, this._loops); a.setRestoreOriginalFrame(this._restoreOriginalFrame); return a }, _copyFrames: function() { for (var a = [], b = 0; b < this._frames.length; b++) a.push(this._frames[b].clone()); return a }, copy: function(a) { return this.copyWithZone(null) }, getLoops: function() { return this._loops }, setLoops: function(a) { this._loops = a }, setRestoreOriginalFrame: function(a) { this._restoreOriginalFrame = a }, getRestoreOriginalFrame: function() { return this._restoreOriginalFrame }, getDuration: function() { return this._totalDelayUnits * this._delayPerUnit }, getDelayPerUnit: function() { return this._delayPerUnit }, setDelayPerUnit: function(a) { this._delayPerUnit = a }, getTotalDelayUnits: function() { return this._totalDelayUnits }, initWithSpriteFrames: function(a, b, c) { cc.arrayVerifyType(a, cc.SpriteFrame); this._loops = void 0 === c ? 1 : c; this._delayPerUnit = b || 0; this._totalDelayUnits = 0; b = this._frames; b.length = 0; if (a) { for (c = 0; c < a.length; c++) { var d = a[c], e = new cc.AnimationFrame; e.initWithSpriteFrame(d, 1, null); b.push(e) } this._totalDelayUnits += a.length } return !0 }, retain: function() {}, release: function() {} }); cc.Animation.create = function(a, b, c) { return new cc.Animation(a, b, c) }; cc.Animation.createWithAnimationFrames = cc.Animation.create; cc.animationCache = { _animations: {}, addAnimation: function(a, b) { this._animations[b] = a }, removeAnimation: function(a) { a && this._animations[a] && delete this._animations[a] }, getAnimation: function(a) { return this._animations[a] ? this._animations[a] : null }, _addAnimationsWithDictionary: function(a, b) { var c = a.animations; if (c) { var d = 1, e = a.properties; if (e) for (var d = null != e.format ? parseInt(e.format) : d, e = e.spritesheets, f = cc.spriteFrameCache, g = cc.path, h = 0; h < e.length; h++) f.addSpriteFrames(g.changeBasename(b, e[h])); switch (d) { case 1: this._parseVersion1(c); break; case 2: this._parseVersion2(c); break; default: cc.log(cc._LogInfos.animationCache__addAnimationsWithDictionary_2) } } else cc.log(cc._LogInfos.animationCache__addAnimationsWithDictionary) }, addAnimations: function(a) { cc.assert(a, cc._LogInfos.animationCache_addAnimations_2); var b = cc.loader.getRes(a); b ? this._addAnimationsWithDictionary(b, a) : cc.log(cc._LogInfos.animationCache_addAnimations) }, _parseVersion1: function(a) { var b = cc.spriteFrameCache, c; for (c in a) { var d = a[c], e = d.frames, d = parseFloat(d.delay) || 0, f = null; if (e) { for (var f = [], g = 0; g < e.length; g++) { var h = b.getSpriteFrame(e[g]); if (h) { var k = new cc.AnimationFrame; k.initWithSpriteFrame(h, 1, null); f.push(k) } else cc.log(cc._LogInfos.animationCache__parseVersion1_2, c, e[g]) } 0 === f.length ? cc.log(cc._LogInfos.animationCache__parseVersion1_3, c) : (f.length !== e.length && cc.log(cc._LogInfos.animationCache__parseVersion1_4, c), f = new cc.Animation(f, d, 1), cc.animationCache.addAnimation(f, c)) } else cc.log(cc._LogInfos.animationCache__parseVersion1, c) } }, _parseVersion2: function(a) { var b = cc.spriteFrameCache, c; for (c in a) { var d = a[c], e = d.loop, f = parseInt(d.loops), e = e ? cc.REPEAT_FOREVER : isNaN(f) ? 1 : f, f = d.restoreOriginalFrame && !0 == d.restoreOriginalFrame ? !0 : !1, g = d.frames; if (g) { for (var h = [], k = 0; k < g.length; k++) { var m = g[k], n = m.spriteframe, p = b.getSpriteFrame(n); if (p) { var n = parseFloat(m.delayUnits) || 0, m = m.notification, t = new cc.AnimationFrame; t.initWithSpriteFrame(p, n, m); h.push(t) } else cc.log(cc._LogInfos.animationCache__parseVersion2_2, c, n) } d = parseFloat(d.delayPerUnit) || 0; g = new cc.Animation; g.initWithAnimationFrames(h, d, e); g.setRestoreOriginalFrame(f); cc.animationCache.addAnimation(g, c) } else cc.log(cc._LogInfos.animationCache__parseVersion2, c) } }, _clear: function() { this._animations = {} } }; cc.SpriteFrame = cc.Class.extend({ _offset: null, _originalSize: null, _rectInPixels: null, _rotated: !1, _rect: null, _offsetInPixels: null, _originalSizeInPixels: null, _texture: null, _textureFilename: "", _textureLoaded: !1, ctor: function(a, b, c, d, e) { this._offset = cc.p(0, 0); this._offsetInPixels = cc.p(0, 0); this._originalSize = cc.size(0, 0); this._rotated = !1; this._originalSizeInPixels = cc.size(0, 0); this._textureFilename = ""; this._texture = null; this._textureLoaded = !1; void 0 !== a && void 0 !== b && (void 0 === c || void 0 === d || void 0 === e ? this.initWithTexture(a, b) : this.initWithTexture(a, b, c, d, e)) }, textureLoaded: function() { return this._textureLoaded }, addLoadedEventListener: function(a, b) { this.addEventListener("load", a, b) }, getRectInPixels: function() { var a = this._rectInPixels; return cc.rect(a.x, a.y, a.width, a.height) }, setRectInPixels: function(a) { this._rectInPixels || (this._rectInPixels = cc.rect(0, 0, 0, 0)); this._rectInPixels.x = a.x; this._rectInPixels.y = a.y; this._rectInPixels.width = a.width; this._rectInPixels.height = a.height; this._rect = cc.rectPixelsToPoints(a) }, isRotated: function() { return this._rotated }, setRotated: function(a) { this._rotated = a }, getRect: function() { var a = this._rect; return cc.rect(a.x, a.y, a.width, a.height) }, setRect: function(a) { this._rect || (this._rect = cc.rect(0, 0, 0, 0)); this._rect.x = a.x; this._rect.y = a.y; this._rect.width = a.width; this._rect.height = a.height; this._rectInPixels = cc.rectPointsToPixels(this._rect) }, getOffsetInPixels: function() { return cc.p(this._offsetInPixels) }, setOffsetInPixels: function(a) { this._offsetInPixels.x = a.x; this._offsetInPixels.y = a.y; cc._pointPixelsToPointsOut(this._offsetInPixels, this._offset) }, getOriginalSizeInPixels: function() { return cc.size(this._originalSizeInPixels) }, setOriginalSizeInPixels: function(a) { this._originalSizeInPixels.width = a.width; this._originalSizeInPixels.height = a.height }, getOriginalSize: function() { return cc.size(this._originalSize) }, setOriginalSize: function(a) { this._originalSize.width = a.width; this._originalSize.height = a.height }, getTexture: function() { if (this._texture) return this._texture; if ("" !== this._textureFilename) { var a = cc.textureCache.addImage(this._textureFilename); a && (this._textureLoaded = a.isLoaded()); return a } return null }, setTexture: function(a) { if (this._texture !== a) { var b = a.isLoaded(); this._textureLoaded = b; this._texture = a; b || a.addEventListener("load", function(a) { this._textureLoaded = !0; if (this._rotated && cc._renderType === cc._RENDER_TYPE_CANVAS) { var b = a.getHtmlElementObj(), b = cc.Sprite.CanvasRenderCmd._cutRotateImageToCanvas(b, this.getRect()), e = new cc.Texture2D; e.initWithElement(b); e.handleLoadedTexture(); this.setTexture(e); b = this.getRect(); this.setRect(cc.rect(0, 0, b.width, b.height)) } b = this._rect; 0 === b.width && 0 === b.height && (b = a.width, a = a.height, this._rect.width = b, this._rect.height = a, this._rectInPixels = cc.rectPointsToPixels(this._rect), this._originalSizeInPixels.width = this._rectInPixels.width, this._originalSizeInPixels.height = this._rectInPixels.height, this._originalSize.width = b, this._originalSize.height = a); this.dispatchEvent("load") }, this) } }, getOffset: function() { return cc.p(this._offset) }, setOffset: function(a) { this._offset.x = a.x; this._offset.y = a.y }, clone: function() { var a = new cc.SpriteFrame; a.initWithTexture(this._textureFilename, this._rectInPixels, this._rotated, this._offsetInPixels, this._originalSizeInPixels); a.setTexture(this._texture); return a }, copyWithZone: function() { var a = new cc.SpriteFrame; a.initWithTexture(this._textureFilename, this._rectInPixels, this._rotated, this._offsetInPixels, this._originalSizeInPixels); a.setTexture(this._texture); return a }, copy: function() { return this.copyWithZone() }, initWithTexture: function(a, b, c, d, e) { 2 === arguments.length && (b = cc.rectPointsToPixels(b)); d = d || cc.p(0, 0); e = e || b; c = c || !1; cc.isString(a) ? (this._texture = null, this._textureFilename = a) : a instanceof cc.Texture2D && this.setTexture(a); a = this.getTexture(); this._rectInPixels = b; b = this._rect = cc.rectPixelsToPoints(b); if (a && a.url && a.isLoaded()) { var f, g; c ? (f = b.x + b.height, g = b.y + b.width) : (f = b.x + b.width, g = b.y + b.height); f > a.getPixelsWide() && cc.error(cc._LogInfos.RectWidth, a.url); g > a.getPixelsHigh() && cc.error(cc._LogInfos.RectHeight, a.url) } this._offsetInPixels.x = d.x; this._offsetInPixels.y = d.y; cc._pointPixelsToPointsOut(d, this._offset); this._originalSizeInPixels.width = e.width; this._originalSizeInPixels.height = e.height; cc._sizePixelsToPointsOut(e, this._originalSize); this._rotated = c; return !0 } }); cc.EventHelper.prototype.apply(cc.SpriteFrame.prototype); cc.SpriteFrame.create = function(a, b, c, d, e) { return new cc.SpriteFrame(a, b, c, d, e) }; cc.SpriteFrame.createWithTexture = cc.SpriteFrame.create; cc.SpriteFrame._frameWithTextureForCanvas = function(a, b, c, d, e) { var f = new cc.SpriteFrame; f._texture = a; f._rectInPixels = b; f._rect = cc.rectPixelsToPoints(b); f._offsetInPixels.x = d.x; f._offsetInPixels.y = d.y; cc._pointPixelsToPointsOut(f._offsetInPixels, f._offset); f._originalSizeInPixels.width = e.width; f._originalSizeInPixels.height = e.height; cc._sizePixelsToPointsOut(f._originalSizeInPixels, f._originalSize); f._rotated = c; return f }; cc.spriteFrameCache = { _CCNS_REG1: /^\s*\{\s*([\-]?\d+[.]?\d*)\s*,\s*([\-]?\d+[.]?\d*)\s*\}\s*$/, _CCNS_REG2: /^\s*\{\s*\{\s*([\-]?\d+[.]?\d*)\s*,\s*([\-]?\d+[.]?\d*)\s*\}\s*,\s*\{\s*([\-]?\d+[.]?\d*)\s*,\s*([\-]?\d+[.]?\d*)\s*\}\s*\}\s*$/, _spriteFrames: {}, _spriteFramesAliases: {}, _frameConfigCache: {}, _rectFromString: function(a) { return (a = this._CCNS_REG2.exec(a)) ? cc.rect(parseFloat(a[1]), parseFloat(a[2]), parseFloat(a[3]), parseFloat(a[4])) : cc.rect(0, 0, 0, 0) }, _pointFromString: function(a) { return (a = this._CCNS_REG1.exec(a)) ? cc.p(parseFloat(a[1]), parseFloat(a[2])) : cc.p(0, 0) }, _sizeFromString: function(a) { return (a = this._CCNS_REG1.exec(a)) ? cc.size(parseFloat(a[1]), parseFloat(a[2])) : cc.size(0, 0) }, _getFrameConfig: function(a) { var b = cc.loader.getRes(a); cc.assert(b, cc._LogInfos.spriteFrameCache__getFrameConfig_2, a); cc.loader.release(a); if (b._inited) return this._frameConfigCache[a] = b; this._frameConfigCache[a] = this._parseFrameConfig(b); return this._frameConfigCache[a] }, _getFrameConfigByJsonObject: function(a, b) { cc.assert(b, cc._LogInfos.spriteFrameCache__getFrameConfig_2, a); this._frameConfigCache[a] = this._parseFrameConfig(b); return this._frameConfigCache[a] }, _parseFrameConfig: function(a) { var b = a.frames, c = a.metadata || a.meta; a = {}; var d = {}, e = 0; c && (e = c.format, e = 1 >= e.length ? parseInt(e) : e, d.image = c.textureFileName || c.textureFileName || c.image); for (var f in b) { var g = b[f]; if (g) { c = {}; if (0 == e) { c.rect = cc.rect(g.x, g.y, g.width, g.height); c.rotated = !1; c.offset = cc.p(g.offsetX, g.offsetY); var h = g.originalWidth, g = g.originalHeight; h && g || cc.log(cc._LogInfos.spriteFrameCache__getFrameConfig); h = Math.abs(h); g = Math.abs(g); c.size = cc.size(h, g) } else if (1 == e || 2 == e) c.rect = this._rectFromString(g.frame), c.rotated = g.rotated || !1, c.offset = this._pointFromString(g.offset), c.size = this._sizeFromString(g.sourceSize); else if (3 == e) { var h = this._sizeFromString(g.spriteSize), k = this._rectFromString(g.textureRect); h && (k = cc.rect(k.x, k.y, h.width, h.height)); c.rect = k; c.rotated = g.textureRotated || !1; c.offset = this._pointFromString(g.spriteOffset); c.size = this._sizeFromString(g.spriteSourceSize); c.aliases = g.aliases } else h = g.frame, k = g.sourceSize, f = g.filename || f, c.rect = cc.rect(h.x, h.y, h.w, h.h), c.rotated = g.rotated || !1, c.offset = cc.p(0, 0), c.size = cc.size(k.w, k.h); a[f] = c } } return { _inited: !0, frames: a, meta: d } }, _addSpriteFramesByObject: function(a, b, c) { cc.assert(a, cc._LogInfos.spriteFrameCache_addSpriteFrames_2); b && b.frames && (b = this._frameConfigCache[a] || this._getFrameConfigByJsonObject(a, b), this._createSpriteFrames(a, b, c)) }, _createSpriteFrames: function(a, b, c) { var d = b.frames; b = b.meta; c ? c instanceof cc.Texture2D || (cc.isString(c) ? c = cc.textureCache.addImage(c) : cc.assert(0, cc._LogInfos.spriteFrameCache_addSpriteFrames_3)) : (c = cc.path.changeBasename(a, b.image || ".png"), c = cc.textureCache.addImage(c)); a = this._spriteFramesAliases; b = this._spriteFrames; for (var e in d) { var f = d[e], g = b[e]; if (!g) { g = new cc.SpriteFrame(c, f.rect, f.rotated, f.offset, f.size); if (f = f.aliases) for (var h = 0, k = f.length; h < k; h++) { var m = f[h]; a[m] && cc.log(cc._LogInfos.spriteFrameCache_addSpriteFrames, m); a[m] = e } cc._renderType === cc._RENDER_TYPE_CANVAS && g.isRotated() && g.getTexture().isLoaded() && (f = g.getTexture().getHtmlElementObj(), f = cc.Sprite.CanvasRenderCmd._cutRotateImageToCanvas(f, g.getRectInPixels()), h = new cc.Texture2D, h.initWithElement(f), h.handleLoadedTexture(), g.setTexture(h), f = g._rect, g.setRect(cc.rect(0, 0, f.width, f.height))); b[e] = g } } }, addSpriteFrames: function(a, b) { cc.assert(a, cc._LogInfos.spriteFrameCache_addSpriteFrames_2); var c = this._frameConfigCache[a] || cc.loader.getRes(a); c && c.frames && (c = this._frameConfigCache[a] || this._getFrameConfig(a), this._createSpriteFrames(a, c, b)) }, _checkConflict: function(a) { a = a.frames; for (var b in a) this._spriteFrames[b] && cc.log(cc._LogInfos.spriteFrameCache__checkConflict, b) }, addSpriteFrame: function(a, b) { this._spriteFrames[b] = a }, removeSpriteFrames: function() { this._spriteFrames = {}; this._spriteFramesAliases = {} }, removeSpriteFrameByName: function(a) { a && (this._spriteFramesAliases[a] && delete this._spriteFramesAliases[a], this._spriteFrames[a] && delete this._spriteFrames[a]) }, removeSpriteFramesFromFile: function(a) { var b = this._spriteFrames, c = this._spriteFramesAliases; if (a = this._frameConfigCache[a]) { a = a.frames; for (var d in a) if (b[d]) { delete b[d]; for (var e in c) c[e] === d && delete c[e] } } }, removeSpriteFramesFromTexture: function(a) { var b = this._spriteFrames, c = this._spriteFramesAliases, d; for (d in b) { var e = b[d]; if (e && e.getTexture() === a) { delete b[d]; for (var f in c) c[f] === d && delete c[f] } } }, getSpriteFrame: function(a) { var b = this._spriteFrames[a]; if (!b) { var c = this._spriteFramesAliases[a]; c && ((b = this._spriteFrames[c.toString()]) || delete this._spriteFramesAliases[a]) } return b }, _clear: function() { this._spriteFrames = {}; this._spriteFramesAliases = {}; this._frameConfigCache = {} } }; cc.configuration = { ERROR: 0, STRING: 1, INT: 2, DOUBLE: 3, BOOLEAN: 4, _maxTextureSize: 0, _maxModelviewStackDepth: 0, _supportsPVRTC: !1, _supportsNPOT: !1, _supportsBGRA8888: !1, _supportsDiscardFramebuffer: !1, _supportsShareableVAO: !1, _maxSamplesAllowed: 0, _maxTextureUnits: 0, _GlExtensions: "", _valueDict: {}, _inited: !1, _init: function() { var a = this._valueDict; a["cocos2d.x.version"] = cc.ENGINE_VERSION; a["cocos2d.x.compiled_with_profiler"] = !1; a["cocos2d.x.compiled_with_gl_state_cache"] = cc.ENABLE_GL_STATE_CACHE; this._inited = !0 }, getMaxTextureSize: function() { return this._maxTextureSize }, getMaxModelviewStackDepth: function() { return this._maxModelviewStackDepth }, getMaxTextureUnits: function() { return this._maxTextureUnits }, supportsNPOT: function() { return this._supportsNPOT }, supportsPVRTC: function() { return this._supportsPVRTC }, supportsETC: function() { return !1 }, supportsS3TC: function() { return !1 }, supportsATITC: function() { return !1 }, supportsBGRA8888: function() { return this._supportsBGRA8888 }, supportsDiscardFramebuffer: function() { return this._supportsDiscardFramebuffer }, supportsShareableVAO: function() { return this._supportsShareableVAO }, checkForGLExtension: function(a) { return -1 < this._GlExtensions.indexOf(a) }, getValue: function(a, b) { this._inited || this._init(); var c = this._valueDict; return c[a] ? c[a] : b }, setValue: function(a, b) { this._valueDict[a] = b }, dumpInfo: function() { 0 === cc.ENABLE_GL_STATE_CACHE && (cc.log(""), cc.log(cc._LogInfos.configuration_dumpInfo), cc.log("")) }, gatherGPUInfo: function() { if (cc._renderType !== cc._RENDER_TYPE_CANVAS) { this._inited || this._init(); var a = cc._renderContext, b = this._valueDict; b["gl.vendor"] = a.getParameter(a.VENDOR); b["gl.renderer"] = a.getParameter(a.RENDERER); b["gl.version"] = a.getParameter(a.VERSION); this._GlExtensions = ""; for (var c = a.getSupportedExtensions(), d = 0; d < c.length; d++) this._GlExtensions += c[d] + " "; this._maxTextureSize = a.getParameter(a.MAX_TEXTURE_SIZE); b["gl.max_texture_size"] = this._maxTextureSize; this._maxTextureUnits = a.getParameter(a.MAX_COMBINED_TEXTURE_IMAGE_UNITS); b["gl.max_texture_units"] = this._maxTextureUnits; this._supportsPVRTC = this.checkForGLExtension("GL_IMG_texture_compression_pvrtc"); b["gl.supports_PVRTC"] = this._supportsPVRTC; this._supportsNPOT = !1; b["gl.supports_NPOT"] = this._supportsNPOT; this._supportsBGRA8888 = this.checkForGLExtension("GL_IMG_texture_format_BGRA888"); b["gl.supports_BGRA8888"] = this._supportsBGRA8888; this._supportsDiscardFramebuffer = this.checkForGLExtension("GL_EXT_discard_framebuffer"); b["gl.supports_discard_framebuffer"] = this._supportsDiscardFramebuffer; this._supportsShareableVAO = this.checkForGLExtension("vertex_array_object"); b["gl.supports_vertex_array_object"] = this._supportsShareableVAO; cc.checkGLErrorDebug() } }, loadConfigFile: function(a) { this._inited || this._init(); var b = cc.loader.getRes(a); if (!b) throw "Please load the resource first : " + a; cc.assert(b, cc._LogInfos.configuration_loadConfigFile_2, a); if (b = b.data) for (var c in b) this._valueDict[c] = b[c]; else cc.log(cc._LogInfos.configuration_loadConfigFile, a) } }; cc.g_NumberOfDraws = 0; cc.GLToClipTransform = function(a) { cc.kmGLGetMatrix(cc.KM_GL_PROJECTION, a); var b = new cc.math.Matrix4; cc.kmGLGetMatrix(cc.KM_GL_MODELVIEW, b); a.multiply(b) }; cc.Director = cc.Class.extend({ _landscape: !1, _nextDeltaTimeZero: !1, _paused: !1, _purgeDirectorInNextLoop: !1, _sendCleanupToScene: !1, _animationInterval: 0, _oldAnimationInterval: 0, _projection: 0, _accumDt: 0, _contentScaleFactor: 1, _displayStats: !1, _deltaTime: 0, _frameRate: 0, _FPSLabel: null, _SPFLabel: null, _drawsLabel: null, _winSizeInPoints: null, _lastUpdate: null, _nextScene: null, _notificationNode: null, _openGLView: null, _scenesStack: null, _projectionDelegate: null, _runningScene: null, _frames: 0, _totalFrames: 0, _secondsPerFrame: 0, _dirtyRegion: null, _scheduler: null, _actionManager: null, _eventProjectionChanged: null, _eventAfterDraw: null, _eventAfterVisit: null, _eventAfterUpdate: null, ctor: function() { var a = this; a._lastUpdate = Date.now(); cc.eventManager.addCustomListener(cc.game.EVENT_SHOW, function() { a._lastUpdate = Date.now() }) }, init: function() { 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; cc.ActionManager ? (this._actionManager = new cc.ActionManager, this._scheduler.scheduleUpdate(this._actionManager, cc.Scheduler.PRIORITY_SYSTEM, !1)) : this._actionManager = null; this._eventAfterDraw = new cc.EventCustom(cc.Director.EVENT_AFTER_DRAW); this._eventAfterDraw.setUserData(this); this._eventAfterVisit = new cc.EventCustom(cc.Director.EVENT_AFTER_VISIT); this._eventAfterVisit.setUserData(this); this._eventAfterUpdate = new cc.EventCustom(cc.Director.EVENT_AFTER_UPDATE); this._eventAfterUpdate.setUserData(this); this._eventProjectionChanged = new cc.EventCustom(cc.Director.EVENT_PROJECTION_CHANGED); this._eventProjectionChanged.setUserData(this); return !0 }, calculateDeltaTime: function() { var a = Date.now(); this._nextDeltaTimeZero ? (this._deltaTime = 0, this._nextDeltaTimeZero = !1) : this._deltaTime = (a - this._lastUpdate) / 1E3; 0 < cc.game.config[cc.game.CONFIG_KEY.debugMode] && 0.2 < this._deltaTime && (this._deltaTime = 1 / 60); this._lastUpdate = a }, convertToGL: null, convertToUI: null, drawScene: function() { var a = cc.renderer; this.calculateDeltaTime(); this._paused || (this._scheduler.update(this._deltaTime), cc.eventManager.dispatchEvent(this._eventAfterUpdate)); this._clear(); this._nextScene && this.setNextScene(); this._beforeVisitScene && this._beforeVisitScene(); this._runningScene && (!0 === a.childrenOrderDirty ? (cc.renderer.clearRenderCommands(), this._runningScene._renderCmd._curLevel = 0, this._runningScene.visit(), a.resetFlag()) : !0 === a.transformDirty() && a.transform(), cc.eventManager.dispatchEvent(this._eventAfterVisit)); this._notificationNode && this._notificationNode.visit(); this._displayStats && this._showStats(); this._afterVisitScene && this._afterVisitScene(); a.rendering(cc._renderContext); cc.eventManager.dispatchEvent(this._eventAfterDraw); this._totalFrames++; this._displayStats && this._calculateMPF() }, _beforeVisitScene: null, _afterVisitScene: null, end: function() { this._purgeDirectorInNextLoop = !0 }, getContentScaleFactor: function() { return this._contentScaleFactor }, getNotificationNode: function() { return this._notificationNode }, getWinSize: function() { return cc.size(this._winSizeInPoints) }, getWinSizeInPixels: function() { return cc.size(this._winSizeInPoints.width * this._contentScaleFactor, this._winSizeInPoints.height * this._contentScaleFactor) }, getVisibleSize: null, getVisibleOrigin: null, getZEye: null, pause: function() { this._paused || (this._oldAnimationInterval = this._animationInterval, this.setAnimationInterval(0.25), this._paused = !0) }, popScene: function() { cc.assert(this._runningScene, cc._LogInfos.Director_popScene); this._scenesStack.pop(); var a = this._scenesStack.length; 0 === a ? this.end() : (this._sendCleanupToScene = !0, this._nextScene = this._scenesStack[a - 1]) }, purgeCachedData: function() { cc.animationCache._clear(); cc.spriteFrameCache._clear(); cc.textureCache._clear() }, purgeDirector: function() { this.getScheduler().unscheduleAll(); cc.eventManager && cc.eventManager.setEnabled(!1); this._runningScene && (this._runningScene.onExitTransitionDidStart(), this._runningScene.onExit(), this._runningScene.cleanup()); this._nextScene = this._runningScene = null; this._scenesStack.length = 0; this.stopAnimation(); this.purgeCachedData(); cc.checkGLErrorDebug() }, pushScene: function(a) { cc.assert(a, cc._LogInfos.Director_pushScene); this._sendCleanupToScene = !1; this._scenesStack.push(a); this._nextScene = a }, runScene: function(a) { cc.assert(a, cc._LogInfos.Director_pushScene); if (this._runningScene) { var b = this._scenesStack.length; 0 === b ? (this._sendCleanupToScene = !0, this._scenesStack[b] = a) : (this._sendCleanupToScene = !0, this._scenesStack[b - 1] = a); this._nextScene = a } else this.pushScene(a), this.startAnimation() }, resume: function() { this._paused && (this.setAnimationInterval(this._oldAnimationInterval), (this._lastUpdate = Date.now()) || cc.log(cc._LogInfos.Director_resume), this._paused = !1, this._deltaTime = 0) }, setContentScaleFactor: function(a) { a !== this._contentScaleFactor && (this._contentScaleFactor = a, this._createStatsLabel()) }, setDepthTest: null, setDefaultValues: function() {}, setNextDeltaTimeZero: function(a) { this._nextDeltaTimeZero = a }, setNextScene: function() { var a = !1, b = !1; cc.TransitionScene && (a = this._runningScene ? this._runningScene instanceof cc.TransitionScene : !1, b = this._nextScene ? this._nextScene instanceof cc.TransitionScene : !1); if (!b) { if (b = this._runningScene) b.onExitTransitionDidStart(), b.onExit(); this._sendCleanupToScene && b && b.cleanup() } this._runningScene = this._nextScene; cc.renderer.childrenOrderDirty = !0; this._nextScene = null; a || null === this._runningScene || (this._runningScene.onEnter(), this._runningScene.onEnterTransitionDidFinish()) }, setNotificationNode: function(a) { this._notificationNode = a }, getDelegate: function() { return this._projectionDelegate }, setDelegate: function(a) { this._projectionDelegate = a }, setOpenGLView: null, setProjection: null, setViewport: null, getOpenGLView: null, getProjection: null, setAlphaBlending: null, _showStats: function() { this._frames++; this._accumDt += this._deltaTime; this._FPSLabel && this._SPFLabel && this._drawsLabel ? (this._accumDt > cc.DIRECTOR_FPS_INTERVAL && (this._SPFLabel.string = this._secondsPerFrame.toFixed(3), this._frameRate = this._frames / this._accumDt, this._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(a) { this._displayStats = a }, getSecondsPerFrame: function() { return this._secondsPerFrame }, isNextDeltaTimeZero: function() { return this._nextDeltaTimeZero }, isPaused: function() { return this._paused }, getTotalFrames: function() { return this._totalFrames }, popToRootScene: function() { this.popToSceneStackLevel(1) }, popToSceneStackLevel: function(a) { cc.assert(this._runningScene, cc._LogInfos.Director_popToSceneStackLevel_2); var b = this._scenesStack, c = b.length; if (0 === c) this.end(); else if (!(a > c)) { for (; c > a;) { var d = b.pop(); d.running && (d.onExitTransitionDidStart(), d.onExit()); d.cleanup(); c-- } this._nextScene = b[b.length - 1]; this._sendCleanupToScene = !1 } }, getScheduler: function() { return this._scheduler }, setScheduler: function(a) { this._scheduler !== a && (this._scheduler = a) }, getActionManager: function() { return this._actionManager }, setActionManager: function(a) { this._actionManager !== a && (this._actionManager = a) }, getDeltaTime: function() { return this._deltaTime }, _createStatsLabel: null, _calculateMPF: function() { this._secondsPerFrame = (Date.now() - this._lastUpdate) / 1E3 } }); cc.Director.EVENT_PROJECTION_CHANGED = "director_projection_changed"; cc.Director.EVENT_AFTER_DRAW = "director_after_draw"; cc.Director.EVENT_AFTER_VISIT = "director_after_visit"; cc.Director.EVENT_AFTER_UPDATE = "director_after_update"; cc.DisplayLinkDirector = cc.Director.extend({ invalid: !1, startAnimation: function() { this._nextDeltaTimeZero = !0; this.invalid = !1 }, mainLoop: function() { this._purgeDirectorInNextLoop ? (this._purgeDirectorInNextLoop = !1, this.purgeDirector()) : this.invalid || this.drawScene() }, stopAnimation: function() { this.invalid = !0 }, setAnimationInterval: function(a) { this._animationInterval = a; this.invalid || (this.stopAnimation(), this.startAnimation()) } }); cc.Director.sharedDirector = null; cc.Director.firstUseDirector = !0; cc.Director._getInstance = function() { 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(a) { this._projection = a; cc.eventManager.dispatchEvent(this._eventProjectionChanged) }, _p.setDepthTest = function() {}, _p.setOpenGLView = function(a) { this._winSizeInPoints.width = cc._canvas.width; this._winSizeInPoints.height = cc._canvas.height; this._openGLView = a || cc.view; cc.eventManager && cc.eventManager.setEnabled(!0) }, _p._clear = function() { var a = this._openGLView.getViewPortRect(), b = cc._renderContext.getContext(); b.setTransform(1, 0, 0, 1, 0, 0); b.clearRect(-a.x, a.y, a.width, a.height) }, _p._createStatsLabel = function() { var a = 0, a = this._winSizeInPoints.width > this._winSizeInPoints.height ? 0 | this._winSizeInPoints.height / 320 * 24 : 0 | this._winSizeInPoints.width / 320 * 24; this._FPSLabel = new cc.LabelTTF("000.0", "Arial", a); this._SPFLabel = new cc.LabelTTF("0.000", "Arial", a); this._drawsLabel = new cc.LabelTTF("0000", "Arial", a); a = cc.DIRECTOR_STATS_POSITION; this._drawsLabel.setPosition(this._drawsLabel.width / 2 + a.x, 5 * this._drawsLabel.height / 2 + a.y); this._SPFLabel.setPosition(this._SPFLabel.width / 2 + a.x, 3 * this._SPFLabel.height / 2 + a.y); this._FPSLabel.setPosition(this._FPSLabel.width / 2 + a.x, this._FPSLabel.height / 2 + a.y) }, _p.getVisibleSize = function() { return this.getWinSize() }, _p.getVisibleOrigin = function() { return cc.p(0, 0) }) : (cc.Director._fpsImage = new Image, cc._addEventListener(cc.Director._fpsImage, "load", function() { cc.Director._fpsImageLoaded = !0 }), cc._fpsImage && (cc.Director._fpsImage.src = cc._fpsImage)); cc._renderType === cc._RENDER_TYPE_WEBGL && function() { cc.DirectorDelegate = cc.Class.extend({ updateProjection: function() {} }); var a = cc.Director.prototype; a.setProjection = function(a) { var c = this._winSizeInPoints; this.setViewport(); var d = this._openGLView, e = d._viewPortRect.x / d._scaleX, f = d._viewPortRect.y / d._scaleY; switch (a) { case cc.Director.PROJECTION_2D: cc.kmGLMatrixMode(cc.KM_GL_PROJECTION); cc.kmGLLoadIdentity(); d = cc.math.Matrix4.createOrthographicProjection(-e, c.width - e, -f, c.height - f, -1024, 1024); cc.kmGLMultMatrix(d); cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); cc.kmGLLoadIdentity(); break; case cc.Director.PROJECTION_3D: var g = this.getZEye(), h = new cc.math.Matrix4, d = new cc.math.Matrix4; cc.kmGLMatrixMode(cc.KM_GL_PROJECTION); cc.kmGLLoadIdentity(); h = cc.math.Matrix4.createPerspectiveProjection(60, c.width / c.height, 0.1, 2 * g); cc.kmGLMultMatrix(h); cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); cc.kmGLLoadIdentity(); g = new cc.math.Vec3(-e + c.width / 2, -f + c.height / 2, g); c = new cc.math.Vec3(-e + c.width / 2, -f + c.height / 2, 0); e = new cc.math.Vec3(0, 1, 0); d.lookAt(g, c, e); cc.kmGLMultMatrix(d); break; case cc.Director.PROJECTION_CUSTOM: this._projectionDelegate && this._projectionDelegate.updateProjection(); break; default: cc.log(cc._LogInfos.Director_setProjection) } this._projection = a; cc.eventManager.dispatchEvent(this._eventProjectionChanged); cc.setProjectionMatrixDirty(); cc.renderer.childrenOrderDirty = !0 }; a.setDepthTest = function(a) { var c = cc._renderContext; a ? (c.clearDepth(1), c.enable(c.DEPTH_TEST), c.depthFunc(c.LEQUAL)) : c.disable(c.DEPTH_TEST) }; a.setOpenGLView = function(a) { this._winSizeInPoints.width = cc._canvas.width; this._winSizeInPoints.height = cc._canvas.height; this._openGLView = a || cc.view; a = cc.configuration; a.gatherGPUInfo(); a.dumpInfo(); this._createStatsLabel(); this.setGLDefaultValues(); cc.eventManager && cc.eventManager.setEnabled(!0) }; a._clear = function() { var a = cc._renderContext; a.clear(a.COLOR_BUFFER_BIT | a.DEPTH_BUFFER_BIT) }; a._beforeVisitScene = function() { cc.kmGLPushMatrix() }; a._afterVisitScene = function() { cc.kmGLPopMatrix() }; a._createStatsLabel = function() { if (!cc.LabelAtlas) this._createStatsLabelForCanvas(); else if (null != cc.Director._fpsImageLoaded && !1 !== cc.Director._fpsImageLoaded) { var a = new cc.Texture2D; a.initWithElement(cc.Director._fpsImage); a.handleLoadedTexture(); var c = cc.view.getDesignResolutionSize().height / 320; 0 === c && (c = this._winSizeInPoints.height / 320); var d = new cc.LabelAtlas; d._setIgnoreContentScaleFactor(!0); d.initWithString("00.0", a, 12, 32, "."); d.scale = c; this._FPSLabel = d; d = new cc.LabelAtlas; d._setIgnoreContentScaleFactor(!0); d.initWithString("0.000", a, 12, 32, "."); d.scale = c; this._SPFLabel = d; d = new cc.LabelAtlas; d._setIgnoreContentScaleFactor(!0); d.initWithString("000", a, 12, 32, "."); d.scale = c; this._drawsLabel = d; a = cc.DIRECTOR_STATS_POSITION; this._drawsLabel.setPosition(a.x, 34 * c + a.y); this._SPFLabel.setPosition(a.x, 17 * c + a.y); this._FPSLabel.setPosition(a) } }; a._createStatsLabelForCanvas = function() { var a = 0, a = this._winSizeInPoints.width > this._winSizeInPoints.height ? 0 | this._winSizeInPoints.height / 320 * 24 : 0 | this._winSizeInPoints.width / 320 * 24; this._FPSLabel = new cc.LabelTTF("000.0", "Arial", a); this._SPFLabel = new cc.LabelTTF("0.000", "Arial", a); this._drawsLabel = new cc.LabelTTF("0000", "Arial", a); a = cc.DIRECTOR_STATS_POSITION; this._drawsLabel.setPosition(this._drawsLabel.width / 2 + a.x, 5 * this._drawsLabel.height / 2 + a.y); this._SPFLabel.setPosition(this._SPFLabel.width / 2 + a.x, 3 * this._SPFLabel.height / 2 + a.y); this._FPSLabel.setPosition(this._FPSLabel.width / 2 + a.x, this._FPSLabel.height / 2 + a.y) }; a.convertToGL = function(a) { var c = new cc.math.Matrix4; cc.GLToClipTransform(c); var d = c.inverse(), c = c.mat[14] / c.mat[15], e = this._openGLView.getDesignResolutionSize(); a = new cc.math.Vec3(2 * a.x / e.width - 1, 1 - 2 * a.y / e.height, c); a.transformCoord(d); return cc.p(a.x, a.y) }; a.convertToUI = function(a) { var c = new cc.math.Matrix4; cc.GLToClipTransform(c); a = new cc.math.Vec3(a.x, a.y, 0); a.transformCoord(c); c = this._openGLView.getDesignResolutionSize(); return cc.p(c.width * (0.5 * a.x + 0.5), c.height * (0.5 * -a.y + 0.5)) }; a.getVisibleSize = function() { return this._openGLView.getVisibleSize() }; a.getVisibleOrigin = function() { return this._openGLView.getVisibleOrigin() }; a.getZEye = function() { return this._winSizeInPoints.height / 1.1566 }; a.setViewport = function() { var a = this._openGLView; if (a) { var c = this._winSizeInPoints; a.setViewPortInPoints(-a._viewPortRect.x / a._scaleX, -a._viewPortRect.y / a._scaleY, c.width, c.height) } }; a.getOpenGLView = function() { return this._openGLView }; a.getProjection = function() { return this._projection }; a.setAlphaBlending = function(a) { a ? cc.glBlendFunc(cc.BLEND_SRC, cc.BLEND_DST) : cc.glBlendFunc(cc._renderContext.ONE, cc._renderContext.ZERO) }; a.setGLDefaultValues = function() { this.setAlphaBlending(!0); this.setDepthTest(!1); this.setProjection(this._projection); cc._renderContext.clearColor(0, 0, 0, 1) } }(); cc.Camera = cc.Class.extend({ _eyeX: null, _eyeY: null, _eyeZ: null, _centerX: null, _centerY: null, _centerZ: null, _upX: null, _upY: null, _upZ: null, _dirty: !1, _lookupMatrix: null, ctor: function() { this._lookupMatrix = new cc.math.Matrix4; this.restore() }, description: function() { return "\x3cCCCamera | center \x3d(" + this._centerX + "," + this._centerY + "," + this._centerZ + ")\x3e" }, setDirty: function(a) { this._dirty = a }, isDirty: function() { return this._dirty }, restore: function() { this._eyeX = this._eyeY = 0; this._eyeZ = cc.Camera.getZEye(); this._upX = this._centerX = this._centerY = this._centerZ = 0; this._upY = 1; this._upZ = 0; this._lookupMatrix.identity(); this._dirty = !1 }, locate: function() { if (this._dirty) { var a = new cc.math.Vec3(this._eyeX, this._eyeY, this._eyeZ), b = new cc.math.Vec3(this._centerX, this._centerY, this._centerZ), c = new cc.math.Vec3(this._upX, this._upY, this._upZ); this._lookupMatrix.lookAt(a, b, c); this._dirty = !1 } cc.kmGLMultMatrix(this._lookupMatrix) }, _locateForRenderer: function(a) { if (this._dirty) { var b = new cc.math.Vec3(this._eyeX, this._eyeY, this._eyeZ), c = new cc.math.Vec3(this._centerX, this._centerY, this._centerZ), d = new cc.math.Vec3(this._upX, this._upY, this._upZ); this._lookupMatrix.lookAt(b, c, d); this._dirty = !1 } a.multiply(this._lookupMatrix) }, setEyeXYZ: function(a, b, c) { this.setEye(a, b, c) }, setEye: function(a, b, c) { this._eyeX = a; this._eyeY = b; this._eyeZ = c; this._dirty = !0 }, setCenterXYZ: function(a, b, c) { this.setCenter(a, b, c) }, setCenter: function(a, b, c) { this._centerX = a; this._centerY = b; this._centerZ = c; this._dirty = !0 }, setUpXYZ: function(a, b, c) { this.setUp(a, b, c) }, setUp: function(a, b, c) { this._upX = a; this._upY = b; this._upZ = c; this._dirty = !0 }, getEyeXYZ: function(a, b, c) { return { x: this._eyeX, y: this._eyeY, z: this._eyeZ } }, getEye: function() { return { x: this._eyeX, y: this._eyeY, z: this._eyeZ } }, getCenterXYZ: function(a, b, c) { return { x: this._centerX, y: this._centerY, z: this._centerZ } }, getCenter: function() { return { x: this._centerX, y: this._centerY, z: this._centerZ } }, getUpXYZ: function(a, b, c) { return { x: this._upX, y: this._upY, z: this._upZ } }, getUp: function() { return { x: this._upX, y: this._upY, z: this._upZ } }, _DISALLOW_COPY_AND_ASSIGN: function(a) {} }); cc.Camera.getZEye = function() { return cc.FLT_EPSILON }; cc.PRIORITY_NON_SYSTEM = cc.PRIORITY_SYSTEM + 1; cc.ListEntry = function(a, b, c, d, e, f, g) { this.prev = a; this.next = b; this.callback = c; this.target = d; this.priority = e; this.paused = f; this.markedForDeletion = g }; cc.HashUpdateEntry = function(a, b, c, d, e) { this.list = a; this.entry = b; this.target = c; this.callback = d; this.hh = e }; cc.HashTimerEntry = cc.hashSelectorEntry = function(a, b, c, d, e, f, g) { this.timers = a; this.target = b; this.timerIndex = c; this.currentTimer = d; this.currentTimerSalvaged = e; this.paused = f; this.hh = g }; cc.Timer = cc.Class.extend({ _scheduler: null, _elapsed: 0, _runForever: !1, _useDelay: !1, _timesExecuted: 0, _repeat: 0, _delay: 0, _interval: 0, getInterval: function() { return this._interval }, setInterval: function(a) { this._interval = a }, setupTimerWithInterval: function(a, b, c) { this._elapsed = -1; this._interval = a; this._delay = c; this._useDelay = 0 < this._delay; this._repeat = b; this._runForever = this._repeat === cc.REPEAT_FOREVER }, trigger: function() { return 0 }, cancel: function() { return 0 }, ctor: function() { this._scheduler = null; this._elapsed = -1; this._useDelay = this._runForever = !1; this._interval = this._delay = this._repeat = this._timesExecuted = 0 }, update: function(a) { -1 === this._elapsed ? this._timesExecuted = this._elapsed = 0 : (this._elapsed += a, this._runForever && !this._useDelay ? this._elapsed >= this._interval && (this.trigger(), this._elapsed = 0) : (this._useDelay ? this._elapsed >= this._delay && (this.trigger(), this._elapsed -= this._delay, this._timesExecuted += 1, this._useDelay = !1) : this._elapsed >= this._interval && (this.trigger(), this._elapsed = 0, this._timesExecuted += 1), !this._runForever && this._timesExecuted > this._repeat && this.cancel())) } }); cc.TimerTargetSelector = cc.Timer.extend({ _target: null, _selector: null, ctor: function() { this._selector = this._target = null }, initWithSelector: function(a, b, c, d, e, f) { this._scheduler = a; this._target = c; this._selector = b; this.setupTimerWithInterval(d, e, f); return !0 }, getSelector: function() { return this._selector }, trigger: function() { this._target && this._selector && this._target.call(this._selector, this._elapsed) }, cancel: function() { this._scheduler.unschedule(this._selector, this._target) } }); cc.TimerTargetCallback = cc.Timer.extend({ _target: null, _callback: null, _key: null, ctor: function() { this._callback = this._target = null }, initWithCallback: function(a, b, c, d, e, f, g) { this._scheduler = a; this._target = c; this._callback = b; this._key = d; this.setupTimerWithInterval(e, f, g); return !0 }, getCallback: function() { return this._callback }, getKey: function() { return this._key }, trigger: function() { this._callback && this._callback.call(this._target, this._elapsed) }, cancel: function() { this._scheduler.unschedule(this._key, this._target) } }); cc.Scheduler = cc.Class.extend({ _timeScale: 1, _updatesNegList: null, _updates0List: null, _updatesPosList: null, _hashForTimers: null, _arrayForTimers: null, _hashForUpdates: null, _currentTarget: null, _currentTargetSalvaged: !1, _updateHashLocked: !1, ctor: function() { this._timeScale = 1; this._updatesNegList = []; this._updates0List = []; this._updatesPosList = []; this._hashForUpdates = {}; this._hashForTimers = {}; this._currentTarget = null; this._updateHashLocked = this._currentTargetSalvaged = !1; this._arrayForTimers = [] }, _schedulePerFrame: function(a, b, c, d) { var e = this._hashForUpdates[b.__instanceId]; if (e && e.entry) if (e.entry.priority !== c) { if (this._updateHashLocked) { cc.log("warning: you CANNOT change update priority in scheduled function"); e.entry.markedForDeletion = !1; e.entry.paused = d; return } this.unscheduleUpdate(b) } else { e.entry.markedForDeletion = !1; e.entry.paused = d; return } 0 === c ? this._appendIn(this._updates0List, a, b, d) : 0 > c ? this._priorityIn(this._updatesNegList, a, b, c, d) : this._priorityIn(this._updatesPosList, a, b, c, d) }, _removeHashElement: function(a) { delete this._hashForTimers[a.target.__instanceId]; cc.arrayRemoveObject(this._arrayForTimers, a); a.Timer = null; a.target = null }, _removeUpdateFromHash: function(a) { if (a = this._hashForUpdates[a.target.__instanceId]) cc.arrayRemoveObject(a.list, a.entry), delete this._hashForUpdates[a.target.__instanceId], a.entry = null, a.target = null }, _priorityIn: function(a, b, c, d, e) { b = new cc.ListEntry(null, null, b, c, d, e, !1); if (a) { e = a.length - 1; for (var f = 0; f <= e && !(d < a[f].priority); f++); a.splice(f, 0, b) } else a = [], a.push(b); this._hashForUpdates[c.__instanceId] = new cc.HashUpdateEntry(a, b, c, null); return a }, _appendIn: function(a, b, c, d) { b = new cc.ListEntry(null, null, b, c, 0, d, !1); a.push(b); this._hashForUpdates[c.__instanceId] = new cc.HashUpdateEntry(a, b, c, null, null) }, setTimeScale: function(a) { this._timeScale = a }, getTimeScale: function() { return this._timeScale }, update: function(a) { this._updateHashLocked = !0; 1 !== this._timeScale && (a *= this._timeScale); var b, c, d, e; b = 0; c = this._updatesNegList; for (d = c.length; b < d; b++) e = c[b], e.paused || e.markedForDeletion || e.callback(a); b = 0; c = this._updates0List; for (d = c.length; b < d; b++) e = c[b], e.paused || e.markedForDeletion || e.callback(a); b = 0; c = this._updatesPosList; for (d = c.length; b < d; b++) e = c[b], e.paused || e.markedForDeletion || e.callback(a); d = this._arrayForTimers; for (b = 0; b < d.length; b++) { this._currentTarget = c = d[b]; this._currentTargetSalvaged = !1; if (!c.paused) for (c.timerIndex = 0; c.timerIndex < c.timers.length; ++c.timerIndex) c.currentTimer = c.timers[c.timerIndex], c.currentTimerSalvaged = !1, c.currentTimer.update(a), c.currentTimer = null; this._currentTargetSalvaged && 0 === this._currentTarget.timers.length && this._removeHashElement(this._currentTarget) } b = 0; for (c = this._updatesNegList; b < c.length;) e = c[b], e.markedForDeletion ? this._removeUpdateFromHash(e) : b++; b = 0; for (c = this._updates0List; b < c.length;) e = c[b], e.markedForDeletion ? this._removeUpdateFromHash(e) : b++; b = 0; for (c = this._updatesPosList; b < c.length;) e = c[b], e.markedForDeletion ? this._removeUpdateFromHash(e) : b++; this._updateHashLocked = !1; this._currentTarget = null }, scheduleCallbackForTarget: function(a, b, c, d, e, f) { this.schedule(b, a, c, d, e, f, a.__instanceId + "") }, schedule: function(a, b, c, d, e, f, g) { var h = !1; if ("function" !== typeof a) var k = a, h = !0; !1 === h ? 5 === arguments.length && (g = e, f = d, e = 0, d = cc.REPEAT_FOREVER) : 4 === arguments.length && (f = d, d = cc.REPEAT_FOREVER, e = 0); cc.assert(b, cc._LogInfos.Scheduler_scheduleCallbackForTarget_3); !1 === h && cc.assert(g, "key should not be empty!"); var m = this._hashForTimers[b.__instanceId]; m ? cc.assert(m.paused === f, "") : (m = new cc.HashTimerEntry(null, b, 0, null, null, f, null), this._arrayForTimers.push(m), this._hashForTimers[b.__instanceId] = m); var n, p; if (null == m.timers) m.timers = []; else if (!1 === h) for (p = 0; p < m.timers.length; p++) { if (n = m.timers[p], a === n._callback) { cc.log(cc._LogInfos.Scheduler_scheduleCallbackForTarget, n.getInterval().toFixed(4), c.toFixed(4)); n._interval = c; return } } else for (p = 0; p < m.timers.length; ++p) if ((n = m.timers[p]) && k === n.getSelector()) { cc.log("CCScheduler#scheduleSelector. Selector already scheduled. Updating interval from: %.4f to %.4f", n.getInterval(), c); n.setInterval(c); return }!1 === h ? (n = new cc.TimerTargetCallback, n.initWithCallback(this, a, b, g, c, d, e)) : (n = new cc.TimerTargetSelector, n.initWithSelector(this, k, b, c, d, e)); m.timers.push(n) }, scheduleUpdate: function(a, b, c) { this._schedulePerFrame(function(b) { a.update(b) }, a, b, c) }, _getUnscheduleMark: function(a, b) { switch (typeof a) { case "number": case "string": return a === b.getKey(); case "function": return a === b._callback; default: return a === b.getSelector() } }, unschedule: function(a, b) { if (b && a) { var c = this._hashForTimers[b.__instanceId]; if (c) for (var d = c.timers, e = 0, f = d.length; e < f; e++) { var g = d[e]; if (this._getUnscheduleMark(a, g)) { g !== c.currentTimer || c.currentTimerSalvaged || (c.currentTimerSalvaged = !0); d.splice(e, 1); c.timerIndex >= e && c.timerIndex--; 0 === d.length && (this._currentTarget === c ? this._currentTargetSalvaged = !0 : this._removeHashElement(c)); break } } } }, unscheduleUpdate: function(a) { null != a && (a = this._hashForUpdates[a.__instanceId]) && (this._updateHashLocked ? a.entry.markedForDeletion = !0 : this._removeUpdateFromHash(a.entry)) }, unscheduleAllForTarget: function(a) { if (null != a) { var b = this._hashForTimers[a.__instanceId]; b && (-1 < b.timers.indexOf(b.currentTimer) && !b.currentTimerSalvaged && (b.currentTimerSalvaged = !0), b.timers.length = 0, this._currentTarget === b ? this._currentTargetSalvaged = !0 : this._removeHashElement(b)); this.unscheduleUpdate(a) } }, unscheduleAll: function() { this.unscheduleAllWithMinPriority(cc.Scheduler.PRIORITY_SYSTEM) }, unscheduleAllWithMinPriority: function(a) { var b, c, d = this._arrayForTimers; for (b = 0; b < d.length; b++) c = d[b], this.unscheduleAllForTarget(c.target); if (0 > a) for (b = 0; b < this._updatesNegList.length; b++)(c = this._updatesNegList[b]) && c.priority >= a && this.unscheduleUpdate(c.target); if (0 >= a) for (b = 0; b < this._updates0List.length; b++)(c = this._updates0List[b]) && this.unscheduleUpdate(c.target); for (b = 0; b < this._updatesPosList.length; b++)(c = this._updatesPosList[b]) && c.priority >= a && this.unscheduleUpdate(c.target) }, isScheduled: function(a, b) { cc.assert(a, "Argument key must not be empty"); cc.assert(b, "Argument target must be non-nullptr"); var c = this._hashForUpdates[b.__instanceId]; if (!c) return !1; if (null != c.timers) for (var c = c.timers, d = 0; d < c.length; ++d) if (a === c[d].getKey()) return !0; return !1 }, pauseAllTargets: function() { return this.pauseAllTargetsWithMinPriority(cc.Scheduler.PRIORITY_SYSTEM) }, pauseAllTargetsWithMinPriority: function(a) { var b = [], c, d = this._arrayForTimers, e, f; e = 0; for (f = d.length; e < f; e++) if (c = d[e]) c.paused = !0, b.push(c.target); if (0 > a) for (e = 0; e < this._updatesNegList.length; e++)(d = this._updatesNegList[e]) && d.priority >= a && (c.paused = !0, b.push(c.target)); if (0 >= a) for (e = 0; e < this._updates0List.length; e++) if (d = this._updates0List[e]) c.paused = !0, b.push(c.target); for (e = 0; e < this._updatesPosList.length; e++)(d = this._updatesPosList[e]) && d.priority >= a && (c.paused = !0, b.push(c.target)); return b }, resumeTargets: function(a) { if (a) for (var b = 0; b < a.length; b++) this.resumeTarget(a[b]) }, pauseTarget: function(a) { cc.assert(a, cc._LogInfos.Scheduler_pauseTarget); var b = this._hashForTimers[a.__instanceId]; b && (b.paused = !0); if (a = this._hashForUpdates[a.__instanceId]) a.entry.paused = !0 }, resumeTarget: function(a) { cc.assert(a, cc._LogInfos.Scheduler_resumeTarget); var b = this._hashForTimers[a.__instanceId]; b && (b.paused = !1); if (a = this._hashForUpdates[a.__instanceId]) a.entry.paused = !1 }, isTargetPaused: function(a) { cc.assert(a, cc._LogInfos.Scheduler_isTargetPaused); var b = this._hashForTimers[a.__instanceId]; return b ? b.paused : (a = this._hashForUpdates[a.__instanceId]) ? a.entry.paused : !1 }, scheduleUpdateForTarget: function(a, b, c) { this.scheduleUpdate(a, b, c) }, unscheduleCallbackForTarget: function(a, b) { this.unschedule(b, a) }, unscheduleUpdateForTarget: function(a) { this.unscheduleUpdate(a) }, unscheduleAllCallbacksForTarget: function(a) { this.unschedule(a.__instanceId + "", a) }, unscheduleAllCallbacks: function() { this.unscheduleAllWithMinPriority(cc.Scheduler.PRIORITY_SYSTEM) }, unscheduleAllCallbacksWithMinPriority: function(a) { this.unscheduleAllWithMinPriority(a) } }); cc.Scheduler.PRIORITY_SYSTEM = -2147483648; cc.PI2 = 2 * Math.PI; cc.DrawingPrimitiveCanvas = cc.Class.extend({ _cacheArray: [], _renderContext: null, ctor: function(a) { this._renderContext = a }, drawPoint: function(a, b) { b || (b = 1); var c = cc.view.getScaleX(), d = cc.view.getScaleY(), d = cc.p(a.x * c, a.y * d), e = this._renderContext.getContext(); e.beginPath(); e.arc(d.x, -d.y, b * c, 0, 2 * Math.PI, !1); e.closePath(); e.fill() }, drawPoints: function(a, b, c) { if (null != a) { c || (c = 1); b = this._renderContext.getContext(); var d = cc.view.getScaleX(), e = cc.view.getScaleY(); b.beginPath(); for (var f = 0, g = a.length; f < g; f++) b.arc(a[f].x * d, -a[f].y * e, c * d, 0, 2 * Math.PI, !1); b.closePath(); b.fill() } }, drawLine: function(a, b) { var c = this._renderContext.getContext(), d = cc.view.getScaleX(), e = cc.view.getScaleY(); c.beginPath(); c.moveTo(a.x * d, -a.y * e); c.lineTo(b.x * d, -b.y * e); c.closePath(); c.stroke() }, drawRect: function(a, b) { this.drawLine(cc.p(a.x, a.y), cc.p(b.x, a.y)); this.drawLine(cc.p(b.x, a.y), cc.p(b.x, b.y)); this.drawLine(cc.p(b.x, b.y), cc.p(a.x, b.y)); this.drawLine(cc.p(a.x, b.y), cc.p(a.x, a.y)) }, drawSolidRect: function(a, b, c) { a = [a, cc.p(b.x, a.y), b, cc.p(a.x, b.y)]; this.drawSolidPoly(a, 4, c) }, drawPoly: function(a, b, c, d) { d = d || !1; if (null != a) { if (3 > a.length) throw Error("Polygon's point must greater than 2"); var e = a[0]; b = this._renderContext.getContext(); var f = cc.view.getScaleX(), g = cc.view.getScaleY(); b.beginPath(); b.moveTo(e.x * f, -e.y * g); for (var e = 1, h = a.length; e < h; e++) b.lineTo(a[e].x * f, -a[e].y * g); c && b.closePath(); d ? b.fill() : b.stroke() } }, drawSolidPoly: function(a, b, c) { this.setDrawColor(c.r, c.g, c.b, c.a); this.drawPoly(a, b, !0, !0) }, drawCircle: function(a, b, c, d, e) { e = e || !1; d = this._renderContext.getContext(); var f = cc.view.getScaleX(), g = cc.view.getScaleY(); d.beginPath(); d.arc(0 | a.x * f, 0 | -(a.y * g), b * f, -c, -(c - 2 * Math.PI), !1); e && d.lineTo(0 | a.x * f, 0 | -(a.y * g)); d.stroke() }, drawQuadBezier: function(a, b, c, d) { for (var e = this._cacheArray, f = e.length = 0, g = 0; g < d; g++) { var h = Math.pow(1 - f, 2) * a.x + 2 * (1 - f) * f * b.x + f * f * c.x, k = Math.pow(1 - f, 2) * a.y + 2 * (1 - f) * f * b.y + f * f * c.y; e.push(cc.p(h, k)); f += 1 / d } e.push(cc.p(c.x, c.y)); this.drawPoly(e, d + 1, !1, !1) }, drawCubicBezier: function(a, b, c, d, e) { for (var f = this._cacheArray, g = f.length = 0, h = 0; h < e; h++) { var k = Math.pow(1 - g, 3) * a.x + 3 * Math.pow(1 - g, 2) * g * b.x + 3 * (1 - g) * g * g * c.x + g * g * g * d.x, m = Math.pow(1 - g, 3) * a.y + 3 * Math.pow(1 - g, 2) * g * b.y + 3 * (1 - g) * g * g * c.y + g * g * g * d.y; f.push(cc.p(k, m)); g += 1 / e } f.push(cc.p(d.x, d.y)); this.drawPoly(f, e + 1, !1, !1) }, drawCatmullRom: function(a, b) { this.drawCardinalSpline(a, 0.5, b) }, drawCardinalSpline: function(a, b, c) { cc._renderContext.setStrokeStyle("rgba(255,255,255,1)"); var d = this._cacheArray; d.length = 0; for (var e, f, g = 1 / a.length, h = 0; h < c + 1; h++) f = h / c, 1 === f ? (e = a.length - 1, f = 1) : (e = 0 | f / g, f = (f - g * e) / g), e = cc.CardinalSplineAt(cc.getControlPointAt(a, e - 1), cc.getControlPointAt(a, e - 0), cc.getControlPointAt(a, e + 1), cc.getControlPointAt(a, e + 2), b, f), d.push(e); this.drawPoly(d, c + 1, !1, !1) }, drawImage: function(a, b, c, d, e) { var f = arguments.length, g = this._renderContext.getContext(); switch (f) { case 2: g.drawImage(a, b.x, -(b.y + a.height)); break; case 3: g.drawImage(a, b.x, -(b.y + c.height), c.width, c.height); break; case 5: g.drawImage(a, b.x, b.y, c.width, c.height, d.x, -(d.y + e.height), e.width, e.height); break; default: throw Error("Argument must be non-nil"); } }, drawStar: function(a, b, c) { a = a || this._renderContext; var d = a.getContext(); b *= cc.view.getScaleX(); c = "rgba(" + (0 | c.r) + "," + (0 | c.g) + "," + (0 | c.b); a.setFillStyle(c + ",1)"); var e = b / 10; d.beginPath(); d.moveTo(-b, b); d.lineTo(0, e); d.lineTo(b, b); d.lineTo(e, 0); d.lineTo(b, -b); d.lineTo(0, -e); d.lineTo(-b, -b); d.lineTo(-e, 0); d.lineTo(-b, b); d.closePath(); d.fill(); var f = d.createRadialGradient(0, 0, e, 0, 0, b); f.addColorStop(0, c + ", 1)"); f.addColorStop(0.3, c + ", 0.8)"); f.addColorStop(1, c + ", 0.0)"); a.setFillStyle(f); d.beginPath(); d.arc(0, 0, b - e, 0, cc.PI2, !1); d.closePath(); d.fill() }, drawColorBall: function(a, b, c) { a = a || this._renderContext; var d = a.getContext(); b *= cc.view.getScaleX(); c = "rgba(" + (0 | c.r) + "," + (0 | c.g) + "," + (0 | c.b); var e = d.createRadialGradient(0, 0, b / 10, 0, 0, b); e.addColorStop(0, c + ", 1)"); e.addColorStop(0.3, c + ", 0.8)"); e.addColorStop(0.6, c + ", 0.4)"); e.addColorStop(1, c + ", 0.0)"); a.setFillStyle(e); d.beginPath(); d.arc(0, 0, b, 0, cc.PI2, !1); d.closePath(); d.fill() }, fillText: function(a, b, c) { this._renderContext.getContext().fillText(a, b, -c) }, setDrawColor: function(a, b, c, d) { this._renderContext.setFillStyle("rgba(" + a + "," + b + "," + c + "," + d / 255 + ")"); this._renderContext.setStrokeStyle("rgba(" + a + "," + b + "," + c + "," + d / 255 + ")") }, setPointSize: function(a) {}, setLineWidth: function(a) { this._renderContext.getContext().lineWidth = a * cc.view.getScaleX() } }); cc.DrawingPrimitiveWebGL = cc.Class.extend({ _renderContext: null, _initialized: !1, _shader: null, _colorLocation: -1, _colorArray: null, _pointSizeLocation: -1, _pointSize: -1, ctor: function(a) { null == a && (a = cc._renderContext); if (!a instanceof WebGLRenderingContext) throw "Can't initialise DrawingPrimitiveWebGL. context need is WebGLRenderingContext"; this._renderContext = a; this._colorArray = new Float32Array([1, 1, 1, 1]) }, lazy_init: function() { this._initialized || (this._shader = cc.shaderCache.programForKey(cc.SHADER_POSITION_UCOLOR), this._colorLocation = this._renderContext.getUniformLocation(this._shader.getProgram(), "u_color"), this._pointSizeLocation = this._renderContext.getUniformLocation(this._shader.getProgram(), "u_pointSize"), this._initialized = !0) }, drawInit: function() { this._initialized = !1 }, drawPoint: function(a) { this.lazy_init(); var b = this._renderContext; this._shader.use(); this._shader.setUniformForModelViewAndProjectionMatrixWithMat4(); cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION); b.uniform4fv(this._colorLocation, this._colorArray); this._shader.setUniformLocationWith1f(this._pointSizeLocation, this._pointSize); var c = b.createBuffer(); b.bindBuffer(b.ARRAY_BUFFER, c); b.bufferData(b.ARRAY_BUFFER, new Float32Array([a.x, a.y]), b.STATIC_DRAW); b.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, b.FLOAT, !1, 0, 0); b.drawArrays(b.POINTS, 0, 1); b.deleteBuffer(c); cc.incrementGLDraws(1) }, drawPoints: function(a, b) { if (a && 0 !== a.length) { this.lazy_init(); var c = this._renderContext; this._shader.use(); this._shader.setUniformForModelViewAndProjectionMatrixWithMat4(); cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION); c.uniform4fv(this._colorLocation, this._colorArray); this._shader.setUniformLocationWith1f(this._pointSizeLocation, this._pointSize); var d = c.createBuffer(); c.bindBuffer(c.ARRAY_BUFFER, d); c.bufferData(c.ARRAY_BUFFER, this._pointsToTypeArray(a), c.STATIC_DRAW); c.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, c.FLOAT, !1, 0, 0); c.drawArrays(c.POINTS, 0, a.length); c.deleteBuffer(d); cc.incrementGLDraws(1) } }, _pointsToTypeArray: function(a) { for (var b = new Float32Array(2 * a.length), c = 0; c < a.length; c++) b[2 * c] = a[c].x, b[2 * c + 1] = a[c].y; return b }, drawLine: function(a, b) { this.lazy_init(); var c = this._renderContext; this._shader.use(); this._shader.setUniformForModelViewAndProjectionMatrixWithMat4(); cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION); c.uniform4fv(this._colorLocation, this._colorArray); var d = c.createBuffer(); c.bindBuffer(c.ARRAY_BUFFER, d); c.bufferData(c.ARRAY_BUFFER, this._pointsToTypeArray([a, b]), c.STATIC_DRAW); c.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, c.FLOAT, !1, 0, 0); c.drawArrays(c.LINES, 0, 2); c.deleteBuffer(d); cc.incrementGLDraws(1) }, drawRect: function(a, b) { this.drawLine(cc.p(a.x, a.y), cc.p(b.x, a.y)); this.drawLine(cc.p(b.x, a.y), cc.p(b.x, b.y)); this.drawLine(cc.p(b.x, b.y), cc.p(a.x, b.y)); this.drawLine(cc.p(a.x, b.y), cc.p(a.x, a.y)) }, drawSolidRect: function(a, b, c) { a = [a, cc.p(b.x, a.y), b, cc.p(a.x, b.y)]; this.drawSolidPoly(a, 4, c) }, drawPoly: function(a, b, c) { this.lazy_init(); b = this._renderContext; this._shader.use(); this._shader.setUniformForModelViewAndProjectionMatrixWithMat4(); cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION); b.uniform4fv(this._colorLocation, this._colorArray); var d = b.createBuffer(); b.bindBuffer(b.ARRAY_BUFFER, d); b.bufferData(b.ARRAY_BUFFER, this._pointsToTypeArray(a), b.STATIC_DRAW); b.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, b.FLOAT, !1, 0, 0); c ? b.drawArrays(b.LINE_LOOP, 0, a.length) : b.drawArrays(b.LINE_STRIP, 0, a.length); b.deleteBuffer(d); cc.incrementGLDraws(1) }, drawSolidPoly: function(a, b, c) { this.lazy_init(); c && this.setDrawColor(c.r, c.g, c.b, c.a); b = this._renderContext; this._shader.use(); this._shader.setUniformForModelViewAndProjectionMatrixWithMat4(); cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION); b.uniform4fv(this._colorLocation, this._colorArray); c = b.createBuffer(); b.bindBuffer(b.ARRAY_BUFFER, c); b.bufferData(b.ARRAY_BUFFER, this._pointsToTypeArray(a), b.STATIC_DRAW); b.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, b.FLOAT, !1, 0, 0); b.drawArrays(b.TRIANGLE_FAN, 0, a.length); b.deleteBuffer(c); cc.incrementGLDraws(1) }, drawCircle: function(a, b, c, d, e) { this.lazy_init(); var f = 1; e && f++; var g = 2 * Math.PI / d; if (e = new Float32Array(2 * (d + 2))) { for (var h = 0; h <= d; h++) { var k = h * g, m = b * Math.cos(k + c) + a.x, k = b * Math.sin(k + c) + a.y; e[2 * h] = m; e[2 * h + 1] = k } e[2 * (d + 1)] = a.x; e[2 * (d + 1) + 1] = a.y; a = this._renderContext; this._shader.use(); this._shader.setUniformForModelViewAndProjectionMatrixWithMat4(); cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION); a.uniform4fv(this._colorLocation, this._colorArray); b = a.createBuffer(); a.bindBuffer(a.ARRAY_BUFFER, b); a.bufferData(a.ARRAY_BUFFER, e, a.STATIC_DRAW); a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, a.FLOAT, !1, 0, 0); a.drawArrays(a.LINE_STRIP, 0, d + f); a.deleteBuffer(b); cc.incrementGLDraws(1) } }, drawQuadBezier: function(a, b, c, d) { this.lazy_init(); for (var e = new Float32Array(2 * (d + 1)), f = 0, g = 0; g < d; g++) e[2 * g] = Math.pow(1 - f, 2) * a.x + 2 * (1 - f) * f * b.x + f * f * c.x, e[2 * g + 1] = Math.pow(1 - f, 2) * a.y + 2 * (1 - f) * f * b.y + f * f * c.y, f += 1 / d; e[2 * d] = c.x; e[2 * d + 1] = c.y; a = this._renderContext; this._shader.use(); this._shader.setUniformForModelViewAndProjectionMatrixWithMat4(); cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION); a.uniform4fv(this._colorLocation, this._colorArray); b = a.createBuffer(); a.bindBuffer(a.ARRAY_BUFFER, b); a.bufferData(a.ARRAY_BUFFER, e, a.STATIC_DRAW); a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, a.FLOAT, !1, 0, 0); a.drawArrays(a.LINE_STRIP, 0, d + 1); a.deleteBuffer(b); cc.incrementGLDraws(1) }, drawCubicBezier: function(a, b, c, d, e) { this.lazy_init(); for (var f = new Float32Array(2 * (e + 1)), g = 0, h = 0; h < e; h++) f[2 * h] = Math.pow(1 - g, 3) * a.x + 3 * Math.pow(1 - g, 2) * g * b.x + 3 * (1 - g) * g * g * c.x + g * g * g * d.x, f[2 * h + 1] = Math.pow(1 - g, 3) * a.y + 3 * Math.pow(1 - g, 2) * g * b.y + 3 * (1 - g) * g * g * c.y + g * g * g * d.y, g += 1 / e; f[2 * e] = d.x; f[2 * e + 1] = d.y; a = this._renderContext; this._shader.use(); this._shader.setUniformForModelViewAndProjectionMatrixWithMat4(); cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION); a.uniform4fv(this._colorLocation, this._colorArray); b = a.createBuffer(); a.bindBuffer(a.ARRAY_BUFFER, b); a.bufferData(a.ARRAY_BUFFER, f, a.STATIC_DRAW); a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, a.FLOAT, !1, 0, 0); a.drawArrays(a.LINE_STRIP, 0, e + 1); a.deleteBuffer(b); cc.incrementGLDraws(1) }, drawCatmullRom: function(a, b) { this.drawCardinalSpline(a, 0.5, b) }, drawCardinalSpline: function(a, b, c) { this.lazy_init(); for (var d = new Float32Array(2 * (c + 1)), e, f, g = 1 / a.length, h = 0; h < c + 1; h++) f = h / c, 1 === f ? (e = a.length - 1, f = 1) : (e = 0 | f / g, f = (f - g * e) / g), e = cc.cardinalSplineAt(cc.getControlPointAt(a, e - 1), cc.getControlPointAt(a, e), cc.getControlPointAt(a, e + 1), cc.getControlPointAt(a, e + 2), b, f), d[2 * h] = e.x, d[2 * h + 1] = e.y; a = this._renderContext; this._shader.use(); this._shader.setUniformForModelViewAndProjectionMatrixWithMat4(); cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION); a.uniform4fv(this._colorLocation, this._colorArray); b = a.createBuffer(); a.bindBuffer(a.ARRAY_BUFFER, b); a.bufferData(a.ARRAY_BUFFER, d, a.STATIC_DRAW); a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, a.FLOAT, !1, 0, 0); a.drawArrays(a.LINE_STRIP, 0, c + 1); a.deleteBuffer(b); cc.incrementGLDraws(1) }, setDrawColor: function(a, b, c, d) { this._colorArray[0] = a / 255; this._colorArray[1] = b / 255; this._colorArray[2] = c / 255; this._colorArray[3] = d / 255 }, setPointSize: function(a) { this._pointSize = a * cc.contentScaleFactor() }, setLineWidth: function(a) { this._renderContext.lineWidth && this._renderContext.lineWidth(a) } }); cc._tmp.PrototypeLabelTTF = function() { var a = cc.LabelTTF.prototype; cc.defineGetterSetter(a, "color", a.getColor, a.setColor); cc.defineGetterSetter(a, "opacity", a.getOpacity, a.setOpacity); cc.defineGetterSetter(a, "string", a.getString, a.setString); cc.defineGetterSetter(a, "textAlign", a.getHorizontalAlignment, a.setHorizontalAlignment); cc.defineGetterSetter(a, "verticalAlign", a.getVerticalAlignment, a.setVerticalAlignment); cc.defineGetterSetter(a, "fontSize", a.getFontSize, a.setFontSize); cc.defineGetterSetter(a, "fontName", a.getFontName, a.setFontName); cc.defineGetterSetter(a, "font", a._getFont, a._setFont); cc.defineGetterSetter(a, "boundingWidth", a._getBoundingWidth, a._setBoundingWidth); cc.defineGetterSetter(a, "boundingHeight", a._getBoundingHeight, a._setBoundingHeight); cc.defineGetterSetter(a, "fillStyle", a._getFillStyle, a.setFontFillColor); cc.defineGetterSetter(a, "strokeStyle", a._getStrokeStyle, a._setStrokeStyle); cc.defineGetterSetter(a, "lineWidth", a._getLineWidth, a._setLineWidth); cc.defineGetterSetter(a, "shadowOffsetX", a._getShadowOffsetX, a._setShadowOffsetX); cc.defineGetterSetter(a, "shadowOffsetY", a._getShadowOffsetY, a._setShadowOffsetY); cc.defineGetterSetter(a, "shadowOpacity", a._getShadowOpacity, a._setShadowOpacity); cc.defineGetterSetter(a, "shadowBlur", a._getShadowBlur, a._setShadowBlur) }; cc.LabelTTF = cc.Sprite.extend({ _dimensions: null, _hAlignment: cc.TEXT_ALIGNMENT_CENTER, _vAlignment: cc.VERTICAL_TEXT_ALIGNMENT_TOP, _fontName: null, _fontSize: 0, _string: "", _originalText: null, _shadowEnabled: !1, _shadowOffset: null, _shadowOpacity: 0, _shadowBlur: 0, _shadowColor: null, _strokeEnabled: !1, _strokeColor: null, _strokeSize: 0, _textFillColor: null, _strokeShadowOffsetX: 0, _strokeShadowOffsetY: 0, _needUpdateTexture: !1, _lineWidths: null, _className: "LabelTTF", _fontStyle: "normal", _fontWeight: "normal", _lineHeight: "normal", initWithString: function(a, b, c, d, e, f) { a = a ? a + "" : ""; c = c || 16; d = d || cc.size(0, 0); e = e || cc.TEXT_ALIGNMENT_LEFT; f = f || cc.VERTICAL_TEXT_ALIGNMENT_TOP; this._opacityModifyRGB = !1; this._dimensions = cc.size(d.width, d.height); this._fontName = b || "Arial"; this._hAlignment = e; this._vAlignment = f; this._fontSize = c; this._renderCmd._setFontStyle(this._fontName, c, this._fontStyle, this._fontWeight); this.string = a; this._renderCmd._setColorsString(); this._renderCmd._updateTexture(); this._setUpdateTextureDirty(); return !0 }, _setUpdateTextureDirty: function() { this._needUpdateTexture = !0; this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.textDirty) }, ctor: function(a, b, c, d, e, f) { cc.Sprite.prototype.ctor.call(this); this._dimensions = cc.size(0, 0); this._hAlignment = cc.TEXT_ALIGNMENT_LEFT; this._vAlignment = cc.VERTICAL_TEXT_ALIGNMENT_TOP; this._opacityModifyRGB = !1; this._fontName = "Arial"; this._shadowEnabled = !1; this._shadowOffset = cc.p(0, 0); this._shadowBlur = this._shadowOpacity = 0; this._strokeEnabled = !1; this._strokeColor = cc.color(255, 255, 255, 255); this._strokeSize = 0; this._textFillColor = cc.color(255, 255, 255, 255); this._strokeShadowOffsetY = this._strokeShadowOffsetX = 0; this._needUpdateTexture = !1; this._lineWidths = []; this._renderCmd._setColorsString(); this._textureLoaded = !0; b && b instanceof cc.FontDefinition ? this.initWithStringAndTextDefinition(a, b) : cc.LabelTTF.prototype.initWithString.call(this, a, b, c, d, e, f) }, init: function() { return this.initWithString(" ", this._fontName, this._fontSize) }, description: function() { return "\x3ccc.LabelTTF | FontName \x3d" + this._fontName + " FontSize \x3d " + this._fontSize.toFixed(1) + "\x3e" }, getLineHeight: function() { return !this._lineHeight || this._lineHeight.charAt ? this._renderCmd._getFontClientHeight() : this._lineHeight || this._renderCmd._getFontClientHeight() }, setLineHeight: function(a) { this._lineHeight = a }, getString: function() { return this._string }, getHorizontalAlignment: function() { return this._hAlignment }, getVerticalAlignment: function() { return this._vAlignment }, getDimensions: function() { return cc.size(this._dimensions) }, getFontSize: function() { return this._fontSize }, getFontName: function() { return this._fontName }, initWithStringAndTextDefinition: function(a, b) { this._updateWithTextDefinition(b, !1); this.string = a; return !0 }, setTextDefinition: function(a) { a && this._updateWithTextDefinition(a, !0) }, getTextDefinition: function() { return this._prepareTextDefinition(!1) }, enableShadow: function(a, b, c, d) { null != a.r && null != a.g && null != a.b && null != a.a ? this._enableShadow(a, b, c) : this._enableShadowNoneColor(a, b, c, d) }, _enableShadowNoneColor: function(a, b, c, d) { c = c || 0.5; !1 === this._shadowEnabled && (this._shadowEnabled = !0); var e = this._shadowOffset; if (e && e.x !== a || e._y !== b) e.x = a, e.y = b; this._shadowOpacity !== c && (this._shadowOpacity = c); this._renderCmd._setColorsString(); this._shadowBlur !== d && (this._shadowBlur = d); this._setUpdateTextureDirty() }, _enableShadow: function(a, b, c) { this._shadowColor || (this._shadowColor = cc.color(255, 255, 255, 128)); this._shadowColor.r = a.r; this._shadowColor.g = a.g; this._shadowColor.b = a.b; this._enableShadowNoneColor(b.width || b.x || 0, b.height || b.y || 0, null != a.a ? a.a / 255 : 0.5, c) }, _getShadowOffsetX: function() { return this._shadowOffset.x }, _setShadowOffsetX: function(a) { !1 === this._shadowEnabled && (this._shadowEnabled = !0); this._shadowOffset.x !== a && (this._shadowOffset.x = a, this._setUpdateTextureDirty()) }, _getShadowOffsetY: function() { return this._shadowOffset._y }, _setShadowOffsetY: function(a) { !1 === this._shadowEnabled && (this._shadowEnabled = !0); this._shadowOffset._y !== a && (this._shadowOffset._y = a, this._setUpdateTextureDirty()) }, _getShadowOffset: function() { return cc.p(this._shadowOffset.x, this._shadowOffset.y) }, _setShadowOffset: function(a) { !1 === this._shadowEnabled && (this._shadowEnabled = !0); if (this._shadowOffset.x !== a.x || this._shadowOffset.y !== a.y) this._shadowOffset.x = a.x, this._shadowOffset.y = a.y, this._setUpdateTextureDirty() }, _getShadowOpacity: function() { return this._shadowOpacity }, _setShadowOpacity: function(a) { !1 === this._shadowEnabled && (this._shadowEnabled = !0); this._shadowOpacity !== a && (this._shadowOpacity = a, this._renderCmd._setColorsString(), this._setUpdateTextureDirty()) }, _getShadowBlur: function() { return this._shadowBlur }, _setShadowBlur: function(a) { !1 === this._shadowEnabled && (this._shadowEnabled = !0); this._shadowBlur !== a && (this._shadowBlur = a, this._setUpdateTextureDirty()) }, disableShadow: function() { this._shadowEnabled && (this._shadowEnabled = !1, this._setUpdateTextureDirty()) }, enableStroke: function(a, b) { !1 === this._strokeEnabled && (this._strokeEnabled = !0); var c = this._strokeColor; if (c.r !== a.r || c.g !== a.g || c.b !== a.b) c.r = a.r, c.g = a.g, c.b = a.b, this._renderCmd._setColorsString(); this._strokeSize !== b && (this._strokeSize = b || 0); this._setUpdateTextureDirty() }, _getStrokeStyle: function() { return this._strokeColor }, _setStrokeStyle: function(a) { !1 === this._strokeEnabled && (this._strokeEnabled = !0); var b = this._strokeColor; if (b.r !== a.r || b.g !== a.g || b.b !== a.b) b.r = a.r, b.g = a.g, b.b = a.b, this._renderCmd._setColorsString(), this._setUpdateTextureDirty() }, _getLineWidth: function() { return this._strokeSize }, _setLineWidth: function(a) { !1 === this._strokeEnabled && (this._strokeEnabled = !0); this._strokeSize !== a && (this._strokeSize = a || 0, this._setUpdateTextureDirty()) }, disableStroke: function() { this._strokeEnabled && (this._strokeEnabled = !1, this._setUpdateTextureDirty()) }, setFontFillColor: function(a) { var b = this._textFillColor; if (b.r !== a.r || b.g !== a.g || b.b !== a.b) b.r = a.r, b.g = a.g, b.b = a.b, this._renderCmd._setColorsString(), this._needUpdateTexture = !0 }, _getFillStyle: function() { return this._textFillColor }, _updateWithTextDefinition: function(a, b) { a.fontDimensions ? (this._dimensions.width = a.boundingWidth, this._dimensions.height = a.boundingHeight) : (this._dimensions.width = 0, this._dimensions.height = 0); this._hAlignment = a.textAlign; this._vAlignment = a.verticalAlign; this._fontName = a.fontName; this._fontSize = a.fontSize || 12; this._lineHeight = a.lineHeight ? a.lineHeight : this._fontSize; this._renderCmd._setFontStyle(a); a.shadowEnabled && this.enableShadow(a.shadowOffsetX, a.shadowOffsetY, a.shadowOpacity, a.shadowBlur); a.strokeEnabled && this.enableStroke(a.strokeStyle, a.lineWidth); this.setFontFillColor(a.fillStyle); b && this._renderCmd._updateTexture(); var c = cc.Node._dirtyFlags; this._renderCmd.setDirtyFlag(c.colorDirty | c.opacityDirty | c.textDirty) }, _prepareTextDefinition: function(a) { var b = new cc.FontDefinition; a ? (b.fontSize = this._fontSize, b.boundingWidth = cc.contentScaleFactor() * this._dimensions.width, b.boundingHeight = cc.contentScaleFactor() * this._dimensions.height) : (b.fontSize = this._fontSize, b.boundingWidth = this._dimensions.width, b.boundingHeight = this._dimensions.height); b.fontName = this._fontName; b.textAlign = this._hAlignment; b.verticalAlign = this._vAlignment; if (this._strokeEnabled) { b.strokeEnabled = !0; var c = this._strokeColor; b.strokeStyle = cc.color(c.r, c.g, c.b); b.lineWidth = this._strokeSize } else b.strokeEnabled = !1; this._shadowEnabled ? (b.shadowEnabled = !0, b.shadowBlur = this._shadowBlur, b.shadowOpacity = this._shadowOpacity, b.shadowOffsetX = (a ? cc.contentScaleFactor() : 1) * this._shadowOffset.x, b.shadowOffsetY = (a ? cc.contentScaleFactor() : 1) * this._shadowOffset.y) : b._shadowEnabled = !1; a = this._textFillColor; b.fillStyle = cc.color(a.r, a.g, a.b); return b }, setString: function(a) { a = String(a); this._originalText !== a && (this._originalText = a + "", this._updateString(), this._setUpdateTextureDirty(), this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)) }, _updateString: function() { this._string && "" !== this._string || this._string === this._originalText || (cc.renderer.childrenOrderDirty = !0); this._string = this._originalText }, setHorizontalAlignment: function(a) { a !== this._hAlignment && (this._hAlignment = a, this._setUpdateTextureDirty()) }, setVerticalAlignment: function(a) { a !== this._vAlignment && (this._vAlignment = a, this._setUpdateTextureDirty()) }, setDimensions: function(a, b) { var c; void 0 === b ? (c = a.width, b = a.height) : c = a; if (c !== this._dimensions.width || b !== this._dimensions.height) this._dimensions.width = c, this._dimensions.height = b, this._updateString(), this._setUpdateTextureDirty() }, _getBoundingWidth: function() { return this._dimensions.width }, _setBoundingWidth: function(a) { a !== this._dimensions.width && (this._dimensions.width = a, this._updateString(), this._setUpdateTextureDirty()) }, _getBoundingHeight: function() { return this._dimensions.height }, _setBoundingHeight: function(a) { a !== this._dimensions.height && (this._dimensions.height = a, this._updateString(), this._setUpdateTextureDirty()) }, setFontSize: function(a) { this._fontSize !== a && (this._fontSize = a, this._renderCmd._setFontStyle(this._fontName, this._fontSize, this._fontStyle, this._fontWeight), this._setUpdateTextureDirty()) }, setFontName: function(a) { this._fontName && this._fontName !== a && (this._fontName = a, this._renderCmd._setFontStyle(this._fontName, this._fontSize, this._fontStyle, this._fontWeight), this._setUpdateTextureDirty()) }, _getFont: function() { return this._renderCmd._getFontStyle() }, _setFont: function(a) { if (a = cc.LabelTTF._fontStyleRE.exec(a)) this._fontSize = parseInt(a[1]), this._fontName = a[2], this._renderCmd._setFontStyle(this._fontName, this._fontSize, this._fontStyle, this._fontWeight), this._setUpdateTextureDirty() }, getContentSize: function() { this._needUpdateTexture && this._renderCmd._updateTTF(); return cc.Sprite.prototype.getContentSize.call(this) }, _getWidth: function() { this._needUpdateTexture && this._renderCmd._updateTTF(); return cc.Sprite.prototype._getWidth.call(this) }, _getHeight: function() { this._needUpdateTexture && this._renderCmd._updateTTF(); return cc.Sprite.prototype._getHeight.call(this) }, setTextureRect: function(a, b, c) { cc.Sprite.prototype.setTextureRect.call(this, a, b, c, !1) }, _createRenderCmd: function() { return cc._renderType === cc._RENDER_TYPE_CANVAS ? new cc.LabelTTF.CanvasRenderCmd(this) : new cc.LabelTTF.WebGLRenderCmd(this) }, _setFontStyle: function(a) { this._fontStyle !== a && (this._fontStyle = a, this._renderCmd._setFontStyle(this._fontName, this._fontSize, this._fontStyle, this._fontWeight), this._setUpdateTextureDirty()) }, _getFontStyle: function() { return this._fontStyle }, _setFontWeight: function(a) { this._fontWeight !== a && (this._fontWeight = a, this._renderCmd._setFontStyle(this._fontName, this._fontSize, this._fontStyle, this._fontWeight), this._setUpdateTextureDirty()) }, _getFontWeight: function() { return this._fontWeight } }); cc.assert(cc.isFunction(cc._tmp.PrototypeLabelTTF), cc._LogInfos.MissingFile, "LabelTTFPropertyDefine.js"); cc._tmp.PrototypeLabelTTF(); delete cc._tmp.PrototypeLabelTTF; cc.LabelTTF._fontStyleRE = /^(\d+)px\s+['"]?([\w\s\d]+)['"]?$/; cc.LabelTTF.create = function(a, b, c, d, e, f) { return new cc.LabelTTF(a, b, c, d, e, f) }; cc.LabelTTF.createWithFontDefinition = cc.LabelTTF.create; cc.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(a, b) { if (a instanceof cc.FontDefinition) { var c = cc.LabelTTF.__fontHeightCache[a._getCanvasFontStr()]; if (0 < c) return c; var d = cc.LabelTTF.__labelHeightDiv; d.innerHTML = "ajghl~!"; d.style.fontFamily = a.fontName; d.style.fontSize = a.fontSize + "px"; d.style.fontStyle = a.fontStyle; d.style.fontWeight = a.fontWeight; c = d.clientHeight; cc.LabelTTF.__fontHeightCache[a._getCanvasFontStr()] = c; d.innerHTML = ""; return c } c = cc.LabelTTF.__fontHeightCache[a + "." + b]; if (0 < c) return c; d = cc.LabelTTF.__labelHeightDiv; d.innerHTML = "ajghl~!"; d.style.fontFamily = a; d.style.fontSize = b + "px"; c = d.clientHeight; cc.LabelTTF.__fontHeightCache[a + "." + b] = c; d.innerHTML = ""; return c }; cc.LabelTTF.__fontHeightCache = {}; cc.LabelTTF._textAlign = ["left", "center", "right"]; cc.LabelTTF._textBaseline = ["top", "middle", "bottom"]; cc.LabelTTF.wrapInspection = !0; cc.LabelTTF._wordRex = /([a-zA-Z0-9\u00c4\u00d6\u00dc\u00e4\u00f6\u00fc\u00df\u00e9\u00e8\u00e7\u00e0\u00f9\u00ea\u00e2\u00ee\u00f4\u00fb]+|\S)/; cc.LabelTTF._symbolRex = /^[!,.:;}\]%\?>\u3001\u2018\u201c\u300b\uff1f\u3002\uff0c\uff01]/; cc.LabelTTF._lastWordRex = /([a-zA-Z0-9\u00c4\u00d6\u00dc\u00e4\u00f6\u00fc\u00df\u00e9\u00e8\u00e7\u00e0\u00f9\u00ea\u00e2\u00ee\u00f4\u00fb]+|\S)$/; cc.LabelTTF._lastEnglish = /[a-zA-Z0-9\u00c4\u00d6\u00dc\u00e4\u00f6\u00fc\u00df\u00e9\u00e8\u00e7\u00e0\u00f9\u00ea\u00e2\u00ee\u00f4\u00fb]+$/; cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9\u00c4\u00d6\u00dc\u00e4\u00f6\u00fc\u00df\u00e9\u00e8\u00e7\u00e0\u00f9\u00ea\u00e2\u00ee\u00f4\u00fb]/; (function() { cc.LabelTTF.RenderCmd = function() { this._fontClientHeight = 18; this._fontStyleStr = ""; this._shadowColorStr = "rgba(128, 128, 128, 0.5)"; this._strokeColorStr = ""; this._fillColorStr = "rgba(255,255,255,1)"; this._labelContext = this._labelCanvas = null; this._lineWidths = []; this._strings = []; this._isMultiLine = !1 }; var a = cc.LabelTTF.RenderCmd.prototype; a.constructor = cc.LabelTTF.RenderCmd; a._getLabelContext = function() { if (this._labelContext) return this._labelContext; var a = this._node; if (!this._labelCanvas) { var c = cc.newElement("canvas"); c.width = 1; c.height = 1; var d = new cc.Texture2D; d.initWithElement(c); a.setTexture(d); this._labelCanvas = c } return this._labelContext = this._labelCanvas.getContext("2d") }; a._setFontStyle = function(a, c, d, e) { a instanceof cc.FontDefinition ? (this._fontStyleStr = a._getCanvasFontStr(), this._fontClientHeight = cc.LabelTTF.__getFontHeightByDiv(a)) : (this._fontStyleStr = d + " " + e + " " + c + "px '" + a + "'", this._fontClientHeight = cc.LabelTTF.__getFontHeightByDiv(a, c)) }; a._getFontStyle = function() { return this._fontStyleStr }; a._getFontClientHeight = function() { return this._fontClientHeight }; a._updateTexture = function() { this._dirtyFlag ^= this._dirtyFlag & cc.Node._dirtyFlags.textDirty; var a = this._node, c = this._getLabelContext(), d = this._labelCanvas, e = a._contentSize; if (0 === a._string.length) return d.width = 1, d.height = e.height || 1, a._texture && a._texture.handleLoadedTexture(), a.setTextureRect(cc.rect(0, 0, 1, e.height)), !0; c.font = this._fontStyleStr; this._updateTTF(); var f = e.width, e = e.height, g = d.width === f && d.height === e; d.width = f; d.height = e; g && c.clearRect(0, 0, f, e); this._drawTTFInCanvas(c); a._texture && a._texture.handleLoadedTexture(); a.setTextureRect(cc.rect(0, 0, f, e)); return !0 }; a._measureConfig = function() { this._getLabelContext().font = this._fontStyleStr }; a._measure = function(a) { return this._getLabelContext().measureText(a).width }; a._updateTTF = function() { var a = this._node, c = a._dimensions.width, d, e, f = this._lineWidths; f.length = 0; this._isMultiLine = !1; this._measureConfig(); if (0 !== c) for (this._strings = a._string.split("\n"), d = 0; d < this._strings.length; d++) this._checkWarp(this._strings, d, c); else for (this._strings = a._string.split("\n"), d = 0, e = this._strings.length; d < e; d++) f.push(this._measure(this._strings[d])); 0 < this._strings.length && (this._isMultiLine = !0); e = d = 0; a._strokeEnabled && (d = e = 2 * a._strokeSize); if (a._shadowEnabled) { var g = a._shadowOffset; d += 2 * Math.abs(g.x); e += 2 * Math.abs(g.y) } c = 0 === c ? this._isMultiLine ? cc.size(Math.ceil(Math.max.apply(Math, f) + d), Math.ceil(this._fontClientHeight * this._strings.length + e)) : cc.size(Math.ceil(this._measure(a._string) + d), Math.ceil(this._fontClientHeight + e)) : 0 === a._dimensions.height ? this._isMultiLine ? cc.size(Math.ceil(c + d), Math.ceil(a.getLineHeight() * this._strings.length + e)) : cc.size(Math.ceil(c + d), Math.ceil(a.getLineHeight() + e)) : cc.size(Math.ceil(c + d), Math.ceil(a._dimensions.height + e)); "normal" !== a._getFontStyle() && (c.width = Math.ceil(c.width + 0.3 * a._fontSize)); a.setContentSize(c); a._strokeShadowOffsetX = d; a._strokeShadowOffsetY = e; a = a._anchorPoint; this._anchorPointInPoints.x = 0.5 * d + (c.width - d) * a.x; this._anchorPointInPoints.y = 0.5 * e + (c.height - e) * a.y }; a._drawTTFInCanvas = function(a) { if (a) { var c = this._node, d = c._strokeShadowOffsetX, e = c._strokeShadowOffsetY, f = c._contentSize.height - e, g = c._vAlignment, h = c._hAlignment, k = c._strokeSize; a.setTransform(1, 0, 0, 1, 0.5 * d, f + 0.5 * e); a.font !== this._fontStyleStr && (a.font = this._fontStyleStr); a.fillStyle = this._fillColorStr; var m = e = 0, n = c._strokeEnabled; n && (a.lineWidth = 2 * k, a.strokeStyle = this._strokeColorStr); c._shadowEnabled && (k = c._shadowOffset, a.shadowColor = this._shadowColorStr, a.shadowOffsetX = k.x, a.shadowOffsetY = -k.y, a.shadowBlur = c._shadowBlur); a.textBaseline = cc.LabelTTF._textBaseline[g]; a.textAlign = cc.LabelTTF._textAlign[h]; var p = c._contentSize.width - d, d = c.getLineHeight(), k = (d - this._fontClientHeight) / 2, e = h === cc.TEXT_ALIGNMENT_RIGHT ? e + p : h === cc.TEXT_ALIGNMENT_CENTER ? e + p / 2 : e + 0; if (this._isMultiLine) for (c = this._strings.length, g === cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM ? m = d - 2 * k + f - d * c : g === cc.VERTICAL_TEXT_ALIGNMENT_CENTER && (m = (d - 2 * k) / 2 + (f - d * c) / 2), g = 0; g < c; g++) h = this._strings[g], p = -f + (d * g + k) + m, n && a.strokeText(h, e, p), a.fillText(h, e, p); else g !== cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM && (m = g === cc.VERTICAL_TEXT_ALIGNMENT_TOP ? m - f : m - 0.5 * f), n && a.strokeText(c._string, e, m), a.fillText(c._string, e, m) } }; a._checkWarp = function(a, c, d) { var e = a[c], f = this._measure(e); if (f > d && 1 < e.length) { for (var g = d / f * e.length | 0, h = e.substr(g), k = f - this._measure(h), m, n = 0, p = 0; k > d && 100 > p++;) g *= d / k, g |= 0, h = e.substr(g), k = f - this._measure(h); for (p = 0; k < d && 100 > p++;) h && (n = (m = cc.LabelTTF._wordRex.exec(h)) ? m[0].length : 1, m = h), g += n, h = e.substr(g), k = f - this._measure(h); g -= n; 0 === g && (g = 1, m = m.substr(1)); d = e.substr(0, g); cc.LabelTTF.wrapInspection && cc.LabelTTF._symbolRex.test(m || h) && (f = cc.LabelTTF._lastWordRex.exec(d), g -= f ? f[0].length : 0, m = e.substr(g), d = e.substr(0, g)); cc.LabelTTF._firsrEnglish.test(m) && (f = cc.LabelTTF._lastEnglish.exec(d)) && d !== f[0] && (g -= f[0].length, m = e.substr(g), d = e.substr(0, g)); a[c] = m || h; a.splice(c, 0, d) } } })(); (function() { cc.LabelTTF.CanvasRenderCmd = function(a) { cc.Sprite.CanvasRenderCmd.call(this, a); cc.LabelTTF.RenderCmd.call(this) }; cc.LabelTTF.CanvasRenderCmd.prototype = Object.create(cc.Sprite.CanvasRenderCmd.prototype); cc.inject(cc.LabelTTF.RenderCmd.prototype, cc.LabelTTF.CanvasRenderCmd.prototype); var a = cc.LabelTTF.CanvasRenderCmd.prototype; a.constructor = cc.LabelTTF.CanvasRenderCmd; a.updateStatus = function() { var a = cc.Node._dirtyFlags, c = this._dirtyFlag, d = c & a.colorDirty, e = c & a.opacityDirty; d && this._updateDisplayColor(); e && this._updateDisplayOpacity(); d ? this._updateColor() : c & a.textDirty && this._updateTexture(); this._dirtyFlag & a.transformDirty && (this.transform(this.getParentRenderCmd(), !0), this._dirtyFlag ^= this._dirtyFlag & cc.Node._dirtyFlags.transformDirty) }; a._syncStatus = function(a) { var c = cc.Node._dirtyFlags, d = this._dirtyFlag, e = a ? a._node : null; e && e._cascadeColorEnabled && a._dirtyFlag & c.colorDirty && (d |= c.colorDirty); e && e._cascadeOpacityEnabled && a._dirtyFlag & c.opacityDirty && (d |= c.opacityDirty); a && a._dirtyFlag & c.transformDirty && (d |= c.transformDirty); var e = d & c.colorDirty, f = d & c.opacityDirty; this._dirtyFlag = d; e && this._syncDisplayColor(); f && this._syncDisplayOpacity(); e ? this._updateColor() : d & c.textDirty && this._updateTexture(); d & c.transformDirty && this.transform(a) }; a._setColorsString = function() { var a = this._displayedColor, c = this._node, d = c._shadowColor || this._displayedColor, e = c._strokeColor, f = c._textFillColor; this._shadowColorStr = "rgba(" + (0 | 0.5 * d.r) + "," + (0 | 0.5 * d.g) + "," + (0 | 0.5 * d.b) + "," + c._shadowOpacity + ")"; this._fillColorStr = "rgba(" + (0 | a.r / 255 * f.r) + "," + (0 | a.g / 255 * f.g) + "," + (0 | a.b / 255 * f.b) + ", 1)"; this._strokeColorStr = "rgba(" + (0 | a.r / 255 * e.r) + "," + (0 | a.g / 255 * e.g) + "," + (0 | a.b / 255 * e.b) + ", 1)" }; a._updateColor = function() { this._setColorsString(); this._updateTexture() } })(); (function() { cc.LabelTTF.WebGLRenderCmd = function(a) { cc.Sprite.WebGLRenderCmd.call(this, a); cc.LabelTTF.RenderCmd.call(this); this.setShaderProgram(cc.shaderCache.programForKey(cc.LabelTTF._SHADER_PROGRAM)) }; var a = cc.LabelTTF.WebGLRenderCmd.prototype = Object.create(cc.Sprite.WebGLRenderCmd.prototype); cc.inject(cc.LabelTTF.RenderCmd.prototype, a); a.constructor = cc.LabelTTF.WebGLRenderCmd; a._setColorsString = function() { this.setDirtyFlag(cc.Node._dirtyFlags.textDirty); var a = this._node, c = a._strokeColor, d = a._textFillColor; this._shadowColorStr = "rgba(128,128,128," + a._shadowOpacity + ")"; this._fillColorStr = "rgba(" + (0 | d.r) + "," + (0 | d.g) + "," + (0 | d.b) + ", 1)"; this._strokeColorStr = "rgba(" + (0 | c.r) + "," + (0 | c.g) + "," + (0 | c.b) + ", 1)" }; a.updateStatus = function() { var a = cc.Node._dirtyFlags, c = this._dirtyFlag, d = c & a.colorDirty, e = c & a.opacityDirty; d && this._updateDisplayColor(); e && this._updateDisplayOpacity(); d || e ? (this._setColorsString(), this._updateColor(), this._updateTexture()) : c & a.textDirty && this._updateTexture(); this._dirtyFlag & a.transformDirty && (this.transform(this.getParentRenderCmd(), !0), this._dirtyFlag ^= this._dirtyFlag & cc.Node._dirtyFlags.transformDirty) }; a._syncStatus = function(a) { var c = cc.Node._dirtyFlags, d = this._dirtyFlag, e = a ? a._node : null; e && e._cascadeColorEnabled && a._dirtyFlag & c.colorDirty && (d |= c.colorDirty); e && e._cascadeOpacityEnabled && a._dirtyFlag & c.opacityDirty && (d |= c.opacityDirty); a && a._dirtyFlag & c.transformDirty && (d |= c.transformDirty); var e = d & c.colorDirty, f = d & c.opacityDirty; this._dirtyFlag = d; e && this._syncDisplayColor(); f && this._syncDisplayOpacity(); e || f ? (this._setColorsString(), this._updateColor(), this._updateTexture()) : d & c.textDirty && this._updateTexture(); this.transform(a) } })(); cc.HashElement = cc.Class.extend({ actions: null, target: null, actionIndex: 0, currentAction: null, currentActionSalvaged: !1, paused: !1, hh: null, ctor: function() { this.actions = []; this.target = null; this.actionIndex = 0; this.currentAction = null; this.paused = this.currentActionSalvaged = !1; this.hh = null } }); cc.ActionManager = cc.Class.extend({ _hashTargets: null, _arrayTargets: null, _currentTarget: null, _currentTargetSalvaged: !1, _searchElementByTarget: function(a, b) { for (var c = 0; c < a.length; c++) if (b === a[c].target) return a[c]; return null }, ctor: function() { this._hashTargets = {}; this._arrayTargets = []; this._currentTarget = null; this._currentTargetSalvaged = !1 }, addAction: function(a, b, c) { if (!a) throw "cc.ActionManager.addAction(): action must be non-null"; if (!b) throw "cc.ActionManager.addAction(): action must be non-null"; var d = this._hashTargets[b.__instanceId]; d || (d = new cc.HashElement, d.paused = c, d.target = b, this._hashTargets[b.__instanceId] = d, this._arrayTargets.push(d)); this._actionAllocWithHashElement(d); d.actions.push(a); a.startWithTarget(b) }, removeAllActions: function() { for (var a = this._arrayTargets, b = 0; b < a.length; b++) { var c = a[b]; c && this.removeAllActionsFromTarget(c.target, !0) } }, removeAllActionsFromTarget: function(a, b) { if (null != a) { var c = this._hashTargets[a.__instanceId]; c && (-1 === c.actions.indexOf(c.currentAction) || c.currentActionSalvaged || (c.currentActionSalvaged = !0), c.actions.length = 0, this._currentTarget !== c || b ? this._deleteHashElement(c) : this._currentTargetSalvaged = !0) } }, removeAction: function(a) { if (null != a) { var b = a.getOriginalTarget(); if (b = this._hashTargets[b.__instanceId]) for (var c = 0; c < b.actions.length; c++) { if (b.actions[c] === a) { b.actions.splice(c, 1); break } } else cc.log(cc._LogInfos.ActionManager_removeAction) } }, removeActionByTag: function(a, b) { a === cc.ACTION_TAG_INVALID && cc.log(cc._LogInfos.ActionManager_addAction); cc.assert(b, cc._LogInfos.ActionManager_addAction); var c = this._hashTargets[b.__instanceId]; if (c) for (var d = c.actions.length, e = 0; e < d; ++e) { var f = c.actions[e]; if (f && f.getTag() === a && f.getOriginalTarget() === b) { this._removeActionAtIndex(e, c); break } } }, getActionByTag: function(a, b) { a === cc.ACTION_TAG_INVALID && cc.log(cc._LogInfos.ActionManager_getActionByTag); var c = this._hashTargets[b.__instanceId]; if (c) { if (null != c.actions) for (var d = 0; d < c.actions.length; ++d) { var e = c.actions[d]; if (e && e.getTag() === a) return e } cc.log(cc._LogInfos.ActionManager_getActionByTag_2, a) } return null }, numberOfRunningActionsInTarget: function(a) { return (a = this._hashTargets[a.__instanceId]) ? a.actions ? a.actions.length : 0 : 0 }, pauseTarget: function(a) { if (a = this._hashTargets[a.__instanceId]) a.paused = !0 }, resumeTarget: function(a) { if (a = this._hashTargets[a.__instanceId]) a.paused = !1 }, pauseAllRunningActions: function() { for (var a = [], b = this._arrayTargets, c = 0; c < b.length; c++) { var d = b[c]; d && !d.paused && (d.paused = !0, a.push(d.target)) } return a }, resumeTargets: function(a) { if (a) for (var b = 0; b < a.length; b++) a[b] && this.resumeTarget(a[b]) }, purgeSharedManager: function() { cc.director.getScheduler().unscheduleUpdate(this) }, _removeActionAtIndex: function(a, b) { b.actions[a] !== b.currentAction || b.currentActionSalvaged || (b.currentActionSalvaged = !0); b.actions.splice(a, 1); b.actionIndex >= a && b.actionIndex--; 0 === b.actions.length && (this._currentTarget === b ? this._currentTargetSalvaged = !0 : this._deleteHashElement(b)) }, _deleteHashElement: function(a) { a && (delete this._hashTargets[a.target.__instanceId], cc.arrayRemoveObject(this._arrayTargets, a), a.actions = null, a.target = null) }, _actionAllocWithHashElement: function(a) { null == a.actions && (a.actions = []) }, update: function(a) { for (var b = this._arrayTargets, c, d = 0; d < b.length; d++) { c = this._currentTarget = b[d]; if (!c.paused) for (c.actionIndex = 0; c.actionIndex < (c.actions ? c.actions.length : 0); c.actionIndex++) if (c.currentAction = c.actions[c.actionIndex], c.currentAction) { c.currentActionSalvaged = !1; c.currentAction.step(a * (c.currentAction._speedMethod ? c.currentAction._speed : 1)); if (c.currentActionSalvaged) c.currentAction = null; else if (c.currentAction.isDone()) { c.currentAction.stop(); var e = c.currentAction; c.currentAction = null; this.removeAction(e) } c.currentAction = null } this._currentTargetSalvaged && 0 === c.actions.length && this._deleteHashElement(c) } } }); cc.math = cc.math || {}; cc.math.EPSILON = 0.015625; cc.math.square = function(a) { return a * a }; cc.math.almostEqual = function(a, b) { return a + cc.math.EPSILON > b && a - cc.math.EPSILON < b }; (function(a) { a.math.Vec2 = function(a, b) { void 0 === b ? (this.x = a.x, this.y = a.y) : (this.x = a || 0, this.y = b || 0) }; var b = a.math.Vec2.prototype; b.fill = function(a, b) { this.x = a; this.y = b }; b.length = function() { return Math.sqrt(a.math.square(this.x) + a.math.square(this.y)) }; b.lengthSq = function() { return a.math.square(this.x) + a.math.square(this.y) }; b.normalize = function() { var a = 1 / this.length(); this.x *= a; this.y *= a; return this }; a.math.Vec2.add = function(a, b, e) { a.x = b.x + e.x; a.y = b.y + e.y; return a }; b.add = function(a) { this.x += a.x; this.y += a.y; return this }; b.dot = function(a) { return this.x * a.x + this.y * a.y }; a.math.Vec2.subtract = function(a, b, e) { a.x = b.x - e.x; a.y = b.y - e.y; return a }; b.subtract = function(a) { this.x -= a.x; this.y -= a.y; return this }; b.transform = function(a) { var b = this.x, e = this.y; this.x = b * a.mat[0] + e * a.mat[3] + a.mat[6]; this.y = b * a.mat[1] + e * a.mat[4] + a.mat[7]; return this }; a.math.Vec2.scale = function(a, b, e) { a.x = b.x * e; a.y = b.y * e; return a }; b.scale = function(a) { this.x *= a; this.y *= a; return this }; b.equals = function(b) { return this.x < b.x + a.math.EPSILON && this.x > b.x - a.math.EPSILON && this.y < b.y + a.math.EPSILON && this.y > b.y - a.math.EPSILON } })(cc); (function(a) { a.kmVec3 = a.math.Vec3 = function(a, b, e) { a && void 0 === b ? (this.x = a.x, this.y = a.y, this.z = a.z) : (this.x = a || 0, this.y = b || 0, this.z = e || 0) }; a.math.vec3 = function(b, d, e) { return new a.math.Vec3(b, d, e) }; var b = a.math.Vec3.prototype; b.fill = function(a, b, e) { a && void 0 === b ? (this.x = a.x, this.y = a.y, this.z = a.z) : (this.x = a, this.y = b, this.z = e); return this }; b.length = function() { return Math.sqrt(a.math.square(this.x) + a.math.square(this.y) + a.math.square(this.z)) }; b.lengthSq = function() { return a.math.square(this.x) + a.math.square(this.y) + a.math.square(this.z) }; b.normalize = function() { var a = 1 / this.length(); this.x *= a; this.y *= a; this.z *= a; return this }; b.cross = function(a) { var b = this.x, e = this.y, f = this.z; this.x = e * a.z - f * a.y; this.y = f * a.x - b * a.z; this.z = b * a.y - e * a.x; return this }; b.dot = function(a) { return this.x * a.x + this.y * a.y + this.z * a.z }; b.add = function(a) { this.x += a.x; this.y += a.y; this.z += a.z; return this }; b.subtract = function(a) { this.x -= a.x; this.y -= a.y; this.z -= a.z; return this }; b.transform = function(a) { var b = this.x, e = this.y, f = this.z; a = a.mat; this.x = b * a[0] + e * a[4] + f * a[8] + a[12]; this.y = b * a[1] + e * a[5] + f * a[9] + a[13]; this.z = b * a[2] + e * a[6] + f * a[10] + a[14]; return this }; b.transformNormal = function(a) { var b = this.x, e = this.y, f = this.z; a = a.mat; this.x = b * a[0] + e * a[4] + f * a[8]; this.y = b * a[1] + e * a[5] + f * a[9]; this.z = b * a[2] + e * a[6] + f * a[10]; return this }; b.transformCoord = function(b) { var d = new a.math.Vec4(this.x, this.y, this.z, 1); d.transform(b); this.x = d.x / d.w; this.y = d.y / d.w; this.z = d.z / d.w; return this }; b.scale = function(a) { this.x *= a; this.y *= a; this.z *= a; return this }; b.equals = function(b) { var d = a.math.EPSILON; return this.x < b.x + d && this.x > b.x - d && this.y < b.y + d && this.y > b.y - d && this.z < b.z + d && this.z > b.z - d }; b.inverseTransform = function(b) { b = b.mat; var d = new a.math.Vec3(this.x - b[12], this.y - b[13], this.z - b[14]); this.x = d.x * b[0] + d.y * b[1] + d.z * b[2]; this.y = d.x * b[4] + d.y * b[5] + d.z * b[6]; this.z = d.x * b[8] + d.y * b[9] + d.z * b[10]; return this }; b.inverseTransformNormal = function(a) { var b = this.x, e = this.y, f = this.z; a = a.mat; this.x = b * a[0] + e * a[1] + f * a[2]; this.y = b * a[4] + e * a[5] + f * a[6]; this.z = b * a[8] + e * a[9] + f * a[10]; return this }; b.assignFrom = function(a) { if (!a) return this; this.x = a.x; this.y = a.y; this.z = a.z; return this }; a.math.Vec3.zero = function(a) { a.x = a.y = a.z = 0; return a }; b.toTypeArray = function() { var a = new Float32Array(3); a[0] = this.x; a[1] = this.y; a[2] = this.z; return a } })(cc); (function(a) { a.math.Vec4 = function(a, b, e, f) { a && void 0 === b ? (this.x = a.x, this.y = a.y, this.z = a.z, this.w = a.w) : (this.x = a || 0, this.y = b || 0, this.z = e || 0, this.w = f || 0) }; a.kmVec4 = a.math.Vec4; var b = a.math.Vec4.prototype; b.fill = function(a, b, e, f) { a && void 0 === b ? (this.x = a.x, this.y = a.y, this.z = a.z, this.w = a.w) : (this.x = a, this.y = b, this.z = e, this.w = f) }; b.add = function(a) { if (!a) return this; this.x += a.x; this.y += a.y; this.z += a.z; this.w += a.w; return this }; b.dot = function(a) { return this.x * a.x + this.y * a.y + this.z * a.z + this.w * a.w }; b.length = function() { return Math.sqrt(a.math.square(this.x) + a.math.square(this.y) + a.math.square(this.z) + a.math.square(this.w)) }; b.lengthSq = function() { return a.math.square(this.x) + a.math.square(this.y) + a.math.square(this.z) + a.math.square(this.w) }; b.lerp = function(a, b) { return this }; b.normalize = function() { var a = 1 / this.length(); this.x *= a; this.y *= a; this.z *= a; this.w *= a; return this }; b.scale = function(a) { this.normalize(); this.x *= a; this.y *= a; this.z *= a; this.w *= a; return this }; b.subtract = function(a) { this.x -= a.x; this.y -= a.y; this.z -= a.z; this.w -= a.w }; b.transform = function(a) { var b = this.x, e = this.y, f = this.z, g = this.w; a = a.mat; this.x = b * a[0] + e * a[4] + f * a[8] + g * a[12]; this.y = b * a[1] + e * a[5] + f * a[9] + g * a[13]; this.z = b * a[2] + e * a[6] + f * a[10] + g * a[14]; this.w = b * a[3] + e * a[7] + f * a[11] + g * a[15]; return this }; a.math.Vec4.transformArray = function(b, d) { for (var e = [], f = 0; f < b.length; f++) { var g = new a.math.Vec4(b[f]); g.transform(d); e.push(g) } return e }; b.equals = function(b) { var d = a.math.EPSILON; return this.x < b.x + d && this.x > b.x - d && this.y < b.y + d && this.y > b.y - d && this.z < b.z + d && this.z > b.z - d && this.w < b.w + d && this.w > b.w - d }; b.assignFrom = function(a) { this.x = a.x; this.y = a.y; this.z = a.z; this.w = a.w; return this }; b.toTypeArray = function() { var a = new Float32Array(4); a[0] = this.x; a[1] = this.y; a[2] = this.z; a[3] = this.w; return a } })(cc); (function(a) { function b(b, d, e) { d = new a.math.Vec2(d); d.subtract(b); e.x = -d.y; e.y = d.x; e.normalize() } a.math.Ray2 = function(b, d) { this.start = b || new a.math.Vec2; this.dir = d || new a.math.Vec2 }; a.math.Ray2.prototype.fill = function(a, b, e, f) { this.start.x = a; this.start.y = b; this.dir.x = e; this.dir.y = f }; a.math.Ray2.prototype.intersectLineSegment = function(b, d, e) { var f = this.start.x, g = this.start.y, h = this.start.x + this.dir.x, k = this.start.y + this.dir.y, m = b.x, n = b.y, p = d.x, t = d.y, r = (t - n) * (h - f) - (p - m) * (k - g); if (r > -a.math.EPSILON && r < a.math.EPSILON) return !1; n = ((p - m) * (g - n) - (t - n) * (f - m)) / r; m = f + n * (h - f); n = g + n * (k - g); if (m < Math.min(b.x, d.x) - a.math.EPSILON || m > Math.max(b.x, d.x) + a.math.EPSILON || n < Math.min(b.y, d.y) - a.math.EPSILON || n > Math.max(b.y, d.y) + a.math.EPSILON || m < Math.min(f, h) - a.math.EPSILON || m > Math.max(f, h) + a.math.EPSILON || n < Math.min(g, k) - a.math.EPSILON || n > Math.max(g, k) + a.math.EPSILON) return !1; e.x = m; e.y = n; return !0 }; a.math.Ray2.prototype.intersectTriangle = function(c, d, e, f, g) { var h = new a.math.Vec2, k = new a.math.Vec2, m = new a.math.Vec2, n = 1E4, p = !1, t; this.intersectLineSegment(c, d, h) && (p = !0, t = h.subtract(this.start).length(), t < n && (k.x = h.x, k.y = h.y, n = t, b(c, d, m))); this.intersectLineSegment(d, e, h) && (p = !0, t = h.subtract(this.start).length(), t < n && (k.x = h.x, k.y = h.y, n = t, b(d, e, m))); this.intersectLineSegment(e, c, h) && (p = !0, t = h.subtract(this.start).length(), t < n && (k.x = h.x, k.y = h.y, b(e, c, m))); p && (f.x = k.x, f.y = k.y, g && (g.x = m.x, g.y = m.y)); return p } })(cc); var Float32Array = Float32Array || Array; (function(a) { a.math.Matrix3 = function(a) { this.mat = a && a.mat ? new Float32Array(a.mat) : new Float32Array(9) }; a.kmMat3 = a.math.Matrix3; var b = a.math.Matrix3.prototype; b.fill = function(a) { var b = this.mat; a = a.mat; b[0] = a[0]; b[1] = a[1]; b[2] = a[2]; b[3] = a[3]; b[4] = a[4]; b[5] = a[5]; b[6] = a[6]; b[7] = a[7]; b[8] = a[8]; return this }; b.adjugate = function() { var a = this.mat, b = a[0], c = a[1], g = a[2], h = a[3], k = a[4], m = a[5], n = a[6], p = a[7], t = a[8]; a[0] = k * t - m * p; a[1] = g * p - c * t; a[2] = c * m - g * k; a[3] = m * n - h * t; a[4] = b * t - g * n; a[5] = g * h - b * m; a[6] = h * p - k * n; a[8] = b * k - c * h; return this }; b.identity = function() { var a = this.mat; a[1] = a[2] = a[3] = a[5] = a[6] = a[7] = 0; a[0] = a[4] = a[8] = 1; return this }; var c = new a.math.Matrix3; b.inverse = function(a) { if (0 === a) return this; c.assignFrom(this); a = 1 / a; this.adjugate(); this.multiplyScalar(a); return this }; b.isIdentity = function() { var a = this.mat; return 1 === a[0] && 0 === a[1] && 0 === a[2] && 0 === a[3] && 1 === a[4] && 0 === a[5] && 0 === a[6] && 0 === a[7] && 1 === a[8] }; b.transpose = function() { var a = this.mat, b = a[1], c = a[2], g = a[5], h = a[6], k = a[7]; a[1] = a[3]; a[2] = h; a[3] = b; a[5] = k; a[6] = c; a[7] = g; return this }; b.determinant = function() { var a = this.mat, b = a[0] * a[4] * a[8] + a[1] * a[5] * a[6] + a[2] * a[3] * a[7]; return b -= a[2] * a[4] * a[6] + a[0] * a[5] * a[7] + a[1] * a[3] * a[8] }; b.multiply = function(a) { var b = this.mat, c = a.mat; a = b[0]; var g = b[1], h = b[2], k = b[3], m = b[4], n = b[5], p = b[6], t = b[7], r = b[8], u = c[0], s = c[1], v = c[2], x = c[3], D = c[4], E = c[5], A = c[6], w = c[7], c = c[8]; b[0] = a * u + k * s + p * v; b[1] = g * u + m * s + t * v; b[2] = h * u + n * s + r * v; b[3] = h * u + n * s + r * v; b[4] = g * x + m * D + t * E; b[5] = h * x + n * D + r * E; b[6] = a * A + k * w + p * c; b[7] = g * A + m * w + t * c; b[8] = h * A + n * w + r * c; return this }; b.multiplyScalar = function(a) { var b = this.mat; b[0] *= a; b[1] *= a; b[2] *= a; b[3] *= a; b[4] *= a; b[5] *= a; b[6] *= a; b[7] *= a; b[8] *= a; return this }; a.math.Matrix3.rotationAxisAngle = function(b, c) { var f = Math.cos(c), g = Math.sin(c), h = new a.math.Matrix3, k = h.mat; k[0] = f + b.x * b.x * (1 - f); k[1] = b.z * g + b.y * b.x * (1 - f); k[2] = -b.y * g + b.z * b.x * (1 - f); k[3] = -b.z * g + b.x * b.y * (1 - f); k[4] = f + b.y * b.y * (1 - f); k[5] = b.x * g + b.z * b.y * (1 - f); k[6] = b.y * g + b.x * b.z * (1 - f); k[7] = -b.x * g + b.y * b.z * (1 - f); k[8] = f + b.z * b.z * (1 - f); return h }; b.assignFrom = function(b) { if (this === b) return a.log("cc.math.Matrix3.assign(): current matrix equals matIn"), this; var c = this.mat; b = b.mat; c[0] = b[0]; c[1] = b[1]; c[2] = b[2]; c[3] = b[3]; c[4] = b[4]; c[5] = b[5]; c[6] = b[6]; c[7] = b[7]; c[8] = b[8]; return this }; b.equals = function(b) { if (this === b) return !0; var c = a.math.EPSILON, f = this.mat; b = b.mat; for (var g = 0; 9 > g; ++g) if (!(f[g] + c > b[g] && f[g] - c < b[g])) return !1; return !0 }; a.math.Matrix3.createByRotationX = function(b) { var c = new a.math.Matrix3, f = c.mat; f[0] = 1; f[1] = 0; f[2] = 0; f[3] = 0; f[4] = Math.cos(b); f[5] = Math.sin(b); f[6] = 0; f[7] = -Math.sin(b); f[8] = Math.cos(b); return c }; a.math.Matrix3.createByRotationY = function(b) { var c = new a.math.Matrix3, f = c.mat; f[0] = Math.cos(b); f[1] = 0; f[2] = -Math.sin(b); f[3] = 0; f[4] = 1; f[5] = 0; f[6] = Math.sin(b); f[7] = 0; f[8] = Math.cos(b); return c }; a.math.Matrix3.createByRotationZ = function(b) { var c = new a.math.Matrix3, f = c.mat; f[0] = Math.cos(b); f[1] = -Math.sin(b); f[2] = 0; f[3] = Math.sin(b); f[4] = Math.cos(b); f[5] = 0; f[6] = 0; f[7] = 0; f[8] = 1; return c }; a.math.Matrix3.createByRotation = function(b) { var c = new a.math.Matrix3, f = c.mat; f[0] = Math.cos(b); f[1] = Math.sin(b); f[2] = 0; f[3] = -Math.sin(b); f[4] = Math.cos(b); f[5] = 0; f[6] = 0; f[7] = 0; f[8] = 1; return c }; a.math.Matrix3.createByScale = function(b, c) { var f = new a.math.Matrix3; f.identity(); f.mat[0] = b; f.mat[4] = c; return f }; a.math.Matrix3.createByTranslation = function(b, c) { var f = new a.math.Matrix3; f.identity(); f.mat[6] = b; f.mat[7] = c; return f }; a.math.Matrix3.createByQuaternion = function(b) { if (!b) return null; var c = new a.math.Matrix3, f = c.mat; f[0] = 1 - 2 * (b.y * b.y + b.z * b.z); f[1] = 2 * (b.x * b.y - b.w * b.z); f[2] = 2 * (b.x * b.z + b.w * b.y); f[3] = 2 * (b.x * b.y + b.w * b.z); f[4] = 1 - 2 * (b.x * b.x + b.z * b.z); f[5] = 2 * (b.y * b.z - b.w * b.x); f[6] = 2 * (b.x * b.z - b.w * b.y); f[7] = 2 * (b.y * b.z + b.w * b.x); f[8] = 1 - 2 * (b.x * b.x + b.y * b.y); return c }; b.rotationToAxisAngle = function() { return a.math.Quaternion.rotationMatrix(this).toAxisAndAngle() } })(cc); (function(a) { a.math.Matrix4 = function(a) { this.mat = a && a.mat ? new Float32Array(a.mat) : new Float32Array(16) }; a.kmMat4 = a.math.Matrix4; var b = a.math.Matrix4.prototype; b.fill = function(a) { for (var b = this.mat, c = 0; 16 > c; c++) b[c] = a[c]; return this }; a.kmMat4Identity = function(a) { var b = a.mat; b[1] = b[2] = b[3] = b[4] = b[6] = b[7] = b[8] = b[9] = b[11] = b[12] = b[13] = b[14] = 0; b[0] = b[5] = b[10] = b[15] = 1; return a }; b.identity = function() { var a = this.mat; a[1] = a[2] = a[3] = a[4] = a[6] = a[7] = a[8] = a[9] = a[11] = a[12] = a[13] = a[14] = 0; a[0] = a[5] = a[10] = a[15] = 1; return this }; b.get = function(a, b) { return this.mat[a + 4 * b] }; b.set = function(a, b, c) { this.mat[a + 4 * b] = c }; b.swap = function(a, b, c, d) { var k = this.mat, m = k[a + 4 * b]; k[a + 4 * b] = k[c + 4 * d]; k[c + 4 * d] = m }; a.math.Matrix4._gaussj = function(a, b) { var c, d = 0, k = 0, m, n, p, t, r = [0, 0, 0, 0], u = [0, 0, 0, 0], s = [0, 0, 0, 0]; for (c = 0; 4 > c; c++) { for (m = t = 0; 4 > m; m++) if (1 !== s[m]) for (n = 0; 4 > n; n++) 0 === s[n] && (p = Math.abs(a.get(m, n)), p >= t && (t = p, k = m, d = n)); ++s[d]; if (k !== d) { for (m = 0; 4 > m; m++) a.swap(k, m, d, m); for (m = 0; 4 > m; m++) b.swap(k, m, d, m) } u[c] = k; r[c] = d; if (0 === a.get(d, d)) return !1; n = 1 / a.get(d, d); a.set(d, d, 1); for (m = 0; 4 > m; m++) a.set(d, m, a.get(d, m) * n); for (m = 0; 4 > m; m++) b.set(d, m, b.get(d, m) * n); for (n = 0; 4 > n; n++) if (n !== d) { p = a.get(n, d); a.set(n, d, 0); for (m = 0; 4 > m; m++) a.set(n, m, a.get(n, m) - a.get(d, m) * p); for (m = 0; 4 > m; m++) b.set(n, m, a.get(n, m) - b.get(d, m) * p) } } for (m = 3; 0 <= m; m--) if (u[m] !== r[m]) for (n = 0; 4 > n; n++) a.swap(n, u[m], n, r[m]); return !0 }; var c = (new a.math.Matrix4).identity(); a.kmMat4Inverse = function(b, d) { var g = new a.math.Matrix4(d); if (!1 === a.math.Matrix4._gaussj(g, c)) return null; b.assignFrom(g); return b }; b.inverse = function() { var b = new a.math.Matrix4(this); return !1 === a.math.Matrix4._gaussj(b, c) ? null : b }; b.isIdentity = function() { var a = this.mat; return 1 === a[0] && 0 === a[1] && 0 === a[2] && 0 === a[3] && 0 === a[4] && 1 === a[5] && 0 === a[6] && 0 === a[7] && 0 === a[8] && 0 === a[9] && 1 === a[10] && 0 === a[11] && 0 === a[12] && 0 === a[13] && 0 === a[14] && 1 === a[15] }; b.transpose = function() { var a = this.mat, b = a[1], c = a[2], d = a[3], k = a[6], m = a[7], n = a[8], p = a[9], t = a[11], r = a[12], u = a[13], s = a[14]; a[1] = a[4]; a[2] = n; a[3] = r; a[4] = b; a[6] = p; a[7] = u; a[8] = c; a[9] = k; a[11] = s; a[12] = d; a[13] = m; a[14] = t; return this }; a.kmMat4Multiply = function(a, b, c) { var d = a.mat, k = b.mat, m = c.mat; c = k[0]; b = k[1]; var n = k[2], p = k[3], t = k[4], r = k[5], u = k[6], s = k[7], v = k[8], x = k[9], D = k[10], E = k[11], A = k[12], w = k[13], B = k[14], k = k[15], y = m[0], z = m[1], F = m[2], J = m[3], C = m[4], N = m[5], L = m[6], P = m[7], S = m[8], I = m[9], T = m[10], K = m[11], U = m[12], V = m[13], aa = m[14], m = m[15]; d[0] = y * c + z * t + F * v + J * A; d[1] = y * b + z * r + F * x + J * w; d[2] = y * n + z * u + F * D + J * B; d[3] = y * p + z * s + F * E + J * k; d[4] = C * c + N * t + L * v + P * A; d[5] = C * b + N * r + L * x + P * w; d[6] = C * n + N * u + L * D + P * B; d[7] = C * p + N * s + L * E + P * k; d[8] = S * c + I * t + T * v + K * A; d[9] = S * b + I * r + T * x + K * w; d[10] = S * n + I * u + T * D + K * B; d[11] = S * p + I * s + T * E + K * k; d[12] = U * c + V * t + aa * v + m * A; d[13] = U * b + V * r + aa * x + m * w; d[14] = U * n + V * u + aa * D + m * B; d[15] = U * p + V * s + aa * E + m * k; return a }; b.multiply = function(a) { var b = this.mat, c = a.mat; a = b[0]; var d = b[1], k = b[2], m = b[3], n = b[4], p = b[5], t = b[6], r = b[7], u = b[8], s = b[9], v = b[10], x = b[11], D = b[12], E = b[13], A = b[14], w = b[15], B = c[0], y = c[1], z = c[2], F = c[3], J = c[4], C = c[5], N = c[6], L = c[7], P = c[8], S = c[9], I = c[10], T = c[11], K = c[12], U = c[13], V = c[14], c = c[15]; b[0] = B * a + y * n + z * u + F * D; b[1] = B * d + y * p + z * s + F * E; b[2] = B * k + y * t + z * v + F * A; b[3] = B * m + y * r + z * x + F * w; b[4] = J * a + C * n + N * u + L * D; b[5] = J * d + C * p + N * s + L * E; b[6] = J * k + C * t + N * v + L * A; b[7] = J * m + C * r + N * x + L * w; b[8] = P * a + S * n + I * u + T * D; b[9] = P * d + S * p + I * s + T * E; b[10] = P * k + S * t + I * v + T * A; b[11] = P * m + S * r + I * x + T * w; b[12] = K * a + U * n + V * u + c * D; b[13] = K * d + U * p + V * s + c * E; b[14] = K * k + U * t + V * v + c * A; b[15] = K * m + U * r + V * x + c * w; return this }; a.getMat4MultiplyValue = function(a, b) { var c = a.mat, d = b.mat, k = new Float32Array(16); k[0] = c[0] * d[0] + c[4] * d[1] + c[8] * d[2] + c[12] * d[3]; k[1] = c[1] * d[0] + c[5] * d[1] + c[9] * d[2] + c[13] * d[3]; k[2] = c[2] * d[0] + c[6] * d[1] + c[10] * d[2] + c[14] * d[3]; k[3] = c[3] * d[0] + c[7] * d[1] + c[11] * d[2] + c[15] * d[3]; k[4] = c[0] * d[4] + c[4] * d[5] + c[8] * d[6] + c[12] * d[7]; k[5] = c[1] * d[4] + c[5] * d[5] + c[9] * d[6] + c[13] * d[7]; k[6] = c[2] * d[4] + c[6] * d[5] + c[10] * d[6] + c[14] * d[7]; k[7] = c[3] * d[4] + c[7] * d[5] + c[11] * d[6] + c[15] * d[7]; k[8] = c[0] * d[8] + c[4] * d[9] + c[8] * d[10] + c[12] * d[11]; k[9] = c[1] * d[8] + c[5] * d[9] + c[9] * d[10] + c[13] * d[11]; k[10] = c[2] * d[8] + c[6] * d[9] + c[10] * d[10] + c[14] * d[11]; k[11] = c[3] * d[8] + c[7] * d[9] + c[11] * d[10] + c[15] * d[11]; k[12] = c[0] * d[12] + c[4] * d[13] + c[8] * d[14] + c[12] * d[15]; k[13] = c[1] * d[12] + c[5] * d[13] + c[9] * d[14] + c[13] * d[15]; k[14] = c[2] * d[12] + c[6] * d[13] + c[10] * d[14] + c[14] * d[15]; k[15] = c[3] * d[12] + c[7] * d[13] + c[11] * d[14] + c[15] * d[15]; return k }; a.kmMat4Assign = function(b, c) { if (b === c) return a.log("cc.kmMat4Assign(): pOut equals pIn"), b; var d = b.mat, h = c.mat; d[0] = h[0]; d[1] = h[1]; d[2] = h[2]; d[3] = h[3]; d[4] = h[4]; d[5] = h[5]; d[6] = h[6]; d[7] = h[7]; d[8] = h[8]; d[9] = h[9]; d[10] = h[10]; d[11] = h[11]; d[12] = h[12]; d[13] = h[13]; d[14] = h[14]; d[15] = h[15]; return b }; b.assignFrom = function(b) { if (this === b) return a.log("cc.mat.Matrix4.assignFrom(): mat4 equals current matrix"), this; var c = this.mat; b = b.mat; c[0] = b[0]; c[1] = b[1]; c[2] = b[2]; c[3] = b[3]; c[4] = b[4]; c[5] = b[5]; c[6] = b[6]; c[7] = b[7]; c[8] = b[8]; c[9] = b[9]; c[10] = b[10]; c[11] = b[11]; c[12] = b[12]; c[13] = b[13]; c[14] = b[14]; c[15] = b[15]; return this }; b.equals = function(b) { if (this === b) return a.log("cc.kmMat4AreEqual(): pMat1 and pMat2 are same object."), !0; var c = this.mat; b = b.mat; for (var d = a.math.EPSILON, h = 0; 16 > h; h++) if (!(c[h] + d > b[h] && c[h] - d < b[h])) return !1; return !0 }; a.math.Matrix4.createByRotationX = function(b, c) { c = c || new a.math.Matrix4; var d = c.mat; d[0] = 1; d[3] = d[2] = d[1] = 0; d[4] = 0; d[5] = Math.cos(b); d[6] = Math.sin(b); d[7] = 0; d[8] = 0; d[9] = -Math.sin(b); d[10] = Math.cos(b); d[11] = 0; d[14] = d[13] = d[12] = 0; d[15] = 1; return c }; a.math.Matrix4.createByRotationY = function(b, c) { c = c || new a.math.Matrix4; var d = c.mat; d[0] = Math.cos(b); d[1] = 0; d[2] = -Math.sin(b); d[3] = 0; d[7] = d[6] = d[4] = 0; d[5] = 1; d[8] = Math.sin(b); d[9] = 0; d[10] = Math.cos(b); d[11] = 0; d[14] = d[13] = d[12] = 0; d[15] = 1; return c }; a.math.Matrix4.createByRotationZ = function(b, c) { c = c || new a.math.Matrix4; var d = c.mat; d[0] = Math.cos(b); d[1] = Math.sin(b); d[3] = d[2] = 0; d[4] = -Math.sin(b); d[5] = Math.cos(b); d[7] = d[6] = 0; d[11] = d[9] = d[8] = 0; d[10] = 1; d[14] = d[13] = d[12] = 0; d[15] = 1; return c }; a.math.Matrix4.createByPitchYawRoll = function(b, c, d, h) { h = h || new a.math.Matrix4; var k = Math.cos(b); b = Math.sin(b); var m = Math.cos(c); c = Math.sin(c); var n = Math.cos(d); d = Math.sin(d); var p = b * c, t = k * c, r = h.mat; r[0] = m * n; r[4] = m * d; r[8] = -c; r[1] = p * n - k * d; r[5] = p * d + k * n; r[9] = b * m; r[2] = t * n + b * d; r[6] = t * d - b * n; r[10] = k * m; r[3] = r[7] = r[11] = 0; r[15] = 1; return h }; a.math.Matrix4.createByQuaternion = function(b, c) { c = c || new a.math.Matrix4; var d = c.mat; d[0] = 1 - 2 * (b.y * b.y + b.z * b.z); d[1] = 2 * (b.x * b.y + b.z * b.w); d[2] = 2 * (b.x * b.z - b.y * b.w); d[3] = 0; d[4] = 2 * (b.x * b.y - b.z * b.w); d[5] = 1 - 2 * (b.x * b.x + b.z * b.z); d[6] = 2 * (b.z * b.y + b.x * b.w); d[7] = 0; d[8] = 2 * (b.x * b.z + b.y * b.w); d[9] = 2 * (b.y * b.z - b.x * b.w); d[10] = 1 - 2 * (b.x * b.x + b.y * b.y); d[11] = 0; d[14] = d[13] = d[12] = 0; d[15] = 1; return c }; a.math.Matrix4.createByRotationTranslation = function(b, c, d) { d = d || new a.math.Matrix4; var h = d.mat; b = b.mat; h[0] = b[0]; h[1] = b[1]; h[2] = b[2]; h[3] = 0; h[4] = b[3]; h[5] = b[4]; h[6] = b[5]; h[7] = 0; h[8] = b[6]; h[9] = b[7]; h[10] = b[8]; h[11] = 0; h[12] = c.x; h[13] = c.y; h[14] = c.z; h[15] = 1; return d }; a.math.Matrix4.createByScale = function(b, c, d, h) { h = h || new a.math.Matrix4; var k = h.mat; k[0] = b; k[5] = c; k[10] = d; k[15] = 1; k[1] = k[2] = k[3] = k[4] = k[6] = k[7] = k[8] = k[9] = k[11] = k[12] = k[13] = k[14] = 0; return h }; a.kmMat4Translation = function(a, b, c, d) { a.mat[0] = a.mat[5] = a.mat[10] = a.mat[15] = 1; a.mat[1] = a.mat[2] = a.mat[3] = a.mat[4] = a.mat[6] = a.mat[7] = a.mat[8] = a.mat[9] = a.mat[11] = 0; a.mat[12] = b; a.mat[13] = c; a.mat[14] = d; return a }; a.math.Matrix4.createByTranslation = function(b, c, d, h) { h = h || new a.math.Matrix4; h.identity(); h.mat[12] = b; h.mat[13] = c; h.mat[14] = d; return h }; b.getUpVec3 = function() { var b = this.mat; return (new a.math.Vec3(b[4], b[5], b[6])).normalize() }; b.getRightVec3 = function() { var b = this.mat; return (new a.math.Vec3(b[0], b[1], b[2])).normalize() }; b.getForwardVec3 = function() { var b = this.mat; return (new a.math.Vec3(b[8], b[9], b[10])).normalize() }; a.kmMat4PerspectiveProjection = function(b, c, d, h, k) { var m = a.degreesToRadians(c / 2); c = k - h; var n = Math.sin(m); if (0 === c || 0 === n || 0 === d) return null; m = Math.cos(m) / n; b.identity(); b.mat[0] = m / d; b.mat[5] = m; b.mat[10] = -(k + h) / c; b.mat[11] = -1; b.mat[14] = -2 * h * k / c; b.mat[15] = 0; return b }; a.math.Matrix4.createPerspectiveProjection = function(b, c, d, h) { var k = a.degreesToRadians(b / 2); b = h - d; var m = Math.sin(k); if (0 === b || 0 === m || 0 === c) return null; var k = Math.cos(k) / m, m = new a.math.Matrix4, n = m.mat; m.identity(); n[0] = k / c; n[5] = k; n[10] = -(h + d) / b; n[11] = -1; n[14] = -2 * d * h / b; n[15] = 0; return m }; a.kmMat4OrthographicProjection = function(a, b, c, d, k, m, n) { a.identity(); a.mat[0] = 2 / (c - b); a.mat[5] = 2 / (k - d); a.mat[10] = -2 / (n - m); a.mat[12] = -((c + b) / (c - b)); a.mat[13] = -((k + d) / (k - d)); a.mat[14] = -((n + m) / (n - m)); return a }; a.math.Matrix4.createOrthographicProjection = function(b, c, d, h, k, m) { var n = new a.math.Matrix4, p = n.mat; n.identity(); p[0] = 2 / (c - b); p[5] = 2 / (h - d); p[10] = -2 / (m - k); p[12] = -((c + b) / (c - b)); p[13] = -((h + d) / (h - d)); p[14] = -((m + k) / (m - k)); return n }; a.kmMat4LookAt = function(b, c, d, h) { d = new a.math.Vec3(d); var k = new a.math.Vec3(h); d.subtract(c); d.normalize(); k.normalize(); h = new a.math.Vec3(d); h.cross(k); h.normalize(); k = new a.math.Vec3(h); k.cross(d); h.normalize(); b.identity(); b.mat[0] = h.x; b.mat[4] = h.y; b.mat[8] = h.z; b.mat[1] = k.x; b.mat[5] = k.y; b.mat[9] = k.z; b.mat[2] = -d.x; b.mat[6] = -d.y; b.mat[10] = -d.z; c = a.math.Matrix4.createByTranslation(-c.x, -c.y, -c.z); b.multiply(c); return b }; var d = new a.math.Matrix4; b.lookAt = function(b, c, g) { c = new a.math.Vec3(c); var h = new a.math.Vec3(g); g = this.mat; c.subtract(b); c.normalize(); h.normalize(); var k = new a.math.Vec3(c); k.cross(h); k.normalize(); h = new a.math.Vec3(k); h.cross(c); k.normalize(); this.identity(); g[0] = k.x; g[4] = k.y; g[8] = k.z; g[1] = h.x; g[5] = h.y; g[9] = h.z; g[2] = -c.x; g[6] = -c.y; g[10] = -c.z; d = a.math.Matrix4.createByTranslation(-b.x, -b.y, -b.z, d); this.multiply(d); return this }; a.kmMat4RotationAxisAngle = function(b, c, d) { var h = Math.cos(d); d = Math.sin(d); c = new a.math.Vec3(c); c.normalize(); b.mat[0] = h + c.x * c.x * (1 - h); b.mat[1] = c.z * d + c.y * c.x * (1 - h); b.mat[2] = -c.y * d + c.z * c.x * (1 - h); b.mat[3] = 0; b.mat[4] = -c.z * d + c.x * c.y * (1 - h); b.mat[5] = h + c.y * c.y * (1 - h); b.mat[6] = c.x * d + c.z * c.y * (1 - h); b.mat[7] = 0; b.mat[8] = c.y * d + c.x * c.z * (1 - h); b.mat[9] = -c.x * d + c.y * c.z * (1 - h); b.mat[10] = h + c.z * c.z * (1 - h); b.mat[11] = 0; b.mat[12] = 0; b.mat[13] = 0; b.mat[14] = 0; b.mat[15] = 1; return b }; a.math.Matrix4.createByAxisAndAngle = function(b, c, d) { d = d || new a.math.Matrix4; var h = this.mat, k = Math.cos(c); c = Math.sin(c); b = new a.math.Vec3(b); b.normalize(); h[0] = k + b.x * b.x * (1 - k); h[1] = b.z * c + b.y * b.x * (1 - k); h[2] = -b.y * c + b.z * b.x * (1 - k); h[3] = 0; h[4] = -b.z * c + b.x * b.y * (1 - k); h[5] = k + b.y * b.y * (1 - k); h[6] = b.x * c + b.z * b.y * (1 - k); h[7] = 0; h[8] = b.y * c + b.x * b.z * (1 - k); h[9] = -b.x * c + b.y * b.z * (1 - k); h[10] = k + b.z * b.z * (1 - k); h[11] = 0; h[12] = h[13] = h[14] = 0; h[15] = 1; return d }; b.extractRotation = function() { var b = new a.math.Matrix3, c = this.mat, d = b.mat; d[0] = c[0]; d[1] = c[1]; d[2] = c[2]; d[3] = c[4]; d[4] = c[5]; d[5] = c[6]; d[6] = c[8]; d[7] = c[9]; d[8] = c[10]; return b }; b.extractPlane = function(b) { var c = new a.math.Plane, d = this.mat; switch (b) { case a.math.Plane.RIGHT: c.a = d[3] - d[0]; c.b = d[7] - d[4]; c.c = d[11] - d[8]; c.d = d[15] - d[12]; break; case a.math.Plane.LEFT: c.a = d[3] + d[0]; c.b = d[7] + d[4]; c.c = d[11] + d[8]; c.d = d[15] + d[12]; break; case a.math.Plane.BOTTOM: c.a = d[3] + d[1]; c.b = d[7] + d[5]; c.c = d[11] + d[9]; c.d = d[15] + d[13]; break; case a.math.Plane.TOP: c.a = d[3] - d[1]; c.b = d[7] - d[5]; c.c = d[11] - d[9]; c.d = d[15] - d[13]; break; case a.math.Plane.FAR: c.a = d[3] - d[2]; c.b = d[7] - d[6]; c.c = d[11] - d[10]; c.d = d[15] - d[14]; break; case a.math.Plane.NEAR: c.a = d[3] + d[2]; c.b = d[7] + d[6]; c.c = d[11] + d[10]; c.d = d[15] + d[14]; break; default: a.log("cc.math.Matrix4.extractPlane: Invalid plane index") } b = Math.sqrt(c.a * c.a + c.b * c.b + c.c * c.c); c.a /= b; c.b /= b; c.c /= b; c.d /= b; return c }; b.toAxisAndAngle = function() { var b = this.extractRotation(); return a.math.Quaternion.rotationMatrix(b).toAxisAndAngle() } })(cc); (function(a) { a.math.Plane = function(a, b, e, f) { a && void 0 === b ? (this.a = a.a, this.b = a.b, this.c = a.c, this.d = a.d) : (this.a = a || 0, this.b = b || 0, this.c = e || 0, this.d = f || 0) }; a.kmPlane = a.math.Plane; var b = a.math.Plane.prototype; a.math.Plane.LEFT = 0; a.math.Plane.RIGHT = 1; a.math.Plane.BOTTOM = 2; a.math.Plane.TOP = 3; a.math.Plane.NEAR = 4; a.math.Plane.FAR = 5; a.math.Plane.POINT_INFRONT_OF_PLANE = 0; a.math.Plane.POINT_BEHIND_PLANE = 1; a.math.Plane.POINT_ON_PLANE = 2; b.dot = function(a) { return this.a * a.x + this.b * a.y + this.c * a.z + this.d * a.w }; b.dotCoord = function(a) { return this.a * a.x + this.b * a.y + this.c * a.z + this.d }; b.dotNormal = function(a) { return this.a * a.x + this.b * a.y + this.c * a.z }; a.math.Plane.fromPointNormal = function(b, d) { return new a.math.Plane(d.x, d.y, d.z, -d.dot(b)) }; a.math.Plane.fromPoints = function(b, d, e) { d = new a.math.Vec3(d); e = new a.math.Vec3(e); var f = new a.math.Plane; d.subtract(b); e.subtract(b); d.cross(e); d.normalize(); f.a = d.x; f.b = d.y; f.c = d.z; f.d = d.scale(-1).dot(b); return f }; b.normalize = function() { var b = new a.math.Vec3(this.a, this.b, this.c), d = 1 / b.length(); b.normalize(); this.a = b.x; this.b = b.y; this.c = b.z; this.d *= d; return this }; b.classifyPoint = function(b) { b = this.a * b.x + this.b * b.y + this.c * b.z + this.d; return 0.001 < b ? a.math.Plane.POINT_INFRONT_OF_PLANE : -0.001 > b ? a.math.Plane.POINT_BEHIND_PLANE : a.math.Plane.POINT_ON_PLANE } })(cc); (function(a) { a.math.Quaternion = function(a, b, e, f) { a && void 0 === b ? (this.x = a.x, this.y = a.y, this.z = a.z, this.w = a.w) : (this.x = a || 0, this.y = b || 0, this.z = e || 0, this.w = f || 0) }; a.kmQuaternion = a.math.Quaternion; var b = a.math.Quaternion.prototype; b.conjugate = function(a) { this.x = -a.x; this.y = -a.y; this.z = -a.z; this.w = a.w; return this }; b.dot = function(a) { return this.w * a.w + this.x * a.x + this.y * a.y + this.z * a.z }; b.exponential = function() { return this }; b.identity = function() { this.z = this.y = this.x = 0; this.w = 1; return this }; b.inverse = function() { var b = this.length(); if (Math.abs(b) > a.math.EPSILON) return this.w = this.z = this.y = this.x = 0, this; this.conjugate(this).scale(1 / b); return this }; b.isIdentity = function() { return 0 === this.x && 0 === this.y && 0 === this.z && 1 === this.w }; b.length = function() { return Math.sqrt(this.lengthSq()) }; b.lengthSq = function() { return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w }; b.multiply = function(a) { var b = this.x, e = this.y, f = this.z, g = this.w; this.w = g * a.w - b * a.x - e * a.y - f * a.z; this.x = g * a.x + b * a.w + e * a.z - f * a.y; this.y = g * a.y + e * a.w + f * a.x - b * a.z; this.z = g * a.z + f * a.w + b * a.y - e * a.x; return this }; b.normalize = function() { var b = this.length(); if (Math.abs(b) <= a.math.EPSILON) throw "current quaternion is an invalid value"; this.scale(1 / b); return this }; b.rotationAxis = function(a, b) { var e = 0.5 * b, f = Math.sin(e); this.w = Math.cos(e); this.x = a.x * f; this.y = a.y * f; this.z = a.z * f; return this }; a.math.Quaternion.rotationMatrix = function(b) { if (!b) return null; var d, e, f; d = []; e = b.mat; b = 0; d[0] = e[0]; d[1] = e[3]; d[2] = e[6]; d[4] = e[1]; d[5] = e[4]; d[6] = e[7]; d[8] = e[2]; d[9] = e[5]; d[10] = e[8]; d[15] = 1; var g = d[0]; b = g[0] + g[5] + g[10] + 1; b > a.math.EPSILON ? (b = 2 * Math.sqrt(b), d = (g[9] - g[6]) / b, e = (g[2] - g[8]) / b, f = (g[4] - g[1]) / b, b *= 0.25) : g[0] > g[5] && g[0] > g[10] ? (b = 2 * Math.sqrt(1 + g[0] - g[5] - g[10]), d = 0.25 * b, e = (g[4] + g[1]) / b, f = (g[2] + g[8]) / b, b = (g[9] - g[6]) / b) : g[5] > g[10] ? (b = 2 * Math.sqrt(1 + g[5] - g[0] - g[10]), d = (g[4] + g[1]) / b, e = 0.25 * b, f = (g[9] + g[6]) / b, b = (g[2] - g[8]) / b) : (b = 2 * Math.sqrt(1 + g[10] - g[0] - g[5]), d = (g[2] + g[8]) / b, e = (g[9] + g[6]) / b, f = 0.25 * b, b = (g[4] - g[1]) / b); return new a.math.Quaternion(d, e, f, b) }; a.math.Quaternion.rotationYawPitchRoll = function(b, d, e) { var f, g, h, k, m; f = a.degreesToRadians(d) / 2; g = a.degreesToRadians(b) / 2; h = a.degreesToRadians(e) / 2; e = Math.cos(f); b = Math.cos(g); d = Math.cos(h); f = Math.sin(f); g = Math.sin(g); h = Math.sin(h); k = b * d; m = g * h; var n = new a.math.Quaternion; n.w = e * k + f * m; n.x = f * k - e * m; n.y = e * g * d + f * b * h; n.z = e * b * h - f * g * d; n.normalize(); return n }; b.slerp = function(b, d) { if (this.x === b.x && this.y === b.y && this.z === b.z && this.w === b.w) return this; var e = this.dot(b), f = Math.acos(e), g = Math.sqrt(1 - a.math.square(e)), e = Math.sin(d * f) / g, f = Math.sin((1 - d) * f) / g, g = new a.math.Quaternion(b); this.scale(f); g.scale(e); this.add(g); return this }; b.toAxisAndAngle = function() { var b, d, e = new a.math.Vec3; b = Math.acos(this.w); d = Math.sqrt(a.math.square(this.x) + a.math.square(this.y) + a.math.square(this.z)); d > -a.math.EPSILON && d < a.math.EPSILON || d < 2 * Math.PI + a.math.EPSILON && d > 2 * Math.PI - a.math.EPSILON ? (b = 0, e.x = 0, e.y = 0, e.z = 1) : (b *= 2, e.x = this.x / d, e.y = this.y / d, e.z = this.z / d, e.normalize()); return { axis: e, angle: b } }; b.scale = function(a) { this.x *= a; this.y *= a; this.z *= a; this.w *= a; return this }; b.assignFrom = function(a) { this.x = a.x; this.y = a.y; this.z = a.z; this.w = a.w; return this }; b.add = function(a) { this.x += a.x; this.y += a.y; this.z += a.z; this.w += a.w; return this }; a.math.Quaternion.rotationBetweenVec3 = function(b, d, e) { var f = new a.math.Vec3(b), g = new a.math.Vec3(d); f.normalize(); g.normalize(); var h = f.dot(g); d = new a.math.Quaternion; if (1 <= h) return d.identity(), d; - 0.999999 > h ? Math.abs(e.lengthSq()) < a.math.EPSILON ? d.rotationAxis(e, Math.PI) : (f = new a.math.Vec3(1, 0, 0), f.cross(b), Math.abs(f.lengthSq()) < a.math.EPSILON && (f.fill(0, 1, 0), f.cross(b)), f.normalize(), d.rotationAxis(f, Math.PI)) : (b = Math.sqrt(2 * (1 + h)), e = 1 / b, f.cross(g), d.x = f.x * e, d.y = f.y * e, d.z = f.z * e, d.w = 0.5 * b, d.normalize()); return d }; b.multiplyVec3 = function(b) { var d = this.x, e = this.y, f = this.z, g = new a.math.Vec3(b), h = new a.math.Vec3(d, e, f), d = new a.math.Vec3(d, e, f); h.cross(b); d.cross(h); h.scale(2 * q.w); d.scale(2); g.add(h); g.add(d); return g } })(cc); cc.math.AABB = function(a, b) { this.min = a || new cc.math.Vec3; this.max = b || new cc.math.Vec3 }; cc.math.AABB.prototype.containsPoint = function(a) { return a.x >= this.min.x && a.x <= this.max.x && a.y >= this.min.y && a.y <= this.max.y && a.z >= this.min.z && a.z <= this.max.z }; cc.math.AABB.containsPoint = function(a, b) { return a.x >= b.min.x && a.x <= b.max.x && a.y >= b.min.y && a.y <= b.max.y && a.z >= b.min.z && a.z <= b.max.z }; cc.math.AABB.prototype.assignFrom = function(a) { this.min.assignFrom(a.min); this.max.assignFrom(a.max) }; cc.math.AABB.assign = function(a, b) { a.min.assignFrom(b.min); a.max.assignFrom(b.max); return a }; (function(a) { a.math.Matrix4Stack = function(a, b) { this.top = a; this.stack = b || [] }; a.km_mat4_stack = a.math.Matrix4Stack; var b = a.math.Matrix4Stack.prototype; b.initialize = function() { this.stack.length = 0; this.top = null }; a.km_mat4_stack_push = function(b, d) { b.stack.push(b.top); b.top = new a.math.Matrix4(d) }; a.km_mat4_stack_pop = function(a, b) { a.top = a.stack.pop() }; a.km_mat4_stack_release = function(a) { a.stack = null; a.top = null }; b.push = function(b) { b = b || this.top; this.stack.push(this.top); this.top = new a.math.Matrix4(b) }; b.pop = function() { this.top = this.stack.pop() }; b.release = function() { this._matrixPool = this.top = this.stack = null }; b._getFromPool = function(b) { var d = this._matrixPool; if (0 === d.length) return new a.math.Matrix4(b); d = d.pop(); d.assignFrom(b); return d }; b._putInPool = function(a) { this._matrixPool.push(a) } })(cc); (function(a) { a.KM_GL_MODELVIEW = 5888; a.KM_GL_PROJECTION = 5889; a.KM_GL_TEXTURE = 5890; a.modelview_matrix_stack = new a.math.Matrix4Stack; a.projection_matrix_stack = new a.math.Matrix4Stack; a.texture_matrix_stack = new a.math.Matrix4Stack; a.current_stack = null; a.lazyInitialize = function() { var b = new a.math.Matrix4; a.modelview_matrix_stack.initialize(); a.projection_matrix_stack.initialize(); a.texture_matrix_stack.initialize(); a.current_stack = a.modelview_matrix_stack; a.initialized = !0; b.identity(); a.modelview_matrix_stack.push(b); a.projection_matrix_stack.push(b); a.texture_matrix_stack.push(b) }; a.lazyInitialize(); a.kmGLFreeAll = function() { a.modelview_matrix_stack.release(); a.modelview_matrix_stack = null; a.projection_matrix_stack.release(); a.projection_matrix_stack = null; a.texture_matrix_stack.release(); a.texture_matrix_stack = null; a.initialized = !1; a.current_stack = null }; a.kmGLPushMatrix = function() { a.current_stack.push(a.current_stack.top) }; a.kmGLPushMatrixWitMat4 = function(b) { a.current_stack.stack.push(a.current_stack.top); b.assignFrom(a.current_stack.top); a.current_stack.top = b }; a.kmGLPopMatrix = function() { a.current_stack.top = a.current_stack.stack.pop() }; a.kmGLMatrixMode = function(b) { switch (b) { case a.KM_GL_MODELVIEW: a.current_stack = a.modelview_matrix_stack; break; case a.KM_GL_PROJECTION: a.current_stack = a.projection_matrix_stack; break; case a.KM_GL_TEXTURE: a.current_stack = a.texture_matrix_stack; break; default: throw "Invalid matrix mode specified"; } }; a.kmGLLoadIdentity = function() { a.current_stack.top.identity() }; a.kmGLLoadMatrix = function(b) { a.current_stack.top.assignFrom(b) }; a.kmGLMultMatrix = function(b) { a.current_stack.top.multiply(b) }; var b = new a.math.Matrix4; a.kmGLTranslatef = function(c, e, f) { c = a.math.Matrix4.createByTranslation(c, e, f, b); a.current_stack.top.multiply(c) }; var c = new a.math.Vec3; a.kmGLRotatef = function(d, e, f, g) { c.fill(e, f, g); d = a.math.Matrix4.createByAxisAndAngle(c, a.degreesToRadians(d), b); a.current_stack.top.multiply(d) }; a.kmGLScalef = function(c, e, f) { c = a.math.Matrix4.createByScale(c, e, f, b); a.current_stack.top.multiply(c) }; a.kmGLGetMatrix = function(b, c) { switch (b) { case a.KM_GL_MODELVIEW: c.assignFrom(a.modelview_matrix_stack.top); break; case a.KM_GL_PROJECTION: c.assignFrom(a.projection_matrix_stack.top); break; case a.KM_GL_TEXTURE: c.assignFrom(a.texture_matrix_stack.top); break; default: throw "Invalid matrix mode specified"; } } })(cc); cc.SHADER_POSITION_UCOLOR_FRAG = "precision lowp float;\nvarying vec4 v_fragmentColor;\nvoid main() \n{ \n gl_FragColor \x3d v_fragmentColor; \n}\n"; cc.SHADER_POSITION_UCOLOR_VERT = "attribute vec4 a_position;\nuniform vec4 u_color;\nuniform float u_pointSize;\nvarying lowp vec4 v_fragmentColor; \nvoid main(void) \n{\n gl_Position \x3d (CC_PMatrix * CC_MVMatrix) * a_position; \n gl_PointSize \x3d u_pointSize; \n v_fragmentColor \x3d u_color; \n}"; cc.SHADER_POSITION_COLOR_FRAG = "precision lowp float; \nvarying vec4 v_fragmentColor; \nvoid main() \n{ \n gl_FragColor \x3d v_fragmentColor; \n} "; cc.SHADER_POSITION_COLOR_VERT = "attribute vec4 a_position;\nattribute vec4 a_color;\nvarying lowp vec4 v_fragmentColor;\nvoid main()\n{\n gl_Position \x3d (CC_PMatrix * CC_MVMatrix) * a_position; \n v_fragmentColor \x3d a_color; \n}"; cc.SHADER_POSITION_COLOR_LENGTH_TEXTURE_FRAG = "// #extension GL_OES_standard_derivatives : enable\nvarying mediump vec4 v_color;\nvarying mediump vec2 v_texcoord;\nvoid main()\t\n{ \n// #if defined GL_OES_standard_derivatives\t\n// gl_FragColor \x3d v_color*smoothstep(0.0, length(fwidth(v_texcoord)), 1.0 - length(v_texcoord)); \n// #else\t\ngl_FragColor \x3d v_color * step(0.0, 1.0 - length(v_texcoord)); \n// #endif \n}"; cc.SHADER_POSITION_COLOR_LENGTH_TEXTURE_VERT = "attribute mediump vec4 a_position; \nattribute mediump vec2 a_texcoord; \nattribute mediump vec4 a_color;\t\nvarying mediump vec4 v_color; \nvarying mediump vec2 v_texcoord;\t\nvoid main() \n{ \n v_color \x3d a_color;//vec4(a_color.rgb * a_color.a, a_color.a); \n v_texcoord \x3d a_texcoord; \n gl_Position \x3d (CC_PMatrix * CC_MVMatrix) * a_position; \n}"; cc.SHADER_POSITION_TEXTURE_FRAG = "precision lowp float; \nvarying vec2 v_texCoord; \nvoid main() \n{ \n gl_FragColor \x3d texture2D(CC_Texture0, v_texCoord); \n}"; cc.SHADER_POSITION_TEXTURE_VERT = "attribute vec4 a_position; \nattribute vec2 a_texCoord; \nvarying mediump vec2 v_texCoord; \nvoid main() \n{ \n gl_Position \x3d (CC_PMatrix * CC_MVMatrix) * a_position; \n v_texCoord \x3d a_texCoord; \n}"; cc.SHADER_POSITION_TEXTURE_UCOLOR_FRAG = "precision lowp float; \nuniform vec4 u_color; \nvarying vec2 v_texCoord; \nvoid main() \n{ \n gl_FragColor \x3d texture2D(CC_Texture0, v_texCoord) * u_color; \n}"; cc.SHADER_POSITION_TEXTURE_UCOLOR_VERT = "attribute vec4 a_position;\nattribute vec2 a_texCoord; \nvarying mediump vec2 v_texCoord; \nvoid main() \n{ \n gl_Position \x3d (CC_PMatrix * CC_MVMatrix) * a_position; \n v_texCoord \x3d a_texCoord; \n}"; cc.SHADER_POSITION_TEXTURE_A8COLOR_FRAG = "precision lowp float; \nvarying vec4 v_fragmentColor; \nvarying vec2 v_texCoord; \nvoid main() \n{ \n gl_FragColor \x3d vec4( v_fragmentColor.rgb, \n v_fragmentColor.a * texture2D(CC_Texture0, v_texCoord).a \n ); \n}"; cc.SHADER_POSITION_TEXTURE_A8COLOR_VERT = "attribute vec4 a_position; \nattribute vec2 a_texCoord; \nattribute vec4 a_color; \nvarying lowp vec4 v_fragmentColor; \nvarying mediump vec2 v_texCoord; \nvoid main() \n{ \n gl_Position \x3d (CC_PMatrix * CC_MVMatrix) * a_position; \n v_fragmentColor \x3d a_color; \n v_texCoord \x3d a_texCoord; \n}"; cc.SHADER_POSITION_TEXTURE_COLOR_FRAG = "precision lowp float;\nvarying vec4 v_fragmentColor; \nvarying vec2 v_texCoord; \nvoid main() \n{ \n gl_FragColor \x3d v_fragmentColor * texture2D(CC_Texture0, v_texCoord); \n}"; cc.SHADER_POSITION_TEXTURE_COLOR_VERT = "attribute vec4 a_position; \nattribute vec2 a_texCoord; \nattribute vec4 a_color; \nvarying lowp vec4 v_fragmentColor; \nvarying mediump vec2 v_texCoord; \nvoid main() \n{ \n gl_Position \x3d (CC_PMatrix * CC_MVMatrix) * a_position; \n v_fragmentColor \x3d a_color; \n v_texCoord \x3d a_texCoord; \n}"; cc.SHADER_POSITION_TEXTURE_COLOR_ALPHATEST_FRAG = "precision lowp float; \nvarying vec4 v_fragmentColor; \nvarying vec2 v_texCoord; \nuniform float CC_alpha_value; \nvoid main() \n{ \n vec4 texColor \x3d texture2D(CC_Texture0, v_texCoord); \n if ( texColor.a \x3c\x3d CC_alpha_value ) \n discard; \n gl_FragColor \x3d texColor * v_fragmentColor; \n}"; cc.SHADEREX_SWITCHMASK_FRAG = "precision lowp float; \nvarying vec4 v_fragmentColor; \nvarying vec2 v_texCoord; \nuniform sampler2D u_texture; \nuniform sampler2D u_mask; \nvoid main() \n{ \n vec4 texColor \x3d texture2D(u_texture, v_texCoord); \n vec4 maskColor \x3d texture2D(u_mask, v_texCoord); \n vec4 finalColor \x3d vec4(texColor.r, texColor.g, texColor.b, maskColor.a * texColor.a); \n gl_FragColor \x3d v_fragmentColor * finalColor; \n}"; cc.shaderCache = { TYPE_POSITION_TEXTURECOLOR: 0, TYPE_POSITION_TEXTURECOLOR_ALPHATEST: 1, TYPE_POSITION_COLOR: 2, TYPE_POSITION_TEXTURE: 3, TYPE_POSITION_TEXTURE_UCOLOR: 4, TYPE_POSITION_TEXTURE_A8COLOR: 5, TYPE_POSITION_UCOLOR: 6, TYPE_POSITION_LENGTH_TEXTURECOLOR: 7, TYPE_MAX: 8, _programs: {}, _init: function() { this.loadDefaultShaders(); return !0 }, _loadDefaultShader: function(a, b) { switch (b) { case this.TYPE_POSITION_TEXTURECOLOR: a.initWithVertexShaderByteArray(cc.SHADER_POSITION_TEXTURE_COLOR_VERT, cc.SHADER_POSITION_TEXTURE_COLOR_FRAG); a.addAttribute(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION); a.addAttribute(cc.ATTRIBUTE_NAME_COLOR, cc.VERTEX_ATTRIB_COLOR); a.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD, cc.VERTEX_ATTRIB_TEX_COORDS); break; case this.TYPE_POSITION_TEXTURECOLOR_ALPHATEST: a.initWithVertexShaderByteArray(cc.SHADER_POSITION_TEXTURE_COLOR_VERT, cc.SHADER_POSITION_TEXTURE_COLOR_ALPHATEST_FRAG); a.addAttribute(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION); a.addAttribute(cc.ATTRIBUTE_NAME_COLOR, cc.VERTEX_ATTRIB_COLOR); a.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD, cc.VERTEX_ATTRIB_TEX_COORDS); break; case this.TYPE_POSITION_COLOR: a.initWithVertexShaderByteArray(cc.SHADER_POSITION_COLOR_VERT, cc.SHADER_POSITION_COLOR_FRAG); a.addAttribute(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION); a.addAttribute(cc.ATTRIBUTE_NAME_COLOR, cc.VERTEX_ATTRIB_COLOR); break; case this.TYPE_POSITION_TEXTURE: a.initWithVertexShaderByteArray(cc.SHADER_POSITION_TEXTURE_VERT, cc.SHADER_POSITION_TEXTURE_FRAG); a.addAttribute(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION); a.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD, cc.VERTEX_ATTRIB_TEX_COORDS); break; case this.TYPE_POSITION_TEXTURE_UCOLOR: a.initWithVertexShaderByteArray(cc.SHADER_POSITION_TEXTURE_UCOLOR_VERT, cc.SHADER_POSITION_TEXTURE_UCOLOR_FRAG); a.addAttribute(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION); a.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD, cc.VERTEX_ATTRIB_TEX_COORDS); break; case this.TYPE_POSITION_TEXTURE_A8COLOR: a.initWithVertexShaderByteArray(cc.SHADER_POSITION_TEXTURE_A8COLOR_VERT, cc.SHADER_POSITION_TEXTURE_A8COLOR_FRAG); a.addAttribute(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION); a.addAttribute(cc.ATTRIBUTE_NAME_COLOR, cc.VERTEX_ATTRIB_COLOR); a.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD, cc.VERTEX_ATTRIB_TEX_COORDS); break; case this.TYPE_POSITION_UCOLOR: a.initWithVertexShaderByteArray(cc.SHADER_POSITION_UCOLOR_VERT, cc.SHADER_POSITION_UCOLOR_FRAG); a.addAttribute("aVertex", cc.VERTEX_ATTRIB_POSITION); break; case this.TYPE_POSITION_LENGTH_TEXTURECOLOR: a.initWithVertexShaderByteArray(cc.SHADER_POSITION_COLOR_LENGTH_TEXTURE_VERT, cc.SHADER_POSITION_COLOR_LENGTH_TEXTURE_FRAG); a.addAttribute(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION); a.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD, cc.VERTEX_ATTRIB_TEX_COORDS); a.addAttribute(cc.ATTRIBUTE_NAME_COLOR, cc.VERTEX_ATTRIB_COLOR); break; default: cc.log("cocos2d: cc.shaderCache._loadDefaultShader, error shader type"); return } a.link(); a.updateUniforms() }, loadDefaultShaders: function() { var a = new cc.GLProgram; this._loadDefaultShader(a, this.TYPE_POSITION_TEXTURECOLOR); this._programs[cc.SHADER_POSITION_TEXTURECOLOR] = a; this._programs.ShaderPositionTextureColor = a; a = new cc.GLProgram; this._loadDefaultShader(a, this.TYPE_POSITION_TEXTURECOLOR_ALPHATEST); this._programs[cc.SHADER_POSITION_TEXTURECOLORALPHATEST] = a; this._programs.ShaderPositionTextureColorAlphaTest = a; a = new cc.GLProgram; this._loadDefaultShader(a, this.TYPE_POSITION_COLOR); this._programs[cc.SHADER_POSITION_COLOR] = a; this._programs.ShaderPositionColor = a; a = new cc.GLProgram; this._loadDefaultShader(a, this.TYPE_POSITION_TEXTURE); this._programs[cc.SHADER_POSITION_TEXTURE] = a; this._programs.ShaderPositionTexture = a; a = new cc.GLProgram; this._loadDefaultShader(a, this.TYPE_POSITION_TEXTURE_UCOLOR); this._programs[cc.SHADER_POSITION_TEXTURE_UCOLOR] = a; this._programs.ShaderPositionTextureUColor = a; a = new cc.GLProgram; this._loadDefaultShader(a, this.TYPE_POSITION_TEXTURE_A8COLOR); this._programs[cc.SHADER_POSITION_TEXTUREA8COLOR] = a; this._programs.ShaderPositionTextureA8Color = a; a = new cc.GLProgram; this._loadDefaultShader(a, this.TYPE_POSITION_UCOLOR); this._programs[cc.SHADER_POSITION_UCOLOR] = a; this._programs.ShaderPositionUColor = a; a = new cc.GLProgram; this._loadDefaultShader(a, this.TYPE_POSITION_LENGTH_TEXTURECOLOR); this._programs[cc.SHADER_POSITION_LENGTHTEXTURECOLOR] = a; this._programs.ShaderPositionLengthTextureColor = a }, reloadDefaultShaders: function() { var a = this.programForKey(cc.SHADER_POSITION_TEXTURECOLOR); a.reset(); this._loadDefaultShader(a, this.TYPE_POSITION_TEXTURECOLOR); a = this.programForKey(cc.SHADER_POSITION_TEXTURECOLORALPHATEST); a.reset(); this._loadDefaultShader(a, this.TYPE_POSITION_TEXTURECOLOR_ALPHATEST); a = this.programForKey(cc.SHADER_POSITION_COLOR); a.reset(); this._loadDefaultShader(a, this.TYPE_POSITION_COLOR); a = this.programForKey(cc.SHADER_POSITION_TEXTURE); a.reset(); this._loadDefaultShader(a, this.TYPE_POSITION_TEXTURE); a = this.programForKey(cc.SHADER_POSITION_TEXTURE_UCOLOR); a.reset(); this._loadDefaultShader(a, this.TYPE_POSITION_TEXTURE_UCOLOR); a = this.programForKey(cc.SHADER_POSITION_TEXTUREA8COLOR); a.reset(); this._loadDefaultShader(a, this.TYPE_POSITION_TEXTURE_A8COLOR); a = this.programForKey(cc.SHADER_POSITION_UCOLOR); a.reset(); this._loadDefaultShader(a, this.TYPE_POSITION_UCOLOR) }, programForKey: function(a) { return this._programs[a] }, getProgram: function(a) { return this._programs[a] }, addProgram: function(a, b) { this._programs[b] = a } }; cc.HashUniformEntry = function(a, b, c) { this.value = a; this.location = b; this.hh = c || {} }; cc.GLProgram = cc.Class.extend({ _glContext: null, _programObj: null, _vertShader: null, _fragShader: null, _uniforms: null, _hashForUniforms: null, _usesTime: !1, _updateUniformLocation: function(a, b, c) { if (null == a) return !1; c = !0; for (var d = null, e = 0; e < this._hashForUniforms.length; e++) this._hashForUniforms[e].location == a && (d = this._hashForUniforms[e]); d ? d.value == b ? c = !1 : d.value = b : (d = new cc.HashUniformEntry, d.location = a, d.value = b, this._hashForUniforms.push(d)); return c }, _description: function() { return "\x3cCCGLProgram \x3d " + this.toString() + " | Program \x3d " + this._programObj.toString() + ", VertexShader \x3d " + this._vertShader.toString() + ", FragmentShader \x3d " + this._fragShader.toString() + "\x3e" }, _compileShader: function(a, b, c) { if (!c || !a) return !1; c = (cc.GLProgram._isHighpSupported() ? "precision highp float;\n" : "precision mediump float;\n") + "uniform mat4 CC_PMatrix; \nuniform mat4 CC_MVMatrix; \nuniform mat4 CC_MVPMatrix; \nuniform vec4 CC_Time; \nuniform vec4 CC_SinTime; \nuniform vec4 CC_CosTime; \nuniform vec4 CC_Random01; \nuniform sampler2D CC_Texture0; \n//CC INCLUDES END \n" + c; this._glContext.shaderSource(a, c); this._glContext.compileShader(a); c = this._glContext.getShaderParameter(a, this._glContext.COMPILE_STATUS); c || (cc.log("cocos2d: ERROR: Failed to compile shader:\n" + this._glContext.getShaderSource(a)), b === this._glContext.VERTEX_SHADER ? cc.log("cocos2d: \n" + this.vertexShaderLog()) : cc.log("cocos2d: \n" + this.fragmentShaderLog())); return !0 === c }, ctor: function(a, b, c) { this._uniforms = []; this._hashForUniforms = []; this._glContext = c || cc._renderContext; a && b && this.init(a, b) }, destroyProgram: function() { this._hashForUniforms = this._uniforms = this._fragShader = this._vertShader = null; this._glContext.deleteProgram(this._programObj) }, initWithVertexShaderByteArray: function(a, b) { var c = this._glContext; this._programObj = c.createProgram(); this._fragShader = this._vertShader = null; a && (this._vertShader = c.createShader(c.VERTEX_SHADER), this._compileShader(this._vertShader, c.VERTEX_SHADER, a) || cc.log("cocos2d: ERROR: Failed to compile vertex shader")); b && (this._fragShader = c.createShader(c.FRAGMENT_SHADER), this._compileShader(this._fragShader, c.FRAGMENT_SHADER, b) || cc.log("cocos2d: ERROR: Failed to compile fragment shader")); this._vertShader && c.attachShader(this._programObj, this._vertShader); cc.checkGLErrorDebug(); this._fragShader && c.attachShader(this._programObj, this._fragShader); this._hashForUniforms.length = 0; cc.checkGLErrorDebug(); return !0 }, initWithString: function(a, b) { return this.initWithVertexShaderByteArray(a, b) }, initWithVertexShaderFilename: function(a, b) { var c = cc.loader.getRes(a); if (!c) throw "Please load the resource firset : " + a; var d = cc.loader.getRes(b); if (!d) throw "Please load the resource firset : " + b; return this.initWithVertexShaderByteArray(c, d) }, init: function(a, b) { return this.initWithVertexShaderFilename(a, b) }, addAttribute: function(a, b) { this._glContext.bindAttribLocation(this._programObj, b, a) }, link: function() { if (!this._programObj) return cc.log("cc.GLProgram.link(): Cannot link invalid program"), !1; this._glContext.linkProgram(this._programObj); this._vertShader && this._glContext.deleteShader(this._vertShader); this._fragShader && this._glContext.deleteShader(this._fragShader); this._fragShader = this._vertShader = null; return cc.game.config[cc.game.CONFIG_KEY.debugMode] && !this._glContext.getProgramParameter(this._programObj, this._glContext.LINK_STATUS) ? (cc.log("cocos2d: ERROR: Failed to link program: " + this._glContext.getProgramInfoLog(this._programObj)), cc.glDeleteProgram(this._programObj), this._programObj = null, !1) : !0 }, use: function() { cc.glUseProgram(this._programObj) }, updateUniforms: function() { this._uniforms[cc.UNIFORM_PMATRIX] = this._glContext.getUniformLocation(this._programObj, cc.UNIFORM_PMATRIX_S); this._uniforms[cc.UNIFORM_MVMATRIX] = this._glContext.getUniformLocation(this._programObj, cc.UNIFORM_MVMATRIX_S); this._uniforms[cc.UNIFORM_MVPMATRIX] = this._glContext.getUniformLocation(this._programObj, cc.UNIFORM_MVPMATRIX_S); this._uniforms[cc.UNIFORM_TIME] = this._glContext.getUniformLocation(this._programObj, cc.UNIFORM_TIME_S); this._uniforms[cc.UNIFORM_SINTIME] = this._glContext.getUniformLocation(this._programObj, cc.UNIFORM_SINTIME_S); this._uniforms[cc.UNIFORM_COSTIME] = this._glContext.getUniformLocation(this._programObj, cc.UNIFORM_COSTIME_S); this._usesTime = null != this._uniforms[cc.UNIFORM_TIME] || null != this._uniforms[cc.UNIFORM_SINTIME] || null != this._uniforms[cc.UNIFORM_COSTIME]; this._uniforms[cc.UNIFORM_RANDOM01] = this._glContext.getUniformLocation(this._programObj, cc.UNIFORM_RANDOM01_S); this._uniforms[cc.UNIFORM_SAMPLER] = this._glContext.getUniformLocation(this._programObj, cc.UNIFORM_SAMPLER_S); this.use(); this.setUniformLocationWith1i(this._uniforms[cc.UNIFORM_SAMPLER], 0) }, getUniformLocationForName: function(a) { if (!a) throw "cc.GLProgram.getUniformLocationForName(): uniform name should be non-null"; if (!this._programObj) throw "cc.GLProgram.getUniformLocationForName(): Invalid operation. Cannot get uniform location when program is not initialized"; return this._glContext.getUniformLocation(this._programObj, a) }, getUniformMVPMatrix: function() { return this._uniforms[cc.UNIFORM_MVPMATRIX] }, getUniformSampler: function() { return this._uniforms[cc.UNIFORM_SAMPLER] }, setUniformLocationWith1i: function(a, b) { this._updateUniformLocation(a, b) && this._glContext.uniform1i(a, b) }, setUniformLocationWith2i: function(a, b, c) { this._updateUniformLocation(a, [b, c]) && this._glContext.uniform2i(a, b, c) }, setUniformLocationWith3i: function(a, b, c, d) { this._updateUniformLocation(a, [b, c, d]) && this._glContext.uniform3i(a, b, c, d) }, setUniformLocationWith4i: function(a, b, c, d, e) { this._updateUniformLocation(a, [b, c, d, e]) && this._glContext.uniform4i(a, b, c, d, e) }, setUniformLocationWith2iv: function(a, b, c) { this._updateUniformLocation(a, b) && this._glContext.uniform2iv(a, b) }, setUniformLocationWith3iv: function(a, b, c) { this._updateUniformLocation(a, b) && this._glContext.uniform3iv(a, b) }, setUniformLocationWith4iv: function(a, b, c) { this._updateUniformLocation(a, b) && this._glContext.uniform4iv(a, b) }, setUniformLocationI32: function(a, b) { this.setUniformLocationWith1i(a, b) }, setUniformLocationWith1f: function(a, b) { this._updateUniformLocation(a, b) && this._glContext.uniform1f(a, b) }, setUniformLocationWith2f: function(a, b, c) { this._updateUniformLocation(a, [b, c ]) && this._glContext.uniform2f(a, b, c) }, setUniformLocationWith3f: function(a, b, c, d) { this._updateUniformLocation(a, [b, c, d]) && this._glContext.uniform3f(a, b, c, d) }, setUniformLocationWith4f: function(a, b, c, d, e) { this._updateUniformLocation(a, [b, c, d, e]) && this._glContext.uniform4f(a, b, c, d, e) }, setUniformLocationWith2fv: function(a, b, c) { this._updateUniformLocation(a, b) && this._glContext.uniform2fv(a, b) }, setUniformLocationWith3fv: function(a, b, c) { this._updateUniformLocation(a, b) && this._glContext.uniform3fv(a, b) }, setUniformLocationWith4fv: function(a, b, c) { this._updateUniformLocation(a, b) && this._glContext.uniform4fv(a, b) }, setUniformLocationWithMatrix4fv: function(a, b, c) { this._updateUniformLocation(a, b) && this._glContext.uniformMatrix4fv(a, !1, b) }, setUniformLocationF32: function() { if (!(2 > arguments.length)) switch (arguments.length) { case 2: this.setUniformLocationWith1f(arguments[0], arguments[1]); break; case 3: this.setUniformLocationWith2f(arguments[0], arguments[1], arguments[2]); break; case 4: this.setUniformLocationWith3f(arguments[0], arguments[1], arguments[2], arguments[3]); break; case 5: this.setUniformLocationWith4f(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]) } }, setUniformsForBuiltins: function() { var a = new cc.math.Matrix4, b = new cc.math.Matrix4, c = new cc.math.Matrix4; cc.kmGLGetMatrix(cc.KM_GL_PROJECTION, a); cc.kmGLGetMatrix(cc.KM_GL_MODELVIEW, b); cc.kmMat4Multiply(c, a, b); this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_PMATRIX], a.mat, 1); this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_MVMATRIX], b.mat, 1); this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_MVPMATRIX], c.mat, 1); this._usesTime && (a = cc.director, a = a.getTotalFrames() * a.getAnimationInterval(), this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_TIME], a / 10, a, 2 * a, 4 * a), this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_SINTIME], a / 8, a / 4, a / 2, Math.sin(a)), this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_COSTIME], a / 8, a / 4, a / 2, Math.cos(a))); - 1 !== this._uniforms[cc.UNIFORM_RANDOM01] && this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_RANDOM01], Math.random(), Math.random(), Math.random(), Math.random()) }, _setUniformsForBuiltinsForRenderer: function(a) { if (a && a._renderCmd) { var b = new cc.math.Matrix4, c = new cc.math.Matrix4; cc.kmGLGetMatrix(cc.KM_GL_PROJECTION, b); cc.kmMat4Multiply(c, b, a._renderCmd._stackMatrix); this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_PMATRIX], b.mat, 1); this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_MVMATRIX], a._renderCmd._stackMatrix.mat, 1); this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_MVPMATRIX], c.mat, 1); this._usesTime && (a = cc.director, a = a.getTotalFrames() * a.getAnimationInterval(), this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_TIME], a / 10, a, 2 * a, 4 * a), this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_SINTIME], a / 8, a / 4, a / 2, Math.sin(a)), this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_COSTIME], a / 8, a / 4, a / 2, Math.cos(a))); - 1 !== this._uniforms[cc.UNIFORM_RANDOM01] && this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_RANDOM01], Math.random(), Math.random(), Math.random(), Math.random()) } }, setUniformForModelViewProjectionMatrix: function() { this._glContext.uniformMatrix4fv(this._uniforms[cc.UNIFORM_MVPMATRIX], !1, cc.getMat4MultiplyValue(cc.projection_matrix_stack.top, cc.modelview_matrix_stack.top)) }, setUniformForModelViewProjectionMatrixWithMat4: function(a) { cc.kmMat4Multiply(a, cc.projection_matrix_stack.top, cc.modelview_matrix_stack.top); this._glContext.uniformMatrix4fv(this._uniforms[cc.UNIFORM_MVPMATRIX], !1, a.mat) }, setUniformForModelViewAndProjectionMatrixWithMat4: function() { this._glContext.uniformMatrix4fv(this._uniforms[cc.UNIFORM_MVMATRIX], !1, cc.modelview_matrix_stack.top.mat); this._glContext.uniformMatrix4fv(this._uniforms[cc.UNIFORM_PMATRIX], !1, cc.projection_matrix_stack.top.mat) }, _setUniformForMVPMatrixWithMat4: function(a) { if (!a) throw "modelView matrix is undefined."; this._glContext.uniformMatrix4fv(this._uniforms[cc.UNIFORM_MVMATRIX], !1, a.mat); this._glContext.uniformMatrix4fv(this._uniforms[cc.UNIFORM_PMATRIX], !1, cc.projection_matrix_stack.top.mat) }, vertexShaderLog: function() { return this._glContext.getShaderInfoLog(this._vertShader) }, getVertexShaderLog: function() { return this._glContext.getShaderInfoLog(this._vertShader) }, getFragmentShaderLog: function() { return this._glContext.getShaderInfoLog(this._vertShader) }, fragmentShaderLog: function() { return this._glContext.getShaderInfoLog(this._fragShader) }, programLog: function() { return this._glContext.getProgramInfoLog(this._programObj) }, getProgramLog: function() { return this._glContext.getProgramInfoLog(this._programObj) }, reset: function() { this._fragShader = this._vertShader = null; this._uniforms.length = 0; this._glContext.deleteProgram(this._programObj); this._programObj = null; for (var a = 0; a < this._hashForUniforms.length; a++) this._hashForUniforms[a].value = null, this._hashForUniforms[a] = null; this._hashForUniforms.length = 0 }, getProgram: function() { return this._programObj }, retain: function() {}, release: function() {} }); cc.GLProgram.create = function(a, b) { return new cc.GLProgram(a, b) }; cc.GLProgram._highpSupported = null; cc.GLProgram._isHighpSupported = function() { if (null == cc.GLProgram._highpSupported) { var a = cc._renderContext, a = a.getShaderPrecisionFormat(a.FRAGMENT_SHADER, a.HIGH_FLOAT); cc.GLProgram._highpSupported = 0 !== a.precision } return cc.GLProgram._highpSupported }; cc.setProgram = function(a, b) { a.shaderProgram = b; var c = a.children; if (c) for (var d = 0; d < c.length; d++) cc.setProgram(c[d], b) }; cc._currentProjectionMatrix = -1; cc._vertexAttribPosition = !1; cc._vertexAttribColor = !1; cc._vertexAttribTexCoords = !1; cc.ENABLE_GL_STATE_CACHE && (cc.MAX_ACTIVETEXTURE = 16, cc._currentShaderProgram = -1, cc._currentBoundTexture = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], cc._blendingSource = -1, cc._blendingDest = -1, cc._GLServerState = 0, cc.TEXTURE_ATLAS_USE_VAO && (cc._uVAO = 0)); cc.glInvalidateStateCache = function() { cc.kmGLFreeAll(); cc._currentProjectionMatrix = -1; cc._vertexAttribPosition = !1; cc._vertexAttribColor = !1; cc._vertexAttribTexCoords = !1; if (cc.ENABLE_GL_STATE_CACHE) { cc._currentShaderProgram = -1; for (var a = 0; a < cc.MAX_ACTIVETEXTURE; a++) cc._currentBoundTexture[a] = -1; cc._blendingSource = -1; cc._blendingDest = -1; cc._GLServerState = 0 } }; cc.glUseProgram = function(a) { a !== cc._currentShaderProgram && (cc._currentShaderProgram = a, cc._renderContext.useProgram(a)) }; cc.ENABLE_GL_STATE_CACHE || (cc.glUseProgram = function(a) { cc._renderContext.useProgram(a) }); cc.glDeleteProgram = function(a) { cc.ENABLE_GL_STATE_CACHE && a === cc._currentShaderProgram && (cc._currentShaderProgram = -1); gl.deleteProgram(a) }; cc.glBlendFunc = function(a, b) { if (a !== cc._blendingSource || b !== cc._blendingDest) cc._blendingSource = a, cc._blendingDest = b, cc.setBlending(a, b) }; cc.setBlending = function(a, b) { var c = cc._renderContext; a === c.ONE && b === c.ZERO ? c.disable(c.BLEND) : (c.enable(c.BLEND), cc._renderContext.blendFunc(a, b)) }; cc.glBlendFuncForParticle = function(a, b) { if (a !== cc._blendingSource || b !== cc._blendingDest) { cc._blendingSource = a; cc._blendingDest = b; var c = cc._renderContext; a === c.ONE && b === c.ZERO ? c.disable(c.BLEND) : (c.enable(c.BLEND), c.blendFuncSeparate(c.SRC_ALPHA, b, a, b)) } }; cc.ENABLE_GL_STATE_CACHE || (cc.glBlendFunc = cc.setBlending); cc.glBlendResetToCache = function() { var a = cc._renderContext; a.blendEquation(a.FUNC_ADD); cc.ENABLE_GL_STATE_CACHE ? cc.setBlending(cc._blendingSource, cc._blendingDest) : cc.setBlending(a.BLEND_SRC, a.BLEND_DST) }; cc.setProjectionMatrixDirty = function() { cc._currentProjectionMatrix = -1 }; cc.glEnableVertexAttribs = function(a) { var b = cc._renderContext, c = a & cc.VERTEX_ATTRIB_FLAG_POSITION; c !== cc._vertexAttribPosition && (c ? b.enableVertexAttribArray(cc.VERTEX_ATTRIB_POSITION) : b.disableVertexAttribArray(cc.VERTEX_ATTRIB_POSITION), cc._vertexAttribPosition = c); c = a & cc.VERTEX_ATTRIB_FLAG_COLOR; c !== cc._vertexAttribColor && (c ? b.enableVertexAttribArray(cc.VERTEX_ATTRIB_COLOR) : b.disableVertexAttribArray(cc.VERTEX_ATTRIB_COLOR), cc._vertexAttribColor = c); a &= cc.VERTEX_ATTRIB_FLAG_TEX_COORDS; a !== cc._vertexAttribTexCoords && (a ? b.enableVertexAttribArray(cc.VERTEX_ATTRIB_TEX_COORDS) : b.disableVertexAttribArray(cc.VERTEX_ATTRIB_TEX_COORDS), cc._vertexAttribTexCoords = a) }; cc.glBindTexture2D = function(a) { cc.glBindTexture2DN(0, a) }; cc.glBindTexture2DN = function(a, b) { if (cc._currentBoundTexture[a] !== b) { cc._currentBoundTexture[a] = b; var c = cc._renderContext; c.activeTexture(c.TEXTURE0 + a); b ? c.bindTexture(c.TEXTURE_2D, b._webTextureObj) : c.bindTexture(c.TEXTURE_2D, null) } }; cc.ENABLE_GL_STATE_CACHE || (cc.glBindTexture2DN = function(a, b) { var c = cc._renderContext; c.activeTexture(c.TEXTURE0 + a); b ? c.bindTexture(c.TEXTURE_2D, b._webTextureObj) : c.bindTexture(c.TEXTURE_2D, null) }); cc.glDeleteTexture = function(a) { cc.glDeleteTextureN(0, a) }; cc.glDeleteTextureN = function(a, b) { cc.ENABLE_GL_STATE_CACHE && b === cc._currentBoundTexture[a] && (cc._currentBoundTexture[a] = -1); cc._renderContext.deleteTexture(b) }; cc.glBindVAO = function(a) { cc.TEXTURE_ATLAS_USE_VAO && cc.ENABLE_GL_STATE_CACHE && cc._uVAO !== a && (cc._uVAO = a) }; cc.glEnable = function(a) {}; cc.IMAGE_FORMAT_JPEG = 0; cc.IMAGE_FORMAT_PNG = 1; cc.IMAGE_FORMAT_RAWDATA = 9; cc.NextPOT = function(a) { a -= 1; a |= a >> 1; a |= a >> 2; a |= a >> 4; a |= a >> 8; return (a | a >> 16) + 1 }; cc.RenderTexture = cc.Node.extend({ sprite: null, clearFlags: 0, clearDepthVal: 0, autoDraw: !1, _texture: null, _pixelFormat: cc.Texture2D.PIXEL_FORMAT_RGBA8888, clearStencilVal: 0, _clearColor: null, _className: "RenderTexture", ctor: function(a, b, c, d) { cc.Node.prototype.ctor.call(this); this._cascadeOpacityEnabled = this._cascadeColorEnabled = !0; this._clearColor = new cc.Color(0, 0, 0, 255); void 0 !== a && void 0 !== b && (c = c || cc.Texture2D.PIXEL_FORMAT_RGBA8888, this.initWithWidthAndHeight(a, b, c, d || 0)); this.setAnchorPoint(0, 0) }, _createRenderCmd: function() { return cc._renderType === cc._RENDER_TYPE_CANVAS ? new cc.RenderTexture.CanvasRenderCmd(this) : new cc.RenderTexture.WebGLRenderCmd(this) }, cleanup: function() { cc.Node.prototype.onExit.call(this); this._renderCmd.cleanup() }, getSprite: function() { return this.sprite }, setSprite: function(a) { this.sprite = a }, setVirtualViewport: function(a, b, c) { this._renderCmd.setVirtualViewport(a, b, c) }, initWithWidthAndHeight: function(a, b, c, d) { return this._renderCmd.initWithWidthAndHeight(a, b, c, d) }, begin: function() { cc.renderer._turnToCacheMode(this.__instanceId); this._renderCmd.begin() }, beginWithClear: function(a, b, c, d, e, f) { var g = cc._renderContext; e = e || g.COLOR_BUFFER_BIT; f = f || g.COLOR_BUFFER_BIT | g.DEPTH_BUFFER_BIT; this._beginWithClear(a, b, c, d, e, f, g.COLOR_BUFFER_BIT | g.DEPTH_BUFFER_BIT | g.STENCIL_BUFFER_BIT) }, _beginWithClear: function(a, b, c, d, e, f, g) { this.begin(); this._renderCmd._beginWithClear(a, b, c, d, e, f, g) }, end: function() { this._renderCmd.end() }, clear: function(a, b, c, d) { this.beginWithClear(a, b, c, d); this.end() }, clearRect: function(a, b, c, d) { this._renderCmd.clearRect(a, b, c, d) }, clearDepth: function(a) { this._renderCmd.clearDepth(a) }, clearStencil: function(a) { this._renderCmd.clearStencil(a) }, getClearFlags: function() { return this.clearFlags }, setClearFlags: function(a) { this.clearFlags = a }, getClearColor: function() { return this._clearColor }, setClearColor: function(a) { var b = this._clearColor; b.r = a.r; b.g = a.g; b.b = a.b; b.a = a.a; this._renderCmd.updateClearColor(a) }, getClearDepth: function() { return this.clearDepthVal }, setClearDepth: function(a) { this.clearDepthVal = a }, getClearStencil: function() { return this.clearStencilVal }, setClearStencil: function(a) { this.clearStencilVal = a }, isAutoDraw: function() { return this.autoDraw }, setAutoDraw: function(a) { this.autoDraw = a }, saveToFile: function(a, b) { cc.log("saveToFile isn't supported on Cocos2d-Html5") }, newCCImage: function(a) { cc.log("saveToFile isn't supported on cocos2d-html5"); return null }, listenToBackground: function(a) {}, listenToForeground: function(a) {} }); _p = cc.RenderTexture.prototype; cc.defineGetterSetter(_p, "clearColorVal", _p.getClearColor, _p.setClearColor); cc.RenderTexture.create = function(a, b, c, d) { return new cc.RenderTexture(a, b, c, d) }; (function() { cc.RenderTexture.CanvasRenderCmd = function(a) { cc.Node.CanvasRenderCmd.call(this, a); this._needDraw = !0; this._clearColorStr = "rgba(255,255,255,1)"; this._cacheCanvas = cc.newElement("canvas"); this._cacheContext = new cc.CanvasContextWrapper(this._cacheCanvas.getContext("2d")) }; var a = cc.RenderTexture.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); a.constructor = cc.RenderTexture.CanvasRenderCmd; a.cleanup = function() { this._cacheCanvas = this._cacheContext = null }; a.clearStencil = function(a) {}; a.setVirtualViewport = function(a, c, d) {}; a.updateClearColor = function(a) { this._clearColorStr = "rgba(" + (0 | a.r) + "," + (0 | a.g) + "," + (0 | a.b) + "," + a.a / 255 + ")" }; a.initWithWidthAndHeight = function(a, c, d, e) { d = this._node; e = this._cacheCanvas; var f = cc.contentScaleFactor(); e.width = 0 | a * f; e.height = 0 | c * f; a = new cc.Texture2D; a.initWithElement(e); a.handleLoadedTexture(); a = d.sprite = new cc.Sprite(a); a.setBlendFunc(cc.ONE, cc.ONE_MINUS_SRC_ALPHA); d.autoDraw = !1; d.addChild(a); return !0 }; a.begin = function() {}; a._beginWithClear = function(a, c, d, e, f, g, h) { a = a || 0; c = c || 0; d = d || 0; e = isNaN(e) ? 255 : e; f = this._cacheContext.getContext(); g = this._cacheCanvas; f.setTransform(1, 0, 0, 1, 0, 0); this._cacheContext.setFillStyle("rgba(" + (0 | a) + "," + (0 | c) + "," + (0 | d) + "," + e / 255 + ")"); f.clearRect(0, 0, g.width, g.height); f.fillRect(0, 0, g.width, g.height) }; a.end = function() { var a = this._node, c = cc.contentScaleFactor(); cc.renderer._renderingToCacheCanvas(this._cacheContext, a.__instanceId, c, c) }; a.clearRect = function(a, c, d, e) { this._cacheContext.clearRect(a, c, d, -e) }; a.clearDepth = function(a) { cc.log("clearDepth isn't supported on Cocos2d-Html5") }; a.visit = function(a) { var c = this._node; this._syncStatus(a); c.sprite.visit(this); this._dirtyFlag = 0 } })(); (function() { cc.RenderTexture.WebGLRenderCmd = function(a) { cc.Node.WebGLRenderCmd.call(this, a); this._needDraw = !0; this._depthRenderBuffer = this._textureCopy = this._oldFBO = this._fBO = null; this._rtTextureRect = new cc.Rect; this._fullRect = new cc.Rect; this._fullViewport = new cc.Rect }; var a = cc.RenderTexture.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); a.constructor = cc.RenderTexture.WebGLRenderCmd; a.setVirtualViewport = function(a, c, d) { this._rtTextureRect.x = a.x; this._rtTextureRect.y = a.y; this._fullRect = c; this._fullViewport = d }; a.rendering = function(a) { var c = a || cc._renderContext; a = this._node; if (a.autoDraw) { a.begin(); var d = a.clearFlags; if (d) { var e = [0, 0, 0, 0], f = 0, g = 0; d & c.COLOR_BUFFER_BIT && (e = c.getParameter(c.COLOR_CLEAR_VALUE), c.clearColor(a._clearColor.r / 255, a._clearColor.g / 255, a._clearColor.b / 255, a._clearColor.a / 255)); d & c.DEPTH_BUFFER_BIT && (f = c.getParameter(c.DEPTH_CLEAR_VALUE), c.clearDepth(a.clearDepthVal)); d & c.STENCIL_BUFFER_BIT && (g = c.getParameter(c.STENCIL_CLEAR_VALUE), c.clearStencil(a.clearStencilVal)); c.clear(d); d & c.COLOR_BUFFER_BIT && c.clearColor(e[0], e[1], e[2], e[3]); d & c.DEPTH_BUFFER_BIT && c.clearDepth(f); d & c.STENCIL_BUFFER_BIT && c.clearStencil(g) } a.sortAllChildren(); c = a._children; for (d = 0; d < c.length; d++) e = c[d], e !== a.sprite && e._renderCmd.visit(a.sprite._renderCmd); a.end() } }; a.clearStencil = function(a) { var c = cc._renderContext, d = c.getParameter(c.STENCIL_CLEAR_VALUE); c.clearStencil(a); c.clear(c.STENCIL_BUFFER_BIT); c.clearStencil(d) }; a.cleanup = function() { this._textureCopy = null; var a = cc._renderContext; a.deleteFramebuffer(this._fBO); this._depthRenderBuffer && a.deleteRenderbuffer(this._depthRenderBuffer) }; a.updateClearColor = function(a) {}; a.initWithWidthAndHeight = function(a, c, d, e) { var f = this._node; d === cc.Texture2D.PIXEL_FORMAT_A8 && cc.log("cc.RenderTexture._initWithWidthAndHeightForWebGL() : only RGB and RGBA formats are valid for a render texture;"); var g = cc._renderContext, h = cc.contentScaleFactor(); this._fullRect = new cc.Rect(0, 0, a, c); this._fullViewport = new cc.Rect(0, 0, a, c); a = 0 | a * h; c = 0 | c * h; this._oldFBO = g.getParameter(g.FRAMEBUFFER_BINDING); var k; cc.configuration.supportsNPOT() ? (h = a, k = c) : (h = cc.NextPOT(a), k = cc.NextPOT(c)); for (var m = new Uint8Array(h * k * 4), n = 0; n < h * k * 4; n++) m[n] = 0; this._pixelFormat = d; n = f._texture = new cc.Texture2D; if (!f._texture) return !1; n.initWithData(m, f._pixelFormat, h, k, cc.size(a, c)); d = g.getParameter(g.RENDERBUFFER_BINDING); if (cc.configuration.checkForGLExtension("GL_QCOM")) { this._textureCopy = new cc.Texture2D; if (!this._textureCopy) return !1; this._textureCopy.initWithData(m, f._pixelFormat, h, k, cc.size(a, c)) } this._fBO = g.createFramebuffer(); g.bindFramebuffer(g.FRAMEBUFFER, this._fBO); g.framebufferTexture2D(g.FRAMEBUFFER, g.COLOR_ATTACHMENT0, g.TEXTURE_2D, n._webTextureObj, 0); 0 !== e && (this._depthRenderBuffer = g.createRenderbuffer(), g.bindRenderbuffer(g.RENDERBUFFER, this._depthRenderBuffer), g.renderbufferStorage(g.RENDERBUFFER, e, h, k), e === g.DEPTH_STENCIL ? g.framebufferRenderbuffer(g.FRAMEBUFFER, g.DEPTH_STENCIL_ATTACHMENT, g.RENDERBUFFER, this._depthRenderBuffer) : e === g.STENCIL_INDEX || e === g.STENCIL_INDEX8 ? g.framebufferRenderbuffer(g.FRAMEBUFFER, g.STENCIL_ATTACHMENT, g.RENDERBUFFER, this._depthRenderBuffer) : e === g.DEPTH_COMPONENT16 && g.framebufferRenderbuffer(g.FRAMEBUFFER, g.DEPTH_ATTACHMENT, g.RENDERBUFFER, this._depthRenderBuffer)); g.checkFramebufferStatus(g.FRAMEBUFFER) !== g.FRAMEBUFFER_COMPLETE && cc.log("Could not attach texture to the framebuffer"); n.setAliasTexParameters(); a = f.sprite = new cc.Sprite(n); a.scaleY = -1; a.setBlendFunc(g.ONE, g.ONE_MINUS_SRC_ALPHA); g.bindRenderbuffer(g.RENDERBUFFER, d); g.bindFramebuffer(g.FRAMEBUFFER, this._oldFBO); f.autoDraw = !1; f.addChild(a); return !0 }; a.begin = function() { var a = this._node; cc.kmGLMatrixMode(cc.KM_GL_PROJECTION); cc.kmGLPushMatrix(); cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); cc.kmGLPushMatrix(); var c = cc._renderContext, d = cc.director; d.setProjection(d.getProjection()); var e = a._texture.getContentSizeInPixels(), f = cc.director.getWinSizeInPixels(), d = f.width / e.width, e = f.height / e.height, d = cc.math.Matrix4.createOrthographicProjection(-1 / d, 1 / d, -1 / e, 1 / e, -1, 1); cc.kmGLMultMatrix(d); d = new cc.Rect(0, 0, 0, 0); d.width = this._fullViewport.width; d.height = this._fullViewport.height; e = d.height / this._fullRect.height; d.x = d.width / this._fullRect.width * (this._fullRect.x - this._rtTextureRect.x); d.y = (this._fullRect.y - this._rtTextureRect.y) * e; c.viewport(d.x, d.y, d.width, d.height); this._oldFBO = c.getParameter(c.FRAMEBUFFER_BINDING); c.bindFramebuffer(c.FRAMEBUFFER, this._fBO); cc.configuration.checkForGLExtension("GL_QCOM") && (c.framebufferTexture2D(c.FRAMEBUFFER, c.COLOR_ATTACHMENT0, c.TEXTURE_2D, this._textureCopy._webTextureObj, 0), c.clear(c.COLOR_BUFFER_BIT | c.DEPTH_BUFFER_BIT), c.framebufferTexture2D(c.FRAMEBUFFER, c.COLOR_ATTACHMENT0, c.TEXTURE_2D, a._texture._webTextureObj, 0)) }; a._beginWithClear = function(a, c, d, e, f, g, h) { a /= 255; c /= 255; d /= 255; e /= 255; var k = cc._renderContext, m = [0, 0, 0, 0], n = 0, p = 0; h & k.COLOR_BUFFER_BIT && (m = k.getParameter(k.COLOR_CLEAR_VALUE), k.clearColor(a, c, d, e)); h & k.DEPTH_BUFFER_BIT && (n = k.getParameter(k.DEPTH_CLEAR_VALUE), k.clearDepth(f)); h & k.STENCIL_BUFFER_BIT && (p = k.getParameter(k.STENCIL_CLEAR_VALUE), k.clearStencil(g)); k.clear(h); h & k.COLOR_BUFFER_BIT && k.clearColor(m[0], m[1], m[2], m[3]); h & k.DEPTH_BUFFER_BIT && k.clearDepth(n); h & k.STENCIL_BUFFER_BIT && k.clearStencil(p) }; a.end = function() { cc.renderer._renderingToBuffer(this._node.__instanceId); var a = cc._renderContext, c = cc.director; a.bindFramebuffer(a.FRAMEBUFFER, this._oldFBO); c.setViewport(); cc.kmGLMatrixMode(cc.KM_GL_PROJECTION); cc.kmGLPopMatrix(); cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); cc.kmGLPopMatrix() }; a.clearRect = function(a, c, d, e) {}; a.clearDepth = function(a) { var c = this._node; c.begin(); var d = cc._renderContext, e = d.getParameter(d.DEPTH_CLEAR_VALUE); d.clearDepth(a); d.clear(d.DEPTH_BUFFER_BIT); d.clearDepth(e); c.end() }; a.visit = function(a) { var c = this._node; c._visible && (cc.kmGLPushMatrix(), this._syncStatus(a), cc.renderer.pushRenderCommand(this), c.sprite.visit(this), this._dirtyFlag = 0, cc.kmGLPopMatrix()) } })(); cc.LabelAtlas = cc.AtlasNode.extend({ _string: null, _mapStartChar: null, _textureLoaded: !1, _className: "LabelAtlas", ctor: function(a, b, c, d, e) { cc.AtlasNode.prototype.ctor.call(this); this._renderCmd.setCascade(); b && cc.LabelAtlas.prototype.initWithString.call(this, a, b, c, d, e) }, _createRenderCmd: function() { return cc._renderType === cc._RENDER_TYPE_WEBGL ? new cc.LabelAtlas.WebGLRenderCmd(this) : new cc.LabelAtlas.CanvasRenderCmd(this) }, textureLoaded: function() { return this._textureLoaded }, addLoadedEventListener: function(a, b) { this.addEventListener("load", a, b) }, initWithString: function(a, b, c, d, e) { var f = a + "", g, h; if (void 0 === c) { c = cc.loader.getRes(b); if (1 !== parseInt(c.version, 10)) return cc.log("cc.LabelAtlas.initWithString(): Unsupported version. Upgrade cocos2d version"), !1; b = cc.path.changeBasename(b, c.textureFilename); d = cc.contentScaleFactor(); g = parseInt(c.itemWidth, 10) / d; h = parseInt(c.itemHeight, 10) / d; c = String.fromCharCode(parseInt(c.firstChar, 10)) } else g = c || 0, h = d || 0, c = e || " "; var k = null, k = b instanceof cc.Texture2D ? b : cc.textureCache.addImage(b); this._textureLoaded = b = k.isLoaded(); b || (this._string = f, k.addEventListener("load", function(a) { this.initWithTexture(k, g, h, f.length); this.string = this._string; this.setColor(this._renderCmd._displayedColor); this.dispatchEvent("load") }, this)); return this.initWithTexture(k, g, h, f.length) ? (this._mapStartChar = c, this.string = f, !0) : !1 }, setColor: function(a) { cc.AtlasNode.prototype.setColor.call(this, a); this._renderCmd.updateAtlasValues() }, getString: function() { return this._string }, addChild: function(a, b, c) { this._renderCmd._addChild(a); cc.Node.prototype.addChild.call(this, a, b, c) }, updateAtlasValues: function() { this._renderCmd.updateAtlasValues() }, setString: function(a) { a = String(a); var b = a.length; this._string = a; this.setContentSize(b * this._itemWidth, this._itemHeight); this._renderCmd.setString(a); this._renderCmd.updateAtlasValues(); this.quadsToDraw = b } }); (function() { var a = cc.LabelAtlas.prototype; cc.defineGetterSetter(a, "opacity", a.getOpacity, a.setOpacity); cc.defineGetterSetter(a, "color", a.getColor, a.setColor); cc.defineGetterSetter(a, "string", a.getString, a.setString) })(); cc.LabelAtlas.create = function(a, b, c, d, e) { return new cc.LabelAtlas(a, b, c, d, e) }; (function() { cc.LabelAtlas.CanvasRenderCmd = function(a) { cc.AtlasNode.CanvasRenderCmd.call(this, a); this._needDraw = !1 }; var a = cc.LabelAtlas.CanvasRenderCmd.prototype = Object.create(cc.AtlasNode.CanvasRenderCmd.prototype); a.constructor = cc.LabelAtlas.CanvasRenderCmd; a.setCascade = function() { var a = this._node; a._cascadeOpacityEnabled = !0; a._cascadeColorEnabled = !1 }; a.updateAtlasValues = function() { for (var a = this._node, c = a._string || "", d = c.length, e = this._texture, f = a._itemWidth, g = a._itemHeight, h = 0; h < d; h++) { var k = c.charCodeAt(h) - a._mapStartChar.charCodeAt(0), m = parseInt(k % a._itemsPerRow, 10), k = parseInt(k / a._itemsPerRow, 10), m = cc.rect(m * f, k * g, f, g), k = c.charCodeAt(h), n = a.getChildByTag(h); n ? 32 === k ? (n.init(), n.setTextureRect(cc.rect(0, 0, 10, 10), !1, cc.size(0, 0))) : (n.initWithTexture(e, m), n.visible = !0) : (n = new cc.Sprite, 32 === k ? (n.init(), n.setTextureRect(cc.rect(0, 0, 10, 10), !1, cc.size(0, 0))) : n.initWithTexture(e, m), cc.Node.prototype.addChild.call(a, n, 0, h)); n.setPosition(h * f + f / 2, g / 2) } }; a.setString = function(a) { a = this._node; if (a._children) { a = a._children; for (var c = a.length, d = 0; d < c; d++) { var e = a[d]; e && !e._lateChild && (e.visible = !1) } } }; a._addChild = function() { child._lateChild = !0 } })(); (function() { cc.LabelAtlas.WebGLRenderCmd = function(a) { cc.AtlasNode.WebGLRenderCmd.call(this, a); this._needDraw = !0 }; var a = cc.LabelAtlas.WebGLRenderCmd.prototype = Object.create(cc.AtlasNode.WebGLRenderCmd.prototype); a.constructor = cc.LabelAtlas.WebGLRenderCmd; a.setCascade = function() { var a = this._node; a._cascadeOpacityEnabled = !0; a._cascadeColorEnabled = !0 }; a.rendering = function(a) { cc.AtlasNode.WebGLRenderCmd.prototype.rendering.call(this, a); cc.LABELATLAS_DEBUG_DRAW && (a = this._node.getContentSize(), a = [cc.p(0, 0), cc.p(a.width, 0), cc.p(a.width, a.height), cc.p(0, a.height)], cc._drawingUtil.drawPoly(a, 4, !0)) }; a.updateAtlasValues = function() { var a = this._node, c = a._string, d = c.length, e = this._textureAtlas, f = e.texture, g = f.pixelsWidth, f = f.pixelsHeight, h = a._itemWidth, k = a._itemHeight; a._ignoreContentScaleFactor || (h = a._itemWidth * cc.contentScaleFactor(), k = a._itemHeight * cc.contentScaleFactor()); d > e.getCapacity() && cc.log("cc.LabelAtlas._updateAtlasValues(): Invalid String length"); for (var m = e.quads, n = this._displayedColor, n = { r: n.r, g: n.g, b: n.b, a: a._displayedOpacity }, p = a._itemWidth, t = 0; t < d; t++) { var r = c.charCodeAt(t) - a._mapStartChar.charCodeAt(0), u = r % a._itemsPerRow, s = 0 | r / a._itemsPerRow, v; cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL ? (u = (2 * u * h + 1) / (2 * g), r = u + (2 * h - 2) / (2 * g), s = (2 * s * k + 1) / (2 * f), v = s + (2 * k - 2) / (2 * f)) : (u = u * h / g, r = u + h / g, s = s * k / f, v = s + k / f); var x = m[t], D = x.tl, E = x.tr, A = x.bl, x = x.br; D.texCoords.u = u; D.texCoords.v = s; E.texCoords.u = r; E.texCoords.v = s; A.texCoords.u = u; A.texCoords.v = v; x.texCoords.u = r; x.texCoords.v = v; A.vertices.x = t * p; A.vertices.y = 0; A.vertices.z = 0; x.vertices.x = t * p + p; x.vertices.y = 0; x.vertices.z = 0; D.vertices.x = t * p; D.vertices.y = a._itemHeight; D.vertices.z = 0; E.vertices.x = t * p + p; E.vertices.y = a._itemHeight; E.vertices.z = 0; D.colors = n; E.colors = n; A.colors = n; x.colors = n } 0 < d && (e.dirty = !0, a = e.totalQuads, d > a && e.increaseTotalQuadsWith(d - a)) }; a.setString = function(a) { a = a.length; a > this._textureAtlas.totalQuads && this._textureAtlas.resizeCapacity(a) }; a._addChild = function() {} })(); cc.LABEL_AUTOMATIC_WIDTH = -1; cc.LabelBMFont = cc.SpriteBatchNode.extend({ _opacityModifyRGB: !1, _string: "", _config: null, _fntFile: "", _initialString: "", _alignment: cc.TEXT_ALIGNMENT_CENTER, _width: -1, _lineBreakWithoutSpaces: !1, _imageOffset: null, _reusedChar: null, _textureLoaded: !1, _className: "LabelBMFont", _createRenderCmd: function() { return cc._renderType === cc._RENDER_TYPE_WEBGL ? new cc.LabelBMFont.WebGLRenderCmd(this) : new cc.LabelBMFont.CanvasRenderCmd(this) }, _setString: function(a, b) { b ? this._initialString = a : this._string = a; var c = this._children; if (c) for (var d = 0; d < c.length; d++) { var e = c[d]; e && e.setVisible(!1) } this._textureLoaded && (this.createFontChars(), b && this.updateLabel()) }, ctor: function(a, b, c, d, e) { cc.SpriteBatchNode.prototype.ctor.call(this); this._imageOffset = cc.p(0, 0); this._reusedChar = []; this._cascadeOpacityEnabled = this._cascadeColorEnabled = !0; this.initWithString(a, b, c, d, e) }, textureLoaded: function() { return this._textureLoaded }, addLoadedEventListener: function(a, b) { this.addEventListener("load", a, b) }, isOpacityModifyRGB: function() { return this._opacityModifyRGB }, setOpacityModifyRGB: function(a) { this._opacityModifyRGB = a; if (a = this._children) for (var b = 0; b < a.length; b++) { var c = a[b]; c && (c.opacityModifyRGB = this._opacityModifyRGB) } }, _changeTextureColor: function() { this._renderCmd._changeTextureColor() }, init: function() { return this.initWithString(null, null, null, null, null) }, initWithString: function(a, b, c, d, e) { a = a || ""; this._config && cc.log("cc.LabelBMFont.initWithString(): re-init is no longer supported"); if (b) { var f = cc.loader.getRes(b); if (!f) return cc.log("cc.LabelBMFont.initWithString(): Impossible to create font. Please check file"), !1; this._config = f; this._fntFile = b; b = cc.textureCache.addImage(f.atlasName); (this._textureLoaded = f = b.isLoaded()) || b.addEventListener("load", function(a) { this._textureLoaded = !0; this.initWithTexture(a, this._initialString.length); this.setString(this._initialString, !0); this.dispatchEvent("load") }, this) } else b = new cc.Texture2D, f = new Image, b.initWithElement(f), this._textureLoaded = !1; return this.initWithTexture(b, a.length) ? (this._alignment = d || cc.TEXT_ALIGNMENT_LEFT, this._imageOffset = e || cc.p(0, 0), this._width = null == c ? -1 : c, this._realOpacity = 255, this._realColor = cc.color(255, 255, 255, 255), this._contentSize.width = 0, this._contentSize.height = 0, this.setAnchorPoint(0.5, 0.5), this._renderCmd._initBatchTexture(), this.setString(a, !0), !0) : !1 }, createFontChars: function() { var a = this._renderCmd._texture || this.textureAtlas.texture, b = 0, c = cc.size(0, 0), d = 0, e = 1, f = this._string, g = f ? f.length : 0; if (0 !== g) { var h, k = this._config, m = k.kerningDict, n = k.commonHeight, p = k.fontDefDictionary; for (h = 0; h < g - 1; h++) 10 === f.charCodeAt(h) && e++; var t = n * e, e = -(n - n * e), r = -1; for (h = 0; h < g; h++) if (n = f.charCodeAt(h), 0 !== n) if (10 === n) b = 0, e -= k.commonHeight; else { var u = m[r << 16 | n & 65535] || 0, s = p[n]; if (s) { var v = cc.rect(s.rect.x, s.rect.y, s.rect.width, s.rect.height), v = cc.rectPixelsToPoints(v); v.x += this._imageOffset.x; v.y += this._imageOffset.y; (r = this.getChildByTag(h)) ? this._renderCmd._updateCharTexture(r, v, n): (r = new cc.Sprite, r.initWithTexture(a, v, !1), r._newTextureWhenChangeColor = !0, this.addChild(r, 0, h)); r.opacityModifyRGB = this._opacityModifyRGB; this._renderCmd._updateCharColorAndOpacity(r); v = cc.p(b + s.xOffset + 0.5 * s.rect.width + u, e + (k.commonHeight - s.yOffset) - 0.5 * v.height * cc.contentScaleFactor()); r.setPosition(cc.pointPixelsToPoints(v)); b += s.xAdvance + u; r = n; d < b && (d = b) } else cc.log("cocos2d: LabelBMFont: character not found " + f[h]) } c.width = s && s.xAdvance < s.rect.width ? d - s.xAdvance + s.rect.width : d; c.height = t; this.setContentSize(cc.sizePixelsToPoints(c)) } }, updateString: function(a) { var b = this._children; if (b) for (var c = 0, d = b.length; c < d; c++) { var e = b[c]; e && (e.visible = !1) } this._config && this.createFontChars(); a || this.updateLabel() }, getString: function() { return this._initialString }, setString: function(a, b) { a = String(a); null == b && (b = !0); null != a && cc.isString(a) || (a += ""); this._initialString = a; this._setString(a, b) }, _setStringForSetter: function(a) { this.setString(a, !1) }, setCString: function(a) { this.setString(a, !0) }, _getCharsWidth: function(a, b) { if (0 >= b) return 0; var c = this.getChildByTag(a), d = this.getChildByTag(a + b); return this._getLetterPosXLeft(d) - this._getLetterPosXLeft(c) }, _checkWarp: function(a, b, c, d) { for (var e = a[b], f = 0, g = 0; g < b; g++) f += a[g].length; var f = f + b - d, h = this._getCharsWidth(f, a[b].length - 1); if (h > c && 1 < e.length) { d = c / h * e.length | 0; for (var g = e.substr(d), k = h - this._getCharsWidth(f + d, g.length - 1), m, n = 0, p = 0; k > c && 100 > p++;) d *= c / k, d |= 0, g = e.substr(d), k = h - this._getCharsWidth(f + d, g.length - 1); for (p = 0; k < c && 100 > p++;) g && (n = (m = cc.LabelTTF._wordRex.exec(g)) ? m[0].length : 1, m = g), this._lineBreakWithoutSpaces && (n = 0), d += n, g = e.substr(d), k = h - this._getCharsWidth(f + d, g.length - 1); d -= n; 0 === d && (d = 1, m = m.substr(1)); c = e.substr(0, d); cc.LabelTTF.wrapInspection && cc.LabelTTF._symbolRex.test(m || g) && (n = (f = cc.LabelTTF._lastWordRex.exec(c)) ? f[0].length : 0, this._lineBreakWithoutSpaces && (n = 0), d -= n, m = e.substr(d), c = e.substr(0, d)); cc.LabelTTF._firsrEnglish.test(m) && (f = cc.LabelTTF._lastEnglish.exec(c)) && c !== f[0] && (n = f[0].length, this._lineBreakWithoutSpaces && (n = 0), d -= n, m = e.substr(d), c = e.substr(0, d)); a[b] = m || g; a.splice(b, 0, c) } }, updateLabel: function() { this.string = this._initialString; var a, b, c; if (0 < this._width) { var d = this.string.split("\n"), e = "", f = 0, g = 0; for (a = 0; a < d.length; a++) g = d.length, this._checkWarp(d, a, this._width * this._scaleX, f), g < d.length && f++, 0 < a && (e += "\n"), e += d[a]; e += String.fromCharCode(0); this._setString(e, !1) } if (this._alignment !== cc.TEXT_ALIGNMENT_LEFT) for (d = a = 0, e = this._string.length, f = [], g = 0; g < e; g++) if (10 === this._string[g].charCodeAt(0) || 0 === this._string[g].charCodeAt(0)) { b = 0; var h = f.length; if (0 === h) d++; else if (c = a + h - 1 + d, !(0 > c)) { var k = this.getChildByTag(c); if (null != k) { b = k.getPositionX() + k._getWidth() / 2; k = 0; switch (this._alignment) { case cc.TEXT_ALIGNMENT_CENTER: k = this.width / 2 - b / 2; break; case cc.TEXT_ALIGNMENT_RIGHT: k = this.width - b } if (0 !== k) for (b = 0; b < h; b++) c = a + b + d, 0 > c || (c = this.getChildByTag(c)) && (c.x += k); a += h; d++; f.length = 0 } } } else f.push(this._string[a]) }, setAlignment: function(a) { this._alignment = a; this.updateLabel() }, _getAlignment: function() { return this._alignment }, setBoundingWidth: function(a) { this._width = a; this.updateLabel() }, _getBoundingWidth: function() { return this._width }, setLineBreakWithoutSpace: function(a) { this._lineBreakWithoutSpaces = a; this.updateLabel() }, setScale: function(a, b) { cc.Node.prototype.setScale.call(this, a, b); this.updateLabel() }, setScaleX: function(a) { cc.Node.prototype.setScaleX.call(this, a); this.updateLabel() }, setScaleY: function(a) { cc.Node.prototype.setScaleY.call(this, a); this.updateLabel() }, setFntFile: function(a) { if (null != a && a !== this._fntFile) { var b = cc.loader.getRes(a); b ? (this._fntFile = a, this._config = b, a = cc.textureCache.addImage(b.atlasName), this._textureLoaded = b = a.isLoaded(), this.texture = a, this._renderCmd._updateFntFileTexture(), b ? this.createFontChars() : a.addEventListener("load", function(a) { this._textureLoaded = !0; this.texture = a; this.createFontChars(); this._changeTextureColor(); this.updateLabel(); this.dispatchEvent("load") }, this)) : cc.log("cc.LabelBMFont.setFntFile() : Impossible to create font. Please check file") } }, getFntFile: function() { return this._fntFile }, setTexture: function(a) { this._renderCmd.setTexture(a) }, setAnchorPoint: function(a, b) { cc.Node.prototype.setAnchorPoint.call(this, a, b); this.updateLabel() }, _setAnchorX: function(a) { cc.Node.prototype._setAnchorX.call(this, a); this.updateLabel() }, _setAnchorY: function(a) { cc.Node.prototype._setAnchorY.call(this, a); this.updateLabel() }, _atlasNameFromFntFile: function(a) {}, _kerningAmountForFirst: function(a, b) { var c = 0; if (this._configuration.kerningDictionary) { var d = this._configuration.kerningDictionary[(a << 16 | b & 65535).toString()]; d && (c = d.amount) } return c }, _getLetterPosXLeft: function(a) { return a.getPositionX() * this._scaleX - a._getWidth() * this._scaleX * a._getAnchorX() }, _getLetterPosXRight: function(a) { return a.getPositionX() * this._scaleX + a._getWidth() * this._scaleX * a._getAnchorX() }, _isspace_unicode: function(a) { a = a.charCodeAt(0); return 9 <= a && 13 >= a || 32 === a || 133 === a || 160 === a || 5760 === a || 8192 <= a && 8202 >= a || 8232 === a || 8233 === a || 8239 === a || 8287 === a || 12288 === a }, _utf8_trim_ws: function(a) { var b = a.length; if (!(0 >= b) && (b -= 1, this._isspace_unicode(a[b]))) { for (var c = b - 1; 0 <= c; --c) if (this._isspace_unicode(a[c])) b = c; else break; this._utf8_trim_from(a, b) } }, _utf8_trim_from: function(a, b) { var c = a.length; b >= c || 0 > b || a.splice(b, c) } }); (function() { var a = cc.LabelBMFont.prototype; cc.EventHelper.prototype.apply(a); cc.defineGetterSetter(a, "string", a.getString, a._setStringForSetter); cc.defineGetterSetter(a, "boundingWidth", a._getBoundingWidth, a.setBoundingWidth); cc.defineGetterSetter(a, "textAlign", a._getAlignment, a.setAlignment) })(); cc.LabelBMFont.create = function(a, b, c, d, e) { return new cc.LabelBMFont(a, b, c, d, e) }; cc._fntLoader = { INFO_EXP: /info [^\n]*(\n|$)/gi, COMMON_EXP: /common [^\n]*(\n|$)/gi, PAGE_EXP: /page [^\n]*(\n|$)/gi, CHAR_EXP: /char [^\n]*(\n|$)/gi, KERNING_EXP: /kerning [^\n]*(\n|$)/gi, ITEM_EXP: /\w+=[^ \r\n]+/gi, INT_EXP: /^[\-]?\d+$/, _parseStrToObj: function(a) { a = a.match(this.ITEM_EXP); var b = {}; if (a) for (var c = 0, d = a.length; c < d; c++) { var e = a[c], f = e.indexOf("\x3d"), g = e.substring(0, f), e = e.substring(f + 1); e.match(this.INT_EXP) ? e = parseInt(e) : '"' === e[0] && (e = e.substring(1, e.length - 1)); b[g] = e } return b }, parseFnt: function(a, b) { var c = {}, d = this._parseStrToObj(a.match(this.INFO_EXP)[0]).padding.split(","); parseInt(d[0]); parseInt(d[1]); parseInt(d[2]); parseInt(d[3]); d = this._parseStrToObj(a.match(this.COMMON_EXP)[0]); c.commonHeight = d.lineHeight; if (cc._renderType === cc._RENDER_TYPE_WEBGL) { var e = cc.configuration.getMaxTextureSize(); (d.scaleW > e.width || d.scaleH > e.height) && cc.log("cc.LabelBMFont._parseCommonArguments(): page can't be larger than supported") } 1 !== d.pages && cc.log("cc.LabelBMFont._parseCommonArguments(): only supports 1 page"); d = this._parseStrToObj(a.match(this.PAGE_EXP)[0]); 0 !== d.id && cc.log("cc.LabelBMFont._parseImageFileName() : file could not be found"); c.atlasName = cc.path.changeBasename(b, d.file); for (var f = a.match(this.CHAR_EXP), g = c.fontDefDictionary = {}, d = 0, e = f.length; d < e; d++) { var h = this._parseStrToObj(f[d]); g[h.id] = { rect: { x: h.x, y: h.y, width: h.width, height: h.height }, xOffset: h.xoffset, yOffset: h.yoffset, xAdvance: h.xadvance } } f = c.kerningDict = {}; if (g = a.match(this.KERNING_EXP)) for (d = 0, e = g.length; d < e; d++) h = this._parseStrToObj(g[d]), f[h.first << 16 | h.second & 65535] = h.amount; return c }, load: function(a, b, c, d) { var e = this; cc.loader.loadTxt(a, function(a, c) { if (a) return d(a); d(null, e.parseFnt(c, b)) }) } }; cc.loader.register(["fnt"], cc._fntLoader); (function() { cc.LabelBMFont.CanvasRenderCmd = function(a) { cc.SpriteBatchNode.CanvasRenderCmd.call(this, a); this._needDraw = !0 }; var a = cc.LabelBMFont.CanvasRenderCmd.prototype = Object.create(cc.SpriteBatchNode.CanvasRenderCmd.prototype); a.constructor = cc.LabelBMFont.CanvasRenderCmd; a.rendering = function() { void 0 }; a._updateCharTexture = function(a, c, d) { 32 === d ? a.setTextureRect(c, !1, cc.size(0, 0)) : (a.setTextureRect(c, !1), a.visible = !0) }; a._updateCharColorAndOpacity = function(a) { a._displayedColor = this._displayedColor; a._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.colorDirty); a._displayedOpacity = this._displayedOpacity; a._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.opacityDirty) }; a._updateFntFileTexture = function() { var a = this._node; a._originalTexture = a.texture }; a.setTexture = function(a) { for (var c = this._node._children, d = this._displayedColor, e = 0; e < c.length; e++) { var f = c[e], g = f._renderCmd, h = g._displayedColor; if (this._texture === g._texture || h.r === d.r && h.g === d.g && h.b === d.b) f.texture = a } this._texture = a }; a._changeTextureColor = cc.sys._supportCanvasNewBlendModes ? function() { var a = this._node, c = a.getTexture(); if (c && 0 < c.getContentSize().width) { var d = this._originalTexture.getHtmlElementObj(); if (d) { var e = c.getHtmlElementObj(), f = cc.rect(0, 0, d.width, d.height); e instanceof HTMLCanvasElement && !a._rectRotated ? cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(d, this._displayedColor, f, e) : (e = cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(d, this._displayedColor, f), c = new cc.Texture2D, c.initWithElement(e), c.handleLoadedTexture()); a.setTexture(c) } } } : function() { var a = this._node, c, d = a.getTexture(); if (d && 0 < d.getContentSize().width && (c = d.getHtmlElementObj())) { var e = cc.textureCache.getTextureColors(this._originalTexture.getHtmlElementObj()); e && (c instanceof HTMLCanvasElement && !this._rectRotated ? (cc.Sprite.CanvasRenderCmd._generateTintImage(c, e, this._displayedColor, null, c), this.setTexture(d)) : (c = cc.Sprite.CanvasRenderCmd._generateTintImage(c, e, this._displayedColor), d = new cc.Texture2D, d.initWithElement(c), d.handleLoadedTexture(), a.setTexture(d))) } }; a._updateChildrenDisplayedOpacity = function(a) { cc.Node.prototype.updateDisplayedOpacity.call(a, this._displayedOpacity) }; a._updateChildrenDisplayedColor = function(a) { cc.Node.prototype.updateDisplayedColor.call(a, this._displayedColor) }; a._initBatchTexture = function() {} })(); (function() { cc.LabelBMFont.WebGLRenderCmd = function(a) { cc.SpriteBatchNode.WebGLRenderCmd.call(this, a); this._needDraw = !0 }; var a = cc.LabelBMFont.WebGLRenderCmd.prototype = Object.create(cc.SpriteBatchNode.WebGLRenderCmd.prototype); a.constructor = cc.LabelBMFont.WebGLRenderCmd; a._updateCharTexture = function(a, c, d) { a.setTextureRect(c, !1); a.visible = !0 }; a._updateFntFileTexture = function() {}; a._changeTextureColor = function() {}; a._updateChildrenDisplayedOpacity = function(a) { a.updateDisplayedOpacity(this._displayedOpacity) }; a._updateChildrenDisplayedColor = function(a) { a.updateDisplayedColor(this._displayedColor) }; a._initBatchTexture = function() { var a = this._node, c = a.textureAtlas.texture; a._opacityModifyRGB = c.hasPremultipliedAlpha(); var d = a._reusedChar = new cc.Sprite; d.initWithTexture(c, cc.rect(0, 0, 0, 0), !1); d.batchNode = a }; a.rendering = function(a) { cc.SpriteBatchNode.WebGLRenderCmd.prototype.rendering.call(this, a); a = this._node; if (cc.LABELBMFONT_DEBUG_DRAW) { a = a.getContentSize(); var c = cc.p(0 | -this._anchorPointInPoints.x, 0 | -this._anchorPointInPoints.y); a = [cc.p(c.x, c.y), cc.p(c.x + a.width, c.y), cc.p(c.x + a.width, c.y + a.height), cc.p(c.x, c.y + a.height)]; cc._drawingUtil.setDrawColor(0, 255, 0, 255); cc._drawingUtil.drawPoly(a, 4, !0) } }; a._updateCharColorAndOpacity = function() {} })(); cc.MotionStreak = cc.Node.extend({ texture: null, fastMode: !1, startingPositionInitialized: !1, _blendFunc: null, _stroke: 0, _fadeDelta: 0, _minSeg: 0, _maxPoints: 0, _nuPoints: 0, _previousNuPoints: 0, _pointVertexes: null, _pointState: null, _vertices: null, _colorPointer: null, _texCoords: null, _verticesBuffer: null, _colorPointerBuffer: null, _texCoordsBuffer: null, _className: "MotionStreak", ctor: function(a, b, c, d, e) { cc.Node.prototype.ctor.call(this); this._positionR = cc.p(0, 0); this._blendFunc = new cc.BlendFunc(cc.SRC_ALPHA, cc.ONE_MINUS_SRC_ALPHA); this.startingPositionInitialized = this.fastMode = !1; this.texture = null; this._previousNuPoints = this._nuPoints = this._maxPoints = this._minSeg = this._fadeDelta = this._stroke = 0; this._texCoordsBuffer = this._colorPointerBuffer = this._verticesBuffer = this._texCoords = this._colorPointer = this._vertices = this._pointState = this._pointVertexes = null; void 0 !== e && this.initWithFade(a, b, c, d, e) }, getTexture: function() { return this.texture }, setTexture: function(a) { this.texture !== a && (this.texture = a) }, getBlendFunc: function() { return this._blendFunc }, setBlendFunc: function(a, b) { void 0 === b ? this._blendFunc = a : (this._blendFunc.src = a, this._blendFunc.dst = b) }, getOpacity: function() { cc.log("cc.MotionStreak.getOpacity has not been supported."); return 0 }, setOpacity: function(a) { cc.log("cc.MotionStreak.setOpacity has not been supported.") }, setOpacityModifyRGB: function(a) {}, isOpacityModifyRGB: function() { return !1 }, isFastMode: function() { return this.fastMode }, setFastMode: function(a) { this.fastMode = a }, isStartingPositionInitialized: function() { return this.startingPositionInitialized }, setStartingPositionInitialized: function(a) { this.startingPositionInitialized = a }, initWithFade: function(a, b, c, d, e) { if (!e) throw "cc.MotionStreak.initWithFade(): Invalid filename or texture"; cc.isString(e) && (e = cc.textureCache.addImage(e)); cc.Node.prototype.setPosition.call(this, cc.p(0, 0)); this.anchorY = this.anchorX = 0; this.ignoreAnchor = !0; this.startingPositionInitialized = !1; this.fastMode = !0; this._minSeg = -1 === b ? c / 5 : b; this._minSeg *= this._minSeg; this._stroke = c; this._fadeDelta = 1 / a; this._maxPoints = a = (0 | 60 * a) + 2; this._nuPoints = 0; this._pointState = new Float32Array(a); this._pointVertexes = new Float32Array(2 * a); this._vertices = new Float32Array(4 * a); this._texCoords = new Float32Array(4 * a); this._colorPointer = new Uint8Array(8 * a); this._verticesBuffer = gl.createBuffer(); this._texCoordsBuffer = gl.createBuffer(); this._colorPointerBuffer = gl.createBuffer(); this._blendFunc.src = gl.SRC_ALPHA; this._blendFunc.dst = gl.ONE_MINUS_SRC_ALPHA; this.texture = e; this.color = d; this.scheduleUpdate(); gl.bindBuffer(gl.ARRAY_BUFFER, this._verticesBuffer); gl.bufferData(gl.ARRAY_BUFFER, this._vertices, gl.DYNAMIC_DRAW); gl.bindBuffer(gl.ARRAY_BUFFER, this._texCoordsBuffer); gl.bufferData(gl.ARRAY_BUFFER, this._texCoords, gl.DYNAMIC_DRAW); gl.bindBuffer(gl.ARRAY_BUFFER, this._colorPointerBuffer); gl.bufferData(gl.ARRAY_BUFFER, this._colorPointer, gl.DYNAMIC_DRAW); return !0 }, tintWithColor: function(a) { this.color = a; for (var b = this._colorPointer, c = 0, d = 2 * this._nuPoints; c < d; c++) b[4 * c] = a.r, b[4 * c + 1] = a.g, b[4 * c + 2] = a.b }, reset: function() { this._nuPoints = 0 }, setPosition: function(a, b) { this.startingPositionInitialized = !0; void 0 === b ? (this._positionR.x = a.x, this._positionR.y = a.y) : (this._positionR.x = a, this._positionR.y = b) }, getPositionX: function() { return this._positionR.x }, setPositionX: function(a) { this._positionR.x = a; this.startingPositionInitialized || (this.startingPositionInitialized = !0) }, getPositionY: function() { return this._positionR.y }, setPositionY: function(a) { this._positionR.y = a; this.startingPositionInitialized || (this.startingPositionInitialized = !0) }, update: function(a) { if (this.startingPositionInitialized) { this._renderCmd._updateDisplayColor(); a *= this._fadeDelta; var b, c, d, e, f = 0, g = this._nuPoints, h = this._pointState, k = this._pointVertexes, m = this._vertices, n = this._colorPointer; for (d = 0; d < g; d++) h[d] -= a, 0 >= h[d] ? f++ : (b = d - f, 0 < f ? (h[b] = h[d], k[2 * b] = k[2 * d], k[2 * b + 1] = k[2 * d + 1], e = 2 * d, c = 2 * b, m[2 * c] = m[2 * e], m[2 * c + 1] = m[2 * e + 1], m[2 * (c + 1)] = m[2 * (e + 1)], m[2 * (c + 1) + 1] = m[2 * (e + 1) + 1], e *= 4, c *= 4, n[c + 0] = n[e + 0], n[c + 1] = n[e + 1], n[c + 2] = n[e + 2], n[c + 4] = n[e + 4], n[c + 5] = n[e + 5], n[c + 6] = n[e + 6]) : c = 8 * b, b = 255 * h[b], n[c + 3] = b, n[c + 7] = b); g -= f; d = !0; g >= this._maxPoints ? d = !1 : 0 < g && (a = cc.pDistanceSQ(cc.p(k[2 * (g - 1)], k[2 * (g - 1) + 1]), this._positionR) < this._minSeg, c = 1 === g ? !1 : cc.pDistanceSQ(cc.p(k[2 * (g - 2)], k[2 * (g - 2) + 1]), this._positionR) < 2 * this._minSeg, a || c) && (d = !1); d && (k[2 * g] = this._positionR.x, k[2 * g + 1] = this._positionR.y, h[g] = 1, h = 8 * g, d = this.getDisplayedColor(), n[h] = d.r, n[h + 1] = d.g, n[h + 2] = d.b, n[h + 4] = d.r, n[h + 5] = d.g, n[h + 6] = d.b, n[h + 3] = 255, n[h + 7] = 255, 0 < g && this.fastMode && (1 < g ? cc.vertexLineToPolygon(k, this._stroke, this._vertices, g, 1) : cc.vertexLineToPolygon(k, this._stroke, this._vertices, 0, 2)), g++); this.fastMode || cc.vertexLineToPolygon(k, this._stroke, this._vertices, 0, g); if (g && this._previousNuPoints !== g) { k = 1 / g; n = this._texCoords; for (d = 0; d < g; d++) n[4 * d] = 0, n[4 * d + 1] = k * d, n[2 * (2 * d + 1)] = 1, n[2 * (2 * d + 1) + 1] = k * d; this._previousNuPoints = g } this._nuPoints = g } }, _createRenderCmd: function() { return cc._renderType === cc._RENDER_TYPE_WEBGL ? new cc.MotionStreak.WebGLRenderCmd(this) : null } }); cc.MotionStreak.create = function(a, b, c, d, e) { return new cc.MotionStreak(a, b, c, d, e) }; cc.MotionStreak.WebGLRenderCmd = function(a) { cc.Node.WebGLRenderCmd.call(this, a); this._needDraw = !0; this._shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR) }; cc.MotionStreak.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); cc.MotionStreak.WebGLRenderCmd.prototype.constructor = cc.Sprite.WebGLRenderCmd; cc.MotionStreak.WebGLRenderCmd.prototype.rendering = function(a) { var b = this._node; 1 >= b._nuPoints || !b.texture || !b.texture.isLoaded() || (a = a || cc._renderContext, this._shaderProgram.use(), this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix), cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX), cc.glBlendFunc(b._blendFunc.src, b._blendFunc.dst), cc.glBindTexture2D(b.texture), a.bindBuffer(a.ARRAY_BUFFER, b._verticesBuffer), a.bufferData(a.ARRAY_BUFFER, b._vertices, a.DYNAMIC_DRAW), a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, a.FLOAT, !1, 0, 0), a.bindBuffer(a.ARRAY_BUFFER, b._texCoordsBuffer), a.bufferData(a.ARRAY_BUFFER, b._texCoords, a.DYNAMIC_DRAW), a.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, a.FLOAT, !1, 0, 0), a.bindBuffer(a.ARRAY_BUFFER, b._colorPointerBuffer), a.bufferData(a.ARRAY_BUFFER, b._colorPointer, a.DYNAMIC_DRAW), a.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, a.UNSIGNED_BYTE, !0, 0, 0), a.drawArrays(a.TRIANGLE_STRIP, 0, 2 * b._nuPoints), cc.g_NumberOfDraws++) }; cc.NodeGrid = cc.Node.extend({ grid: null, _target: null, getGrid: function() { return this.grid }, setGrid: function(a) { this.grid = a }, setTarget: function(a) { this._target = a }, _transformForWebGL: function() { var a = this._transform4x4, b = cc.current_stack.top, c = this.getNodeToParentTransform(), d = a.mat; d[0] = c.a; d[4] = c.c; d[12] = c.tx; d[1] = c.b; d[5] = c.d; d[13] = c.ty; d[14] = this._vertexZ; b.multiply(a); null === this._camera || this.grid && this.grid.isActive() || (b = this._renderCmd._anchorPointInPoints, a = b.x, b = b.y, 0 !== a || 0 !== b ? (cc.SPRITEBATCHNODE_RENDER_SUBPIXEL || (a |= 0, b |= 0), cc.kmGLTranslatef(a, b, 0), this._camera.locate(), cc.kmGLTranslatef(-a, -b, 0)) : this._camera.locate()) }, _createRenderCmd: function() { return cc._renderType === cc._RENDER_TYPE_WEBGL ? new cc.NodeGrid.WebGLRenderCmd(this) : new cc.Node.CanvasRenderCmd(this) } }); _p = cc.NodeGrid.prototype; cc.defineGetterSetter(_p, "target", null, _p.setTarget); cc.NodeGrid.create = function() { return new cc.NodeGrid }; (function() { cc.NodeGrid.WebGLRenderCmd = function(a) { cc.Node.WebGLRenderCmd.call(this, a); this._needDraw = !1; this._gridBeginCommand = new cc.CustomRenderCmd(this, this.onGridBeginDraw); this._gridEndCommand = new cc.CustomRenderCmd(this, this.onGridEndDraw) }; var a = cc.NodeGrid.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); a.constructor = cc.NodeGrid.WebGLRenderCmd; a.visit = function(a) { var c = this._node; if (c._visible) { a = a || this.getParentRenderCmd(); c._parent && c._parent._renderCmd && (this._curLevel = c._parent._renderCmd._curLevel + 1); var d = cc.current_stack; d.stack.push(d.top); this._syncStatus(a); d.top = this._stackMatrix; cc.renderer.pushRenderCommand(this._gridBeginCommand); c._target && c._target.visit(); if ((a = c._children) && 0 < a.length) { var e = a.length; c.sortAllChildren(); for (c = 0; c < e; c++) { var f = a[c]; f && f.visit() } } cc.renderer.pushRenderCommand(this._gridEndCommand); this._dirtyFlag = 0; d.top = d.stack.pop() } }; a.onGridBeginDraw = function() { var a = this._node.grid; a && a._active && a.beforeDraw() }; a.onGridEndDraw = function() { var a = this._node.grid; a && a._active && a.afterDraw(this._node) } })(); cc.v2fzero = function() { return { x: 0, y: 0 } }; cc.v2f = function(a, b) { return { x: a, y: b } }; cc.v2fadd = function(a, b) { return cc.v2f(a.x + b.x, a.y + b.y) }; cc.v2fsub = function(a, b) { return cc.v2f(a.x - b.x, a.y - b.y) }; cc.v2fmult = function(a, b) { return cc.v2f(a.x * b, a.y * b) }; cc.v2fperp = function(a) { return cc.v2f(-a.y, a.x) }; cc.v2fneg = function(a) { return cc.v2f(-a.x, -a.y) }; cc.v2fdot = function(a, b) { return a.x * b.x + a.y * b.y }; cc.v2fforangle = function(a) { return cc.v2f(Math.cos(a), Math.sin(a)) }; cc.v2fnormalize = function(a) { a = cc.pNormalize(cc.p(a.x, a.y)); return cc.v2f(a.x, a.y) }; cc.__v2f = function(a) { return cc.v2f(a.x, a.y) }; cc.__t = function(a) { return { u: a.x, v: a.y } }; cc.DrawNodeCanvas = cc.Node.extend({ _buffer: null, _blendFunc: null, _lineWidth: 1, _drawColor: null, _className: "DrawNodeCanvas", ctor: function() { cc.Node.prototype.ctor.call(this); var a = this._renderCmd; a._buffer = this._buffer = []; a._drawColor = this._drawColor = cc.color(255, 255, 255, 255); a._blendFunc = this._blendFunc = new cc.BlendFunc(cc.BLEND_SRC, cc.BLEND_DST); this.init() }, getBlendFunc: function() { return this._blendFunc }, setBlendFunc: function(a, b) { void 0 === b ? (this._blendFunc.src = a.src, this._blendFunc.dst = a.dst) : (this._blendFunc.src = a, this._blendFunc.dst = b) }, setLineWidth: function(a) { this._lineWidth = a }, getLineWidth: function() { return this._lineWidth }, setDrawColor: function(a) { var b = this._drawColor; b.r = a.r; b.g = a.g; b.b = a.b; b.a = null == a.a ? 255 : a.a }, getDrawColor: function() { return cc.color(this._drawColor.r, this._drawColor.g, this._drawColor.b, this._drawColor.a) }, drawRect: function(a, b, c, d, e) { d = null == d ? this._lineWidth : d; e = e || this.getDrawColor(); null == e.a && (e.a = 255); a = [a, cc.p(b.x, a.y), b, cc.p(a.x, b.y)]; b = new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY); b.verts = a; b.lineWidth = d; b.lineColor = e; b.isClosePolygon = !0; b.isStroke = !0; b.lineCap = "butt"; if (b.fillColor = c) null == c.a && (c.a = 255), b.isFill = !0; this._buffer.push(b) }, drawCircle: function(a, b, c, d, e, f, g) { f = f || this._lineWidth; g = g || this.getDrawColor(); null == g.a && (g.a = 255); for (var h = 2 * Math.PI / d, k = [], m = 0; m <= d; m++) { var n = m * h, p = b * Math.cos(n + c) + a.x, n = b * Math.sin(n + c) + a.y; k.push(cc.p(p, n)) } e && k.push(cc.p(a.x, a.y)); a = new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY); a.verts = k; a.lineWidth = f; a.lineColor = g; a.isClosePolygon = !0; a.isStroke = !0; this._buffer.push(a) }, drawQuadBezier: function(a, b, c, d, e, f) { e = e || this._lineWidth; f = f || this.getDrawColor(); null == f.a && (f.a = 255); for (var g = [], h = 0, k = 0; k < d; k++) { var m = Math.pow(1 - h, 2) * a.x + 2 * (1 - h) * h * b.x + h * h * c.x, n = Math.pow(1 - h, 2) * a.y + 2 * (1 - h) * h * b.y + h * h * c.y; g.push(cc.p(m, n)); h += 1 / d } g.push(cc.p(c.x, c.y)); a = new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY); a.verts = g; a.lineWidth = e; a.lineColor = f; a.isStroke = !0; a.lineCap = "round"; this._buffer.push(a) }, drawCubicBezier: function(a, b, c, d, e, f, g) { f = f || this._lineWidth; g = g || this.getDrawColor(); null == g.a && (g.a = 255); for (var h = [], k = 0, m = 0; m < e; m++) { var n = Math.pow(1 - k, 3) * a.x + 3 * Math.pow(1 - k, 2) * k * b.x + 3 * (1 - k) * k * k * c.x + k * k * k * d.x, p = Math.pow(1 - k, 3) * a.y + 3 * Math.pow(1 - k, 2) * k * b.y + 3 * (1 - k) * k * k * c.y + k * k * k * d.y; h.push(cc.p(n, p)); k += 1 / e } h.push(cc.p(d.x, d.y)); a = new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY); a.verts = h; a.lineWidth = f; a.lineColor = g; a.isStroke = !0; a.lineCap = "round"; this._buffer.push(a) }, drawCatmullRom: function(a, b, c, d) { this.drawCardinalSpline(a, 0.5, b, c, d) }, drawCardinalSpline: function(a, b, c, d, e) { d = d || this._lineWidth; e = e || this.getDrawColor(); null == e.a && (e.a = 255); for (var f = [], g, h, k = 1 / a.length, m = 0; m < c + 1; m++) h = m / c, 1 === h ? (g = a.length - 1, h = 1) : (g = 0 | h / k, h = (h - k * g) / k), g = cc.cardinalSplineAt(cc.getControlPointAt(a, g - 1), cc.getControlPointAt(a, g - 0), cc.getControlPointAt(a, g + 1), cc.getControlPointAt(a, g + 2), b, h), f.push(g); a = new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY); a.verts = f; a.lineWidth = d; a.lineColor = e; a.isStroke = !0; a.lineCap = "round"; this._buffer.push(a) }, drawDot: function(a, b, c) { c = c || this.getDrawColor(); null == c.a && (c.a = 255); var d = new cc._DrawNodeElement(cc.DrawNode.TYPE_DOT); d.verts = [a]; d.lineWidth = b; d.fillColor = c; this._buffer.push(d) }, drawDots: function(a, b, c) { if (a && 0 != a.length) { c = c || this.getDrawColor(); null == c.a && (c.a = 255); for (var d = 0, e = a.length; d < e; d++) this.drawDot(a[d], b, c) } }, drawSegment: function(a, b, c, d) { c = c || this._lineWidth; d = d || this.getDrawColor(); null == d.a && (d.a = 255); var e = new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY); e.verts = [a, b]; e.lineWidth = 2 * c; e.lineColor = d; e.isStroke = !0; e.lineCap = "round"; this._buffer.push(e) }, drawPoly_: function(a, b, c, d) { c = null == c ? this._lineWidth : c; d = d || this.getDrawColor(); null == d.a && (d.a = 255); var e = new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY); e.verts = a; e.fillColor = b; e.lineWidth = c; e.lineColor = d; e.isClosePolygon = !0; e.isStroke = !0; e.lineCap = "round"; b && (e.isFill = !0); this._buffer.push(e) }, drawPoly: function(a, b, c, d) { for (var e = [], f = 0; f < a.length; f++) e.push(cc.p(a[f].x, a[f].y)); return this.drawPoly_(e, b, c, d) }, clear: function() { this._buffer.length = 0 }, _createRenderCmd: function() { return new cc.DrawNode.CanvasRenderCmd(this) } }); cc.DrawNodeWebGL = cc.Node.extend({ _bufferCapacity: 0, _buffer: null, _trianglesArrayBuffer: null, _trianglesWebBuffer: null, _trianglesReader: null, _lineWidth: 1, _drawColor: null, _blendFunc: null, _dirty: !1, _className: "DrawNodeWebGL", getBlendFunc: function() { return this._blendFunc }, setBlendFunc: function(a, b) { void 0 === b ? (this._blendFunc.src = a.src, this._blendFunc.dst = a.dst) : (this._blendFunc.src = a, this._blendFunc.dst = b) }, ctor: function() { cc.Node.prototype.ctor.call(this); this._buffer = []; this._blendFunc = new cc.BlendFunc(cc.BLEND_SRC, cc.BLEND_DST); this._drawColor = cc.color(255, 255, 255, 255); this.init() }, init: function() { return cc.Node.prototype.init.call(this) ? (this.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_LENGTHTEXTURECOLOR), this._ensureCapacity(64), this._trianglesWebBuffer = cc._renderContext.createBuffer(), this._dirty = !0) : !1 }, setLineWidth: function(a) { this._lineWidth = a }, getLineWidth: function() { return this._lineWidth }, setDrawColor: function(a) { var b = this._drawColor; b.r = a.r; b.g = a.g; b.b = a.b; b.a = a.a }, getDrawColor: function() { return cc.color(this._drawColor.r, this._drawColor.g, this._drawColor.b, this._drawColor.a) }, drawRect: function(a, b, c, d, e) { d = null == d ? this._lineWidth : d; e = e || this.getDrawColor(); null == e.a && (e.a = 255); a = [a, cc.p(b.x, a.y), b, cc.p(a.x, b.y)]; null == c ? this._drawSegments(a, d, e, !0) : this.drawPoly(a, c, d, e) }, drawCircle: function(a, b, c, d, e, f, g) { f = f || this._lineWidth; g = g || this.getDrawColor(); null == g.a && (g.a = 255); var h = 2 * Math.PI / d, k = [], m; for (m = 0; m <= d; m++) { var n = m * h, p = b * Math.cos(n + c) + a.x, n = b * Math.sin(n + c) + a.y; k.push(cc.p(p, n)) } e && k.push(cc.p(a.x, a.y)); f *= 0.5; m = 0; for (a = k.length; m < a - 1; m++) this.drawSegment(k[m], k[m + 1], f, g) }, drawQuadBezier: function(a, b, c, d, e, f) { e = e || this._lineWidth; f = f || this.getDrawColor(); null == f.a && (f.a = 255); for (var g = [], h = 0, k = 0; k < d; k++) { var m = Math.pow(1 - h, 2) * a.x + 2 * (1 - h) * h * b.x + h * h * c.x, n = Math.pow(1 - h, 2) * a.y + 2 * (1 - h) * h * b.y + h * h * c.y; g.push(cc.p(m, n)); h += 1 / d } g.push(cc.p(c.x, c.y)); this._drawSegments(g, e, f, !1) }, drawCubicBezier: function(a, b, c, d, e, f, g) { f = f || this._lineWidth; g = g || this.getDrawColor(); null == g.a && (g.a = 255); for (var h = [], k = 0, m = 0; m < e; m++) { var n = Math.pow(1 - k, 3) * a.x + 3 * Math.pow(1 - k, 2) * k * b.x + 3 * (1 - k) * k * k * c.x + k * k * k * d.x, p = Math.pow(1 - k, 3) * a.y + 3 * Math.pow(1 - k, 2) * k * b.y + 3 * (1 - k) * k * k * c.y + k * k * k * d.y; h.push(cc.p(n, p)); k += 1 / e } h.push(cc.p(d.x, d.y)); this._drawSegments(h, f, g, !1) }, drawCatmullRom: function(a, b, c, d) { this.drawCardinalSpline(a, 0.5, b, c, d) }, drawCardinalSpline: function(a, b, c, d, e) { d = d || this._lineWidth; e = e || this.getDrawColor(); null == e.a && (e.a = 255); for (var f = [], g, h, k = 1 / a.length, m = 0; m < c + 1; m++) h = m / c, 1 === h ? (g = a.length - 1, h = 1) : (g = 0 | h / k, h = (h - k * g) / k), g = cc.cardinalSplineAt(cc.getControlPointAt(a, g - 1), cc.getControlPointAt(a, g - 0), cc.getControlPointAt(a, g + 1), cc.getControlPointAt(a, g + 2), b, h), f.push(g); d *= 0.5; a = 0; for (b = f.length; a < b - 1; a++) this.drawSegment(f[a], f[a + 1], d, e) }, _render: function() { var a = cc._renderContext; cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); a.bindBuffer(a.ARRAY_BUFFER, this._trianglesWebBuffer); this._dirty && (a.bufferData(a.ARRAY_BUFFER, this._trianglesArrayBuffer, a.STREAM_DRAW), this._dirty = !1); var b = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT; a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, a.FLOAT, !1, b, 0); a.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, a.UNSIGNED_BYTE, !0, b, 8); a.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, a.FLOAT, !1, b, 12); a.drawArrays(a.TRIANGLES, 0, 3 * this._buffer.length); cc.incrementGLDraws(1) }, _ensureCapacity: function(a) { var b = this._buffer; if (b.length + a > this._bufferCapacity) { var c = cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT; this._bufferCapacity += Math.max(this._bufferCapacity, a); if (null == b || 0 === b.length) this._buffer = [], this._trianglesArrayBuffer = new ArrayBuffer(c * this._bufferCapacity), this._trianglesReader = new Uint8Array(this._trianglesArrayBuffer); else { a = []; for (var d = new ArrayBuffer(c * this._bufferCapacity), e = 0; e < b.length; e++) a[e] = new cc.V2F_C4B_T2F_Triangle(b[e].a, b[e].b, b[e].c, d, e * c); this._trianglesReader = new Uint8Array(d); this._trianglesArrayBuffer = d; this._buffer = a } } }, drawDot: function(a, b, c) { c = c || this.getDrawColor(); null == c.a && (c.a = 255); var d = { r: 0 | c.r, g: 0 | c.g, b: 0 | c.b, a: 0 | c.a }; c = { vertices: { x: a.x - b, y: a.y - b }, colors: d, texCoords: { u: -1, v: -1 } }; var e = { vertices: { x: a.x - b, y: a.y + b }, colors: d, texCoords: { u: -1, v: 1 } }, f = { vertices: { x: a.x + b, y: a.y + b }, colors: d, texCoords: { u: 1, v: 1 } }; a = { vertices: { x: a.x + b, y: a.y - b }, colors: d, texCoords: { u: 1, v: -1 } }; this._ensureCapacity(6); this._buffer.push(new cc.V2F_C4B_T2F_Triangle(c, e, f, this._trianglesArrayBuffer, this._buffer.length * cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT)); this._buffer.push(new cc.V2F_C4B_T2F_Triangle(c, f, a, this._trianglesArrayBuffer, this._buffer.length * cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT)); this._dirty = !0 }, drawDots: function(a, b, c) { if (a && 0 !== a.length) { c = c || this.getDrawColor(); null == c.a && (c.a = 255); for (var d = 0, e = a.length; d < e; d++) this.drawDot(a[d], b, c) } }, drawSegment: function(a, b, c, d) { d = d || this.getDrawColor(); null == d.a && (d.a = 255); c = c || 0.5 * this._lineWidth; this._ensureCapacity(18); d = { r: 0 | d.r, g: 0 | d.g, b: 0 | d.b, a: 0 | d.a }; var e = cc.__v2f(a), f = cc.__v2f(b); b = cc.v2fnormalize(cc.v2fperp(cc.v2fsub(f, e))); a = cc.v2fperp(b); var g = cc.v2fmult(b, c), h = cc.v2fmult(a, c); c = cc.v2fsub(f, cc.v2fadd(g, h)); var k = cc.v2fadd(f, cc.v2fsub(g, h)), m = cc.v2fsub(f, g), f = cc.v2fadd(f, g), n = cc.v2fsub(e, g), p = cc.v2fadd(e, g), t = cc.v2fsub(e, cc.v2fsub(g, h)), e = cc.v2fadd(e, cc.v2fadd(g, h)), g = cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT, h = this._trianglesArrayBuffer, r = this._buffer; r.push(new cc.V2F_C4B_T2F_Triangle({ vertices: c, colors: d, texCoords: cc.__t(cc.v2fneg(cc.v2fadd(b, a))) }, { vertices: k, colors: d, texCoords: cc.__t(cc.v2fsub(b, a)) }, { vertices: m, colors: d, texCoords: cc.__t(cc.v2fneg(b)) }, h, r.length * g)); r.push(new cc.V2F_C4B_T2F_Triangle({ vertices: f, colors: d, texCoords: cc.__t(b) }, { vertices: k, colors: d, texCoords: cc.__t(cc.v2fsub(b, a)) }, { vertices: m, colors: d, texCoords: cc.__t(cc.v2fneg(b)) }, h, r.length * g)); r.push(new cc.V2F_C4B_T2F_Triangle({ vertices: f, colors: d, texCoords: cc.__t(b) }, { vertices: n, colors: d, texCoords: cc.__t(cc.v2fneg(b)) }, { vertices: m, colors: d, texCoords: cc.__t(cc.v2fneg(b)) }, h, r.length * g)); r.push(new cc.V2F_C4B_T2F_Triangle({ vertices: f, colors: d, texCoords: cc.__t(b) }, { vertices: n, colors: d, texCoords: cc.__t(cc.v2fneg(b)) }, { vertices: p, colors: d, texCoords: cc.__t(b) }, h, r.length * g)); r.push(new cc.V2F_C4B_T2F_Triangle({ vertices: t, colors: d, texCoords: cc.__t(cc.v2fsub(a, b)) }, { vertices: n, colors: d, texCoords: cc.__t(cc.v2fneg(b)) }, { vertices: p, colors: d, texCoords: cc.__t(b) }, h, r.length * g)); r.push(new cc.V2F_C4B_T2F_Triangle({ vertices: t, colors: d, texCoords: cc.__t(cc.v2fsub(a, b)) }, { vertices: e, colors: d, texCoords: cc.__t(cc.v2fadd(b, a)) }, { vertices: p, colors: d, texCoords: cc.__t(b) }, h, r.length * g)); this._dirty = !0 }, drawPoly: function(a, b, c, d) { if (null == b) this._drawSegments(a, c, d, !0); else { null == b.a && (b.a = 255); null == d.a && (d.a = 255); c = null == c ? this._lineWidth : c; c *= 0.5; b = { r: 0 | b.r, g: 0 | b.g, b: 0 | b.b, a: 0 | b.a }; d = { r: 0 | d.r, g: 0 | d.g, b: 0 | d.b, a: 0 | d.a }; var e = [], f, g, h, k, m = a.length; for (f = 0; f < m; f++) { g = cc.__v2f(a[(f - 1 + m) % m]); h = cc.__v2f(a[f]); k = cc.__v2f(a[(f + 1) % m]); var n = cc.v2fnormalize(cc.v2fperp(cc.v2fsub(h, g))); h = cc.v2fnormalize(cc.v2fperp(cc.v2fsub(k, h))); n = cc.v2fmult(cc.v2fadd(n, h), 1 / (cc.v2fdot(n, h) + 1)); e[f] = { offset: n, n: h } } n = 0 < c; this._ensureCapacity(3 * (3 * m - 2)); var p = cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT, t = this._trianglesArrayBuffer, r = this._buffer, u = !1 == n ? 0.5 : 0; for (f = 0; f < m - 2; f++) g = cc.v2fsub(cc.__v2f(a[0]), cc.v2fmult(e[0].offset, u)), h = cc.v2fsub(cc.__v2f(a[f + 1]), cc.v2fmult(e[f + 1].offset, u)), k = cc.v2fsub(cc.__v2f(a[f + 2]), cc.v2fmult(e[f + 2].offset, u)), r.push(new cc.V2F_C4B_T2F_Triangle({ vertices: g, colors: b, texCoords: cc.__t(cc.v2fzero()) }, { vertices: h, colors: b, texCoords: cc.__t(cc.v2fzero()) }, { vertices: k, colors: b, texCoords: cc.__t(cc.v2fzero()) }, t, r.length * p)); for (f = 0; f < m; f++) { u = (f + 1) % m; g = cc.__v2f(a[f]); h = cc.__v2f(a[u]); k = e[f].n; var s = e[f].offset, v = e[u].offset, u = n ? cc.v2fsub(g, cc.v2fmult(s, c)) : cc.v2fsub(g, cc.v2fmult(s, 0.5)), x = n ? cc.v2fsub(h, cc.v2fmult(v, c)) : cc.v2fsub(h, cc.v2fmult(v, 0.5)); g = n ? cc.v2fadd(g, cc.v2fmult(s, c)) : cc.v2fadd(g, cc.v2fmult(s, 0.5)); h = n ? cc.v2fadd(h, cc.v2fmult(v, c)) : cc.v2fadd(h, cc.v2fmult(v, 0.5)); n ? (r.push(new cc.V2F_C4B_T2F_Triangle({ vertices: u, colors: d, texCoords: cc.__t(cc.v2fneg(k)) }, { vertices: x, colors: d, texCoords: cc.__t(cc.v2fneg(k)) }, { vertices: h, colors: d, texCoords: cc.__t(k) }, t, r.length * p)), r.push(new cc.V2F_C4B_T2F_Triangle({ vertices: u, colors: d, texCoords: cc.__t(cc.v2fneg(k)) }, { vertices: g, colors: d, texCoords: cc.__t(k) }, { vertices: h, colors: d, texCoords: cc.__t(k) }, t, r.length * p))) : (r.push(new cc.V2F_C4B_T2F_Triangle({ vertices: u, colors: b, texCoords: cc.__t(cc.v2fzero()) }, { vertices: x, colors: b, texCoords: cc.__t(cc.v2fzero()) }, { vertices: h, colors: b, texCoords: cc.__t(k) }, t, r.length * p)), r.push(new cc.V2F_C4B_T2F_Triangle({ vertices: u, colors: b, texCoords: cc.__t(cc.v2fzero()) }, { vertices: g, colors: b, texCoords: cc.__t(k) }, { vertices: h, colors: b, texCoords: cc.__t(k) }, t, r.length * p))) } this._dirty = !0 } }, _drawSegments: function(a, b, c, d) { b = null == b ? this._lineWidth : b; c = c || this._drawColor; null == c.a && (c.a = 255); b *= 0.5; if (!(0 >= b)) { c = { r: 0 | c.r, g: 0 | c.g, b: 0 | c.b, a: 0 | c.a }; var e = [], f, g, h, k, m = a.length; for (f = 0; f < m; f++) { g = cc.__v2f(a[(f - 1 + m) % m]); h = cc.__v2f(a[f]); k = cc.__v2f(a[(f + 1) % m]); var n = cc.v2fnormalize(cc.v2fperp(cc.v2fsub(h, g))); h = cc.v2fnormalize(cc.v2fperp(cc.v2fsub(k, h))); k = cc.v2fmult(cc.v2fadd(n, h), 1 / (cc.v2fdot(n, h) + 1)); e[f] = { offset: k, n: h } } this._ensureCapacity(3 * (3 * m - 2)); k = cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT; var n = this._trianglesArrayBuffer, p = this._buffer; d = d ? m : m - 1; for (f = 0; f < d; f++) { var t = (f + 1) % m; g = cc.__v2f(a[f]); h = cc.__v2f(a[t]); var r = e[f].n, u = e[f].offset, s = e[t].offset, t = cc.v2fsub(g, cc.v2fmult(u, b)), v = cc.v2fsub(h, cc.v2fmult(s, b)); g = cc.v2fadd(g, cc.v2fmult(u, b)); h = cc.v2fadd(h, cc.v2fmult(s, b)); p.push(new cc.V2F_C4B_T2F_Triangle({ vertices: t, colors: c, texCoords: cc.__t(cc.v2fneg(r)) }, { vertices: v, colors: c, texCoords: cc.__t(cc.v2fneg(r)) }, { vertices: h, colors: c, texCoords: cc.__t(r) }, n, p.length * k)); p.push(new cc.V2F_C4B_T2F_Triangle({ vertices: t, colors: c, texCoords: cc.__t(cc.v2fneg(r)) }, { vertices: g, colors: c, texCoords: cc.__t(r) }, { vertices: h, colors: c, texCoords: cc.__t(r) }, n, p.length * k)) } this._dirty = !0 } }, clear: function() { this._buffer.length = 0; this._dirty = !0 }, _createRenderCmd: function() { return new cc.DrawNode.WebGLRenderCmd(this) } }); cc.DrawNode = cc._renderType === cc._RENDER_TYPE_WEBGL ? cc.DrawNodeWebGL : cc.DrawNodeCanvas; cc.DrawNode.create = function() { return new cc.DrawNode }; cc._DrawNodeElement = function(a, b, c, d, e, f, g, h, k) { this.type = a; this.verts = b || null; this.fillColor = c || null; this.lineWidth = d || 0; this.lineColor = e || null; this.lineCap = f || "butt"; this.isClosePolygon = g || !1; this.isFill = h || !1; this.isStroke = k || !1 }; cc.DrawNode.TYPE_DOT = 0; cc.DrawNode.TYPE_SEGMENT = 1; cc.DrawNode.TYPE_POLY = 2; (function() { cc.DrawNode.CanvasRenderCmd = function(a) { cc.Node.CanvasRenderCmd.call(this, a); this._needDraw = !0; this._blendFunc = this._drawColor = this._buffer = null }; cc.DrawNode.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); cc.DrawNode.CanvasRenderCmd.prototype.constructor = cc.DrawNode.CanvasRenderCmd; cc.DrawNode.CanvasRenderCmd.prototype.rendering = function(a, b, c) { a = a || cc._renderContext; a.getContext(); var d = this._node._displayedOpacity / 255; if (0 !== d) { a.setTransform(this._worldTransform, b, c); a.setGlobalAlpha(d); this._blendFunc && this._blendFunc.src === cc.SRC_ALPHA && this._blendFunc.dst === cc.ONE && a.setCompositeOperation("lighter"); for (var d = this._buffer, e = 0, f = d.length; e < f; e++) { var g = d[e]; switch (g.type) { case cc.DrawNode.TYPE_DOT: this._drawDot(a, g, b, c); break; case cc.DrawNode.TYPE_SEGMENT: this._drawSegment(a, g, b, c); break; case cc.DrawNode.TYPE_POLY: this._drawPoly(a, g, b, c) } } } }; cc.DrawNode.CanvasRenderCmd.prototype._drawDot = function(a, b, c, d) { var e = b.fillColor, f = b.verts[0]; b = b.lineWidth; var g = a.getContext(); a.setFillStyle("rgba(" + (0 | e.r) + "," + (0 | e.g) + "," + (0 | e.b) + "," + e.a / 255 + ")"); g.beginPath(); g.arc(f.x * c, -f.y * d, b * c, 0, 2 * Math.PI, !1); g.closePath(); g.fill() }; cc.DrawNode.CanvasRenderCmd.prototype._drawSegment = function(a, b, c, d) { var e = b.lineColor, f = b.verts[0], g = b.verts[1], h = b.lineWidth; b = b.lineCap; var k = a.getContext(); a.setStrokeStyle("rgba(" + (0 | e.r) + "," + (0 | e.g) + "," + (0 | e.b) + "," + e.a / 255 + ")"); k.lineWidth = h * c; k.beginPath(); k.lineCap = b; k.moveTo(f.x * c, -f.y * d); k.lineTo(g.x * c, -g.y * d); k.stroke() }; cc.DrawNode.CanvasRenderCmd.prototype._drawPoly = function(a, b, c, d) { var e = b.verts, f = b.lineCap; if (null != e) { var g = b.fillColor, h = b.lineWidth, k = b.lineColor, m = b.isClosePolygon, n = b.isFill; b = b.isStroke; var p = a.getContext(), t = e[0]; p.lineCap = f; g && a.setFillStyle("rgba(" + (0 | g.r) + "," + (0 | g.g) + "," + (0 | g.b) + "," + g.a / 255 + ")"); h && (p.lineWidth = h * c); k && a.setStrokeStyle("rgba(" + (0 | k.r) + "," + (0 | k.g) + "," + (0 | k.b) + "," + k.a / 255 + ")"); p.beginPath(); p.moveTo(t.x * c, -t.y * d); a = 1; for (f = e.length; a < f; a++) p.lineTo(e[a].x * c, -e[a].y * d); m && p.closePath(); n && p.fill(); b && p.stroke() } } })(); (function() { cc.DrawNode.WebGLRenderCmd = function(a) { cc.Node.WebGLRenderCmd.call(this, a); this._needDraw = !0 }; cc.DrawNode.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); cc.DrawNode.WebGLRenderCmd.prototype.constructor = cc.DrawNode.WebGLRenderCmd; cc.DrawNode.WebGLRenderCmd.prototype.rendering = function(a) { a = this._node; cc.glBlendFunc(a._blendFunc.src, a._blendFunc.dst); this._shaderProgram.use(); this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix); a._render() } })(); cc.stencilBits = -1; cc.ClippingNode = cc.Node.extend({ alphaThreshold: 0, inverted: !1, _stencil: null, _className: "ClippingNode", ctor: function(a) { a = a || null; cc.Node.prototype.ctor.call(this); this._stencil = a; this.alphaThreshold = 1; this.inverted = !1; this._renderCmd.initStencilBits() }, init: function(a) { this._stencil = a; this.alphaThreshold = 1; this.inverted = !1; this._renderCmd.initStencilBits(); return !0 }, onEnter: function() { cc.Node.prototype.onEnter.call(this); this._stencil.onEnter() }, onEnterTransitionDidFinish: function() { cc.Node.prototype.onEnterTransitionDidFinish.call(this); this._stencil.onEnterTransitionDidFinish() }, onExitTransitionDidStart: function() { this._stencil.onExitTransitionDidStart(); cc.Node.prototype.onExitTransitionDidStart.call(this) }, onExit: function() { this._stencil.onExit(); cc.Node.prototype.onExit.call(this) }, getAlphaThreshold: function() { return this.alphaThreshold }, setAlphaThreshold: function(a) { this.alphaThreshold = a }, isInverted: function() { return this.inverted }, setInverted: function(a) { this.inverted = a }, getStencil: function() { return this._stencil }, setStencil: function(a) { this._stencil !== a && this._renderCmd.setStencil(a) }, _createRenderCmd: function() { return cc._renderType === cc._RENDER_TYPE_CANVAS ? new cc.ClippingNode.CanvasRenderCmd(this) : new cc.ClippingNode.WebGLRenderCmd(this) } }); _p = cc.ClippingNode.prototype; cc.defineGetterSetter(_p, "stencil", _p.getStencil, _p.setStencil); cc.ClippingNode.create = function(a) { return new cc.ClippingNode(a) }; (function() { cc.ClippingNode.CanvasRenderCmd = function(a) { cc.Node.CanvasRenderCmd.call(this, a); this._clipElemType = this._godhelpme = this._needDraw = !1; this._rendererSaveCmd = new cc.CustomRenderCmd(this, this._saveCmdCallback); this._rendererClipCmd = new cc.CustomRenderCmd(this, this._clipCmdCallback); this._rendererRestoreCmd = new cc.CustomRenderCmd(this, this._restoreCmdCallback) }; var a = cc.ClippingNode.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); a.constructor = cc.ClippingNode.CanvasRenderCmd; a.initStencilBits = function() {}; a.setStencil = function(a) { if (null != a) if (this._node._stencil = a, a instanceof cc.DrawNode) { if (a._buffer) for (var c = 0; c < a._buffer.length; c++) a._buffer[c].isFill = !1, a._buffer[c].isStroke = !1; a._renderCmd.rendering = function(c, e, f) { e = e || cc.view.getScaleX(); f = f || cc.view.getScaleY(); c = c || cc._renderContext; var g = c.getContext(), h = this._transform; c.save(); g.transform(h.a, h.b, h.c, h.d, h.tx * e, -h.ty * f); g.beginPath(); for (h = 0; h < a._buffer.length; h++) { var k = a._buffer[h].verts, m = k[0]; g.moveTo(m.x * e, -m.y * f); for (var m = 1, n = k.length; m < n; m++) g.lineTo(k[m].x * e, -k[m].y * f) } c.restore() } } else a._parent = this._node }; a._saveCmdCallback = function(a, c, d) { var e = a || cc._renderContext; a = e.getContext(); this._clipElemType ? (c = cc.ClippingNode.CanvasRenderCmd._getSharedCache(), d = a.canvas, c.width = d.width, c.height = d.height, c.getContext("2d").drawImage(d, 0, 0)) : (e.save(), e.save(), e.setTransform(this._worldTransform, c, d)) }; a._setStencilCompositionOperation = function(a) { if (a) { var c = this._node; a._renderCmd && a._renderCmd._blendFuncStr && (a._renderCmd._blendFuncStr = c.inverted ? "destination-out" : "destination-in"); if (a._children) { a = a._children; for (var c = 0, d = a.length; c < d; c++) this._setStencilCompositionOperation(a[c]) } } }; a._clipCmdCallback = function(a) { var c = this._node; a = a || cc._renderContext; var d = a.getContext(); this._clipElemType ? this._setStencilCompositionOperation(c._stencil) : (a.restore(), c.inverted && (c = d.canvas, a.save(), d.setTransform(1, 0, 0, 1, 0, 0), d.moveTo(0, 0), d.lineTo(0, c.height), d.lineTo(c.width, c.height), d.lineTo(c.width, 0), d.lineTo(0, 0), a.restore()), d.closePath(), d.clip()) }; a._restoreCmdCallback = function(a) { var c = cc.ClippingNode.CanvasRenderCmd._getSharedCache(); a = a || cc._renderContext; var d = a.getContext(); this._clipElemType ? (d.save(), d.setTransform(1, 0, 0, 1, 0, 0), d.globalCompositeOperation = "destination-over", d.drawImage(c, 0, 0), d.restore(), this._dirtyFlag = 0) : a.restore() }; a.transform = function(a, c) { cc.Node.CanvasRenderCmd.prototype.transform.call(this, a, c); var d = this._node; d._stencil && d._stencil._renderCmd && d._stencil._renderCmd.transform(this, c) }; a._cangodhelpme = function(a) { if (!0 === a || !1 === a) cc.ClippingNode.CanvasRenderCmd.prototype._godhelpme = a; return cc.ClippingNode.CanvasRenderCmd.prototype._godhelpme }; a.visit = function(a) { var c = this._node; if (c._visible) { if (a = a || this.getParentRenderCmd()) this._curLevel = a._curLevel + 1; this._clipElemType = !(!this._cangodhelpme() && c._stencil instanceof cc.DrawNode); if (c._stencil && c._stencil.visible) { this._syncStatus(a); cc.renderer.pushRenderCommand(this._rendererSaveCmd); this._clipElemType ? cc.Node.CanvasRenderCmd.prototype.visit.call(this, a) : c._stencil.visit(this); cc.renderer.pushRenderCommand(this._rendererClipCmd); if (this._clipElemType) c._stencil.visit(this); else { a = c._children; this._cangodhelpme(!0); var d = a.length; if (0 < d) for (c.sortAllChildren(), c = 0; c < d; c++) a[c]._renderCmd.visit(this); this._cangodhelpme(!1) } cc.renderer.pushRenderCommand(this._rendererRestoreCmd); this._dirtyFlag = 0 } else this.inverted && cc.Node.CanvasRenderCmd.prototype.visit.call(this, a) } }; cc.ClippingNode.CanvasRenderCmd._sharedCache = null; cc.ClippingNode.CanvasRenderCmd._getSharedCache = function() { return cc.ClippingNode.CanvasRenderCmd._sharedCache || (cc.ClippingNode.CanvasRenderCmd._sharedCache = document.createElement("canvas")) } })(); (function() { cc.ClippingNode.WebGLRenderCmd = function(a) { cc.Node.WebGLRenderCmd.call(this, a); this._needDraw = !1; this._beforeVisitCmd = new cc.CustomRenderCmd(this, this._onBeforeVisit); this._afterDrawStencilCmd = new cc.CustomRenderCmd(this, this._onAfterDrawStencil); this._afterVisitCmd = new cc.CustomRenderCmd(this, this._onAfterVisit); this._mask_layer_le = this._currentDepthWriteMask = this._currentStencilEnabled = this._currentStencilWriteMask = this._currentStencilPassDepthPass = this._currentStencilPassDepthFail = this._currentStencilFail = this._currentStencilValueMask = this._currentStencilRef = this._currentStencilFunc = null }; var a = cc.ClippingNode.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); a.constructor = cc.ClippingNode.WebGLRenderCmd; cc.ClippingNode.WebGLRenderCmd._init_once = null; cc.ClippingNode.WebGLRenderCmd._visit_once = null; cc.ClippingNode.WebGLRenderCmd._layer = -1; a.initStencilBits = function() { cc.ClippingNode.WebGLRenderCmd._init_once = !0; cc.ClippingNode.WebGLRenderCmd._init_once && (cc.stencilBits = cc._renderContext.getParameter(cc._renderContext.STENCIL_BITS), 0 >= cc.stencilBits && cc.log("Stencil buffer is not enabled."), cc.ClippingNode.WebGLRenderCmd._init_once = !1) }; a.transform = function(a, c) { var d = this._node; cc.Node.WebGLRenderCmd.prototype.transform.call(this, a, c); d._stencil && d._stencil._renderCmd.transform(this, c) }; a.visit = function(a) { var c = this._node; if (c._visible) if (c._parent && c._parent._renderCmd && (this._curLevel = c._parent._renderCmd._curLevel + 1), 1 > cc.stencilBits) cc.Node.WebGLRenderCmd.prototype.visit.call(this, a); else if (c._stencil && c._stencil.visible) if (cc.ClippingNode.WebGLRenderCmd._layer + 1 === cc.stencilBits) cc.ClippingNode.WebGLRenderCmd._visit_once = !0, cc.ClippingNode.WebGLRenderCmd._visit_once && (cc.log("Nesting more than " + cc.stencilBits + "stencils is not supported. Everything will be drawn without stencil for this node and its children."), cc.ClippingNode.WebGLRenderCmd._visit_once = !1), cc.Node.WebGLRenderCmd.prototype.visit.call(this, a); else { cc.renderer.pushRenderCommand(this._beforeVisitCmd); var d = cc.current_stack; d.stack.push(d.top); this._syncStatus(a); d.top = this._stackMatrix; c._stencil._renderCmd.visit(this); cc.renderer.pushRenderCommand(this._afterDrawStencilCmd); if ((a = c._children) && 0 < a.length) { var e = a.length; c.sortAllChildren(); for (c = 0; c < e; c++) a[c]._renderCmd.visit(this) } cc.renderer.pushRenderCommand(this._afterVisitCmd); this._dirtyFlag = 0; d.top = d.stack.pop() } else c.inverted && cc.Node.WebGLRenderCmd.prototype.visit.call(this, a) }; a.setStencil = function(a) { var c = this._node; c._stencil && (c._stencil._parent = null); c._stencil = a; c._stencil && (c._stencil._parent = c) }; a._drawFullScreenQuadClearStencil = function() { var a = cc.projection_matrix_stack; a.push(); a.top.identity(); var c = cc.modelview_matrix_stack; c.push(); c.top.identity(); cc._drawingUtil.drawSolidRect(cc.p(-1, -1), cc.p(1, 1), cc.color(255, 255, 255, 255)); a.pop(); c.pop() }; a._onBeforeVisit = function(a) { var c = a || cc._renderContext; a = this._node; cc.ClippingNode.WebGLRenderCmd._layer++; var d = 1 << cc.ClippingNode.WebGLRenderCmd._layer; this._mask_layer_le = d | d - 1; this._currentStencilEnabled = c.isEnabled(c.STENCIL_TEST); this._currentStencilWriteMask = c.getParameter(c.STENCIL_WRITEMASK); this._currentStencilFunc = c.getParameter(c.STENCIL_FUNC); this._currentStencilRef = c.getParameter(c.STENCIL_REF); this._currentStencilValueMask = c.getParameter(c.STENCIL_VALUE_MASK); this._currentStencilFail = c.getParameter(c.STENCIL_FAIL); this._currentStencilPassDepthFail = c.getParameter(c.STENCIL_PASS_DEPTH_FAIL); this._currentStencilPassDepthPass = c.getParameter(c.STENCIL_PASS_DEPTH_PASS); c.enable(c.STENCIL_TEST); c.stencilMask(d); this._currentDepthWriteMask = c.getParameter(c.DEPTH_WRITEMASK); c.depthMask(!1); c.stencilFunc(c.NEVER, d, d); c.stencilOp(a.inverted ? c.REPLACE : c.ZERO, c.KEEP, c.KEEP); this._drawFullScreenQuadClearStencil(); c.stencilFunc(c.NEVER, d, d); c.stencilOp(a.inverted ? c.ZERO : c.REPLACE, c.KEEP, c.KEEP); 1 > a.alphaThreshold && (d = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLORALPHATEST), c = c.getUniformLocation(d.getProgram(), cc.UNIFORM_ALPHA_TEST_VALUE_S), cc.glUseProgram(d.getProgram()), d.setUniformLocationWith1f(c, a.alphaThreshold), cc.setProgram(a._stencil, d)) }; a._onAfterDrawStencil = function(a) { a = a || cc._renderContext; a.depthMask(this._currentDepthWriteMask); a.stencilFunc(a.EQUAL, this._mask_layer_le, this._mask_layer_le); a.stencilOp(a.KEEP, a.KEEP, a.KEEP) }; a._onAfterVisit = function(a) { a = a || cc._renderContext; a.stencilFunc(this._currentStencilFunc, this._currentStencilRef, this._currentStencilValueMask); a.stencilOp(this._currentStencilFail, this._currentStencilPassDepthFail, this._currentStencilPassDepthPass); a.stencilMask(this._currentStencilWriteMask); this._currentStencilEnabled || a.disable(a.STENCIL_TEST); cc.ClippingNode.WebGLRenderCmd._layer-- } })(); cc.GridBase = cc.Class.extend({ _active: !1, _reuseGrid: 0, _gridSize: null, _texture: null, _step: null, _grabber: null, _isTextureFlipped: !1, _shaderProgram: null, _directorProjection: 0, _dirty: !1, ctor: function(a, b, c) { cc._checkWebGLRenderMode(); this._active = !1; this._reuseGrid = 0; this._texture = this._gridSize = null; this._step = cc.p(0, 0); this._grabber = null; this._isTextureFlipped = !1; this._shaderProgram = null; this._directorProjection = 0; this._dirty = !1; void 0 !== a && this.initWithSize(a, b, c) }, isActive: function() { return this._active }, setActive: function(a) { this._active = a; if (!a) { a = cc.director; var b = a.getProjection(); a.setProjection(b) } }, getReuseGrid: function() { return this._reuseGrid }, setReuseGrid: function(a) { this._reuseGrid = a }, getGridSize: function() { return cc.size(this._gridSize.width, this._gridSize.height) }, setGridSize: function(a) { this._gridSize.width = parseInt(a.width); this._gridSize.height = parseInt(a.height) }, getStep: function() { return cc.p(this._step.x, this._step.y) }, setStep: function(a) { this._step.x = a.x; this._step.y = a.y }, isTextureFlipped: function() { return this._isTextureFlipped }, setTextureFlipped: function(a) { this._isTextureFlipped !== a && (this._isTextureFlipped = a, this.calculateVertexPoints()) }, initWithSize: function(a, b, c) { if (!b) { var d = cc.director.getWinSizeInPixels(), e = cc.NextPOT(d.width), f = cc.NextPOT(d.height), g = new Uint8Array(e * f * 4); if (!g) return cc.log("cocos2d: CCGrid: not enough memory."), !1; b = new cc.Texture2D; b.initWithData(g, cc.Texture2D.PIXEL_FORMAT_RGBA8888, e, f, d); if (!b) return cc.log("cocos2d: CCGrid: error creating texture"), !1 } this._active = !1; this._reuseGrid = 0; this._gridSize = a; this._texture = b; this._isTextureFlipped = c || !1; this._step.x = this._texture.width / a.width; this._step.y = this._texture.height / a.height; this._grabber = new cc.Grabber; if (!this._grabber) return !1; this._grabber.grab(this._texture); this._shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURE); this.calculateVertexPoints(); return !0 }, beforeDraw: function() { this._directorProjection = cc.director.getProjection(); this._grabber.beforeRender(this._texture) }, afterDraw: function(a) { this._grabber.afterRender(this._texture); if (a && a.getCamera().isDirty()) { var b = a.getAnchorPointInPoints(), c = a._renderCmd._stackMatrix, d = cc.math.Matrix4.createByTranslation(b.x, b.y, 0); c.multiply(d); a._camera._locateForRenderer(c); d = cc.math.Matrix4.createByTranslation(-b.x, -b.y, 0, d); c.multiply(d) } cc.glBindTexture2D(this._texture); this.beforeBlit(); this.blit(a); this.afterBlit() }, beforeBlit: function() {}, afterBlit: function() {}, blit: function() { cc.log("cc.GridBase.blit(): Shall be overridden in subclass.") }, reuse: function() { cc.log("cc.GridBase.reuse(): Shall be overridden in subclass.") }, calculateVertexPoints: function() { cc.log("cc.GridBase.calculateVertexPoints(): Shall be overridden in subclass.") }, set2DProjection: function() { var a = cc.director.getWinSizeInPixels(); cc._renderContext.viewport(0, 0, a.width, a.height); cc.kmGLMatrixMode(cc.KM_GL_PROJECTION); cc.kmGLLoadIdentity(); a = cc.math.Matrix4.createOrthographicProjection(0, a.width, 0, a.height, -1, 1); cc.kmGLMultMatrix(a); cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); cc.kmGLLoadIdentity(); cc.setProjectionMatrixDirty() } }); cc.GridBase.create = function(a, b, c) { return new cc.GridBase(a, b, c) }; cc.Grid3D = cc.GridBase.extend({ _texCoordinates: null, _vertices: null, _originalVertices: null, _indices: null, _texCoordinateBuffer: null, _verticesBuffer: null, _indicesBuffer: null, _needDepthTestForBlit: !1, _oldDepthTestValue: !1, _oldDepthWriteValue: !1, ctor: function(a, b, c) { cc.GridBase.prototype.ctor.call(this); this._indicesBuffer = this._verticesBuffer = this._texCoordinateBuffer = this._indices = this._originalVertices = this._vertices = this._texCoordinates = null; void 0 !== a && this.initWithSize(a, b, c) }, vertex: function(a) { return this.getVertex(a) }, getVertex: function(a) { a.x === (0 | a.x) && a.y === (0 | a.y) || cc.log("cc.Grid3D.vertex() : Numbers must be integers"); a = 0 | 3 * (a.x * (this._gridSize.height + 1) + a.y); var b = this._vertices; return new cc.Vertex3F(b[a], b[a + 1], b[a + 2]) }, originalVertex: function(a) { return this.getOriginalVertex(a) }, getOriginalVertex: function(a) { a.x === (0 | a.x) && a.y === (0 | a.y) || cc.log("cc.Grid3D.originalVertex() : Numbers must be integers"); a = 0 | 3 * (a.x * (this._gridSize.height + 1) + a.y); var b = this._originalVertices; return new cc.Vertex3F(b[a], b[a + 1], b[a + 2]) }, setVertex: function(a, b) { a.x === (0 | a.x) && a.y === (0 | a.y) || cc.log("cc.Grid3D.setVertex() : Numbers must be integers"); var c = 0 | 3 * (a.x * (this._gridSize.height + 1) + a.y), d = this._vertices; d[c] = b.x; d[c + 1] = b.y; d[c + 2] = b.z; this._dirty = !0 }, beforeBlit: function() { if (this._needDepthTestForBlit) { var a = cc._renderContext; this._oldDepthTestValue = a.isEnabled(a.DEPTH_TEST); this._oldDepthWriteValue = a.getParameter(a.DEPTH_WRITEMASK); a.enable(a.DEPTH_TEST); a.depthMask(!0) } }, afterBlit: function() { if (this._needDepthTestForBlit) { var a = cc._renderContext; this._oldDepthTestValue ? a.enable(a.DEPTH_TEST) : a.disable(a.DEPTH_TEST); a.depthMask(this._oldDepthWriteValue) } }, blit: function(a) { var b = this._gridSize.width * this._gridSize.height; cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_TEX_COORDS); this._shaderProgram.use(); this._shaderProgram._setUniformForMVPMatrixWithMat4(a._renderCmd._stackMatrix); a = cc._renderContext; var c = this._dirty; a.bindBuffer(a.ARRAY_BUFFER, this._verticesBuffer); c && a.bufferData(a.ARRAY_BUFFER, this._vertices, a.DYNAMIC_DRAW); a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 3, a.FLOAT, !1, 0, 0); a.bindBuffer(a.ARRAY_BUFFER, this._texCoordinateBuffer); c && a.bufferData(a.ARRAY_BUFFER, this._texCoordinates, a.DYNAMIC_DRAW); a.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, a.FLOAT, !1, 0, 0); a.bindBuffer(a.ELEMENT_ARRAY_BUFFER, this._indicesBuffer); c && a.bufferData(a.ELEMENT_ARRAY_BUFFER, this._indices, a.STATIC_DRAW); a.drawElements(a.TRIANGLES, 6 * b, a.UNSIGNED_SHORT, 0); c && (this._dirty = !1); cc.incrementGLDraws(1) }, reuse: function() { if (0 < this._reuseGrid) { for (var a = this._originalVertices, b = this._vertices, c = 0, d = this._vertices.length; c < d; c++) a[c] = b[c]; --this._reuseGrid } }, calculateVertexPoints: function() { var a = cc._renderContext, b = this._texture.pixelsWidth, c = this._texture.pixelsHeight, d = this._texture.getContentSizeInPixels().height, e = this._gridSize, f = (e.width + 1) * (e.height + 1); this._vertices = new Float32Array(3 * f); this._texCoordinates = new Float32Array(2 * f); this._indices = new Uint16Array(e.width * e.height * 6); this._verticesBuffer && a.deleteBuffer(this._verticesBuffer); this._verticesBuffer = a.createBuffer(); this._texCoordinateBuffer && a.deleteBuffer(this._texCoordinateBuffer); this._texCoordinateBuffer = a.createBuffer(); this._indicesBuffer && a.deleteBuffer(this._indicesBuffer); this._indicesBuffer = a.createBuffer(); for (var g, h, k = this._indices, m = this._texCoordinates, n = this._isTextureFlipped, p = this._vertices, f = 0; f < e.width; ++f) for (g = 0; g < e.height; ++g) { var t = g * e.width + f; h = f * this._step.x; var r = h + this._step.x, u = g * this._step.y, s = u + this._step.y, v = f * (e.height + 1) + g, x = (f + 1) * (e.height + 1) + g, D = (f + 1) * (e.height + 1) + (g + 1), E = f * (e.height + 1) + (g + 1); k[6 * t] = v; k[6 * t + 1] = x; k[6 * t + 2] = E; k[6 * t + 3] = x; k[6 * t + 4] = D; k[6 * t + 5] = E; var t = [3 * v, 3 * x, 3 * D, 3 * E], A = [{ x: h, y: u, z: 0 }, { x: r, y: u, z: 0 }, { x: r, y: s, z: 0 }, { x: h, y: s, z: 0 }], v = [2 * v, 2 * x, 2 * D, 2 * E], r = [cc.p(h, u), cc.p(r, u), cc.p(r, s), cc.p(h, s)]; for (h = 0; 4 > h; ++h) p[t[h]] = A[h].x, p[t[h] + 1] = A[h].y, p[t[h] + 2] = A[h].z, m[v[h]] = r[h].x / b, m[v[h] + 1] = n ? (d - r[h].y) / c : r[h].y / c } this._originalVertices = new Float32Array(this._vertices); a.bindBuffer(a.ARRAY_BUFFER, this._verticesBuffer); a.bufferData(a.ARRAY_BUFFER, this._vertices, a.DYNAMIC_DRAW); a.bindBuffer(a.ARRAY_BUFFER, this._texCoordinateBuffer); a.bufferData(a.ARRAY_BUFFER, this._texCoordinates, a.DYNAMIC_DRAW); a.bindBuffer(a.ELEMENT_ARRAY_BUFFER, this._indicesBuffer); a.bufferData(a.ELEMENT_ARRAY_BUFFER, this._indices, a.STATIC_DRAW); this._dirty = !0 }, setNeedDepthTestForBlit: function(a) { this._needDepthTestForBlit = a }, getNeedDepthTestForBlit: function() { return this._needDepthTestForBlit } }); cc.Grid3D.create = function(a, b, c) { return new cc.Grid3D(a, b, c) }; cc.TiledGrid3D = cc.GridBase.extend({ _texCoordinates: null, _vertices: null, _originalVertices: null, _indices: null, _texCoordinateBuffer: null, _verticesBuffer: null, _indicesBuffer: null, ctor: function(a, b, c) { cc.GridBase.prototype.ctor.call(this); this._indicesBuffer = this._verticesBuffer = this._texCoordinateBuffer = this._indices = this._originalVertices = this._vertices = this._texCoordinates = null; void 0 !== a && this.initWithSize(a, b, c) }, tile: function(a) { return this.getTile(a) }, getTile: function(a) { a.x === (0 | a.x) && a.y === (0 | a.y) || cc.log("cc.TiledGrid3D.tile() : Numbers must be integers"); a = 12 * (this._gridSize.height * a.x + a.y); var b = this._vertices; return new cc.Quad3(new cc.Vertex3F(b[a], b[a + 1], b[a + 2]), new cc.Vertex3F(b[a + 3], b[a + 4], b[a + 5]), new cc.Vertex3F(b[a + 6], b[a + 7], b[a + 8]), new cc.Vertex3F(b[a + 9], b[a + 10], b[a + 11])) }, getOriginalTile: function(a) { a.x === (0 | a.x) && a.y === (0 | a.y) || cc.log("cc.TiledGrid3D.originalTile() : Numbers must be integers"); a = 12 * (this._gridSize.height * a.x + a.y); var b = this._originalVertices; return new cc.Quad3(new cc.Vertex3F(b[a], b[a + 1], b[a + 2]), new cc.Vertex3F(b[a + 3], b[a + 4], b[a + 5]), new cc.Vertex3F(b[a + 6], b[a + 7], b[a + 8]), new cc.Vertex3F(b[a + 9], b[a + 10], b[a + 11])) }, originalTile: function(a) { return this.getOriginalTile(a) }, setTile: function(a, b) { a.x === (0 | a.x) && a.y === (0 | a.y) || cc.log("cc.TiledGrid3D.setTile() : Numbers must be integers"); var c = 12 * (this._gridSize.height * a.x + a.y), d = this._vertices; d[c] = b.bl.x; d[c + 1] = b.bl.y; d[c + 2] = b.bl.z; d[c + 3] = b.br.x; d[c + 4] = b.br.y; d[c + 5] = b.br.z; d[c + 6] = b.tl.x; d[c + 7] = b.tl.y; d[c + 8] = b.tl.z; d[c + 9] = b.tr.x; d[c + 10] = b.tr.y; d[c + 11] = b.tr.z; this._dirty = !0 }, blit: function(a) { var b = this._gridSize.width * this._gridSize.height; this._shaderProgram.use(); this._shaderProgram._setUniformForMVPMatrixWithMat4(a._renderCmd._stackMatrix); a = cc._renderContext; var c = this._dirty; cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_TEX_COORDS); a.bindBuffer(a.ARRAY_BUFFER, this._verticesBuffer); c && a.bufferData(a.ARRAY_BUFFER, this._vertices, a.DYNAMIC_DRAW); a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 3, a.FLOAT, !1, 0, this._vertices); a.bindBuffer(a.ARRAY_BUFFER, this._texCoordinateBuffer); c && a.bufferData(a.ARRAY_BUFFER, this._texCoordinates, a.DYNAMIC_DRAW); a.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, a.FLOAT, !1, 0, this._texCoordinates); a.bindBuffer(a.ELEMENT_ARRAY_BUFFER, this._indicesBuffer); c && a.bufferData(a.ELEMENT_ARRAY_BUFFER, this._indices, a.STATIC_DRAW); a.drawElements(a.TRIANGLES, 6 * b, a.UNSIGNED_SHORT, 0); c && (this._dirty = !1); cc.incrementGLDraws(1) }, reuse: function() { if (0 < this._reuseGrid) { for (var a = this._vertices, b = this._originalVertices, c = 0; c < a.length; c++) b[c] = a[c]; --this._reuseGrid } }, calculateVertexPoints: function() { var a = this._texture.pixelsWidth, b = this._texture.pixelsHeight, c = this._texture.getContentSizeInPixels().height, d = this._gridSize, e = d.width * d.height; this._vertices = new Float32Array(12 * e); this._texCoordinates = new Float32Array(8 * e); this._indices = new Uint16Array(6 * e); var f = cc._renderContext; this._verticesBuffer && f.deleteBuffer(this._verticesBuffer); this._verticesBuffer = f.createBuffer(); this._texCoordinateBuffer && f.deleteBuffer(this._texCoordinateBuffer); this._texCoordinateBuffer = f.createBuffer(); this._indicesBuffer && f.deleteBuffer(this._indicesBuffer); this._indicesBuffer = f.createBuffer(); var g, h, k = 0, m = this._step, n = this._vertices, p = this._texCoordinates, t = this._isTextureFlipped; for (g = 0; g < d.width; g++) for (h = 0; h < d.height; h++) { var r = g * m.x, u = r + m.x, s = h * m.y, v = s + m.y; n[12 * k] = r; n[12 * k + 1] = s; n[12 * k + 2] = 0; n[12 * k + 3] = u; n[12 * k + 4] = s; n[12 * k + 5] = 0; n[12 * k + 6] = r; n[12 * k + 7] = v; n[12 * k + 8] = 0; n[12 * k + 9] = u; n[12 * k + 10] = v; n[12 * k + 11] = 0; var x = s, D = v; t && (x = c - s, D = c - v); p[8 * k] = r / a; p[8 * k + 1] = x / b; p[8 * k + 2] = u / a; p[8 * k + 3] = x / b; p[8 * k + 4] = r / a; p[8 * k + 5] = D / b; p[8 * k + 6] = u / a; p[8 * k + 7] = D / b; k++ } a = this._indices; for (g = 0; g < e; g++) a[6 * g + 0] = 4 * g + 0, a[6 * g + 1] = 4 * g + 1, a[6 * g + 2] = 4 * g + 2, a[6 * g + 3] = 4 * g + 1, a[6 * g + 4] = 4 * g + 2, a[6 * g + 5] = 4 * g + 3; this._originalVertices = new Float32Array(this._vertices); f.bindBuffer(f.ARRAY_BUFFER, this._verticesBuffer); f.bufferData(f.ARRAY_BUFFER, this._vertices, f.DYNAMIC_DRAW); f.bindBuffer(f.ARRAY_BUFFER, this._texCoordinateBuffer); f.bufferData(f.ARRAY_BUFFER, this._texCoordinates, f.DYNAMIC_DRAW); f.bindBuffer(f.ELEMENT_ARRAY_BUFFER, this._indicesBuffer); f.bufferData(f.ELEMENT_ARRAY_BUFFER, this._indices, f.DYNAMIC_DRAW); this._dirty = !0 } }); cc.TiledGrid3D.create = function(a, b, c) { return new cc.TiledGrid3D(a, b, c) }; cc.Grabber = cc.Class.extend({ _FBO: null, _oldFBO: null, _oldClearColor: null, _gl: null, ctor: function() { cc._checkWebGLRenderMode(); this._gl = cc._renderContext; this._oldClearColor = [0, 0, 0, 0]; this._oldFBO = null; this._FBO = this._gl.createFramebuffer() }, grab: function(a) { var b = this._gl; this._oldFBO = b.getParameter(b.FRAMEBUFFER_BINDING); b.bindFramebuffer(b.FRAMEBUFFER, this._FBO); b.framebufferTexture2D(b.FRAMEBUFFER, b.COLOR_ATTACHMENT0, b.TEXTURE_2D, a._webTextureObj, 0); b.checkFramebufferStatus(b.FRAMEBUFFER) !== b.FRAMEBUFFER_COMPLETE && cc.log("Frame Grabber: could not attach texture to frmaebuffer"); b.bindFramebuffer(b.FRAMEBUFFER, this._oldFBO) }, beforeRender: function(a) { a = this._gl; this._oldFBO = a.getParameter(a.FRAMEBUFFER_BINDING); a.bindFramebuffer(a.FRAMEBUFFER, this._FBO); this._oldClearColor = a.getParameter(a.COLOR_CLEAR_VALUE); a.clearColor(0, 0, 0, 0); a.clear(a.COLOR_BUFFER_BIT | a.DEPTH_BUFFER_BIT) }, afterRender: function(a) { a = this._gl; a.bindFramebuffer(a.FRAMEBUFFER, this._oldFBO); a.colorMask(!0, !0, !0, !0) }, destroy: function() { this._gl.deleteFramebuffer(this._FBO) } }); cc.ACTION_TAG_INVALID = -1; cc.Action = cc.Class.extend({ originalTarget: null, target: null, tag: cc.ACTION_TAG_INVALID, ctor: function() { this.target = this.originalTarget = null; this.tag = cc.ACTION_TAG_INVALID }, copy: function() { cc.log("copy is deprecated. Please use clone instead."); return this.clone() }, clone: function() { var a = new cc.Action; a.originalTarget = null; a.target = null; a.tag = this.tag; return a }, isDone: function() { return !0 }, startWithTarget: function(a) { this.target = this.originalTarget = a }, stop: function() { this.target = null }, step: function(a) { cc.log("[Action step]. override me") }, update: function(a) { cc.log("[Action update]. override me") }, getTarget: function() { return this.target }, setTarget: function(a) { this.target = a }, getOriginalTarget: function() { return this.originalTarget }, setOriginalTarget: function(a) { this.originalTarget = a }, getTag: function() { return this.tag }, setTag: function(a) { this.tag = a }, retain: function() {}, release: function() {} }); cc.action = function() { return new cc.Action }; cc.Action.create = cc.action; cc.FiniteTimeAction = cc.Action.extend({ _duration: 0, ctor: function() { cc.Action.prototype.ctor.call(this); this._duration = 0 }, getDuration: function() { return this._duration * (this._timesForRepeat || 1) }, setDuration: function(a) { this._duration = a }, reverse: function() { cc.log("cocos2d: FiniteTimeAction#reverse: Implement me"); return null }, clone: function() { return new cc.FiniteTimeAction } }); cc.Speed = cc.Action.extend({ _speed: 0, _innerAction: null, ctor: function(a, b) { cc.Action.prototype.ctor.call(this); this._speed = 0; this._innerAction = null; a && this.initWithAction(a, b) }, getSpeed: function() { return this._speed }, setSpeed: function(a) { this._speed = a }, initWithAction: function(a, b) { if (!a) throw "cc.Speed.initWithAction(): action must be non nil"; this._innerAction = a; this._speed = b; return !0 }, clone: function() { var a = new cc.Speed; a.initWithAction(this._innerAction.clone(), this._speed); return a }, startWithTarget: function(a) { cc.Action.prototype.startWithTarget.call(this, a); this._innerAction.startWithTarget(a) }, stop: function() { this._innerAction.stop(); cc.Action.prototype.stop.call(this) }, step: function(a) { this._innerAction.step(a * this._speed) }, isDone: function() { return this._innerAction.isDone() }, reverse: function() { return new cc.Speed(this._innerAction.reverse(), this._speed) }, setInnerAction: function(a) { this._innerAction !== a && (this._innerAction = a) }, getInnerAction: function() { return this._innerAction } }); cc.speed = function(a, b) { return new cc.Speed(a, b) }; cc.Speed.create = cc.speed; cc.Follow = cc.Action.extend({ _followedNode: null, _boundarySet: !1, _boundaryFullyCovered: !1, _halfScreenSize: null, _fullScreenSize: null, _worldRect: null, leftBoundary: 0, rightBoundary: 0, topBoundary: 0, bottomBoundary: 0, ctor: function(a, b) { cc.Action.prototype.ctor.call(this); this._followedNode = null; this._boundaryFullyCovered = this._boundarySet = !1; this._fullScreenSize = this._halfScreenSize = null; this.bottomBoundary = this.topBoundary = this.rightBoundary = this.leftBoundary = 0; this._worldRect = cc.rect(0, 0, 0, 0); a && (b ? this.initWithTarget(a, b) : this.initWithTarget(a)) }, clone: function() { var a = new cc.Follow, b = this._worldRect, b = new cc.Rect(b.x, b.y, b.width, b.height); a.initWithTarget(this._followedNode, b); return a }, isBoundarySet: function() { return this._boundarySet }, setBoudarySet: function(a) { this._boundarySet = a }, initWithTarget: function(a, b) { if (!a) throw "cc.Follow.initWithAction(): followedNode must be non nil"; b = b || cc.rect(0, 0, 0, 0); this._followedNode = a; this._worldRect = b; this._boundarySet = !cc._rectEqualToZero(b); this._boundaryFullyCovered = !1; var c = cc.director.getWinSize(); this._fullScreenSize = cc.p(c.width, c.height); this._halfScreenSize = cc.pMult(this._fullScreenSize, 0.5); this._boundarySet && (this.leftBoundary = -(b.x + b.width - this._fullScreenSize.x), this.rightBoundary = -b.x, this.topBoundary = -b.y, this.bottomBoundary = -(b.y + b.height - this._fullScreenSize.y), this.rightBoundary < this.leftBoundary && (this.rightBoundary = this.leftBoundary = (this.leftBoundary + this.rightBoundary) / 2), this.topBoundary < this.bottomBoundary && (this.topBoundary = this.bottomBoundary = (this.topBoundary + this.bottomBoundary) / 2), this.topBoundary === this.bottomBoundary && this.leftBoundary === this.rightBoundary && (this._boundaryFullyCovered = !0)); return !0 }, step: function(a) { a = this._followedNode.x; var b = this._followedNode.y; a = this._halfScreenSize.x - a; b = this._halfScreenSize.y - b; this.target._renderCmd._dirtyFlag = 0; this._boundarySet ? this._boundaryFullyCovered || this.target.setPosition(cc.clampf(a, this.leftBoundary, this.rightBoundary), cc.clampf(b, this.bottomBoundary, this.topBoundary)) : this.target.setPosition(a, b) }, isDone: function() { return !this._followedNode.running }, stop: function() { this.target = null; cc.Action.prototype.stop.call(this) } }); cc.follow = function(a, b) { return new cc.Follow(a, b) }; cc.Follow.create = cc.follow; cc.ActionInterval = cc.FiniteTimeAction.extend({ _elapsed: 0, _firstTick: !1, _easeList: null, _timesForRepeat: 1, _repeatForever: !1, _repeatMethod: !1, _speed: 1, _speedMethod: !1, ctor: function(a) { this._timesForRepeat = this._speed = 1; this._repeatForever = !1; this.MAX_VALUE = 2; this._speedMethod = this._repeatMethod = !1; cc.FiniteTimeAction.prototype.ctor.call(this); void 0 !== a && this.initWithDuration(a) }, getElapsed: function() { return this._elapsed }, initWithDuration: function(a) { this._duration = 0 === a ? cc.FLT_EPSILON : a; this._elapsed = 0; return this._firstTick = !0 }, isDone: function() { return this._elapsed >= this._duration }, _cloneDecoration: function(a) { a._repeatForever = this._repeatForever; a._speed = this._speed; a._timesForRepeat = this._timesForRepeat; a._easeList = this._easeList; a._speedMethod = this._speedMethod; a._repeatMethod = this._repeatMethod }, _reverseEaseList: function(a) { if (this._easeList) { a._easeList = []; for (var b = 0; b < this._easeList.length; b++) a._easeList.push(this._easeList[b].reverse()) } }, clone: function() { var a = new cc.ActionInterval(this._duration); this._cloneDecoration(a); return a }, easing: function(a) { this._easeList ? this._easeList.length = 0 : this._easeList = []; for (var b = 0; b < arguments.length; b++) this._easeList.push(arguments[b]); return this }, _computeEaseTime: function(a) { var b = this._easeList; if (!b || 0 === b.length) return a; for (var c = 0, d = b.length; c < d; c++) a = b[c].easing(a); return a }, step: function(a) { this._firstTick ? (this._firstTick = !1, this._elapsed = 0) : this._elapsed += a; a = this._elapsed / (1.192092896E-7 < this._duration ? this._duration : 1.192092896E-7); a = 1 > a ? a : 1; this.update(0 < a ? a : 0); this._repeatMethod && 1 < this._timesForRepeat && this.isDone() && (this._repeatForever || this._timesForRepeat--, this.startWithTarget(this.target), this.step(this._elapsed - this._duration)) }, startWithTarget: function(a) { cc.Action.prototype.startWithTarget.call(this, a); this._elapsed = 0; this._firstTick = !0 }, reverse: function() { cc.log("cc.IntervalAction: reverse not implemented."); return null }, setAmplitudeRate: function(a) { cc.log("cc.ActionInterval.setAmplitudeRate(): it should be overridden in subclass.") }, getAmplitudeRate: function() { cc.log("cc.ActionInterval.getAmplitudeRate(): it should be overridden in subclass."); return 0 }, speed: function(a) { if (0 >= a) return cc.log("The speed parameter error"), this; this._speedMethod = !0; this._speed *= a; return this }, getSpeed: function() { return this._speed }, setSpeed: function(a) { this._speed = a; return this }, repeat: function(a) { a = Math.round(a); if (isNaN(a) || 1 > a) return cc.log("The repeat parameter error"), this; this._repeatMethod = !0; this._timesForRepeat *= a; return this }, repeatForever: function() { this._repeatMethod = !0; this._timesForRepeat = this.MAX_VALUE; this._repeatForever = !0; return this } }); cc.actionInterval = function(a) { return new cc.ActionInterval(a) }; cc.ActionInterval.create = cc.actionInterval; cc.Sequence = cc.ActionInterval.extend({ _actions: null, _split: null, _last: 0, ctor: function(a) { cc.ActionInterval.prototype.ctor.call(this); this._actions = []; var b = a instanceof Array ? a : arguments, c = b.length - 1; 0 <= c && null == b[c] && cc.log("parameters should not be ending with null in Javascript"); if (0 <= c) { for (var d = b[0], e = 1; e < c; e++) b[e] && (d = cc.Sequence._actionOneTwo(d, b[e])); this.initWithTwoActions(d, b[c]) } }, initWithTwoActions: function(a, b) { if (!a || !b) throw "cc.Sequence.initWithTwoActions(): arguments must all be non nil"; this.initWithDuration(a._duration + b._duration); this._actions[0] = a; this._actions[1] = b; return !0 }, clone: function() { var a = new cc.Sequence; this._cloneDecoration(a); a.initWithTwoActions(this._actions[0].clone(), this._actions[1].clone()); return a }, startWithTarget: function(a) { cc.ActionInterval.prototype.startWithTarget.call(this, a); this._split = this._actions[0]._duration / this._duration; this._last = -1 }, stop: function() { -1 !== this._last && this._actions[this._last].stop(); cc.Action.prototype.stop.call(this) }, update: function(a) { var b = 0, c = this._split, d = this._actions, e = this._last; a = this._computeEaseTime(a); a < c ? (a = 0 !== c ? a / c : 1, 0 === b && 1 === e && (d[1].update(0), d[1].stop())) : (b = 1, a = 1 === c ? 1 : (a - c) / (1 - c), -1 === e && (d[0].startWithTarget(this.target), d[0].update(1), d[0].stop()), e || (d[0].update(1), d[0].stop())); d = d[b]; e === b && d.isDone() || (e !== b && d.startWithTarget(this.target), a *= d._timesForRepeat, d.update(1 < a ? a % 1 : a), this._last = b) }, reverse: function() { var a = cc.Sequence._actionOneTwo(this._actions[1].reverse(), this._actions[0].reverse()); this._cloneDecoration(a); this._reverseEaseList(a); return a } }); cc.sequence = function(a) { var b = a instanceof Array ? a : arguments; 0 < b.length && null == b[b.length - 1] && cc.log("parameters should not be ending with null in Javascript"); for (var c, d, e, f; b && 0 < b.length;) for (d = Array.prototype.shift.call(b), f = d._timesForRepeat || 1, d._repeatMethod = !1, d._timesForRepeat = 1, e = 0, c || (c = d, e = 1), e; e < f; e++) c = cc.Sequence._actionOneTwo(c, d); return c }; cc.Sequence.create = cc.sequence; cc.Sequence._actionOneTwo = function(a, b) { var c = new cc.Sequence; c.initWithTwoActions(a, b); return c }; cc.Repeat = cc.ActionInterval.extend({ _times: 0, _total: 0, _nextDt: 0, _actionInstant: !1, _innerAction: null, ctor: function(a, b) { cc.ActionInterval.prototype.ctor.call(this); void 0 !== b && this.initWithAction(a, b) }, initWithAction: function(a, b) { return this.initWithDuration(a._duration * b) ? (this._times = b, this._innerAction = a, a instanceof cc.ActionInstant && (this._actionInstant = !0, this._times -= 1), this._total = 0, !0) : !1 }, clone: function() { var a = new cc.Repeat; this._cloneDecoration(a); a.initWithAction(this._innerAction.clone(), this._times); return a }, startWithTarget: function(a) { this._total = 0; this._nextDt = this._innerAction._duration / this._duration; cc.ActionInterval.prototype.startWithTarget.call(this, a); this._innerAction.startWithTarget(a) }, stop: function() { this._innerAction.stop(); cc.Action.prototype.stop.call(this) }, update: function(a) { a = this._computeEaseTime(a); var b = this._innerAction, c = this._duration, d = this._times, e = this._nextDt; if (a >= e) { for (; a > e && this._total < d;) b.update(1), this._total++, b.stop(), b.startWithTarget(this.target), this._nextDt = e += b._duration / c; 1 <= a && this._total < d && this._total++; this._actionInstant || (this._total === d ? (b.update(1), b.stop()) : b.update(a - (e - b._duration / c))) } else b.update(a * d % 1) }, isDone: function() { return this._total === this._times }, reverse: function() { var a = new cc.Repeat(this._innerAction.reverse(), this._times); this._cloneDecoration(a); this._reverseEaseList(a); return a }, setInnerAction: function(a) { this._innerAction !== a && (this._innerAction = a) }, getInnerAction: function() { return this._innerAction } }); cc.repeat = function(a, b) { return new cc.Repeat(a, b) }; cc.Repeat.create = cc.repeat; cc.RepeatForever = cc.ActionInterval.extend({ _innerAction: null, ctor: function(a) { cc.ActionInterval.prototype.ctor.call(this); this._innerAction = null; a && this.initWithAction(a) }, initWithAction: function(a) { if (!a) throw "cc.RepeatForever.initWithAction(): action must be non null"; this._innerAction = a; return !0 }, clone: function() { var a = new cc.RepeatForever; this._cloneDecoration(a); a.initWithAction(this._innerAction.clone()); return a }, startWithTarget: function(a) { cc.ActionInterval.prototype.startWithTarget.call(this, a); this._innerAction.startWithTarget(a) }, step: function(a) { var b = this._innerAction; b.step(a); b.isDone() && (b.startWithTarget(this.target), b.step(b.getElapsed() - b._duration)) }, isDone: function() { return !1 }, reverse: function() { var a = new cc.RepeatForever(this._innerAction.reverse()); this._cloneDecoration(a); this._reverseEaseList(a); return a }, setInnerAction: function(a) { this._innerAction !== a && (this._innerAction = a) }, getInnerAction: function() { return this._innerAction } }); cc.repeatForever = function(a) { return new cc.RepeatForever(a) }; cc.RepeatForever.create = cc.repeatForever; cc.Spawn = cc.ActionInterval.extend({ _one: null, _two: null, ctor: function(a) { cc.ActionInterval.prototype.ctor.call(this); this._two = this._one = null; var b = a instanceof Array ? a : arguments, c = b.length - 1; 0 <= c && null == b[c] && cc.log("parameters should not be ending with null in Javascript"); if (0 <= c) { for (var d = b[0], e = 1; e < c; e++) b[e] && (d = cc.Spawn._actionOneTwo(d, b[e])); this.initWithTwoActions(d, b[c]) } }, initWithTwoActions: function(a, b) { if (!a || !b) throw "cc.Spawn.initWithTwoActions(): arguments must all be non null"; var c = !1, d = a._duration, e = b._duration; this.initWithDuration(Math.max(d, e)) && (this._one = a, this._two = b, d > e ? this._two = cc.Sequence._actionOneTwo(b, cc.delayTime(d - e)) : d < e && (this._one = cc.Sequence._actionOneTwo(a, cc.delayTime(e - d))), c = !0); return c }, clone: function() { var a = new cc.Spawn; this._cloneDecoration(a); a.initWithTwoActions(this._one.clone(), this._two.clone()); return a }, startWithTarget: function(a) { cc.ActionInterval.prototype.startWithTarget.call(this, a); this._one.startWithTarget(a); this._two.startWithTarget(a) }, stop: function() { this._one.stop(); this._two.stop(); cc.Action.prototype.stop.call(this) }, update: function(a) { a = this._computeEaseTime(a); this._one && this._one.update(a); this._two && this._two.update(a) }, reverse: function() { var a = cc.Spawn._actionOneTwo(this._one.reverse(), this._two.reverse()); this._cloneDecoration(a); this._reverseEaseList(a); return a } }); cc.spawn = function(a) { var b = a instanceof Array ? a : arguments; 0 < b.length && null == b[b.length - 1] && cc.log("parameters should not be ending with null in Javascript"); for (var c = b[0], d = 1; d < b.length; d++) null != b[d] && (c = cc.Spawn._actionOneTwo(c, b[d])); return c }; cc.Spawn.create = cc.spawn; cc.Spawn._actionOneTwo = function(a, b) { var c = new cc.Spawn; c.initWithTwoActions(a, b); return c }; cc.RotateTo = cc.ActionInterval.extend({ _dstAngleX: 0, _startAngleX: 0, _diffAngleX: 0, _dstAngleY: 0, _startAngleY: 0, _diffAngleY: 0, ctor: function(a, b, c) { cc.ActionInterval.prototype.ctor.call(this); void 0 !== b && this.initWithDuration(a, b, c) }, initWithDuration: function(a, b, c) { return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._dstAngleX = b || 0, this._dstAngleY = c || this._dstAngleX, !0) : !1 }, clone: function() { var a = new cc.RotateTo; this._cloneDecoration(a); a.initWithDuration(this._duration, this._dstAngleX, this._dstAngleY); return a }, startWithTarget: function(a) { cc.ActionInterval.prototype.startWithTarget.call(this, a); var b = a.rotationX % 360, c = this._dstAngleX - b; 180 < c && (c -= 360); - 180 > c && (c += 360); this._startAngleX = b; this._diffAngleX = c; this._startAngleY = a.rotationY % 360; a = this._dstAngleY - this._startAngleY; 180 < a && (a -= 360); - 180 > a && (a += 360); this._diffAngleY = a }, reverse: function() { cc.log("cc.RotateTo.reverse(): it should be overridden in subclass.") }, update: function(a) { a = this._computeEaseTime(a); this.target && (this.target.rotationX = this._startAngleX + this._diffAngleX * a, this.target.rotationY = this._startAngleY + this._diffAngleY * a) } }); cc.rotateTo = function(a, b, c) { return new cc.RotateTo(a, b, c) }; cc.RotateTo.create = cc.rotateTo; cc.RotateBy = cc.ActionInterval.extend({ _angleX: 0, _startAngleX: 0, _angleY: 0, _startAngleY: 0, ctor: function(a, b, c) { cc.ActionInterval.prototype.ctor.call(this); void 0 !== b && this.initWithDuration(a, b, c) }, initWithDuration: function(a, b, c) { return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._angleX = b || 0, this._angleY = c || this._angleX, !0) : !1 }, clone: function() { var a = new cc.RotateBy; this._cloneDecoration(a); a.initWithDuration(this._duration, this._angleX, this._angleY); return a }, startWithTarget: function(a) { cc.ActionInterval.prototype.startWithTarget.call(this, a); this._startAngleX = a.rotationX; this._startAngleY = a.rotationY }, update: function(a) { a = this._computeEaseTime(a); this.target && (this.target.rotationX = this._startAngleX + this._angleX * a, this.target.rotationY = this._startAngleY + this._angleY * a) }, reverse: function() { var a = new cc.RotateBy(this._duration, -this._angleX, -this._angleY); this._cloneDecoration(a); this._reverseEaseList(a); return a } }); cc.rotateBy = function(a, b, c) { return new cc.RotateBy(a, b, c) }; cc.RotateBy.create = cc.rotateBy; cc.MoveBy = cc.ActionInterval.extend({ _positionDelta: null, _startPosition: null, _previousPosition: null, ctor: function(a, b, c) { cc.ActionInterval.prototype.ctor.call(this); this._positionDelta = cc.p(0, 0); this._startPosition = cc.p(0, 0); this._previousPosition = cc.p(0, 0); void 0 !== b && this.initWithDuration(a, b, c) }, initWithDuration: function(a, b, c) { return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (void 0 !== b.x && (c = b.y, b = b.x), this._positionDelta.x = b, this._positionDelta.y = c, !0) : !1 }, clone: function() { var a = new cc.MoveBy; this._cloneDecoration(a); a.initWithDuration(this._duration, this._positionDelta); return a }, startWithTarget: function(a) { cc.ActionInterval.prototype.startWithTarget.call(this, a); var b = a.getPositionX(); a = a.getPositionY(); this._previousPosition.x = b; this._previousPosition.y = a; this._startPosition.x = b; this._startPosition.y = a }, update: function(a) { a = this._computeEaseTime(a); if (this.target) { var b = this._positionDelta.x * a; a *= this._positionDelta.y; var c = this._startPosition; if (cc.ENABLE_STACKABLE_ACTIONS) { var d = this.target.getPositionX(), e = this.target.getPositionY(), f = this._previousPosition; c.x = c.x + d - f.x; c.y = c.y + e - f.y; b += c.x; a += c.y; f.x = b; f.y = a; this.target.setPosition(b, a) } else this.target.setPosition(c.x + b, c.y + a) } }, reverse: function() { var a = new cc.MoveBy(this._duration, cc.p(-this._positionDelta.x, -this._positionDelta.y)); this._cloneDecoration(a); this._reverseEaseList(a); return a } }); cc.moveBy = function(a, b, c) { return new cc.MoveBy(a, b, c) }; cc.MoveBy.create = cc.moveBy; cc.MoveTo = cc.MoveBy.extend({ _endPosition: null, ctor: function(a, b, c) { cc.MoveBy.prototype.ctor.call(this); this._endPosition = cc.p(0, 0); void 0 !== b && this.initWithDuration(a, b, c) }, initWithDuration: function(a, b, c) { return cc.MoveBy.prototype.initWithDuration.call(this, a, b, c) ? (void 0 !== b.x && (c = b.y, b = b.x), this._endPosition.x = b, this._endPosition.y = c, !0) : !1 }, clone: function() { var a = new cc.MoveTo; this._cloneDecoration(a); a.initWithDuration(this._duration, this._endPosition); return a }, startWithTarget: function(a) { cc.MoveBy.prototype.startWithTarget.call(this, a); this._positionDelta.x = this._endPosition.x - a.getPositionX(); this._positionDelta.y = this._endPosition.y - a.getPositionY() } }); cc.moveTo = function(a, b, c) { return new cc.MoveTo(a, b, c) }; cc.MoveTo.create = cc.moveTo; cc.SkewTo = cc.ActionInterval.extend({ _skewX: 0, _skewY: 0, _startSkewX: 0, _startSkewY: 0, _endSkewX: 0, _endSkewY: 0, _deltaX: 0, _deltaY: 0, ctor: function(a, b, c) { cc.ActionInterval.prototype.ctor.call(this); void 0 !== c && this.initWithDuration(a, b, c) }, initWithDuration: function(a, b, c) { var d = !1; cc.ActionInterval.prototype.initWithDuration.call(this, a) && (this._endSkewX = b, this._endSkewY = c, d = !0); return d }, clone: function() { var a = new cc.SkewTo; this._cloneDecoration(a); a.initWithDuration(this._duration, this._endSkewX, this._endSkewY); return a }, startWithTarget: function(a) { cc.ActionInterval.prototype.startWithTarget.call(this, a); this._startSkewX = a.skewX % 180; this._deltaX = this._endSkewX - this._startSkewX; 180 < this._deltaX && (this._deltaX -= 360); - 180 > this._deltaX && (this._deltaX += 360); this._startSkewY = a.skewY % 360; this._deltaY = this._endSkewY - this._startSkewY; 180 < this._deltaY && (this._deltaY -= 360); - 180 > this._deltaY && (this._deltaY += 360) }, update: function(a) { a = this._computeEaseTime(a); this.target.skewX = this._startSkewX + this._deltaX * a; this.target.skewY = this._startSkewY + this._deltaY * a } }); cc.skewTo = function(a, b, c) { return new cc.SkewTo(a, b, c) }; cc.SkewTo.create = cc.skewTo; cc.SkewBy = cc.SkewTo.extend({ ctor: function(a, b, c) { cc.SkewTo.prototype.ctor.call(this); void 0 !== c && this.initWithDuration(a, b, c) }, initWithDuration: function(a, b, c) { var d = !1; cc.SkewTo.prototype.initWithDuration.call(this, a, b, c) && (this._skewX = b, this._skewY = c, d = !0); return d }, clone: function() { var a = new cc.SkewBy; this._cloneDecoration(a); a.initWithDuration(this._duration, this._skewX, this._skewY); return a }, startWithTarget: function(a) { cc.SkewTo.prototype.startWithTarget.call(this, a); this._deltaX = this._skewX; this._deltaY = this._skewY; this._endSkewX = this._startSkewX + this._deltaX; this._endSkewY = this._startSkewY + this._deltaY }, reverse: function() { var a = new cc.SkewBy(this._duration, -this._skewX, -this._skewY); this._cloneDecoration(a); this._reverseEaseList(a); return a } }); cc.skewBy = function(a, b, c) { return new cc.SkewBy(a, b, c) }; cc.SkewBy.create = cc.skewBy; cc.JumpBy = cc.ActionInterval.extend({ _startPosition: null, _delta: null, _height: 0, _jumps: 0, _previousPosition: null, ctor: function(a, b, c, d, e) { cc.ActionInterval.prototype.ctor.call(this); this._startPosition = cc.p(0, 0); this._previousPosition = cc.p(0, 0); this._delta = cc.p(0, 0); void 0 !== d && this.initWithDuration(a, b, c, d, e) }, initWithDuration: function(a, b, c, d, e) { return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (void 0 === e && (e = d, d = c, c = b.y, b = b.x), this._delta.x = b, this._delta.y = c, this._height = d, this._jumps = e, !0) : !1 }, clone: function() { var a = new cc.JumpBy; this._cloneDecoration(a); a.initWithDuration(this._duration, this._delta, this._height, this._jumps); return a }, startWithTarget: function(a) { cc.ActionInterval.prototype.startWithTarget.call(this, a); var b = a.getPositionX(); a = a.getPositionY(); this._previousPosition.x = b; this._previousPosition.y = a; this._startPosition.x = b; this._startPosition.y = a }, update: function(a) { a = this._computeEaseTime(a); if (this.target) { var b = a * this._jumps % 1, b = 4 * this._height * b * (1 - b), b = b + this._delta.y * a; a *= this._delta.x; var c = this._startPosition; if (cc.ENABLE_STACKABLE_ACTIONS) { var d = this.target.getPositionX(), e = this.target.getPositionY(), f = this._previousPosition; c.x = c.x + d - f.x; c.y = c.y + e - f.y; a += c.x; b += c.y; f.x = a; f.y = b; this.target.setPosition(a, b) } else this.target.setPosition(c.x + a, c.y + b) } }, reverse: function() { var a = new cc.JumpBy(this._duration, cc.p(-this._delta.x, -this._delta.y), this._height, this._jumps); this._cloneDecoration(a); this._reverseEaseList(a); return a } }); cc.jumpBy = function(a, b, c, d, e) { return new cc.JumpBy(a, b, c, d, e) }; cc.JumpBy.create = cc.jumpBy; cc.JumpTo = cc.JumpBy.extend({ _endPosition: null, ctor: function(a, b, c, d, e) { cc.JumpBy.prototype.ctor.call(this); this._endPosition = cc.p(0, 0); void 0 !== d && this.initWithDuration(a, b, c, d, e) }, initWithDuration: function(a, b, c, d, e) { return cc.JumpBy.prototype.initWithDuration.call(this, a, b, c, d, e) ? (void 0 === e && (c = b.y, b = b.x), this._endPosition.x = b, this._endPosition.y = c, !0) : !1 }, startWithTarget: function(a) { cc.JumpBy.prototype.startWithTarget.call(this, a); this._delta.x = this._endPosition.x - this._startPosition.x; this._delta.y = this._endPosition.y - this._startPosition.y }, clone: function() { var a = new cc.JumpTo; this._cloneDecoration(a); a.initWithDuration(this._duration, this._endPosition, this._height, this._jumps); return a } }); cc.jumpTo = function(a, b, c, d, e) { return new cc.JumpTo(a, b, c, d, e) }; cc.JumpTo.create = cc.jumpTo; cc.bezierAt = function(a, b, c, d, e) { return Math.pow(1 - e, 3) * a + 3 * e * Math.pow(1 - e, 2) * b + 3 * Math.pow(e, 2) * (1 - e) * c + Math.pow(e, 3) * d }; cc.BezierBy = cc.ActionInterval.extend({ _config: null, _startPosition: null, _previousPosition: null, ctor: function(a, b) { cc.ActionInterval.prototype.ctor.call(this); this._config = []; this._startPosition = cc.p(0, 0); this._previousPosition = cc.p(0, 0); b && this.initWithDuration(a, b) }, initWithDuration: function(a, b) { return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._config = b, !0) : !1 }, clone: function() { var a = new cc.BezierBy; this._cloneDecoration(a); for (var b = [], c = 0; c < this._config.length; c++) { var d = this._config[c]; b.push(cc.p(d.x, d.y)) } a.initWithDuration(this._duration, b); return a }, startWithTarget: function(a) { cc.ActionInterval.prototype.startWithTarget.call(this, a); var b = a.getPositionX(); a = a.getPositionY(); this._previousPosition.x = b; this._previousPosition.y = a; this._startPosition.x = b; this._startPosition.y = a }, update: function(a) { a = this._computeEaseTime(a); if (this.target) { var b = this._config, c = b[0].y, d = b[1].y, e = b[2].y, b = cc.bezierAt(0, b[0].x, b[1].x, b[2].x, a); a = cc.bezierAt(0, c, d, e, a); c = this._startPosition; if (cc.ENABLE_STACKABLE_ACTIONS) { var d = this.target.getPositionX(), e = this.target.getPositionY(), f = this._previousPosition; c.x = c.x + d - f.x; c.y = c.y + e - f.y; b += c.x; a += c.y; f.x = b; f.y = a; this.target.setPosition(b, a) } else this.target.setPosition(c.x + b, c.y + a) } }, reverse: function() { var a = this._config, a = [cc.pAdd(a[1], cc.pNeg(a[2])), cc.pAdd(a[0], cc.pNeg(a[2])), cc.pNeg(a[2])], a = new cc.BezierBy(this._duration, a); this._cloneDecoration(a); this._reverseEaseList(a); return a } }); cc.bezierBy = function(a, b) { return new cc.BezierBy(a, b) }; cc.BezierBy.create = cc.bezierBy; cc.BezierTo = cc.BezierBy.extend({ _toConfig: null, ctor: function(a, b) { cc.BezierBy.prototype.ctor.call(this); this._toConfig = []; b && this.initWithDuration(a, b) }, initWithDuration: function(a, b) { return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._toConfig = b, !0) : !1 }, clone: function() { var a = new cc.BezierTo; this._cloneDecoration(a); a.initWithDuration(this._duration, this._toConfig); return a }, startWithTarget: function(a) { cc.BezierBy.prototype.startWithTarget.call(this, a); a = this._startPosition; var b = this._toConfig, c = this._config; c[0] = cc.pSub(b[0], a); c[1] = cc.pSub(b[1], a); c[2] = cc.pSub(b[2], a) } }); cc.bezierTo = function(a, b) { return new cc.BezierTo(a, b) }; cc.BezierTo.create = cc.bezierTo; cc.ScaleTo = cc.ActionInterval.extend({ _scaleX: 1, _scaleY: 1, _startScaleX: 1, _startScaleY: 1, _endScaleX: 0, _endScaleY: 0, _deltaX: 0, _deltaY: 0, ctor: function(a, b, c) { cc.ActionInterval.prototype.ctor.call(this); void 0 !== b && this.initWithDuration(a, b, c) }, initWithDuration: function(a, b, c) { return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._endScaleX = b, this._endScaleY = null != c ? c : b, !0) : !1 }, clone: function() { var a = new cc.ScaleTo; this._cloneDecoration(a); a.initWithDuration(this._duration, this._endScaleX, this._endScaleY); return a }, startWithTarget: function(a) { cc.ActionInterval.prototype.startWithTarget.call(this, a); this._startScaleX = a.scaleX; this._startScaleY = a.scaleY; this._deltaX = this._endScaleX - this._startScaleX; this._deltaY = this._endScaleY - this._startScaleY }, update: function(a) { a = this._computeEaseTime(a); this.target && (this.target.scaleX = this._startScaleX + this._deltaX * a, this.target.scaleY = this._startScaleY + this._deltaY * a) } }); cc.scaleTo = function(a, b, c) { return new cc.ScaleTo(a, b, c) }; cc.ScaleTo.create = cc.scaleTo; cc.ScaleBy = cc.ScaleTo.extend({ startWithTarget: function(a) { cc.ScaleTo.prototype.startWithTarget.call(this, a); this._deltaX = this._startScaleX * this._endScaleX - this._startScaleX; this._deltaY = this._startScaleY * this._endScaleY - this._startScaleY }, reverse: function() { var a = new cc.ScaleBy(this._duration, 1 / this._endScaleX, 1 / this._endScaleY); this._cloneDecoration(a); this._reverseEaseList(a); return a }, clone: function() { var a = new cc.ScaleBy; this._cloneDecoration(a); a.initWithDuration(this._duration, this._endScaleX, this._endScaleY); return a } }); cc.scaleBy = function(a, b, c) { return new cc.ScaleBy(a, b, c) }; cc.ScaleBy.create = cc.scaleBy; cc.Blink = cc.ActionInterval.extend({ _times: 0, _originalState: !1, ctor: function(a, b) { cc.ActionInterval.prototype.ctor.call(this); void 0 !== b && this.initWithDuration(a, b) }, initWithDuration: function(a, b) { return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._times = b, !0) : !1 }, clone: function() { var a = new cc.Blink; this._cloneDecoration(a); a.initWithDuration(this._duration, this._times); return a }, update: function(a) { a = this._computeEaseTime(a); if (this.target && !this.isDone()) { var b = 1 / this._times; this.target.visible = a % b > b / 2 } }, startWithTarget: function(a) { cc.ActionInterval.prototype.startWithTarget.call(this, a); this._originalState = a.visible }, stop: function() { this.target.visible = this._originalState; cc.ActionInterval.prototype.stop.call(this) }, reverse: function() { var a = new cc.Blink(this._duration, this._times); this._cloneDecoration(a); this._reverseEaseList(a); return a } }); cc.blink = function(a, b) { return new cc.Blink(a, b) }; cc.Blink.create = cc.blink; cc.FadeTo = cc.ActionInterval.extend({ _toOpacity: 0, _fromOpacity: 0, ctor: function(a, b) { cc.ActionInterval.prototype.ctor.call(this); void 0 !== b && this.initWithDuration(a, b) }, initWithDuration: function(a, b) { return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._toOpacity = b, !0) : !1 }, clone: function() { var a = new cc.FadeTo; this._cloneDecoration(a); a.initWithDuration(this._duration, this._toOpacity); return a }, update: function(a) { a = this._computeEaseTime(a); var b = void 0 !== this._fromOpacity ? this._fromOpacity : 255; this.target.opacity = b + (this._toOpacity - b) * a }, startWithTarget: function(a) { cc.ActionInterval.prototype.startWithTarget.call(this, a); this._fromOpacity = a.opacity } }); cc.fadeTo = function(a, b) { return new cc.FadeTo(a, b) }; cc.FadeTo.create = cc.fadeTo; cc.FadeIn = cc.FadeTo.extend({ _reverseAction: null, ctor: function(a) { cc.FadeTo.prototype.ctor.call(this); null == a && (a = 0); this.initWithDuration(a, 255) }, reverse: function() { var a = new cc.FadeOut; a.initWithDuration(this._duration, 0); this._cloneDecoration(a); this._reverseEaseList(a); return a }, clone: function() { var a = new cc.FadeIn; this._cloneDecoration(a); a.initWithDuration(this._duration, this._toOpacity); return a }, startWithTarget: function(a) { this._reverseAction && (this._toOpacity = this._reverseAction._fromOpacity); cc.FadeTo.prototype.startWithTarget.call(this, a) } }); cc.fadeIn = function(a) { return new cc.FadeIn(a) }; cc.FadeIn.create = cc.fadeIn; cc.FadeOut = cc.FadeTo.extend({ ctor: function(a) { cc.FadeTo.prototype.ctor.call(this); null == a && (a = 0); this.initWithDuration(a, 0) }, reverse: function() { var a = new cc.FadeIn; a._reverseAction = this; a.initWithDuration(this._duration, 255); this._cloneDecoration(a); this._reverseEaseList(a); return a }, clone: function() { var a = new cc.FadeOut; this._cloneDecoration(a); a.initWithDuration(this._duration, this._toOpacity); return a } }); cc.fadeOut = function(a) { return new cc.FadeOut(a) }; cc.FadeOut.create = cc.fadeOut; cc.TintTo = cc.ActionInterval.extend({ _to: null, _from: null, ctor: function(a, b, c, d) { cc.ActionInterval.prototype.ctor.call(this); this._to = cc.color(0, 0, 0); this._from = cc.color(0, 0, 0); void 0 !== d && this.initWithDuration(a, b, c, d) }, initWithDuration: function(a, b, c, d) { return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._to = cc.color(b, c, d), !0) : !1 }, clone: function() { var a = new cc.TintTo; this._cloneDecoration(a); var b = this._to; a.initWithDuration(this._duration, b.r, b.g, b.b); return a }, startWithTarget: function(a) { cc.ActionInterval.prototype.startWithTarget.call(this, a); this._from = this.target.color }, update: function(a) { a = this._computeEaseTime(a); var b = this._from, c = this._to; b && (this.target.color = cc.color(b.r + (c.r - b.r) * a, b.g + (c.g - b.g) * a, b.b + (c.b - b.b) * a)) } }); cc.tintTo = function(a, b, c, d) { return new cc.TintTo(a, b, c, d) }; cc.TintTo.create = cc.tintTo; cc.TintBy = cc.ActionInterval.extend({ _deltaR: 0, _deltaG: 0, _deltaB: 0, _fromR: 0, _fromG: 0, _fromB: 0, ctor: function(a, b, c, d) { cc.ActionInterval.prototype.ctor.call(this); void 0 !== d && this.initWithDuration(a, b, c, d) }, initWithDuration: function(a, b, c, d) { return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._deltaR = b, this._deltaG = c, this._deltaB = d, !0) : !1 }, clone: function() { var a = new cc.TintBy; this._cloneDecoration(a); a.initWithDuration(this._duration, this._deltaR, this._deltaG, this._deltaB); return a }, startWithTarget: function(a) { cc.ActionInterval.prototype.startWithTarget.call(this, a); a = a.color; this._fromR = a.r; this._fromG = a.g; this._fromB = a.b }, update: function(a) { a = this._computeEaseTime(a); this.target.color = cc.color(this._fromR + this._deltaR * a, this._fromG + this._deltaG * a, this._fromB + this._deltaB * a) }, reverse: function() { var a = new cc.TintBy(this._duration, -this._deltaR, -this._deltaG, -this._deltaB); this._cloneDecoration(a); this._reverseEaseList(a); return a } }); cc.tintBy = function(a, b, c, d) { return new cc.TintBy(a, b, c, d) }; cc.TintBy.create = cc.tintBy; cc.DelayTime = cc.ActionInterval.extend({ update: function(a) {}, reverse: function() { var a = new cc.DelayTime(this._duration); this._cloneDecoration(a); this._reverseEaseList(a); return a }, clone: function() { var a = new cc.DelayTime; this._cloneDecoration(a); a.initWithDuration(this._duration); return a } }); cc.delayTime = function(a) { return new cc.DelayTime(a) }; cc.DelayTime.create = cc.delayTime; cc.ReverseTime = cc.ActionInterval.extend({ _other: null, ctor: function(a) { cc.ActionInterval.prototype.ctor.call(this); this._other = null; a && this.initWithAction(a) }, initWithAction: function(a) { if (!a) throw "cc.ReverseTime.initWithAction(): action must be non null"; if (a === this._other) throw "cc.ReverseTime.initWithAction(): the action was already passed in."; return cc.ActionInterval.prototype.initWithDuration.call(this, a._duration) ? (this._other = a, !0) : !1 }, clone: function() { var a = new cc.ReverseTime; this._cloneDecoration(a); a.initWithAction(this._other.clone()); return a }, startWithTarget: function(a) { cc.ActionInterval.prototype.startWithTarget.call(this, a); this._other.startWithTarget(a) }, update: function(a) { a = this._computeEaseTime(a); this._other && this._other.update(1 - a) }, reverse: function() { return this._other.clone() }, stop: function() { this._other.stop(); cc.Action.prototype.stop.call(this) } }); cc.reverseTime = function(a) { return new cc.ReverseTime(a) }; cc.ReverseTime.create = cc.reverseTime; cc.Animate = cc.ActionInterval.extend({ _animation: null, _nextFrame: 0, _origFrame: null, _executedLoops: 0, _splitTimes: null, ctor: function(a) { cc.ActionInterval.prototype.ctor.call(this); this._splitTimes = []; a && this.initWithAnimation(a) }, getAnimation: function() { return this._animation }, setAnimation: function(a) { this._animation = a }, initWithAnimation: function(a) { if (!a) throw "cc.Animate.initWithAnimation(): animation must be non-NULL"; var b = a.getDuration(); if (this.initWithDuration(b * a.getLoops())) { this._nextFrame = 0; this.setAnimation(a); this._origFrame = null; this._executedLoops = 0; var c = this._splitTimes, d = c.length = 0, e = b / a.getTotalDelayUnits(); a = a.getFrames(); cc.arrayVerifyType(a, cc.AnimationFrame); for (var f = 0; f < a.length; f++) { var g = d * e / b, d = d + a[f].getDelayUnits(); c.push(g) } return !0 } return !1 }, clone: function() { var a = new cc.Animate; this._cloneDecoration(a); a.initWithAnimation(this._animation.clone()); return a }, startWithTarget: function(a) { cc.ActionInterval.prototype.startWithTarget.call(this, a); this._animation.getRestoreOriginalFrame() && (this._origFrame = a.displayFrame()); this._executedLoops = this._nextFrame = 0 }, update: function(a) { a = this._computeEaseTime(a); 1 > a && (a *= this._animation.getLoops(), (0 | a) > this._executedLoops && (this._nextFrame = 0, this._executedLoops++), a %= 1); for (var b = this._animation.getFrames(), c = b.length, d = this._splitTimes, e = this._nextFrame; e < c; e++) if (d[e] <= a) this.target.setSpriteFrame(b[e].getSpriteFrame()), this._nextFrame = e + 1; else break }, reverse: function() { var a = this._animation, b = a.getFrames(), c = []; cc.arrayVerifyType(b, cc.AnimationFrame); if (0 < b.length) for (var d = b.length - 1; 0 <= d; d--) { var e = b[d]; if (!e) break; c.push(e.clone()) } b = new cc.Animation(c, a.getDelayPerUnit(), a.getLoops()); b.setRestoreOriginalFrame(a.getRestoreOriginalFrame()); a = new cc.Animate(b); this._cloneDecoration(a); this._reverseEaseList(a); return a }, stop: function() { this._animation.getRestoreOriginalFrame() && this.target && this.target.setSpriteFrame(this._origFrame); cc.Action.prototype.stop.call(this) } }); cc.animate = function(a) { return new cc.Animate(a) }; cc.Animate.create = cc.animate; cc.TargetedAction = cc.ActionInterval.extend({ _action: null, _forcedTarget: null, ctor: function(a, b) { cc.ActionInterval.prototype.ctor.call(this); b && this.initWithTarget(a, b) }, initWithTarget: function(a, b) { return this.initWithDuration(b._duration) ? (this._forcedTarget = a, this._action = b, !0) : !1 }, clone: function() { var a = new cc.TargetedAction; this._cloneDecoration(a); a.initWithTarget(this._forcedTarget, this._action.clone()); return a }, startWithTarget: function(a) { cc.ActionInterval.prototype.startWithTarget.call(this, a); this._action.startWithTarget(this._forcedTarget) }, stop: function() { this._action.stop() }, update: function(a) { a = this._computeEaseTime(a); this._action.update(a) }, getForcedTarget: function() { return this._forcedTarget }, setForcedTarget: function(a) { this._forcedTarget !== a && (this._forcedTarget = a) } }); cc.targetedAction = function(a, b) { return new cc.TargetedAction(a, b) }; cc.TargetedAction.create = cc.targetedAction; cc.ActionInstant = cc.FiniteTimeAction.extend({ isDone: function() { return !0 }, step: function(a) { this.update(1) }, update: function(a) {}, reverse: function() { return this.clone() }, clone: function() { return new cc.ActionInstant } }); cc.Show = cc.ActionInstant.extend({ update: function(a) { this.target.visible = !0 }, reverse: function() { return new cc.Hide }, clone: function() { return new cc.Show } }); cc.show = function() { return new cc.Show }; cc.Show.create = cc.show; cc.Hide = cc.ActionInstant.extend({ update: function(a) { this.target.visible = !1 }, reverse: function() { return new cc.Show }, clone: function() { return new cc.Hide } }); cc.hide = function() { return new cc.Hide }; cc.Hide.create = cc.hide; cc.ToggleVisibility = cc.ActionInstant.extend({ update: function(a) { this.target.visible = !this.target.visible }, reverse: function() { return new cc.ToggleVisibility }, clone: function() { return new cc.ToggleVisibility } }); cc.toggleVisibility = function() { return new cc.ToggleVisibility }; cc.ToggleVisibility.create = cc.toggleVisibility; cc.RemoveSelf = cc.ActionInstant.extend({ _isNeedCleanUp: !0, ctor: function(a) { cc.FiniteTimeAction.prototype.ctor.call(this); void 0 !== a && this.init(a) }, update: function(a) { this.target.removeFromParent(this._isNeedCleanUp) }, init: function(a) { this._isNeedCleanUp = a; return !0 }, reverse: function() { return new cc.RemoveSelf(this._isNeedCleanUp) }, clone: function() { return new cc.RemoveSelf(this._isNeedCleanUp) } }); cc.removeSelf = function(a) { return new cc.RemoveSelf(a) }; cc.RemoveSelf.create = cc.removeSelf; cc.FlipX = cc.ActionInstant.extend({ _flippedX: !1, ctor: function(a) { cc.FiniteTimeAction.prototype.ctor.call(this); this._flippedX = !1; void 0 !== a && this.initWithFlipX(a) }, initWithFlipX: function(a) { this._flippedX = a; return !0 }, update: function(a) { this.target.flippedX = this._flippedX }, reverse: function() { return new cc.FlipX(!this._flippedX) }, clone: function() { var a = new cc.FlipX; a.initWithFlipX(this._flippedX); return a } }); cc.flipX = function(a) { return new cc.FlipX(a) }; cc.FlipX.create = cc.flipX; cc.FlipY = cc.ActionInstant.extend({ _flippedY: !1, ctor: function(a) { cc.FiniteTimeAction.prototype.ctor.call(this); this._flippedY = !1; void 0 !== a && this.initWithFlipY(a) }, initWithFlipY: function(a) { this._flippedY = a; return !0 }, update: function(a) { this.target.flippedY = this._flippedY }, reverse: function() { return new cc.FlipY(!this._flippedY) }, clone: function() { var a = new cc.FlipY; a.initWithFlipY(this._flippedY); return a } }); cc.flipY = function(a) { return new cc.FlipY(a) }; cc.FlipY.create = cc.flipY; cc.Place = cc.ActionInstant.extend({ _x: 0, _y: 0, ctor: function(a, b) { cc.FiniteTimeAction.prototype.ctor.call(this); this._y = this._x = 0; void 0 !== a && (void 0 !== a.x && (b = a.y, a = a.x), this.initWithPosition(a, b)) }, initWithPosition: function(a, b) { this._x = a; this._y = b; return !0 }, update: function(a) { this.target.setPosition(this._x, this._y) }, clone: function() { var a = new cc.Place; a.initWithPosition(this._x, this._y); return a } }); cc.place = function(a, b) { return new cc.Place(a, b) }; cc.Place.create = cc.place; cc.CallFunc = cc.ActionInstant.extend({ _selectorTarget: null, _callFunc: null, _function: null, _data: null, ctor: function(a, b, c) { cc.FiniteTimeAction.prototype.ctor.call(this); void 0 !== a && (void 0 === b ? this.initWithFunction(a) : this.initWithFunction(a, b, c)) }, initWithFunction: function(a, b, c) { b ? (this._data = c, this._callFunc = a, this._selectorTarget = b) : a && (this._function = a); return !0 }, execute: function() { null != this._callFunc ? this._callFunc.call(this._selectorTarget, this.target, this._data) : this._function && this._function.call(null, this.target) }, update: function(a) { this.execute() }, getTargetCallback: function() { return this._selectorTarget }, setTargetCallback: function(a) { a !== this._selectorTarget && (this._selectorTarget && (this._selectorTarget = null), this._selectorTarget = a) }, clone: function() { var a = new cc.CallFunc; this._selectorTarget ? a.initWithFunction(this._callFunc, this._selectorTarget, this._data) : this._function && a.initWithFunction(this._function); return a } }); cc.callFunc = function(a, b, c) { return new cc.CallFunc(a, b, c) }; cc.CallFunc.create = cc.callFunc; cc.ActionCamera = cc.ActionInterval.extend({ _centerXOrig: 0, _centerYOrig: 0, _centerZOrig: 0, _eyeXOrig: 0, _eyeYOrig: 0, _eyeZOrig: 0, _upXOrig: 0, _upYOrig: 0, _upZOrig: 0, ctor: function() { cc.ActionInterval.prototype.ctor.call(this); this._upZOrig = this._upYOrig = this._upXOrig = this._eyeZOrig = this._eyeYOrig = this._eyeXOrig = this._centerZOrig = this._centerYOrig = this._centerXOrig = 0 }, startWithTarget: function(a) { cc.ActionInterval.prototype.startWithTarget.call(this, a); a = a.getCamera(); var b = a.getCenter(); this._centerXOrig = b.x; this._centerYOrig = b.y; this._centerZOrig = b.z; b = a.getEye(); this._eyeXOrig = b.x; this._eyeYOrig = b.y; this._eyeZOrig = b.z; a = a.getUp(); this._upXOrig = a.x; this._upYOrig = a.y; this._upZOrig = a.z }, clone: function() { return new cc.ActionCamera }, reverse: function() { return new cc.ReverseTime(this) } }); cc.OrbitCamera = cc.ActionCamera.extend({ _radius: 0, _deltaRadius: 0, _angleZ: 0, _deltaAngleZ: 0, _angleX: 0, _deltaAngleX: 0, _radZ: 0, _radDeltaZ: 0, _radX: 0, _radDeltaX: 0, ctor: function(a, b, c, d, e, f, g) { cc.ActionCamera.prototype.ctor.call(this); void 0 !== g && this.initWithDuration(a, b, c, d, e, f, g) }, initWithDuration: function(a, b, c, d, e, f, g) { return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._radius = b, this._deltaRadius = c, this._angleZ = d, this._deltaAngleZ = e, this._angleX = f, this._deltaAngleX = g, this._radDeltaZ = cc.degreesToRadians(e), this._radDeltaX = cc.degreesToRadians(g), !0) : !1 }, sphericalRadius: function() { var a, b; b = this.target.getCamera(); var c = b.getEye(); a = b.getCenter(); b = c.x - a.x; var d = c.y - a.y; a = c.z - a.z; var c = Math.sqrt(Math.pow(b, 2) + Math.pow(d, 2) + Math.pow(a, 2)), e = Math.sqrt(Math.pow(b, 2) + Math.pow(d, 2)); 0 === e && (e = cc.FLT_EPSILON); 0 === c && (c = cc.FLT_EPSILON); a = Math.acos(a / c); b = 0 > b ? Math.PI - Math.asin(d / e) : Math.asin(d / e); return { newRadius: c / cc.Camera.getZEye(), zenith: a, azimuth: b } }, startWithTarget: function(a) { cc.ActionInterval.prototype.startWithTarget.call(this, a); a = this.sphericalRadius(); isNaN(this._radius) && (this._radius = a.newRadius); isNaN(this._angleZ) && (this._angleZ = cc.radiansToDegrees(a.zenith)); isNaN(this._angleX) && (this._angleX = cc.radiansToDegrees(a.azimuth)); this._radZ = cc.degreesToRadians(this._angleZ); this._radX = cc.degreesToRadians(this._angleX) }, clone: function() { var a = new cc.OrbitCamera; a.initWithDuration(this._duration, this._radius, this._deltaRadius, this._angleZ, this._deltaAngleZ, this._angleX, this._deltaAngleX); return a }, update: function(a) { a = this._computeEaseTime(a); var b = (this._radius + this._deltaRadius * a) * cc.Camera.getZEye(), c = this._radZ + this._radDeltaZ * a, d = this._radX + this._radDeltaX * a; a = Math.sin(c) * Math.cos(d) * b + this._centerXOrig; d = Math.sin(c) * Math.sin(d) * b + this._centerYOrig; b = Math.cos(c) * b + this._centerZOrig; this.target.getCamera().setEye(a, d, b); this.target.setNodeDirty() } }); cc.orbitCamera = function(a, b, c, d, e, f, g) { return new cc.OrbitCamera(a, b, c, d, e, f, g) }; cc.OrbitCamera.create = cc.orbitCamera; cc.ActionEase = cc.ActionInterval.extend({ _inner: null, ctor: function(a) { cc.ActionInterval.prototype.ctor.call(this); a && this.initWithAction(a) }, initWithAction: function(a) { if (!a) throw "cc.ActionEase.initWithAction(): action must be non nil"; return this.initWithDuration(a.getDuration()) ? (this._inner = a, !0) : !1 }, clone: function() { var a = new cc.ActionEase; a.initWithAction(this._inner.clone()); return a }, startWithTarget: function(a) { cc.ActionInterval.prototype.startWithTarget.call(this, a); this._inner.startWithTarget(this.target) }, stop: function() { this._inner.stop(); cc.ActionInterval.prototype.stop.call(this) }, update: function(a) { this._inner.update(a) }, reverse: function() { return new cc.ActionEase(this._inner.reverse()) }, getInnerAction: function() { return this._inner } }); cc.actionEase = function(a) { return new cc.ActionEase(a) }; cc.ActionEase.create = cc.actionEase; cc.EaseRateAction = cc.ActionEase.extend({ _rate: 0, ctor: function(a, b) { cc.ActionEase.prototype.ctor.call(this); void 0 !== b && this.initWithAction(a, b) }, setRate: function(a) { this._rate = a }, getRate: function() { return this._rate }, initWithAction: function(a, b) { return cc.ActionEase.prototype.initWithAction.call(this, a) ? (this._rate = b, !0) : !1 }, clone: function() { var a = new cc.EaseRateAction; a.initWithAction(this._inner.clone(), this._rate); return a }, reverse: function() { return new cc.EaseRateAction(this._inner.reverse(), 1 / this._rate) } }); cc.easeRateAction = function(a, b) { return new cc.EaseRateAction(a, b) }; cc.EaseRateAction.create = cc.easeRateAction; cc.EaseIn = cc.EaseRateAction.extend({ update: function(a) { this._inner.update(Math.pow(a, this._rate)) }, reverse: function() { return new cc.EaseIn(this._inner.reverse(), 1 / this._rate) }, clone: function() { var a = new cc.EaseIn; a.initWithAction(this._inner.clone(), this._rate); return a } }); cc.EaseIn.create = function(a, b) { return new cc.EaseIn(a, b) }; cc.easeIn = function(a) { return { _rate: a, easing: function(a) { return Math.pow(a, this._rate) }, reverse: function() { return cc.easeIn(1 / this._rate) } } }; cc.EaseOut = cc.EaseRateAction.extend({ update: function(a) { this._inner.update(Math.pow(a, 1 / this._rate)) }, reverse: function() { return new cc.EaseOut(this._inner.reverse(), 1 / this._rate) }, clone: function() { var a = new cc.EaseOut; a.initWithAction(this._inner.clone(), this._rate); return a } }); cc.EaseOut.create = function(a, b) { return new cc.EaseOut(a, b) }; cc.easeOut = function(a) { return { _rate: a, easing: function(a) { return Math.pow(a, 1 / this._rate) }, reverse: function() { return cc.easeOut(1 / this._rate) } } }; cc.EaseInOut = cc.EaseRateAction.extend({ update: function(a) { a *= 2; 1 > a ? this._inner.update(0.5 * Math.pow(a, this._rate)) : this._inner.update(1 - 0.5 * Math.pow(2 - a, this._rate)) }, clone: function() { var a = new cc.EaseInOut; a.initWithAction(this._inner.clone(), this._rate); return a }, reverse: function() { return new cc.EaseInOut(this._inner.reverse(), this._rate) } }); cc.EaseInOut.create = function(a, b) { return new cc.EaseInOut(a, b) }; cc.easeInOut = function(a) { return { _rate: a, easing: function(a) { a *= 2; return 1 > a ? 0.5 * Math.pow(a, this._rate) : 1 - 0.5 * Math.pow(2 - a, this._rate) }, reverse: function() { return cc.easeInOut(this._rate) } } }; cc.EaseExponentialIn = cc.ActionEase.extend({ update: function(a) { this._inner.update(0 === a ? 0 : Math.pow(2, 10 * (a - 1))) }, reverse: function() { return new cc.EaseExponentialOut(this._inner.reverse()) }, clone: function() { var a = new cc.EaseExponentialIn; a.initWithAction(this._inner.clone()); return a } }); cc.EaseExponentialIn.create = function(a) { return new cc.EaseExponentialIn(a) }; cc._easeExponentialInObj = { easing: function(a) { return 0 === a ? 0 : Math.pow(2, 10 * (a - 1)) }, reverse: function() { return cc._easeExponentialOutObj } }; cc.easeExponentialIn = function() { return cc._easeExponentialInObj }; cc.EaseExponentialOut = cc.ActionEase.extend({ update: function(a) { this._inner.update(1 === a ? 1 : -Math.pow(2, -10 * a) + 1) }, reverse: function() { return new cc.EaseExponentialIn(this._inner.reverse()) }, clone: function() { var a = new cc.EaseExponentialOut; a.initWithAction(this._inner.clone()); return a } }); cc.EaseExponentialOut.create = function(a) { return new cc.EaseExponentialOut(a) }; cc._easeExponentialOutObj = { easing: function(a) { return 1 === a ? 1 : -Math.pow(2, -10 * a) + 1 }, reverse: function() { return cc._easeExponentialInObj } }; cc.easeExponentialOut = function() { return cc._easeExponentialOutObj }; cc.EaseExponentialInOut = cc.ActionEase.extend({ update: function(a) { 1 !== a && 0 !== a && (a *= 2, a = 1 > a ? 0.5 * Math.pow(2, 10 * (a - 1)) : 0.5 * (-Math.pow(2, -10 * (a - 1)) + 2)); this._inner.update(a) }, reverse: function() { return new cc.EaseExponentialInOut(this._inner.reverse()) }, clone: function() { var a = new cc.EaseExponentialInOut; a.initWithAction(this._inner.clone()); return a } }); cc.EaseExponentialInOut.create = function(a) { return new cc.EaseExponentialInOut(a) }; cc._easeExponentialInOutObj = { easing: function(a) { return 1 !== a && 0 !== a ? (a *= 2, 1 > a ? 0.5 * Math.pow(2, 10 * (a - 1)) : 0.5 * (-Math.pow(2, -10 * (a - 1)) + 2)) : a }, reverse: function() { return cc._easeExponentialInOutObj } }; cc.easeExponentialInOut = function() { return cc._easeExponentialInOutObj }; cc.EaseSineIn = cc.ActionEase.extend({ update: function(a) { a = 0 === a || 1 === a ? a : -1 * Math.cos(a * Math.PI / 2) + 1; this._inner.update(a) }, reverse: function() { return new cc.EaseSineOut(this._inner.reverse()) }, clone: function() { var a = new cc.EaseSineIn; a.initWithAction(this._inner.clone()); return a } }); cc.EaseSineIn.create = function(a) { return new cc.EaseSineIn(a) }; cc._easeSineInObj = { easing: function(a) { return 0 === a || 1 === a ? a : -1 * Math.cos(a * Math.PI / 2) + 1 }, reverse: function() { return cc._easeSineOutObj } }; cc.easeSineIn = function() { return cc._easeSineInObj }; cc.EaseSineOut = cc.ActionEase.extend({ update: function(a) { a = 0 === a || 1 === a ? a : Math.sin(a * Math.PI / 2); this._inner.update(a) }, reverse: function() { return new cc.EaseSineIn(this._inner.reverse()) }, clone: function() { var a = new cc.EaseSineOut; a.initWithAction(this._inner.clone()); return a } }); cc.EaseSineOut.create = function(a) { return new cc.EaseSineOut(a) }; cc._easeSineOutObj = { easing: function(a) { return 0 === a || 1 === a ? a : Math.sin(a * Math.PI / 2) }, reverse: function() { return cc._easeSineInObj } }; cc.easeSineOut = function() { return cc._easeSineOutObj }; cc.EaseSineInOut = cc.ActionEase.extend({ update: function(a) { a = 0 === a || 1 === a ? a : -0.5 * (Math.cos(Math.PI * a) - 1); this._inner.update(a) }, clone: function() { var a = new cc.EaseSineInOut; a.initWithAction(this._inner.clone()); return a }, reverse: function() { return new cc.EaseSineInOut(this._inner.reverse()) } }); cc.EaseSineInOut.create = function(a) { return new cc.EaseSineInOut(a) }; cc._easeSineInOutObj = { easing: function(a) { return 0 === a || 1 === a ? a : -0.5 * (Math.cos(Math.PI * a) - 1) }, reverse: function() { return cc._easeSineInOutObj } }; cc.easeSineInOut = function() { return cc._easeSineInOutObj }; cc.EaseElastic = cc.ActionEase.extend({ _period: 0.3, ctor: function(a, b) { cc.ActionEase.prototype.ctor.call(this); a && this.initWithAction(a, b) }, getPeriod: function() { return this._period }, setPeriod: function(a) { this._period = a }, initWithAction: function(a, b) { cc.ActionEase.prototype.initWithAction.call(this, a); this._period = null == b ? 0.3 : b; return !0 }, reverse: function() { cc.log("cc.EaseElastic.reverse(): it should be overridden in subclass."); return null }, clone: function() { var a = new cc.EaseElastic; a.initWithAction(this._inner.clone(), this._period); return a } }); cc.EaseElastic.create = function(a, b) { return new cc.EaseElastic(a, b) }; cc.EaseElasticIn = cc.EaseElastic.extend({ update: function(a) { var b = 0; 0 === a || 1 === a ? b = a : (b = this._period / 4, a -= 1, b = -Math.pow(2, 10 * a) * Math.sin((a - b) * Math.PI * 2 / this._period)); this._inner.update(b) }, reverse: function() { return new cc.EaseElasticOut(this._inner.reverse(), this._period) }, clone: function() { var a = new cc.EaseElasticIn; a.initWithAction(this._inner.clone(), this._period); return a } }); cc.EaseElasticIn.create = function(a, b) { return new cc.EaseElasticIn(a, b) }; cc._easeElasticInObj = { easing: function(a) { if (0 === a || 1 === a) return a; a -= 1; return -Math.pow(2, 10 * a) * Math.sin((a - 0.075) * Math.PI * 2 / 0.3) }, reverse: function() { return cc._easeElasticOutObj } }; cc.easeElasticIn = function(a) { return a && 0.3 !== a ? { _period: a, easing: function(a) { if (0 === a || 1 === a) return a; a -= 1; return -Math.pow(2, 10 * a) * Math.sin((a - this._period / 4) * Math.PI * 2 / this._period) }, reverse: function() { return cc.easeElasticOut(this._period) } } : cc._easeElasticInObj }; cc.EaseElasticOut = cc.EaseElastic.extend({ update: function(a) { var b = 0; 0 === a || 1 === a ? b = a : (b = this._period / 4, b = Math.pow(2, -10 * a) * Math.sin((a - b) * Math.PI * 2 / this._period) + 1); this._inner.update(b) }, reverse: function() { return new cc.EaseElasticIn(this._inner.reverse(), this._period) }, clone: function() { var a = new cc.EaseElasticOut; a.initWithAction(this._inner.clone(), this._period); return a } }); cc.EaseElasticOut.create = function(a, b) { return new cc.EaseElasticOut(a, b) }; cc._easeElasticOutObj = { easing: function(a) { return 0 === a || 1 === a ? a : Math.pow(2, -10 * a) * Math.sin((a - 0.075) * Math.PI * 2 / 0.3) + 1 }, reverse: function() { return cc._easeElasticInObj } }; cc.easeElasticOut = function(a) { return a && 0.3 !== a ? { _period: a, easing: function(a) { return 0 === a || 1 === a ? a : Math.pow(2, -10 * a) * Math.sin((a - this._period / 4) * Math.PI * 2 / this._period) + 1 }, reverse: function() { return cc.easeElasticIn(this._period) } } : cc._easeElasticOutObj }; cc.EaseElasticInOut = cc.EaseElastic.extend({ update: function(a) { var b = 0, b = this._period; if (0 === a || 1 === a) b = a; else { b || (b = this._period = 0.3 * 1.5); var c = b / 4; a = 2 * a - 1; b = 0 > a ? -0.5 * Math.pow(2, 10 * a) * Math.sin((a - c) * Math.PI * 2 / b) : Math.pow(2, -10 * a) * Math.sin((a - c) * Math.PI * 2 / b) * 0.5 + 1 } this._inner.update(b) }, reverse: function() { return new cc.EaseElasticInOut(this._inner.reverse(), this._period) }, clone: function() { var a = new cc.EaseElasticInOut; a.initWithAction(this._inner.clone(), this._period); return a } }); cc.EaseElasticInOut.create = function(a, b) { return new cc.EaseElasticInOut(a, b) }; cc.easeElasticInOut = function(a) { return { _period: a || 0.3, easing: function(a) { var c = 0, c = this._period; if (0 === a || 1 === a) c = a; else { c || (c = this._period = 0.3 * 1.5); var d = c / 4; a = 2 * a - 1; c = 0 > a ? -0.5 * Math.pow(2, 10 * a) * Math.sin((a - d) * Math.PI * 2 / c) : Math.pow(2, -10 * a) * Math.sin((a - d) * Math.PI * 2 / c) * 0.5 + 1 } return c }, reverse: function() { return cc.easeElasticInOut(this._period) } } }; cc.EaseBounce = cc.ActionEase.extend({ bounceTime: function(a) { if (a < 1 / 2.75) return 7.5625 * a * a; if (a < 2 / 2.75) return a -= 1.5 / 2.75, 7.5625 * a * a + 0.75; if (a < 2.5 / 2.75) return a -= 2.25 / 2.75, 7.5625 * a * a + 0.9375; a -= 2.625 / 2.75; return 7.5625 * a * a + 0.984375 }, clone: function() { var a = new cc.EaseBounce; a.initWithAction(this._inner.clone()); return a }, reverse: function() { return new cc.EaseBounce(this._inner.reverse()) } }); cc.EaseBounce.create = function(a) { return new cc.EaseBounce(a) }; cc.EaseBounceIn = cc.EaseBounce.extend({ update: function(a) { a = 1 - this.bounceTime(1 - a); this._inner.update(a) }, reverse: function() { return new cc.EaseBounceOut(this._inner.reverse()) }, clone: function() { var a = new cc.EaseBounceIn; a.initWithAction(this._inner.clone()); return a } }); cc.EaseBounceIn.create = function(a) { return new cc.EaseBounceIn(a) }; cc._bounceTime = function(a) { if (a < 1 / 2.75) return 7.5625 * a * a; if (a < 2 / 2.75) return a -= 1.5 / 2.75, 7.5625 * a * a + 0.75; if (a < 2.5 / 2.75) return a -= 2.25 / 2.75, 7.5625 * a * a + 0.9375; a -= 2.625 / 2.75; return 7.5625 * a * a + 0.984375 }; cc._easeBounceInObj = { easing: function(a) { return 1 - cc._bounceTime(1 - a) }, reverse: function() { return cc._easeBounceOutObj } }; cc.easeBounceIn = function() { return cc._easeBounceInObj }; cc.EaseBounceOut = cc.EaseBounce.extend({ update: function(a) { a = this.bounceTime(a); this._inner.update(a) }, reverse: function() { return new cc.EaseBounceIn(this._inner.reverse()) }, clone: function() { var a = new cc.EaseBounceOut; a.initWithAction(this._inner.clone()); return a } }); cc.EaseBounceOut.create = function(a) { return new cc.EaseBounceOut(a) }; cc._easeBounceOutObj = { easing: function(a) { return cc._bounceTime(a) }, reverse: function() { return cc._easeBounceInObj } }; cc.easeBounceOut = function() { return cc._easeBounceOutObj }; cc.EaseBounceInOut = cc.EaseBounce.extend({ update: function(a) { var b = 0, b = 0.5 > a ? 0.5 * (1 - this.bounceTime(1 - 2 * a)) : 0.5 * this.bounceTime(2 * a - 1) + 0.5; this._inner.update(b) }, clone: function() { var a = new cc.EaseBounceInOut; a.initWithAction(this._inner.clone()); return a }, reverse: function() { return new cc.EaseBounceInOut(this._inner.reverse()) } }); cc.EaseBounceInOut.create = function(a) { return new cc.EaseBounceInOut(a) }; cc._easeBounceInOutObj = { easing: function(a) { return a = 0.5 > a ? 0.5 * (1 - cc._bounceTime(1 - 2 * a)) : 0.5 * cc._bounceTime(2 * a - 1) + 0.5 }, reverse: function() { return cc._easeBounceInOutObj } }; cc.easeBounceInOut = function() { return cc._easeBounceInOutObj }; cc.EaseBackIn = cc.ActionEase.extend({ update: function(a) { this._inner.update(0 === a || 1 === a ? a : a * a * (2.70158 * a - 1.70158)) }, reverse: function() { return new cc.EaseBackOut(this._inner.reverse()) }, clone: function() { var a = new cc.EaseBackIn; a.initWithAction(this._inner.clone()); return a } }); cc.EaseBackIn.create = function(a) { return new cc.EaseBackIn(a) }; cc._easeBackInObj = { easing: function(a) { return 0 === a || 1 === a ? a : a * a * (2.70158 * a - 1.70158) }, reverse: function() { return cc._easeBackOutObj } }; cc.easeBackIn = function() { return cc._easeBackInObj }; cc.EaseBackOut = cc.ActionEase.extend({ update: function(a) { a -= 1; this._inner.update(a * a * (2.70158 * a + 1.70158) + 1) }, reverse: function() { return new cc.EaseBackIn(this._inner.reverse()) }, clone: function() { var a = new cc.EaseBackOut; a.initWithAction(this._inner.clone()); return a } }); cc.EaseBackOut.create = function(a) { return new cc.EaseBackOut(a) }; cc._easeBackOutObj = { easing: function(a) { a -= 1; return a * a * (2.70158 * a + 1.70158) + 1 }, reverse: function() { return cc._easeBackInObj } }; cc.easeBackOut = function() { return cc._easeBackOutObj }; cc.EaseBackInOut = cc.ActionEase.extend({ update: function(a) { a *= 2; 1 > a ? this._inner.update(a * a * (3.5949095 * a - 2.5949095) / 2) : (a -= 2, this._inner.update(a * a * (3.5949095 * a + 2.5949095) / 2 + 1)) }, clone: function() { var a = new cc.EaseBackInOut; a.initWithAction(this._inner.clone()); return a }, reverse: function() { return new cc.EaseBackInOut(this._inner.reverse()) } }); cc.EaseBackInOut.create = function(a) { return new cc.EaseBackInOut(a) }; cc._easeBackInOutObj = { easing: function(a) { a *= 2; if (1 > a) return a * a * (3.5949095 * a - 2.5949095) / 2; a -= 2; return a * a * (3.5949095 * a + 2.5949095) / 2 + 1 }, reverse: function() { return cc._easeBackInOutObj } }; cc.easeBackInOut = function() { return cc._easeBackInOutObj }; cc.EaseBezierAction = cc.ActionEase.extend({ _p0: null, _p1: null, _p2: null, _p3: null, ctor: function(a) { cc.ActionEase.prototype.ctor.call(this, a) }, _updateTime: function(a, b, c, d, e) { return Math.pow(1 - e, 3) * a + 3 * e * Math.pow(1 - e, 2) * b + 3 * Math.pow(e, 2) * (1 - e) * c + Math.pow(e, 3) * d }, update: function(a) { a = this._updateTime(this._p0, this._p1, this._p2, this._p3, a); this._inner.update(a) }, clone: function() { var a = new cc.EaseBezierAction; a.initWithAction(this._inner.clone()); a.setBezierParamer(this._p0, this._p1, this._p2, this._p3); return a }, reverse: function() { var a = new cc.EaseBezierAction(this._inner.reverse()); a.setBezierParamer(this._p3, this._p2, this._p1, this._p0); return a }, setBezierParamer: function(a, b, c, d) { this._p0 = a || 0; this._p1 = b || 0; this._p2 = c || 0; this._p3 = d || 0 } }); cc.EaseBezierAction.create = function(a) { return new cc.EaseBezierAction(a) }; cc.easeBezierAction = function(a, b, c, d) { return { easing: function(e) { return cc.EaseBezierAction.prototype._updateTime(a, b, c, d, e) }, reverse: function() { return cc.easeBezierAction(d, c, b, a) } } }; cc.EaseQuadraticActionIn = cc.ActionEase.extend({ _updateTime: function(a) { return Math.pow(a, 2) }, update: function(a) { this._inner.update(this._updateTime(a)) }, clone: function() { var a = new cc.EaseQuadraticActionIn; a.initWithAction(this._inner.clone()); return a }, reverse: function() { return new cc.EaseQuadraticActionIn(this._inner.reverse()) } }); cc.EaseQuadraticActionIn.create = function(a) { return new cc.EaseQuadraticActionIn(a) }; cc._easeQuadraticActionIn = { easing: cc.EaseQuadraticActionIn.prototype._updateTime, reverse: function() { return cc._easeQuadraticActionIn } }; cc.easeQuadraticActionIn = function() { return cc._easeQuadraticActionIn }; cc.EaseQuadraticActionOut = cc.ActionEase.extend({ _updateTime: function(a) { return -a * (a - 2) }, update: function(a) { this._inner.update(this._updateTime(a)) }, clone: function() { var a = new cc.EaseQuadraticActionOut; a.initWithAction(); return a }, reverse: function() { return new cc.EaseQuadraticActionOut(this._inner.reverse()) } }); cc.EaseQuadraticActionOut.create = function(a) { return new cc.EaseQuadraticActionOut(a) }; cc._easeQuadraticActionOut = { easing: cc.EaseQuadraticActionOut.prototype._updateTime, reverse: function() { return cc._easeQuadraticActionOut } }; cc.easeQuadraticActionOut = function() { return cc._easeQuadraticActionOut }; cc.EaseQuadraticActionInOut = cc.ActionEase.extend({ _updateTime: function(a) { var b = a; a *= 2; 1 > a ? b = a * a * 0.5 : (--a, b = -0.5 * (a * (a - 2) - 1)); return b }, update: function(a) { this._inner.update(this._updateTime(a)) }, clone: function() { var a = new cc.EaseQuadraticActionInOut; a.initWithAction(this._inner.clone()); return a }, reverse: function() { return new cc.EaseQuadraticActionInOut(this._inner.reverse()) } }); cc.EaseQuadraticActionInOut.create = function(a) { return new cc.EaseQuadraticActionInOut(a) }; cc._easeQuadraticActionInOut = { easing: cc.EaseQuadraticActionInOut.prototype._updateTime, reverse: function() { return cc._easeQuadraticActionInOut } }; cc.easeQuadraticActionInOut = function() { return cc._easeQuadraticActionInOut }; cc.EaseQuarticActionIn = cc.ActionEase.extend({ _updateTime: function(a) { return a * a * a * a }, update: function(a) { this._inner.update(this._updateTime(a)) }, clone: function() { var a = new cc.EaseQuarticActionIn; a.initWithAction(this._inner.clone()); return a }, reverse: function() { return new cc.EaseQuarticActionIn(this._inner.reverse()) } }); cc.EaseQuarticActionIn.create = function(a) { return new cc.EaseQuarticActionIn(a) }; cc._easeQuarticActionIn = { easing: cc.EaseQuarticActionIn.prototype._updateTime, reverse: function() { return cc._easeQuarticActionIn } }; cc.easeQuarticActionIn = function() { return cc._easeQuarticActionIn }; cc.EaseQuarticActionOut = cc.ActionEase.extend({ _updateTime: function(a) { a -= 1; return -(a * a * a * a - 1) }, update: function(a) { this._inner.update(this._updateTime(a)) }, clone: function() { var a = new cc.EaseQuarticActionOut; a.initWithAction(this._inner.clone()); return a }, reverse: function() { return new cc.EaseQuarticActionOut(this._inner.reverse()) } }); cc.EaseQuarticActionOut.create = function(a) { return new cc.EaseQuarticActionOut(a) }; cc._easeQuarticActionOut = { easing: cc.EaseQuarticActionOut.prototype._updateTime, reverse: function() { return cc._easeQuarticActionOut } }; cc.easeQuarticActionOut = function() { return cc._easeQuarticActionOut }; cc.EaseQuarticActionInOut = cc.ActionEase.extend({ _updateTime: function(a) { a *= 2; if (1 > a) return 0.5 * a * a * a * a; a -= 2; return -0.5 * (a * a * a * a - 2) }, update: function(a) { this._inner.update(this._updateTime(a)) }, clone: function() { var a = new cc.EaseQuarticActionInOut; a.initWithAction(this._inner.clone()); return a }, reverse: function() { return new cc.EaseQuarticActionInOut(this._inner.reverse()) } }); cc.EaseQuarticActionInOut.create = function(a) { return new cc.EaseQuarticActionInOut(a) }; cc._easeQuarticActionInOut = { easing: cc.EaseQuarticActionInOut.prototype._updateTime, reverse: function() { return cc._easeQuarticActionInOut } }; cc.easeQuarticActionInOut = function() { return cc._easeQuarticActionInOut }; cc.EaseQuinticActionIn = cc.ActionEase.extend({ _updateTime: function(a) { return a * a * a * a * a }, update: function(a) { this._inner.update(this._updateTime(a)) }, clone: function() { var a = new cc.EaseQuinticActionIn; a.initWithAction(this._inner.clone()); return a }, reverse: function() { return new cc.EaseQuinticActionIn(this._inner.reverse()) } }); cc.EaseQuinticActionIn.create = function(a) { return new cc.EaseQuinticActionIn(a) }; cc._easeQuinticActionIn = { easing: cc.EaseQuinticActionIn.prototype._updateTime, reverse: function() { return cc._easeQuinticActionIn } }; cc.easeQuinticActionIn = function() { return cc._easeQuinticActionIn }; cc.EaseQuinticActionOut = cc.ActionEase.extend({ _updateTime: function(a) { a -= 1; return a * a * a * a * a + 1 }, update: function(a) { this._inner.update(this._updateTime(a)) }, clone: function() { var a = new cc.EaseQuinticActionOut; a.initWithAction(this._inner.clone()); return a }, reverse: function() { return new cc.EaseQuinticActionOut(this._inner.reverse()) } }); cc.EaseQuinticActionOut.create = function(a) { return new cc.EaseQuinticActionOut(a) }; cc._easeQuinticActionOut = { easing: cc.EaseQuinticActionOut.prototype._updateTime, reverse: function() { return cc._easeQuinticActionOut } }; cc.easeQuinticActionOut = function() { return cc._easeQuinticActionOut }; cc.EaseQuinticActionInOut = cc.ActionEase.extend({ _updateTime: function(a) { a *= 2; if (1 > a) return 0.5 * a * a * a * a * a; a -= 2; return 0.5 * (a * a * a * a * a + 2) }, update: function(a) { this._inner.update(this._updateTime(a)) }, clone: function() { var a = new cc.EaseQuinticActionInOut; a.initWithAction(this._inner.clone()); return a }, reverse: function() { return new cc.EaseQuinticActionInOut(this._inner.reverse()) } }); cc.EaseQuinticActionInOut.create = function(a) { return new cc.EaseQuinticActionInOut(a) }; cc._easeQuinticActionInOut = { easing: cc.EaseQuinticActionInOut.prototype._updateTime, reverse: function() { return cc._easeQuinticActionInOut } }; cc.easeQuinticActionInOut = function() { return cc._easeQuinticActionInOut }; cc.EaseCircleActionIn = cc.ActionEase.extend({ _updateTime: function(a) { return -1 * (Math.sqrt(1 - a * a) - 1) }, update: function(a) { this._inner.update(this._updateTime(a)) }, clone: function() { var a = new cc.EaseCircleActionIn; a.initWithAction(this._inner.clone()); return a }, reverse: function() { return new cc.EaseCircleActionIn(this._inner.reverse()) } }); cc.EaseCircleActionIn.create = function(a) { return new cc.EaseCircleActionIn(a) }; cc._easeCircleActionIn = { easing: cc.EaseCircleActionIn.prototype._updateTime, reverse: function() { return cc._easeCircleActionIn } }; cc.easeCircleActionIn = function() { return cc._easeCircleActionIn }; cc.EaseCircleActionOut = cc.ActionEase.extend({ _updateTime: function(a) { a -= 1; return Math.sqrt(1 - a * a) }, update: function(a) { this._inner.update(this._updateTime(a)) }, clone: function() { var a = new cc.EaseCircleActionOut; a.initWithAction(this._inner.clone()); return a }, reverse: function() { return new cc.EaseCircleActionOut(this._inner.reverse()) } }); cc.EaseCircleActionOut.create = function(a) { return new cc.EaseCircleActionOut(a) }; cc._easeCircleActionOut = { easing: cc.EaseCircleActionOut.prototype._updateTime, reverse: function() { return cc._easeCircleActionOut } }; cc.easeCircleActionOut = function() { return cc._easeCircleActionOut }; cc.EaseCircleActionInOut = cc.ActionEase.extend({ _updateTime: function(a) { a *= 2; if (1 > a) return -0.5 * (Math.sqrt(1 - a * a) - 1); a -= 2; return 0.5 * (Math.sqrt(1 - a * a) + 1) }, update: function(a) { this._inner.update(this._updateTime(a)) }, clone: function() { var a = new cc.EaseCircleActionInOut; a.initWithAction(this._inner.clone()); return a }, reverse: function() { return new cc.EaseCircleActionInOut(this._inner.reverse()) } }); cc.EaseCircleActionInOut.create = function(a) { return new cc.EaseCircleActionInOut(a) }; cc._easeCircleActionInOut = { easing: cc.EaseCircleActionInOut.prototype._updateTime, reverse: function() { return cc._easeCircleActionInOut } }; cc.easeCircleActionInOut = function() { return cc._easeCircleActionInOut }; cc.EaseCubicActionIn = cc.ActionEase.extend({ _updateTime: function(a) { return a * a * a }, update: function(a) { this._inner.update(this._updateTime(a)) }, clone: function() { var a = new cc.EaseCubicActionIn; a.initWithAction(this._inner.clone()); return a }, reverse: function() { return new cc.EaseCubicActionIn(this._inner.reverse()) } }); cc.EaseCubicActionIn.create = function(a) { return new cc.EaseCubicActionIn(a) }; cc._easeCubicActionIn = { easing: cc.EaseCubicActionIn.prototype._updateTime, reverse: function() { return cc._easeCubicActionIn } }; cc.easeCubicActionIn = function() { return cc._easeCubicActionIn }; cc.EaseCubicActionOut = cc.ActionEase.extend({ _updateTime: function(a) { a -= 1; return a * a * a + 1 }, update: function(a) { this._inner.update(this._updateTime(a)) }, clone: function() { var a = new cc.EaseCubicActionOut; a.initWithAction(this._inner.clone()); return a }, reverse: function() { return new cc.EaseCubicActionOut(this._inner.reverse()) } }); cc.EaseCubicActionOut.create = function(a) { return new cc.EaseCubicActionOut(a) }; cc._easeCubicActionOut = { easing: cc.EaseCubicActionOut.prototype._updateTime, reverse: function() { return cc._easeCubicActionOut } }; cc.easeCubicActionOut = function() { return cc._easeCubicActionOut }; cc.EaseCubicActionInOut = cc.ActionEase.extend({ _updateTime: function(a) { a *= 2; if (1 > a) return 0.5 * a * a * a; a -= 2; return 0.5 * (a * a * a + 2) }, update: function(a) { this._inner.update(this._updateTime(a)) }, clone: function() { var a = new cc.EaseCubicActionInOut; a.initWithAction(this._inner.clone()); return a }, reverse: function() { return new cc.EaseCubicActionInOut(this._inner.reverse()) } }); cc.EaseCubicActionInOut.create = function(a) { return new cc.EaseCubicActionInOut(a) }; cc._easeCubicActionInOut = { easing: cc.EaseCubicActionInOut.prototype._updateTime, reverse: function() { return cc._easeCubicActionInOut } }; cc.easeCubicActionInOut = function() { return cc._easeCubicActionInOut }; cc.cardinalSplineAt = function(a, b, c, d, e, f) { var g = f * f, h = g * f, k = (1 - e) / 2; e = k * (-h + 2 * g - f); var m = k * (-h + g) + (2 * h - 3 * g + 1); f = k * (h - 2 * g + f) + (-2 * h + 3 * g); g = k * (h - g); return cc.p(a.x * e + b.x * m + c.x * f + d.x * g, a.y * e + b.y * m + c.y * f + d.y * g) }; cc.reverseControlPoints = function(a) { for (var b = [], c = a.length - 1; 0 <= c; c--) b.push(cc.p(a[c].x, a[c].y)); return b }; cc.cloneControlPoints = function(a) { for (var b = [], c = 0; c < a.length; c++) b.push(cc.p(a[c].x, a[c].y)); return b }; cc.copyControlPoints = cc.cloneControlPoints; cc.getControlPointAt = function(a, b) { var c = Math.min(a.length - 1, Math.max(b, 0)); return a[c] }; cc.reverseControlPointsInline = function(a) { for (var b = a.length, c = 0 | b / 2, d = 0; d < c; ++d) { var e = a[d]; a[d] = a[b - d - 1]; a[b - d - 1] = e } }; cc.CardinalSplineTo = cc.ActionInterval.extend({ _points: null, _deltaT: 0, _tension: 0, _previousPosition: null, _accumulatedDiff: null, ctor: function(a, b, c) { cc.ActionInterval.prototype.ctor.call(this); this._points = []; void 0 !== c && this.initWithDuration(a, b, c) }, initWithDuration: function(a, b, c) { if (!b || 0 === b.length) throw "Invalid configuration. It must at least have one control point"; return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this.setPoints(b), this._tension = c, !0) : !1 }, clone: function() { var a = new cc.CardinalSplineTo; a.initWithDuration(this._duration, cc.copyControlPoints(this._points), this._tension); return a }, startWithTarget: function(a) { cc.ActionInterval.prototype.startWithTarget.call(this, a); this._deltaT = 1 / (this._points.length - 1); this._previousPosition = cc.p(this.target.getPositionX(), this.target.getPositionY()); this._accumulatedDiff = cc.p(0, 0) }, update: function(a) { a = this._computeEaseTime(a); var b, c = this._points; if (1 === a) b = c.length - 1, a = 1; else { var d = this._deltaT; b = 0 | a / d; a = (a - d * b) / d } b = cc.cardinalSplineAt(cc.getControlPointAt(c, b - 1), cc.getControlPointAt(c, b - 0), cc.getControlPointAt(c, b + 1), cc.getControlPointAt(c, b + 2), this._tension, a); cc.ENABLE_STACKABLE_ACTIONS && (c = this.target.getPositionX() - this._previousPosition.x, a = this.target.getPositionY() - this._previousPosition.y, 0 !== c || 0 !== a) && (d = this._accumulatedDiff, c = d.x + c, a = d.y + a, d.x = c, d.y = a, b.x += c, b.y += a); this.updatePosition(b) }, reverse: function() { var a = cc.reverseControlPoints(this._points); return cc.cardinalSplineTo(this._duration, a, this._tension) }, updatePosition: function(a) { this.target.setPosition(a); this._previousPosition = a }, getPoints: function() { return this._points }, setPoints: function(a) { this._points = a } }); cc.cardinalSplineTo = function(a, b, c) { return new cc.CardinalSplineTo(a, b, c) }; cc.CardinalSplineTo.create = cc.cardinalSplineTo; cc.CardinalSplineBy = cc.CardinalSplineTo.extend({ _startPosition: null, ctor: function(a, b, c) { cc.CardinalSplineTo.prototype.ctor.call(this); this._startPosition = cc.p(0, 0); void 0 !== c && this.initWithDuration(a, b, c) }, startWithTarget: function(a) { cc.CardinalSplineTo.prototype.startWithTarget.call(this, a); this._startPosition.x = a.getPositionX(); this._startPosition.y = a.getPositionY() }, reverse: function() { for (var a = this._points.slice(), b, c = a[0], d = 1; d < a.length; ++d) b = a[d], a[d] = cc.pSub(b, c), c = b; a = cc.reverseControlPoints(a); c = a[a.length - 1]; a.pop(); c.x = -c.x; c.y = -c.y; a.unshift(c); for (d = 1; d < a.length; ++d) b = a[d], b.x = -b.x, b.y = -b.y, b.x += c.x, b.y += c.y, c = a[d] = b; return cc.cardinalSplineBy(this._duration, a, this._tension) }, updatePosition: function(a) { var b = this._startPosition, c = a.x + b.x; a = a.y + b.y; this._previousPosition.x = c; this._previousPosition.y = a; this.target.setPosition(c, a) }, clone: function() { var a = new cc.CardinalSplineBy; a.initWithDuration(this._duration, cc.copyControlPoints(this._points), this._tension); return a } }); cc.cardinalSplineBy = function(a, b, c) { return new cc.CardinalSplineBy(a, b, c) }; cc.CardinalSplineBy.create = cc.cardinalSplineBy; cc.CatmullRomTo = cc.CardinalSplineTo.extend({ ctor: function(a, b) { b && this.initWithDuration(a, b) }, initWithDuration: function(a, b) { return cc.CardinalSplineTo.prototype.initWithDuration.call(this, a, b, 0.5) }, clone: function() { var a = new cc.CatmullRomTo; a.initWithDuration(this._duration, cc.copyControlPoints(this._points)); return a } }); cc.catmullRomTo = function(a, b) { return new cc.CatmullRomTo(a, b) }; cc.CatmullRomTo.create = cc.catmullRomTo; cc.CatmullRomBy = cc.CardinalSplineBy.extend({ ctor: function(a, b) { cc.CardinalSplineBy.prototype.ctor.call(this); b && this.initWithDuration(a, b) }, initWithDuration: function(a, b) { return cc.CardinalSplineTo.prototype.initWithDuration.call(this, a, b, 0.5) }, clone: function() { var a = new cc.CatmullRomBy; a.initWithDuration(this._duration, cc.copyControlPoints(this._points)); return a } }); cc.catmullRomBy = function(a, b) { return new cc.CatmullRomBy(a, b) }; cc.CatmullRomBy.create = cc.catmullRomBy; cc.ActionTweenDelegate = cc.Class.extend({ updateTweenAction: function(a, b) {} }); cc.ActionTween = cc.ActionInterval.extend({ key: "", from: 0, to: 0, delta: 0, ctor: function(a, b, c, d) { cc.ActionInterval.prototype.ctor.call(this); this.key = ""; void 0 !== d && this.initWithDuration(a, b, c, d) }, initWithDuration: function(a, b, c, d) { return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this.key = b, this.to = d, this.from = c, !0) : !1 }, startWithTarget: function(a) { if (!a || !a.updateTweenAction) throw "cc.ActionTween.startWithTarget(): target must be non-null, and target must implement updateTweenAction function"; cc.ActionInterval.prototype.startWithTarget.call(this, a); this.delta = this.to - this.from }, update: function(a) { this.target.updateTweenAction(this.to - this.delta * (1 - a), this.key) }, reverse: function() { return new cc.ActionTween(this.duration, this.key, this.to, this.from) }, clone: function() { var a = new cc.ActionTween; a.initWithDuration(this._duration, this.key, this.from, this.to); return a } }); cc.actionTween = function(a, b, c, d) { return new cc.ActionTween(a, b, c, d) }; cc.ActionTween.create = cc.actionTween; cc.GridAction = cc.ActionInterval.extend({ _gridSize: null, _gridNodeTarget: null, ctor: function(a, b) { cc._checkWebGLRenderMode(); cc.ActionInterval.prototype.ctor.call(this); this._gridSize = cc.size(0, 0); b && this.initWithDuration(a, b) }, _cacheTargetAsGridNode: function() {}, clone: function() { var a = new cc.GridAction, b = this._gridSize; a.initWithDuration(this._duration, cc.size(b.width, b.height)); return a }, startWithTarget: function(a) { cc.ActionInterval.prototype.startWithTarget.call(this, a); cc.renderer.childrenOrderDirty = !0; var b = this.getGrid(), c = this.target; (a = c.grid) && 0 < a.getReuseGrid() ? (b = a.getGridSize(), a.isActive() && b.width === this._gridSize.width && b.height === this._gridSize.height && a.reuse()) : (a && a.isActive() && a.setActive(!1), c.grid = b, c.grid.setActive(!0)) }, reverse: function() { return new cc.ReverseTime(this) }, initWithDuration: function(a, b) { return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._gridSize.width = b.width, this._gridSize.height = b.height, !0) : !1 }, getGrid: function() { cc.log("cc.GridAction.getGrid(): it should be overridden in subclass.") } }); cc.gridAction = function(a, b) { return new cc.GridAction(a, b) }; cc.GridAction.create = cc.gridAction; cc.Grid3DAction = cc.GridAction.extend({ getGrid: function() { return new cc.Grid3D(this._gridSize) }, vertex: function(a) { return this.getVertex(a) }, getVertex: function(a) { return this.target.grid.getVertex(a) }, originalVertex: function(a) { return this.getOriginalVertex(a) }, getOriginalVertex: function(a) { return this.target.grid.originalVertex(a) }, setVertex: function(a, b) { this.target.grid.setVertex(a, b) } }); cc.grid3DAction = function(a, b) { return new cc.Grid3DAction(a, b) }; cc.Grid3DAction.create = cc.grid3DAction; cc.TiledGrid3DAction = cc.GridAction.extend({ tile: function(a) { return this.getTile(a) }, getTile: function(a) { return this.target.grid.tile(a) }, originalTile: function(a) { return this.getOriginalTile(a) }, getOriginalTile: function(a) { return this.target.grid.originalTile(a) }, setTile: function(a, b) { this.target.grid.setTile(a, b) }, getGrid: function() { return new cc.TiledGrid3D(this._gridSize) } }); cc.tiledGrid3DAction = function(a, b) { return new cc.TiledGrid3DAction(a, b) }; cc.TiledGrid3DAction.create = cc.tiledGrid3DAction; cc.StopGrid = cc.ActionInstant.extend({ startWithTarget: function(a) { cc.ActionInstant.prototype.startWithTarget.call(this, a); cc.renderer.childrenOrderDirty = !0; (a = this.target.grid) && a.isActive() && a.setActive(!1) } }); cc.stopGrid = function() { return new cc.StopGrid }; cc.StopGrid.create = cc.stopGrid; cc.ReuseGrid = cc.ActionInstant.extend({ _times: null, ctor: function(a) { cc.ActionInstant.prototype.ctor.call(this); void 0 !== a && this.initWithTimes(a) }, initWithTimes: function(a) { this._times = a; return !0 }, startWithTarget: function(a) { cc.ActionInstant.prototype.startWithTarget.call(this, a); cc.renderer.childrenOrderDirty = !0; this.target.grid && this.target.grid.isActive() && this.target.grid.setReuseGrid(this.target.grid.getReuseGrid() + this._times) } }); cc.reuseGrid = function(a) { return new cc.ReuseGrid(a) }; cc.ReuseGrid.create = cc.reuseGrid; cc.Waves3D = cc.Grid3DAction.extend({ _waves: 0, _amplitude: 0, _amplitudeRate: 0, ctor: function(a, b, c, d) { cc.GridAction.prototype.ctor.call(this); void 0 !== d && this.initWithDuration(a, b, c, d) }, getAmplitude: function() { return this._amplitude }, setAmplitude: function(a) { this._amplitude = a }, getAmplitudeRate: function() { return this._amplitudeRate }, setAmplitudeRate: function(a) { this._amplitudeRate = a }, initWithDuration: function(a, b, c, d) { return cc.Grid3DAction.prototype.initWithDuration.call(this, a, b) ? (this._waves = c, this._amplitude = d, this._amplitudeRate = 1, !0) : !1 }, update: function(a) { for (var b = this._gridSize, c = this._amplitude, d = cc.p(0, 0), e = this._amplitudeRate, f = this._waves, g = 0; g < b.width + 1; ++g) for (var h = 0; h < b.height + 1; ++h) { d.x = g; d.y = h; var k = this.originalVertex(d); k.z += Math.sin(Math.PI * a * f * 2 + 0.01 * (k.y + k.x)) * c * e; this.setVertex(d, k) } } }); cc.waves3D = function(a, b, c, d) { return new cc.Waves3D(a, b, c, d) }; cc.Waves3D.create = cc.waves3D; cc.FlipX3D = cc.Grid3DAction.extend({ ctor: function(a) { void 0 !== a ? cc.GridAction.prototype.ctor.call(this, a, cc.size(1, 1)) : cc.GridAction.prototype.ctor.call(this) }, initWithDuration: function(a) { return cc.Grid3DAction.prototype.initWithDuration.call(this, a, cc.size(1, 1)) }, initWithSize: function(a, b) { return 1 !== a.width || 1 !== a.height ? (cc.log("Grid size must be (1,1)"), !1) : cc.Grid3DAction.prototype.initWithDuration.call(this, b, a) }, update: function(a) { var b = Math.PI * a; a = Math.sin(b); var c = Math.cos(b / 2), b = new cc.Vertex3F, d = cc.p(0, 0); d.x = d.y = 1; var e = this.originalVertex(d); d.x = d.y = 0; var d = this.originalVertex(d), f = e.x, g = d.x, h, k; f > g ? (e = cc.p(0, 0), d = cc.p(0, 1), h = cc.p(1, 0), k = cc.p(1, 1)) : (h = cc.p(0, 0), k = cc.p(0, 1), e = cc.p(1, 0), d = cc.p(1, 1), f = g); b.x = f - f * c; b.z = Math.abs(parseFloat(f * a / 4)); a = this.originalVertex(e); a.x = b.x; a.z += b.z; this.setVertex(e, a); a = this.originalVertex(d); a.x = b.x; a.z += b.z; this.setVertex(d, a); a = this.originalVertex(h); a.x -= b.x; a.z -= b.z; this.setVertex(h, a); a = this.originalVertex(k); a.x -= b.x; a.z -= b.z; this.setVertex(k, a) } }); cc.flipX3D = function(a) { return new cc.FlipX3D(a) }; cc.FlipX3D.create = cc.flipX3D; cc.FlipY3D = cc.FlipX3D.extend({ ctor: function(a) { void 0 !== a ? cc.GridAction.prototype.ctor.call(this, a, cc.size(1, 1)) : cc.GridAction.prototype.ctor.call(this) }, update: function(a) { var b = Math.PI * a; a = Math.sin(b); var c = Math.cos(b / 2), b = new cc.Vertex3F, d = cc.p(0, 0); d.x = d.y = 1; var e = this.originalVertex(d); d.x = d.y = 0; var d = this.originalVertex(d), f = e.y, g = d.y, h, k; f > g ? (e = cc.p(0, 0), d = cc.p(0, 1), h = cc.p(1, 0), k = cc.p(1, 1)) : (d = cc.p(0, 0), e = cc.p(0, 1), k = cc.p(1, 0), h = cc.p(1, 1), f = g); b.y = f - f * c; b.z = Math.abs(parseFloat(f * a) / 4); a = this.originalVertex(e); a.y = b.y; a.z += b.z; this.setVertex(e, a); a = this.originalVertex(d); a.y -= b.y; a.z -= b.z; this.setVertex(d, a); a = this.originalVertex(h); a.y = b.y; a.z += b.z; this.setVertex(h, a); a = this.originalVertex(k); a.y -= b.y; a.z -= b.z; this.setVertex(k, a) } }); cc.flipY3D = function(a) { return new cc.FlipY3D(a) }; cc.FlipY3D.create = cc.flipY3D; cc.Lens3D = cc.Grid3DAction.extend({ _position: null, _radius: 0, _lensEffect: 0, _concave: !1, _dirty: !1, ctor: function(a, b, c, d) { cc.GridAction.prototype.ctor.call(this); this._position = cc.p(0, 0); void 0 !== d && this.initWithDuration(a, b, c, d) }, getLensEffect: function() { return this._lensEffect }, setLensEffect: function(a) { this._lensEffect = a }, setConcave: function(a) { this._concave = a }, getPosition: function() { return this._position }, setPosition: function(a) { cc.pointEqualToPoint(a, this._position) || (this._position.x = a.x, this._position.y = a.y, this._dirty = !0) }, initWithDuration: function(a, b, c, d) { return cc.Grid3DAction.prototype.initWithDuration.call(this, a, b) ? (this.setPosition(c), this._radius = d, this._lensEffect = 0.7, this._dirty = !0) : !1 }, update: function(a) { if (this._dirty) { a = this._gridSize.width; for (var b = this._gridSize.height, c = this._radius, d = this._lensEffect, e = cc.p(0, 0), f = cc.p(0, 0), g, h, k, m = 0; m < a + 1; ++m) for (var n = 0; n < b + 1; ++n) e.x = m, e.y = n, g = this.originalVertex(e), f.x = this._position.x - g.x, f.y = this._position.y - g.y, h = cc.pLength(f), h < c && (h = c - h, h /= c, 0 === h && (h = 0.001), h = Math.log(h) * d, k = Math.exp(h) * c, h = cc.pLength(f), 0 < h && (f.x /= h, f.y /= h, f.x *= k, f.y *= k, g.z += cc.pLength(f) * d)), this.setVertex(e, g); this._dirty = !1 } } }); cc.lens3D = function(a, b, c, d) { return new cc.Lens3D(a, b, c, d) }; cc.Lens3D.create = cc.lens3D; cc.Ripple3D = cc.Grid3DAction.extend({ _position: null, _radius: 0, _waves: 0, _amplitude: 0, _amplitudeRate: 0, ctor: function(a, b, c, d, e, f) { cc.GridAction.prototype.ctor.call(this); this._position = cc.p(0, 0); void 0 !== f && this.initWithDuration(a, b, c, d, e, f) }, getPosition: function() { return this._position }, setPosition: function(a) { this._position.x = a.x; this._position.y = a.y }, getAmplitude: function() { return this._amplitude }, setAmplitude: function(a) { this._amplitude = a }, getAmplitudeRate: function() { return this._amplitudeRate }, setAmplitudeRate: function(a) { this._amplitudeRate = a }, initWithDuration: function(a, b, c, d, e, f) { return cc.Grid3DAction.prototype.initWithDuration.call(this, a, b) ? (this.setPosition(c), this._radius = d, this._waves = e, this._amplitude = f, this._amplitudeRate = 1, !0) : !1 }, update: function(a) { for (var b = this._gridSize.width, c = this._gridSize.height, d = cc.p(0, 0), e = this._radius, f = this._waves, g = this._amplitude, h = this._amplitudeRate, k, m, n = cc.p(0, 0), p = 0; p < b + 1; ++p) for (var t = 0; t < c + 1; ++t) { d.x = p; d.y = t; k = this.originalVertex(d); n.x = this._position.x - k.x; n.y = this._position.y - k.y; m = cc.pLength(n); if (m < e) { m = e - m; var r = Math.pow(m / e, 2); k.z += Math.sin(a * Math.PI * f * 2 + 0.1 * m) * g * h * r } this.setVertex(d, k) } } }); cc.ripple3D = function(a, b, c, d, e, f) { return new cc.Ripple3D(a, b, c, d, e, f) }; cc.Ripple3D.create = cc.ripple3D; cc.Shaky3D = cc.Grid3DAction.extend({ _randRange: 0, _shakeZ: !1, ctor: function(a, b, c, d) { cc.GridAction.prototype.ctor.call(this); void 0 !== d && this.initWithDuration(a, b, c, d) }, initWithDuration: function(a, b, c, d) { return cc.Grid3DAction.prototype.initWithDuration.call(this, a, b) ? (this._randRange = c, this._shakeZ = d, !0) : !1 }, update: function(a) { a = this._gridSize.width; for (var b = this._gridSize.height, c = this._randRange, d = this._shakeZ, e = cc.p(0, 0), f, g = 0; g < a + 1; ++g) for (var h = 0; h < b + 1; ++h) e.x = g, e.y = h, f = this.originalVertex(e), f.x += cc.rand() % (2 * c) - c, f.y += cc.rand() % (2 * c) - c, d && (f.z += cc.rand() % (2 * c) - c), this.setVertex(e, f) } }); cc.shaky3D = function(a, b, c, d) { return new cc.Shaky3D(a, b, c, d) }; cc.Shaky3D.create = cc.shaky3D; cc.Liquid = cc.Grid3DAction.extend({ _waves: 0, _amplitude: 0, _amplitudeRate: 0, ctor: function(a, b, c, d) { cc.GridAction.prototype.ctor.call(this); void 0 !== d && this.initWithDuration(a, b, c, d) }, getAmplitude: function() { return this._amplitude }, setAmplitude: function(a) { this._amplitude = a }, getAmplitudeRate: function() { return this._amplitudeRate }, setAmplitudeRate: function(a) { this._amplitudeRate = a }, initWithDuration: function(a, b, c, d) { return cc.Grid3DAction.prototype.initWithDuration.call(this, a, b) ? (this._waves = c, this._amplitude = d, this._amplitudeRate = 1, !0) : !1 }, update: function(a) { for (var b = this._gridSize.width, c = this._gridSize.height, d = cc.p(0, 0), e = this._waves, f = this._amplitude, g = this._amplitudeRate, h, k = 1; k < b; ++k) for (var m = 1; m < c; ++m) d.x = k, d.y = m, h = this.originalVertex(d), h.x += Math.sin(a * Math.PI * e * 2 + 0.01 * h.x) * f * g, h.y += Math.sin(a * Math.PI * e * 2 + 0.01 * h.y) * f * g, this.setVertex(d, h) } }); cc.liquid = function(a, b, c, d) { return new cc.Liquid(a, b, c, d) }; cc.Liquid.create = cc.liquid; cc.Waves = cc.Grid3DAction.extend({ _waves: 0, _amplitude: 0, _amplitudeRate: 0, _vertical: !1, _horizontal: !1, ctor: function(a, b, c, d, e, f) { cc.GridAction.prototype.ctor.call(this); void 0 !== f && this.initWithDuration(a, b, c, d, e, f) }, getAmplitude: function() { return this._amplitude }, setAmplitude: function(a) { this._amplitude = a }, getAmplitudeRate: function() { return this._amplitudeRate }, setAmplitudeRate: function(a) { this._amplitudeRate = a }, initWithDuration: function(a, b, c, d, e, f) { return cc.Grid3DAction.prototype.initWithDuration.call(this, a, b) ? (this._waves = c, this._amplitude = d, this._amplitudeRate = 1, this._horizontal = e, this._vertical = f, !0) : !1 }, update: function(a) { for (var b = this._gridSize.width, c = this._gridSize.height, d = cc.p(0, 0), e = this._vertical, f = this._horizontal, g = this._waves, h = this._amplitude, k = this._amplitudeRate, m, n = 0; n < b + 1; ++n) for (var p = 0; p < c + 1; ++p) d.x = n, d.y = p, m = this.originalVertex(d), e && (m.x += Math.sin(a * Math.PI * g * 2 + 0.01 * m.y) * h * k), f && (m.y += Math.sin(a * Math.PI * g * 2 + 0.01 * m.x) * h * k), this.setVertex(d, m) } }); cc.waves = function(a, b, c, d, e, f) { return new cc.Waves(a, b, c, d, e, f) }; cc.Waves.create = cc.waves; cc.Twirl = cc.Grid3DAction.extend({ _position: null, _twirls: 0, _amplitude: 0, _amplitudeRate: 0, ctor: function(a, b, c, d, e) { cc.GridAction.prototype.ctor.call(this); this._position = cc.p(0, 0); void 0 !== e && this.initWithDuration(a, b, c, d, e) }, getPosition: function() { return this._position }, setPosition: function(a) { this._position.x = a.x; this._position.y = a.y }, getAmplitude: function() { return this._amplitude }, setAmplitude: function(a) { this._amplitude = a }, getAmplitudeRate: function() { return this._amplitudeRate }, setAmplitudeRate: function(a) { this._amplitudeRate = a }, initWithDuration: function(a, b, c, d, e) { return cc.Grid3DAction.prototype.initWithDuration.call(this, a, b) ? (this.setPosition(c), this._twirls = d, this._amplitude = e, this._amplitudeRate = 1, !0) : !1 }, update: function(a) { for (var b = this._position, c = this._gridSize.width, d = this._gridSize.height, e = cc.p(0, 0), f = 0.1 * this._amplitude * this._amplitudeRate, g = this._twirls, h, k, m, n = cc.p(0, 0), p = 0; p < c + 1; ++p) for (var t = 0; t < d + 1; ++t) e.x = p, e.y = t, h = this.originalVertex(e), n.x = p - c / 2, n.y = t - d / 2, k = cc.pLength(n) * Math.cos(Math.PI / 2 + a * Math.PI * g * 2) * f, m = Math.sin(k) * (h.y - b.y) + Math.cos(k) * (h.x - b.x), k = Math.cos(k) * (h.y - b.y) - Math.sin(k) * (h.x - b.x), h.x = b.x + m, h.y = b.y + k, this.setVertex(e, h) } }); cc.twirl = function(a, b, c, d, e) { return new cc.Twirl(a, b, c, d, e) }; cc.Twirl.create = cc.twirl; cc.ShakyTiles3D = cc.TiledGrid3DAction.extend({ _randRange: 0, _shakeZ: !1, ctor: function(a, b, c, d) { cc.GridAction.prototype.ctor.call(this); void 0 !== d && this.initWithDuration(a, b, c, d) }, initWithDuration: function(a, b, c, d) { return cc.TiledGrid3DAction.prototype.initWithDuration.call(this, a, b) ? (this._randRange = c, this._shakeZ = d, !0) : !1 }, update: function(a) { a = this._gridSize; for (var b = this._randRange, c = cc.p(0, 0), d = 0; d < a.width; ++d) for (var e = 0; e < a.height; ++e) { c.x = d; c.y = e; var f = this.originalTile(c); f.bl.x += cc.rand() % (2 * b) - b; f.br.x += cc.rand() % (2 * b) - b; f.tl.x += cc.rand() % (2 * b) - b; f.tr.x += cc.rand() % (2 * b) - b; f.bl.y += cc.rand() % (2 * b) - b; f.br.y += cc.rand() % (2 * b) - b; f.tl.y += cc.rand() % (2 * b) - b; f.tr.y += cc.rand() % (2 * b) - b; this._shakeZ && (f.bl.z += cc.rand() % (2 * b) - b, f.br.z += cc.rand() % (2 * b) - b, f.tl.z += cc.rand() % (2 * b) - b, f.tr.z += cc.rand() % (2 * b) - b); this.setTile(c, f) } } }); cc.shakyTiles3D = function(a, b, c, d) { return new cc.ShakyTiles3D(a, b, c, d) }; cc.ShakyTiles3D.create = cc.shakyTiles3D; cc.ShatteredTiles3D = cc.TiledGrid3DAction.extend({ _randRange: 0, _once: !1, _shatterZ: !1, ctor: function(a, b, c, d) { cc.GridAction.prototype.ctor.call(this); void 0 !== d && this.initWithDuration(a, b, c, d) }, initWithDuration: function(a, b, c, d) { return cc.TiledGrid3DAction.prototype.initWithDuration.call(this, a, b) ? (this._once = !1, this._randRange = c, this._shatterZ = d, !0) : !1 }, update: function(a) { if (!1 === this._once) { a = this._gridSize; for (var b = this._randRange, c, d = cc.p(0, 0), e = 0; e < a.width; ++e) for (var f = 0; f < a.height; ++f) d.x = e, d.y = f, c = this.originalTile(d), c.bl.x += cc.rand() % (2 * b) - b, c.br.x += cc.rand() % (2 * b) - b, c.tl.x += cc.rand() % (2 * b) - b, c.tr.x += cc.rand() % (2 * b) - b, c.bl.y += cc.rand() % (2 * b) - b, c.br.y += cc.rand() % (2 * b) - b, c.tl.y += cc.rand() % (2 * b) - b, c.tr.y += cc.rand() % (2 * b) - b, this._shatterZ && (c.bl.z += cc.rand() % (2 * b) - b, c.br.z += cc.rand() % (2 * b) - b, c.tl.z += cc.rand() % (2 * b) - b, c.tr.z += cc.rand() % (2 * b) - b), this.setTile(d, c); this._once = !0 } } }); cc.shatteredTiles3D = function(a, b, c, d) { return new cc.ShatteredTiles3D(a, b, c, d) }; cc.ShatteredTiles3D.create = cc.shatteredTiles3D; cc.Tile = function(a, b, c) { this.position = a || cc.p(0, 0); this.startPosition = b || cc.p(0, 0); this.delta = c || cc.p(0, 0) }; cc.ShuffleTiles = cc.TiledGrid3DAction.extend({ _seed: 0, _tilesCount: 0, _tilesOrder: null, _tiles: null, ctor: function(a, b, c) { cc.GridAction.prototype.ctor.call(this); this._tilesOrder = []; this._tiles = []; void 0 !== c && this.initWithDuration(a, b, c) }, initWithDuration: function(a, b, c) { return cc.TiledGrid3DAction.prototype.initWithDuration.call(this, a, b) ? (this._seed = c, this._tilesOrder.length = 0, this._tiles.length = 0, !0) : !1 }, shuffle: function(a, b) { for (var c = b - 1; 0 <= c; c--) { var d = 0 | cc.rand() % (c + 1), e = a[c]; a[c] = a[d]; a[d] = e } }, getDelta: function(a) { var b = this._gridSize, c = a.width * b.height + a.height; return cc.size(this._tilesOrder[c] / b.height - a.width, this._tilesOrder[c] % b.height - a.height) }, placeTile: function(a, b) { var c = this.originalTile(a), d = this.target.grid.getStep(), e = b.position; c.bl.x += e.x * d.x; c.bl.y += e.y * d.y; c.br.x += e.x * d.x; c.br.y += e.y * d.y; c.tl.x += e.x * d.x; c.tl.y += e.y * d.y; c.tr.x += e.x * d.x; c.tr.y += e.y * d.y; this.setTile(a, c) }, startWithTarget: function(a) { cc.TiledGrid3DAction.prototype.startWithTarget.call(this, a); a = this._gridSize; this._tilesCount = a.width * a.height; for (var b = this._tilesOrder, c = b.length = 0; c < this._tilesCount; ++c) b[c] = c; this.shuffle(b, this._tilesCount); for (var b = this._tiles, c = b.length = 0, d = cc.size(0, 0), e = 0; e < a.width; ++e) for (var f = 0; f < a.height; ++f) b[c] = new cc.Tile, b[c].position = cc.p(e, f), b[c].startPosition = cc.p(e, f), d.width = e, d.height = f, b[c].delta = this.getDelta(d), ++c }, update: function(a) { for (var b = 0, c = this._gridSize, d = this._tiles, e, f = cc.p(0, 0), g = 0; g < c.width; ++g) for (var h = 0; h < c.height; ++h) f.x = g, f.y = h, e = d[b], e.position.x = e.delta.width * a, e.position.y = e.delta.height * a, this.placeTile(f, e), ++b } }); cc.shuffleTiles = function(a, b, c) { return new cc.ShuffleTiles(a, b, c) }; cc.ShuffleTiles.create = cc.shuffleTiles; cc.FadeOutTRTiles = cc.TiledGrid3DAction.extend({ testFunc: function(a, b) { var c = this._gridSize.width * b, d = this._gridSize.height * b; return 0 === c + d ? 1 : Math.pow((a.width + a.height) / (c + d), 6) }, turnOnTile: function(a) { this.setTile(a, this.originalTile(a)) }, turnOffTile: function(a) { this.setTile(a, new cc.Quad3) }, transformTile: function(a, b) { var c = this.originalTile(a), d = this.target.grid.getStep(); c.bl.x += d.x / 2 * (1 - b); c.bl.y += d.y / 2 * (1 - b); c.br.x -= d.x / 2 * (1 - b); c.br.y += d.y / 2 * (1 - b); c.tl.x += d.x / 2 * (1 - b); c.tl.y -= d.y / 2 * (1 - b); c.tr.x -= d.x / 2 * (1 - b); c.tr.y -= d.y / 2 * (1 - b); this.setTile(a, c) }, update: function(a) { for (var b = this._gridSize, c = cc.p(0, 0), d = cc.size(0, 0), e, f = 0; f < b.width; ++f) for (var g = 0; g < b.height; ++g) c.x = f, c.y = g, d.width = f, d.height = g, e = this.testFunc(d, a), 0 === e ? this.turnOffTile(c) : 1 > e ? this.transformTile(c, e) : this.turnOnTile(c) } }); cc.fadeOutTRTiles = function(a, b) { return new cc.FadeOutTRTiles(a, b) }; cc.FadeOutTRTiles.create = cc.fadeOutTRTiles; cc.FadeOutBLTiles = cc.FadeOutTRTiles.extend({ testFunc: function(a, b) { return 0 === a.width + a.height ? 1 : Math.pow((this._gridSize.width * (1 - b) + this._gridSize.height * (1 - b)) / (a.width + a.height), 6) } }); cc.fadeOutBLTiles = function(a, b) { return new cc.FadeOutBLTiles(a, b) }; cc.FadeOutBLTiles.create = cc.fadeOutBLTiles; cc.FadeOutUpTiles = cc.FadeOutTRTiles.extend({ testFunc: function(a, b) { var c = this._gridSize.height * b; return 0 === c ? 1 : Math.pow(a.height / c, 6) }, transformTile: function(a, b) { var c = this.originalTile(a), d = this.target.grid.getStep(); c.bl.y += d.y / 2 * (1 - b); c.br.y += d.y / 2 * (1 - b); c.tl.y -= d.y / 2 * (1 - b); c.tr.y -= d.y / 2 * (1 - b); this.setTile(a, c) } }); cc.fadeOutUpTiles = function(a, b) { return new cc.FadeOutUpTiles(a, b) }; cc.FadeOutUpTiles.create = cc.fadeOutUpTiles; cc.FadeOutDownTiles = cc.FadeOutUpTiles.extend({ testFunc: function(a, b) { return 0 === a.height ? 1 : Math.pow(this._gridSize.height * (1 - b) / a.height, 6) } }); cc.fadeOutDownTiles = function(a, b) { return new cc.FadeOutDownTiles(a, b) }; cc.FadeOutDownTiles.create = cc.fadeOutDownTiles; cc.TurnOffTiles = cc.TiledGrid3DAction.extend({ _seed: null, _tilesCount: 0, _tilesOrder: null, ctor: function(a, b, c) { cc.GridAction.prototype.ctor.call(this); this._tilesOrder = []; void 0 !== b && this.initWithDuration(a, b, c) }, initWithDuration: function(a, b, c) { return cc.TiledGrid3DAction.prototype.initWithDuration.call(this, a, b) ? (this._seed = c || 0, this._tilesOrder.length = 0, !0) : !1 }, shuffle: function(a, b) { for (var c = b - 1; 0 <= c; c--) { var d = 0 | cc.rand() % (c + 1), e = a[c]; a[c] = a[d]; a[d] = e } }, turnOnTile: function(a) { this.setTile(a, this.originalTile(a)) }, turnOffTile: function(a) { this.setTile(a, new cc.Quad3) }, startWithTarget: function(a) { cc.TiledGrid3DAction.prototype.startWithTarget.call(this, a); this._tilesCount = this._gridSize.width * this._gridSize.height; a = this._tilesOrder; for (var b = a.length = 0; b < this._tilesCount; ++b) a[b] = b; this.shuffle(a, this._tilesCount) }, update: function(a) { a = 0 | a * this._tilesCount; for (var b = this._gridSize, c, d = cc.p(0, 0), e = this._tilesOrder, f = 0; f < this._tilesCount; f++) c = e[f], d.x = 0 | c / b.height, d.y = c % (0 | b.height), f < a ? this.turnOffTile(d) : this.turnOnTile(d) } }); cc.turnOffTiles = function(a, b, c) { return new cc.TurnOffTiles(a, b, c) }; cc.TurnOffTiles.create = cc.turnOffTiles; cc.WavesTiles3D = cc.TiledGrid3DAction.extend({ _waves: 0, _amplitude: 0, _amplitudeRate: 0, ctor: function(a, b, c, d) { cc.GridAction.prototype.ctor.call(this); void 0 !== d && this.initWithDuration(a, b, c, d) }, getAmplitude: function() { return this._amplitude }, setAmplitude: function(a) { this._amplitude = a }, getAmplitudeRate: function() { return this._amplitudeRate }, setAmplitudeRate: function(a) { this._amplitudeRate = a }, initWithDuration: function(a, b, c, d) { return cc.TiledGrid3DAction.prototype.initWithDuration.call(this, a, b) ? (this._waves = c, this._amplitude = d, this._amplitudeRate = 1, !0) : !1 }, update: function(a) { for (var b = this._gridSize, c = this._waves, d = this._amplitude, e = this._amplitudeRate, f = cc.p(0, 0), g, h = 0; h < b.width; h++) for (var k = 0; k < b.height; k++) f.x = h, f.y = k, g = this.originalTile(f), g.bl.z = Math.sin(a * Math.PI * c * 2 + 0.01 * (g.bl.y + g.bl.x)) * d * e, g.br.z = g.bl.z, g.tl.z = g.bl.z, g.tr.z = g.bl.z, this.setTile(f, g) } }); cc.wavesTiles3D = function(a, b, c, d) { return new cc.WavesTiles3D(a, b, c, d) }; cc.WavesTiles3D.create = cc.wavesTiles3D; cc.JumpTiles3D = cc.TiledGrid3DAction.extend({ _jumps: 0, _amplitude: 0, _amplitudeRate: 0, ctor: function(a, b, c, d) { cc.GridAction.prototype.ctor.call(this); void 0 !== d && this.initWithDuration(a, b, c, d) }, getAmplitude: function() { return this._amplitude }, setAmplitude: function(a) { this._amplitude = a }, getAmplitudeRate: function() { return this._amplitudeRate }, setAmplitudeRate: function(a) { this._amplitudeRate = a }, initWithDuration: function(a, b, c, d) { return cc.TiledGrid3DAction.prototype.initWithDuration.call(this, a, b) ? (this._jumps = c, this._amplitude = d, this._amplitudeRate = 1, !0) : !1 }, update: function(a) { var b = Math.sin(Math.PI * a * this._jumps * 2) * this._amplitude * this._amplitudeRate; a = Math.sin(Math.PI * (a * this._jumps * 2 + 1)) * this._amplitude * this._amplitudeRate; for (var c = this._gridSize, d = this.target.grid, e, f = cc.p(0, 0), g = 0; g < c.width; g++) for (var h = 0; h < c.height; h++) f.x = g, f.y = h, e = d.originalTile(f), 0 === (g + h) % 2 ? (e.bl.z += b, e.br.z += b, e.tl.z += b, e.tr.z += b) : (e.bl.z += a, e.br.z += a, e.tl.z += a, e.tr.z += a), d.setTile(f, e) } }); cc.jumpTiles3D = function(a, b, c, d) { return new cc.JumpTiles3D(a, b, c, d) }; cc.JumpTiles3D.create = cc.jumpTiles3D; cc.SplitRows = cc.TiledGrid3DAction.extend({ _rows: 0, _winSize: null, ctor: function(a, b) { cc.GridAction.prototype.ctor.call(this); void 0 !== b && this.initWithDuration(a, b) }, initWithDuration: function(a, b) { this._rows = b; return cc.TiledGrid3DAction.prototype.initWithDuration.call(this, a, cc.size(1, b)) }, update: function(a) { for (var b = this._gridSize, c = this._winSize.width, d, e, f = cc.p(0, 0), g = 0; g < b.height; ++g) f.y = g, d = this.originalTile(f), e = 1, 0 === g % 2 && (e = -1), d.bl.x += e * c * a, d.br.x += e * c * a, d.tl.x += e * c * a, d.tr.x += e * c * a, this.setTile(f, d) }, startWithTarget: function(a) { cc.TiledGrid3DAction.prototype.startWithTarget.call(this, a); this._winSize = cc.director.getWinSizeInPixels() } }); cc.splitRows = function(a, b) { return new cc.SplitRows(a, b) }; cc.SplitRows.create = cc.splitRows; cc.SplitCols = cc.TiledGrid3DAction.extend({ _cols: 0, _winSize: null, ctor: function(a, b) { cc.GridAction.prototype.ctor.call(this); void 0 !== b && this.initWithDuration(a, b) }, initWithDuration: function(a, b) { this._cols = b; return cc.TiledGrid3DAction.prototype.initWithDuration.call(this, a, cc.size(b, 1)) }, update: function(a) { for (var b = this._gridSize.width, c = this._winSize.height, d, e, f = cc.p(0, 0), g = 0; g < b; ++g) f.x = g, d = this.originalTile(f), e = 1, 0 === g % 2 && (e = -1), d.bl.y += e * c * a, d.br.y += e * c * a, d.tl.y += e * c * a, d.tr.y += e * c * a, this.setTile(f, d); cc.renderer.childrenOrderDirty = !0 }, startWithTarget: function(a) { cc.TiledGrid3DAction.prototype.startWithTarget.call(this, a); this._winSize = cc.director.getWinSizeInPixels() } }); cc.splitCols = function(a, b) { return new cc.SplitCols(a, b) }; cc.SplitCols.create = cc.splitCols; cc.PageTurn3D = cc.Grid3DAction.extend({ getGrid: function() { var a = new cc.Grid3D(this._gridSize); a.setNeedDepthTestForBlit(!0); return a }, clone: function() { var a = new cc.PageTurn3D; a.initWithDuration(this._duration, this._gridSize); return a }, update: function(a) { var b = Math.max(0, a - 0.25), b = -100 - b * b * 500; a = -Math.PI / 2 * Math.sqrt(a); var c = +Math.PI / 2 + a; a = Math.sin(c); for (var c = Math.cos(c), d = this._gridSize, e = cc.p(0, 0), f = 0; f <= d.width; ++f) for (var g = 0; g <= d.height; ++g) { e.x = f; e.y = g; var h = this.getOriginalVertex(e), k = Math.sqrt(h.x * h.x + (h.y - b) * (h.y - b)), m = k * a, n = Math.asin(h.x / k) / a, p = Math.cos(n); h.x = n <= Math.PI ? m * Math.sin(n) : 0; h.y = k + b - m * (1 - p) * a; h.z = m * (1 - p) * c / 7; 0.5 > h.z && (h.z = 0.5); this.setVertex(e, h) } } }); cc.pageTurn3D = function(a, b) { return new cc.PageTurn3D(a, b) }; cc.PageTurn3D.create = cc.pageTurn3D; cc.ProgressTimer = cc.Node.extend({ _type: null, _percentage: 0, _sprite: null, _midPoint: null, _barChangeRate: null, _reverseDirection: !1, _className: "ProgressTimer", ctor: function(a) { cc.Node.prototype.ctor.call(this); this._type = cc.ProgressTimer.TYPE_RADIAL; this._percentage = 0; this._midPoint = cc.p(0, 0); this._barChangeRate = cc.p(0, 0); this._reverseDirection = !1; this._sprite = null; a && this.initWithSprite(a) }, getMidpoint: function() { return cc.p(this._midPoint.x, this._midPoint.y) }, setMidpoint: function(a) { this._midPoint = cc.pClamp(a, cc.p(0, 0), cc.p(1, 1)) }, getBarChangeRate: function() { return cc.p(this._barChangeRate.x, this._barChangeRate.y) }, setBarChangeRate: function(a) { this._barChangeRate = cc.pClamp(a, cc.p(0, 0), cc.p(1, 1)) }, getType: function() { return this._type }, getPercentage: function() { return this._percentage }, getSprite: function() { return this._sprite }, setPercentage: function(a) { this._percentage !== a && (this._percentage = cc.clampf(a, 0, 100), this._renderCmd._updateProgress()) }, setOpacityModifyRGB: function(a) {}, isOpacityModifyRGB: function() { return !1 }, isReverseDirection: function() { return this._reverseDirection }, setColor: function(a) { this._sprite.color = a; this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.colorDirty) }, setOpacity: function(a) { this._sprite.opacity = a; this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.opacityDirty) }, getColor: function() { return this._sprite.color }, getOpacity: function() { return this._sprite.opacity }, setReverseProgress: function(a) { this._reverseDirection !== a && (this._reverseDirection = a, this._renderCmd.releaseData()) }, setSprite: function(a) { this._sprite !== a && ((this._sprite = a) ? this.setContentSize(a.width, a.height) : this.setContentSize(0, 0), this._renderCmd.releaseData()) }, setType: function(a) { a !== this._type && (this._type = a, this._renderCmd.releaseData()) }, setReverseDirection: function(a) { this._reverseDirection !== a && (this._reverseDirection = a, this._renderCmd.releaseData()) }, initWithSprite: function(a) { this.percentage = 0; this.setAnchorPoint(0.5, 0.5); this._type = cc.ProgressTimer.TYPE_RADIAL; this._reverseDirection = !1; this.midPoint = cc.p(0.5, 0.5); this.barChangeRate = cc.p(1, 1); this.setSprite(a); this._renderCmd.initCmd(); return !0 }, _createRenderCmd: function() { return cc._renderType === cc._RENDER_TYPE_CANVAS ? new cc.ProgressTimer.CanvasRenderCmd(this) : new cc.ProgressTimer.WebGLRenderCmd(this) } }); _p = cc.ProgressTimer.prototype; cc.defineGetterSetter(_p, "midPoint", _p.getMidpoint, _p.setMidpoint); cc.defineGetterSetter(_p, "barChangeRate", _p.getBarChangeRate, _p.setBarChangeRate); cc.defineGetterSetter(_p, "type", _p.getType, _p.setType); cc.defineGetterSetter(_p, "percentage", _p.getPercentage, _p.setPercentage); cc.defineGetterSetter(_p, "sprite", _p.getSprite, _p.setSprite); cc.defineGetterSetter(_p, "reverseDir", _p.isReverseDirection, _p.setReverseDirection); cc.ProgressTimer.create = function(a) { return new cc.ProgressTimer(a) }; cc.ProgressTimer.TEXTURE_COORDS_COUNT = 4; cc.ProgressTimer.TEXTURE_COORDS = 75; cc.ProgressTimer.TYPE_RADIAL = 0; cc.ProgressTimer.TYPE_BAR = 1; cc.ProgressTo = cc.ActionInterval.extend({ _to: 0, _from: 0, ctor: function(a, b) { cc.ActionInterval.prototype.ctor.call(this); this._from = this._to = 0; void 0 !== b && this.initWithDuration(a, b) }, initWithDuration: function(a, b) { return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._to = b, !0) : !1 }, clone: function() { var a = new cc.ProgressTo; a.initWithDuration(this._duration, this._to); return a }, reverse: function() { cc.log("cc.ProgressTo.reverse(): reverse hasn't been supported."); return null }, startWithTarget: function(a) { cc.ActionInterval.prototype.startWithTarget.call(this, a); this._from = a.percentage }, update: function(a) { this.target instanceof cc.ProgressTimer && (this.target.percentage = this._from + (this._to - this._from) * a) } }); cc.progressTo = function(a, b) { return new cc.ProgressTo(a, b) }; cc.ProgressTo.create = cc.progressTo; cc.ProgressFromTo = cc.ActionInterval.extend({ _to: 0, _from: 0, ctor: function(a, b, c) { cc.ActionInterval.prototype.ctor.call(this); this._from = this._to = 0; void 0 !== c && this.initWithDuration(a, b, c) }, initWithDuration: function(a, b, c) { return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._to = c, this._from = b, !0) : !1 }, clone: function() { var a = new cc.ProgressFromTo; a.initWithDuration(this._duration, this._from, this._to); return a }, reverse: function() { return cc.progressFromTo(this._duration, this._to, this._from) }, startWithTarget: function(a) { cc.ActionInterval.prototype.startWithTarget.call(this, a) }, update: function(a) { this.target instanceof cc.ProgressTimer && (this.target.percentage = this._from + (this._to - this._from) * a) } }); cc.progressFromTo = function(a, b, c) { return new cc.ProgressFromTo(a, b, c) }; cc.ProgressFromTo.create = cc.progressFromTo; (function() { cc.ProgressTimer.CanvasRenderCmd = function(a) { cc.Node.CanvasRenderCmd.call(this, a); this._needDraw = !0; this._PI180 = Math.PI / 180; this._barRect = cc.rect(0, 0, 0, 0); this._origin = cc.p(0, 0); this._radius = 0; this._endAngle = this._startAngle = 270; this._counterClockWise = !1 }; var a = cc.ProgressTimer.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); a.constructor = cc.ProgressTimer.CanvasRenderCmd; a.rendering = function(a, c, d) { a = a || cc._renderContext; var e = a.getContext(), f = this._node, g = f._sprite, h = g._renderCmd._textureCoord, k = g._renderCmd._displayedOpacity / 255; if (0 !== h.width && 0 !== h.height && g._texture && h.validRect && 0 !== k) { a.setTransform(this._worldTransform, c, d); a.setCompositeOperation(g._blendFuncStr); a.setGlobalAlpha(k); var m = g._rect, n = g._offsetPosition, k = n.x, p = -n.y - m.height, t = m.width, m = m.height; a.save(); g._flippedX && (k = -k - t, e.scale(-1, 1)); g._flippedY && (p = n.y, e.scale(1, -1)); f._type === cc.ProgressTimer.TYPE_BAR ? (f = this._barRect, e.beginPath(), e.rect(f.x * c, f.y * d, f.width * c, f.height * d), e.clip(), e.closePath()) : f._type === cc.ProgressTimer.TYPE_RADIAL && (f = this._origin.x * c, n = this._origin.y * d, e.beginPath(), e.arc(f, n, this._radius * d, this._PI180 * this._startAngle, this._PI180 * this._endAngle, this._counterClockWise), e.lineTo(f, n), e.clip(), e.closePath()); f = g._texture.getHtmlElementObj(); g._colorized ? e.drawImage(f, 0, 0, h.width, h.height, k * c, p * d, t * c, m * d) : e.drawImage(f, h.renderX, h.renderY, h.width, h.height, k * c, p * d, t * c, m * d); a.restore(); cc.g_NumberOfDraws++ } }; a.releaseData = function() {}; a.initCmd = function() {}; a._updateProgress = function() { var a = this._node, c = a._sprite, d = c.width, e = c.height, f = a._midPoint; if (a._type === cc.ProgressTimer.TYPE_RADIAL) { this._radius = Math.round(Math.sqrt(d * d + e * e)); var g, h = !1, k = this._origin; k.x = d * f.x; k.y = -e * f.y; a._reverseDirection ? (g = 270, f = 270 - 3.6 * a._percentage) : (f = -90, g = -90 + 3.6 * a._percentage); c._flippedX && (k.x -= 2 * d * a._midPoint.x, f = -f - 180, g = -g - 180, h = !h); c._flippedY && (k.y += 2 * e * a._midPoint.y, h = !h, f = -f, g = -g); this._startAngle = f; this._endAngle = g; this._counterClockWise = h } else h = a._barChangeRate, k = a._percentage / 100, a = this._barRect, h = cc.size(d * (1 - h.x), e * (1 - h.y)), k = cc.size((d - h.width) * k, (e - h.height) * k), h = cc.size(h.width + k.width, h.height + k.height), g = cc.p(d * f.x, e * f.y), k = g.x - h.width / 2, 0.5 < f.x && h.width / 2 >= d - g.x && (k = d - h.width), d = g.y - h.height / 2, 0.5 < f.y && h.height / 2 >= e - g.y && (d = e - h.height), a.x = 0, e = 1, c._flippedX && (a.x -= h.width, e = -1), 0 < k && (a.x += k * e), a.y = 0, e = 1, c._flippedY && (a.y += h.height, e = -1), 0 < d && (a.y -= d * e), a.width = h.width, a.height = -h.height }; a._updateColor = function() {}; a._syncStatus = function(a) { var c = this._node; if (c._sprite) { var d = cc.Node._dirtyFlags, e = this._dirtyFlag, f = a ? a._node : null; f && f._cascadeColorEnabled && a._dirtyFlag & d.colorDirty && (e |= d.colorDirty); f && f._cascadeOpacityEnabled && a._dirtyFlag & d.opacityDirty && (e |= d.opacityDirty); a && a._dirtyFlag & d.transformDirty && (e |= d.transformDirty); this._dirtyFlag = e; var c = c._sprite._renderCmd, f = c._dirtyFlag, g = f & d.opacityDirty; f & d.colorDirty && c._syncDisplayColor(); g && c._syncDisplayOpacity(); e & d.transformDirty && this.transform(a) } }; a.updateStatus = function() { var a = this._node; if (a._sprite) { var c = cc.Node._dirtyFlags, d = this._dirtyFlag, a = a._sprite._renderCmd, e = a._dirtyFlag, f = e & c.opacityDirty; e & c.colorDirty && a._updateDisplayColor(); f && a._updateDisplayOpacity(); d & c.transformDirty && this.transform(this.getParentRenderCmd(), !0); this._dirtyFlag = 0 } } })(); (function() { cc.ProgressTimer.WebGLRenderCmd = function(a) { cc.Node.WebGLRenderCmd.call(this, a); this._needDraw = !0; this._vertexWebGLBuffer = cc._renderContext.createBuffer(); this._vertexDataCount = 0; this._vertexArrayBuffer = this._vertexData = null; this._vertexDataDirty = !1 }; var a = cc.ProgressTimer.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); a.constructor = cc.ProgressTimer.WebGLRenderCmd; a.rendering = function(a) { var c = this._node; a = a || cc._renderContext; if (this._vertexData && c._sprite) { this._shaderProgram.use(); this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix); var d = c._sprite._blendFunc; cc.glBlendFunc(d.src, d.dst); cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); cc.glBindTexture2D(c._sprite.texture); a.bindBuffer(a.ARRAY_BUFFER, this._vertexWebGLBuffer); this._vertexDataDirty && (a.bufferData(a.ARRAY_BUFFER, this._vertexArrayBuffer, a.DYNAMIC_DRAW), this._vertexDataDirty = !1); d = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT; a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, a.FLOAT, !1, d, 0); a.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, a.UNSIGNED_BYTE, !0, d, 8); a.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, a.FLOAT, !1, d, 12); c._type === cc.ProgressTimer.TYPE_RADIAL ? a.drawArrays(a.TRIANGLE_FAN, 0, this._vertexDataCount) : c._type === cc.ProgressTimer.TYPE_BAR && (c._reverseDirection ? (a.drawArrays(a.TRIANGLE_STRIP, 0, this._vertexDataCount / 2), a.drawArrays(a.TRIANGLE_STRIP, 4, this._vertexDataCount / 2), cc.g_NumberOfDraws++) : a.drawArrays(a.TRIANGLE_STRIP, 0, this._vertexDataCount)); cc.g_NumberOfDraws++ } }; a._syncStatus = function(a) { var c = this._node; if (c._sprite) { var d = cc.Node._dirtyFlags, e = this._dirtyFlag, f = a ? a._node : null; f && f._cascadeColorEnabled && a._dirtyFlag & d.colorDirty && (e |= d.colorDirty); f && f._cascadeOpacityEnabled && a._dirtyFlag & d.opacityDirty && (e |= d.opacityDirty); a && a._dirtyFlag & d.transformDirty && (e |= d.transformDirty); this._dirtyFlag = e; c = c._sprite._renderCmd; f = c._dirtyFlag; e = f & d.colorDirty; d = f & d.opacityDirty; e && c._syncDisplayColor(); d && c._syncDisplayOpacity(); if (e || d) c._updateColor(), this._updateColor(); this.transform(a); c._dirtyFlag = 0 } }; a.updateStatus = function() { var a = this._node; if (a._sprite) { var c = cc.Node._dirtyFlags, d = this._dirtyFlag, a = a._sprite._renderCmd, e = a._dirtyFlag, f = e & c.colorDirty, e = e & c.opacityDirty; f && (a._updateDisplayColor(), this._dirtyFlag ^= this._dirtyFlag & c.colorDirty); e && (a._updateDisplayOpacity(), this._dirtyFlag ^= this._dirtyFlag & c.opacityDirty); if (f || e) a._updateColor(), this._updateColor(); d & c.transformDirty && this.transform(this.getParentRenderCmd(), !0) } }; a.releaseData = function() { this._vertexData && (this._vertexArrayBuffer = this._vertexData = null, this._vertexDataCount = 0) }; a.initCmd = function() { this._vertexArrayBuffer = this._vertexData = null; this._vertexDataCount = 0; this._shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR) }; a._updateProgress = function() { var a = this._node._type; a === cc.ProgressTimer.TYPE_RADIAL ? this._updateRadial() : a === cc.ProgressTimer.TYPE_BAR && this._updateBar(); this._vertexDataDirty = !0 }; a._updateBar = function() { var a = this._node; if (a._sprite) { var c, d = a._percentage / 100; c = a._barChangeRate; c = cc.pMult(cc.p(1 - c.x + d * c.x, 1 - c.y + d * c.y), 0.5); d = cc.pSub(a._midPoint, c); a = cc.pAdd(a._midPoint, c); 0 > d.x && (a.x += -d.x, d.x = 0); 1 < a.x && (d.x -= a.x - 1, a.x = 1); 0 > d.y && (a.y += -d.y, d.y = 0); 1 < a.y && (d.y -= a.y - 1, a.y = 1); if (this._reverseDirection) { if (!this._vertexData) { this._vertexDataCount = 8; var e = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT; this._vertexArrayBuffer = new ArrayBuffer(8 * e); var f = []; for (c = 0; 8 > c; c++) f[c] = new cc.V2F_C4B_T2F(null, null, null, this._vertexArrayBuffer, c * e); f[0].texCoords = this._textureCoordFromAlphaPoint(cc.p(0, 1)); f[0].vertices = this._vertexFromAlphaPoint(cc.p(0, 1)); f[1].texCoords = this._textureCoordFromAlphaPoint(cc.p(0, 0)); f[1].vertices = this._vertexFromAlphaPoint(cc.p(0, 0)); f[6].texCoords = this._textureCoordFromAlphaPoint(cc.p(1, 1)); f[6].vertices = this._vertexFromAlphaPoint(cc.p(1, 1)); f[7].texCoords = this._textureCoordFromAlphaPoint(cc.p(1, 0)); f[7].vertices = this._vertexFromAlphaPoint(cc.p(1, 0)); this._vertexData = f } c = this._vertexData; c[2].texCoords = this._textureCoordFromAlphaPoint(cc.p(d.x, a.y)); c[2].vertices = this._vertexFromAlphaPoint(cc.p(d.x, a.y)); c[3].texCoords = this._textureCoordFromAlphaPoint(cc.p(d.x, d.y)); c[3].vertices = this._vertexFromAlphaPoint(cc.p(d.x, d.y)); c[4].texCoords = this._textureCoordFromAlphaPoint(cc.p(a.x, a.y)); c[4].vertices = this._vertexFromAlphaPoint(cc.p(a.x, a.y)); c[5].texCoords = this._textureCoordFromAlphaPoint(cc.p(a.x, d.y)); c[5].vertices = this._vertexFromAlphaPoint(cc.p(a.x, d.y)) } else { if (!this._vertexData) for (this._vertexDataCount = 4, e = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT, this._vertexArrayBuffer = new ArrayBuffer(4 * e), this._vertexData = [], c = 0; 4 > c; c++) this._vertexData[c] = new cc.V2F_C4B_T2F(null, null, null, this._vertexArrayBuffer, c * e); c = this._vertexData; c[0].texCoords = this._textureCoordFromAlphaPoint(cc.p(d.x, a.y)); c[0].vertices = this._vertexFromAlphaPoint(cc.p(d.x, a.y)); c[1].texCoords = this._textureCoordFromAlphaPoint(cc.p(d.x, d.y)); c[1].vertices = this._vertexFromAlphaPoint(cc.p(d.x, d.y)); c[2].texCoords = this._textureCoordFromAlphaPoint(cc.p(a.x, a.y)); c[2].vertices = this._vertexFromAlphaPoint(cc.p(a.x, a.y)); c[3].texCoords = this._textureCoordFromAlphaPoint(cc.p(a.x, d.y)); c[3].vertices = this._vertexFromAlphaPoint(cc.p(a.x, d.y)) } this._updateColor() } }; a._updateRadial = function() { var a = this._node; if (a._sprite) { var c, d = a._midPoint; c = a._percentage / 100; var e = 2 * cc.PI * (a._reverseDirection ? c : 1 - c), a = cc.p(d.x, 1), f = cc.pRotateByAngle(a, d, e), e = 0; if (0 === c) f = a, e = 0; else if (1 === c) f = a, e = 4; else { var g = cc.FLT_MAX, h = cc.ProgressTimer.TEXTURE_COORDS_COUNT; for (c = 0; c <= h; ++c) { var k = (c + (h - 1)) % h, m = this._boundaryTexCoord(c % h), k = this._boundaryTexCoord(k); 0 === c ? k = cc.pLerp(m, k, 1 - d.x) : 4 === c && (m = cc.pLerp(m, k, 1 - d.x)); var n = cc.p(0, 0); cc.pLineIntersect(m, k, d, f, n) && (0 !== c && 4 !== c || 0 <= n.x && 1 >= n.x) && 0 <= n.y && n.y < g && (g = n.y, e = c) } f = cc.pAdd(d, cc.pMult(cc.pSub(f, d), g)) } g = !0; this._vertexDataCount !== e + 3 && (g = !1, this._vertexArrayBuffer = this._vertexData = null, this._vertexDataCount = 0); if (!this._vertexData) { h = this._vertexDataCount = e + 3; m = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT; this._vertexArrayBuffer = new ArrayBuffer(h * m); k = []; for (c = 0; c < h; c++) k[c] = new cc.V2F_C4B_T2F(null, null, null, this._vertexArrayBuffer, c * m); this._vertexData = k; if (!this._vertexData) { cc.log("cc.ProgressTimer._updateRadial() : Not enough memory"); return } } this._updateColor(); h = this._vertexData; if (!g) for (h[0].texCoords = this._textureCoordFromAlphaPoint(d), h[0].vertices = this._vertexFromAlphaPoint(d), h[1].texCoords = this._textureCoordFromAlphaPoint(a), h[1].vertices = this._vertexFromAlphaPoint(a), c = 0; c < e; c++) d = this._boundaryTexCoord(c), h[c + 2].texCoords = this._textureCoordFromAlphaPoint(d), h[c + 2].vertices = this._vertexFromAlphaPoint(d); h[this._vertexDataCount - 1].texCoords = this._textureCoordFromAlphaPoint(f); h[this._vertexDataCount - 1].vertices = this._vertexFromAlphaPoint(f) } }; a._boundaryTexCoord = function(a) { if (a < cc.ProgressTimer.TEXTURE_COORDS_COUNT) { var c = cc.ProgressTimer.TEXTURE_COORDS; return this._node._reverseDirection ? cc.p(c >> 7 - (a << 1) & 1, c >> 7 - ((a << 1) + 1) & 1) : cc.p(c >> (a << 1) + 1 & 1, c >> (a << 1) & 1) } return cc.p(0, 0) }; a._textureCoordFromAlphaPoint = function(a) { var c = this._node._sprite; if (!c) return { u: 0, v: 0 }; var d = c.quad, e = cc.p(d.bl.texCoords.u, d.bl.texCoords.v), d = cc.p(d.tr.texCoords.u, d.tr.texCoords.v); c.textureRectRotated && (c = a.x, a.x = a.y, a.y = c); return { u: e.x * (1 - a.x) + d.x * a.x, v: e.y * (1 - a.y) + d.y * a.y } }; a._vertexFromAlphaPoint = function(a) { var c = this._node._sprite; if (!c) return { x: 0, y: 0 }; var d = c.quad, c = cc.p(d.bl.vertices.x, d.bl.vertices.y), d = cc.p(d.tr.vertices.x, d.tr.vertices.y); return { x: c.x * (1 - a.x) + d.x * a.x, y: c.y * (1 - a.y) + d.y * a.y } }; a._updateColor = function() { var a = this._node; if (a._sprite && this._vertexData) { for (var a = a._sprite.quad.tl.colors, c = this._vertexData, d = 0, e = this._vertexDataCount; d < e; ++d) c[d].colors = a; this._vertexDataDirty = !0 } } })(); cc.SCENE_FADE = 4208917214; cc.TRANSITION_ORIENTATION_LEFT_OVER = 0; cc.TRANSITION_ORIENTATION_RIGHT_OVER = 1; cc.TRANSITION_ORIENTATION_UP_OVER = 0; cc.TRANSITION_ORIENTATION_DOWN_OVER = 1; cc.TransitionScene = cc.Scene.extend({ _inScene: null, _outScene: null, _duration: null, _isInSceneOnTop: !1, _isSendCleanupToScene: !1, _className: "TransitionScene", ctor: function(a, b) { cc.Scene.prototype.ctor.call(this); void 0 !== a && void 0 !== b && this.initWithDuration(a, b) }, _setNewScene: function(a) { this.unschedule(this._setNewScene); a = cc.director; this._isSendCleanupToScene = a.isSendCleanupToScene(); a.runScene(this._inScene); cc.eventManager.setEnabled(!0); this._outScene.visible = !0 }, _sceneOrder: function() { this._isInSceneOnTop = !0 }, visit: function() { this._isInSceneOnTop ? (this._outScene.visit(), this._inScene.visit()) : (this._inScene.visit(), this._outScene.visit()); cc.Node.prototype.visit.call(this) }, onEnter: function() { cc.Node.prototype.onEnter.call(this); cc.eventManager.setEnabled(!1); this._outScene.onExitTransitionDidStart(); this._inScene.onEnter() }, onExit: function() { cc.Node.prototype.onExit.call(this); cc.eventManager.setEnabled(!0); this._outScene.onExit(); this._inScene.onEnterTransitionDidFinish() }, cleanup: function() { cc.Node.prototype.cleanup.call(this); this._isSendCleanupToScene && this._outScene.cleanup() }, initWithDuration: function(a, b) { if (!b) throw "cc.TransitionScene.initWithDuration(): Argument scene must be non-nil"; if (this.init()) { this._duration = a; this.attr({ x: 0, y: 0, anchorX: 0, anchorY: 0 }); this._inScene = b; this._outScene = cc.director.getRunningScene(); this._outScene || (this._outScene = new cc.Scene, this._outScene.init()); if (this._inScene === this._outScene) throw "cc.TransitionScene.initWithDuration(): Incoming scene must be different from the outgoing scene"; this._sceneOrder(); return !0 } return !1 }, finish: function() { this._inScene.attr({ visible: !0, x: 0, y: 0, scale: 1, rotation: 0 }); cc._renderType === cc._RENDER_TYPE_WEBGL && this._inScene.getCamera().restore(); this._outScene.attr({ visible: !1, x: 0, y: 0, scale: 1, rotation: 0 }); cc._renderType === cc._RENDER_TYPE_WEBGL && this._outScene.getCamera().restore(); this.schedule(this._setNewScene, 0) }, hideOutShowIn: function() { this._inScene.visible = !0; this._outScene.visible = !1 } }); cc.TransitionScene.create = function(a, b) { return new cc.TransitionScene(a, b) }; cc.TransitionSceneOriented = cc.TransitionScene.extend({ _orientation: 0, ctor: function(a, b, c) { cc.TransitionScene.prototype.ctor.call(this); void 0 != c && this.initWithDuration(a, b, c) }, initWithDuration: function(a, b, c) { cc.TransitionScene.prototype.initWithDuration.call(this, a, b) && (this._orientation = c); return !0 } }); cc.TransitionSceneOriented.create = function(a, b, c) { return new cc.TransitionSceneOriented(a, b, c) }; cc.TransitionRotoZoom = cc.TransitionScene.extend({ ctor: function(a, b) { cc.TransitionScene.prototype.ctor.call(this); b && this.initWithDuration(a, b) }, onEnter: function() { cc.TransitionScene.prototype.onEnter.call(this); this._inScene.attr({ scale: 0.001, anchorX: 0.5, anchorY: 0.5 }); this._outScene.attr({ scale: 1, anchorX: 0.5, anchorY: 0.5 }); var a = cc.sequence(cc.spawn(cc.scaleBy(this._duration / 2, 0.001), cc.rotateBy(this._duration / 2, 720)), cc.delayTime(this._duration / 2)); this._outScene.runAction(a); this._inScene.runAction(cc.sequence(a.reverse(), cc.callFunc(this.finish, this))) } }); cc.TransitionRotoZoom.create = function(a, b) { return new cc.TransitionRotoZoom(a, b) }; cc.TransitionJumpZoom = cc.TransitionScene.extend({ ctor: function(a, b) { cc.TransitionScene.prototype.ctor.call(this); b && this.initWithDuration(a, b) }, onEnter: function() { cc.TransitionScene.prototype.onEnter.call(this); var a = cc.director.getWinSize(); this._inScene.attr({ scale: 0.5, x: a.width, y: 0, anchorX: 0.5, anchorY: 0.5 }); this._outScene.anchorX = 0.5; this._outScene.anchorY = 0.5; var b = cc.jumpBy(this._duration / 4, cc.p(-a.width, 0), a.width / 4, 2), c = cc.scaleTo(this._duration / 4, 1), a = cc.scaleTo(this._duration / 4, 0.5), a = cc.sequence(a, b), b = cc.sequence(b, c), c = cc.delayTime(this._duration / 2); this._outScene.runAction(a); this._inScene.runAction(cc.sequence(c, b, cc.callFunc(this.finish, this))) } }); cc.TransitionJumpZoom.create = function(a, b) { return new cc.TransitionJumpZoom(a, b) }; cc.TransitionMoveInL = cc.TransitionScene.extend({ ctor: function(a, b) { cc.TransitionScene.prototype.ctor.call(this); b && this.initWithDuration(a, b) }, onEnter: function() { cc.TransitionScene.prototype.onEnter.call(this); this.initScenes(); var a = this.action(); this._inScene.runAction(cc.sequence(this.easeActionWithAction(a), cc.callFunc(this.finish, this))) }, initScenes: function() { this._inScene.setPosition(-cc.director.getWinSize().width, 0) }, action: function() { return cc.moveTo(this._duration, cc.p(0, 0)) }, easeActionWithAction: function(a) { return new cc.EaseOut(a, 2) } }); cc.TransitionMoveInL.create = function(a, b) { return new cc.TransitionMoveInL(a, b) }; cc.TransitionMoveInR = cc.TransitionMoveInL.extend({ ctor: function(a, b) { cc.TransitionMoveInL.prototype.ctor.call(this); b && this.initWithDuration(a, b) }, initScenes: function() { this._inScene.setPosition(cc.director.getWinSize().width, 0) } }); cc.TransitionMoveInR.create = function(a, b) { return new cc.TransitionMoveInR(a, b) }; cc.TransitionMoveInT = cc.TransitionMoveInL.extend({ ctor: function(a, b) { cc.TransitionMoveInL.prototype.ctor.call(this); b && this.initWithDuration(a, b) }, initScenes: function() { this._inScene.setPosition(0, cc.director.getWinSize().height) } }); cc.TransitionMoveInT.create = function(a, b) { return new cc.TransitionMoveInT(a, b) }; cc.TransitionMoveInB = cc.TransitionMoveInL.extend({ ctor: function(a, b) { cc.TransitionMoveInL.prototype.ctor.call(this); b && this.initWithDuration(a, b) }, initScenes: function() { this._inScene.setPosition(0, -cc.director.getWinSize().height) } }); cc.TransitionMoveInB.create = function(a, b) { return new cc.TransitionMoveInB(a, b) }; cc.ADJUST_FACTOR = 0.5; cc.TransitionSlideInL = cc.TransitionScene.extend({ ctor: function(a, b) { cc.TransitionScene.prototype.ctor.call(this); b && this.initWithDuration(a, b) }, _sceneOrder: function() { this._isInSceneOnTop = !1 }, onEnter: function() { cc.TransitionScene.prototype.onEnter.call(this); this.initScenes(); var a = this.action(), b = this.action(), a = this.easeActionWithAction(a), b = cc.sequence(this.easeActionWithAction(b), cc.callFunc(this.finish, this)); this._inScene.runAction(a); this._outScene.runAction(b) }, initScenes: function() { this._inScene.setPosition(-cc.director.getWinSize().width + cc.ADJUST_FACTOR, 0) }, action: function() { return cc.moveBy(this._duration, cc.p(cc.director.getWinSize().width - cc.ADJUST_FACTOR, 0)) }, easeActionWithAction: function(a) { return new cc.EaseInOut(a, 2) } }); cc.TransitionSlideInL.create = function(a, b) { return new cc.TransitionSlideInL(a, b) }; cc.TransitionSlideInR = cc.TransitionSlideInL.extend({ ctor: function(a, b) { cc.TransitionSlideInL.prototype.ctor.call(this); b && this.initWithDuration(a, b) }, _sceneOrder: function() { this._isInSceneOnTop = !0 }, initScenes: function() { this._inScene.setPosition(cc.director.getWinSize().width - cc.ADJUST_FACTOR, 0) }, action: function() { return cc.moveBy(this._duration, cc.p(-(cc.director.getWinSize().width - cc.ADJUST_FACTOR), 0)) } }); cc.TransitionSlideInR.create = function(a, b) { return new cc.TransitionSlideInR(a, b) }; cc.TransitionSlideInB = cc.TransitionSlideInL.extend({ ctor: function(a, b) { cc.TransitionSlideInL.prototype.ctor.call(this); b && this.initWithDuration(a, b) }, _sceneOrder: function() { this._isInSceneOnTop = !1 }, initScenes: function() { this._inScene.setPosition(0, -(cc.director.getWinSize().height - cc.ADJUST_FACTOR)) }, action: function() { return cc.moveBy(this._duration, cc.p(0, cc.director.getWinSize().height - cc.ADJUST_FACTOR)) } }); cc.TransitionSlideInB.create = function(a, b) { return new cc.TransitionSlideInB(a, b) }; cc.TransitionSlideInT = cc.TransitionSlideInL.extend({ ctor: function(a, b) { cc.TransitionSlideInL.prototype.ctor.call(this); b && this.initWithDuration(a, b) }, _sceneOrder: function() { this._isInSceneOnTop = !0 }, initScenes: function() { this._inScene.setPosition(0, cc.director.getWinSize().height - cc.ADJUST_FACTOR) }, action: function() { return cc.moveBy(this._duration, cc.p(0, -(cc.director.getWinSize().height - cc.ADJUST_FACTOR))) } }); cc.TransitionSlideInT.create = function(a, b) { return new cc.TransitionSlideInT(a, b) }; cc.TransitionShrinkGrow = cc.TransitionScene.extend({ ctor: function(a, b) { cc.TransitionScene.prototype.ctor.call(this); b && this.initWithDuration(a, b) }, onEnter: function() { cc.TransitionScene.prototype.onEnter.call(this); this._inScene.attr({ scale: 0.001, anchorX: 2 / 3, anchorY: 0.5 }); this._outScene.attr({ scale: 1, anchorX: 1 / 3, anchorY: 0.5 }); var a = cc.scaleTo(this._duration, 0.01), b = cc.scaleTo(this._duration, 1); this._inScene.runAction(this.easeActionWithAction(b)); this._outScene.runAction(cc.sequence(this.easeActionWithAction(a), cc.callFunc(this.finish, this))) }, easeActionWithAction: function(a) { return new cc.EaseOut(a, 2) } }); cc.TransitionShrinkGrow.create = function(a, b) { return new cc.TransitionShrinkGrow(a, b) }; cc.TransitionFlipX = cc.TransitionSceneOriented.extend({ ctor: function(a, b, c) { cc.TransitionSceneOriented.prototype.ctor.call(this); null == c && (c = cc.TRANSITION_ORIENTATION_RIGHT_OVER); b && this.initWithDuration(a, b, c) }, onEnter: function() { cc.TransitionScene.prototype.onEnter.call(this); var a, b; this._inScene.visible = !1; var c; this._orientation === cc.TRANSITION_ORIENTATION_RIGHT_OVER ? (a = 90, c = 270, b = 90) : (a = -90, c = 90, b = -90); a = cc.sequence(cc.delayTime(this._duration / 2), cc.show(), cc.orbitCamera(this._duration / 2, 1, 0, c, a, 0, 0), cc.callFunc(this.finish, this)); b = cc.sequence(cc.orbitCamera(this._duration / 2, 1, 0, 0, b, 0, 0), cc.hide(), cc.delayTime(this._duration / 2)); this._inScene.runAction(a); this._outScene.runAction(b) } }); cc.TransitionFlipX.create = function(a, b, c) { return new cc.TransitionFlipX(a, b, c) }; cc.TransitionFlipY = cc.TransitionSceneOriented.extend({ ctor: function(a, b, c) { cc.TransitionSceneOriented.prototype.ctor.call(this); null == c && (c = cc.TRANSITION_ORIENTATION_UP_OVER); b && this.initWithDuration(a, b, c) }, onEnter: function() { cc.TransitionScene.prototype.onEnter.call(this); var a, b; this._inScene.visible = !1; var c; this._orientation === cc.TRANSITION_ORIENTATION_UP_OVER ? (a = 90, c = 270, b = 90) : (a = -90, c = 90, b = -90); a = cc.sequence(cc.delayTime(this._duration / 2), cc.show(), cc.orbitCamera(this._duration / 2, 1, 0, c, a, 90, 0), cc.callFunc(this.finish, this)); b = cc.sequence(cc.orbitCamera(this._duration / 2, 1, 0, 0, b, 90, 0), cc.hide(), cc.delayTime(this._duration / 2)); this._inScene.runAction(a); this._outScene.runAction(b) } }); cc.TransitionFlipY.create = function(a, b, c) { return new cc.TransitionFlipY(a, b, c) }; cc.TransitionFlipAngular = cc.TransitionSceneOriented.extend({ ctor: function(a, b, c) { cc.TransitionSceneOriented.prototype.ctor.call(this); null == c && (c = cc.TRANSITION_ORIENTATION_RIGHT_OVER); b && this.initWithDuration(a, b, c) }, onEnter: function() { cc.TransitionScene.prototype.onEnter.call(this); var a, b; this._inScene.visible = !1; var c; this._orientation === cc.TRANSITION_ORIENTATION_RIGHT_OVER ? (a = 90, c = 270, b = 90) : (a = -90, c = 90, b = -90); a = cc.sequence(cc.delayTime(this._duration / 2), cc.show(), cc.orbitCamera(this._duration / 2, 1, 0, c, a, -45, 0), cc.callFunc(this.finish, this)); b = cc.sequence(cc.orbitCamera(this._duration / 2, 1, 0, 0, b, 45, 0), cc.hide(), cc.delayTime(this._duration / 2)); this._inScene.runAction(a); this._outScene.runAction(b) } }); cc.TransitionFlipAngular.create = function(a, b, c) { return new cc.TransitionFlipAngular(a, b, c) }; cc.TransitionZoomFlipX = cc.TransitionSceneOriented.extend({ ctor: function(a, b, c) { cc.TransitionSceneOriented.prototype.ctor.call(this); null == c && (c = cc.TRANSITION_ORIENTATION_RIGHT_OVER); b && this.initWithDuration(a, b, c) }, onEnter: function() { cc.TransitionScene.prototype.onEnter.call(this); var a, b; this._inScene.visible = !1; var c; this._orientation === cc.TRANSITION_ORIENTATION_RIGHT_OVER ? (a = 90, c = 270, b = 90) : (a = -90, c = 90, b = -90); a = cc.sequence(cc.delayTime(this._duration / 2), cc.spawn(cc.orbitCamera(this._duration / 2, 1, 0, c, a, 0, 0), cc.scaleTo(this._duration / 2, 1), cc.show()), cc.callFunc(this.finish, this)); b = cc.sequence(cc.spawn(cc.orbitCamera(this._duration / 2, 1, 0, 0, b, 0, 0), cc.scaleTo(this._duration / 2, 0.5)), cc.hide(), cc.delayTime(this._duration / 2)); this._inScene.scale = 0.5; this._inScene.runAction(a); this._outScene.runAction(b) } }); cc.TransitionZoomFlipX.create = function(a, b, c) { return new cc.TransitionZoomFlipX(a, b, c) }; cc.TransitionZoomFlipY = cc.TransitionSceneOriented.extend({ ctor: function(a, b, c) { cc.TransitionSceneOriented.prototype.ctor.call(this); null == c && (c = cc.TRANSITION_ORIENTATION_UP_OVER); b && this.initWithDuration(a, b, c) }, onEnter: function() { cc.TransitionScene.prototype.onEnter.call(this); var a, b; this._inScene.visible = !1; var c; this._orientation === cc.TRANSITION_ORIENTATION_UP_OVER ? (a = 90, c = 270, b = 90) : (a = -90, c = 90, b = -90); a = cc.sequence(cc.delayTime(this._duration / 2), cc.spawn(cc.orbitCamera(this._duration / 2, 1, 0, c, a, 90, 0), cc.scaleTo(this._duration / 2, 1), cc.show()), cc.callFunc(this.finish, this)); b = cc.sequence(cc.spawn(cc.orbitCamera(this._duration / 2, 1, 0, 0, b, 90, 0), cc.scaleTo(this._duration / 2, 0.5)), cc.hide(), cc.delayTime(this._duration / 2)); this._inScene.scale = 0.5; this._inScene.runAction(a); this._outScene.runAction(b) } }); cc.TransitionZoomFlipY.create = function(a, b, c) { return new cc.TransitionZoomFlipY(a, b, c) }; cc.TransitionZoomFlipAngular = cc.TransitionSceneOriented.extend({ ctor: function(a, b, c) { cc.TransitionSceneOriented.prototype.ctor.call(this); null == c && (c = cc.TRANSITION_ORIENTATION_RIGHT_OVER); b && this.initWithDuration(a, b, c) }, onEnter: function() { cc.TransitionScene.prototype.onEnter.call(this); var a, b; this._inScene.visible = !1; var c; this._orientation === cc.TRANSITION_ORIENTATION_RIGHT_OVER ? (a = 90, c = 270, b = 90) : (a = -90, c = 90, b = -90); a = cc.sequence(cc.delayTime(this._duration / 2), cc.spawn(cc.orbitCamera(this._duration / 2, 1, 0, c, a, -45, 0), cc.scaleTo(this._duration / 2, 1), cc.show()), cc.show(), cc.callFunc(this.finish, this)); b = cc.sequence(cc.spawn(cc.orbitCamera(this._duration / 2, 1, 0, 0, b, 45, 0), cc.scaleTo(this._duration / 2, 0.5)), cc.hide(), cc.delayTime(this._duration / 2)); this._inScene.scale = 0.5; this._inScene.runAction(a); this._outScene.runAction(b) } }); cc.TransitionZoomFlipAngular.create = function(a, b, c) { return new cc.TransitionZoomFlipAngular(a, b, c) }; cc.TransitionFade = cc.TransitionScene.extend({ _color: null, ctor: function(a, b, c) { cc.TransitionScene.prototype.ctor.call(this); this._color = cc.color(); b && this.initWithDuration(a, b, c) }, onEnter: function() { cc.TransitionScene.prototype.onEnter.call(this); var a = new cc.LayerColor(this._color); this._inScene.visible = !1; this.addChild(a, 2, cc.SCENE_FADE); var a = this.getChildByTag(cc.SCENE_FADE), b = cc.sequence(cc.fadeIn(this._duration / 2), cc.callFunc(this.hideOutShowIn, this), cc.fadeOut(this._duration / 2), cc.callFunc(this.finish, this)); a.runAction(b) }, onExit: function() { cc.TransitionScene.prototype.onExit.call(this); this.removeChildByTag(cc.SCENE_FADE, !1) }, initWithDuration: function(a, b, c) { c = c || cc.color.BLACK; cc.TransitionScene.prototype.initWithDuration.call(this, a, b) && (this._color.r = c.r, this._color.g = c.g, this._color.b = c.b, this._color.a = 0); return !0 } }); cc.TransitionFade.create = function(a, b, c) { return new cc.TransitionFade(a, b, c) }; cc.TransitionCrossFade = cc.TransitionScene.extend({ ctor: function(a, b) { cc.TransitionScene.prototype.ctor.call(this); b && this.initWithDuration(a, b) }, onEnter: function() { cc.TransitionScene.prototype.onEnter.call(this); var a = cc.color(0, 0, 0, 0), b = cc.director.getWinSize(), a = new cc.LayerColor(a), c = new cc.RenderTexture(b.width, b.height); c.sprite.anchorX = 0.5; c.sprite.anchorY = 0.5; c.attr({ x: b.width / 2, y: b.height / 2, anchorX: 0.5, anchorY: 0.5 }); c.begin(); this._inScene.visit(); c.end(); var d = new cc.RenderTexture(b.width, b.height); d.setPosition(b.width / 2, b.height / 2); d.sprite.anchorX = d.anchorX = 0.5; d.sprite.anchorY = d.anchorY = 0.5; d.begin(); this._outScene.visit(); d.end(); c.sprite.setBlendFunc(cc.ONE, cc.ONE); d.sprite.setBlendFunc(cc.SRC_ALPHA, cc.ONE_MINUS_SRC_ALPHA); a.addChild(c); a.addChild(d); c.sprite.opacity = 255; d.sprite.opacity = 255; b = cc.sequence(cc.fadeTo(this._duration, 0), cc.callFunc(this.hideOutShowIn, this), cc.callFunc(this.finish, this)); d.sprite.runAction(b); this.addChild(a, 2, cc.SCENE_FADE) }, onExit: function() { this.removeChildByTag(cc.SCENE_FADE, !1); cc.TransitionScene.prototype.onExit.call(this) }, visit: function() { cc.Node.prototype.visit.call(this) }, draw: function() {} }); cc.TransitionCrossFade.create = function(a, b) { return new cc.TransitionCrossFade(a, b) }; cc.TransitionTurnOffTiles = cc.TransitionScene.extend({ _gridProxy: null, ctor: function(a, b) { cc.TransitionScene.prototype.ctor.call(this); this._gridProxy = new cc.NodeGrid; b && this.initWithDuration(a, b) }, _sceneOrder: function() { this._isInSceneOnTop = !1 }, onEnter: function() { cc.TransitionScene.prototype.onEnter.call(this); this._gridProxy.setTarget(this._outScene); this._gridProxy.onEnter(); var a = cc.director.getWinSize(), a = cc.turnOffTiles(this._duration, cc.size(0 | a.width / a.height * 12, 12)), a = this.easeActionWithAction(a); this._gridProxy.runAction(cc.sequence(a, cc.callFunc(this.finish, this), cc.stopGrid())) }, visit: function() { this._inScene.visit(); this._gridProxy.visit() }, easeActionWithAction: function(a) { return a } }); cc.TransitionTurnOffTiles.create = function(a, b) { return new cc.TransitionTurnOffTiles(a, b) }; cc.TransitionSplitCols = cc.TransitionScene.extend({ _gridProxy: null, _switchTargetToInscene: function() { this._gridProxy.setTarget(this._inScene) }, ctor: function(a, b) { cc.TransitionScene.prototype.ctor.call(this); this._gridProxy = new cc.NodeGrid; b && this.initWithDuration(a, b) }, onEnter: function() { cc.TransitionScene.prototype.onEnter.call(this); this._gridProxy.setTarget(this._outScene); this._gridProxy.onEnter(); var a = this.action(), a = cc.sequence(a, cc.callFunc(this._switchTargetToInscene, this), a.reverse()); this._gridProxy.runAction(cc.sequence(this.easeActionWithAction(a), cc.callFunc(this.finish, this), cc.stopGrid())) }, onExit: function() { this._gridProxy.setTarget(null); this._gridProxy.onExit(); cc.TransitionScene.prototype.onExit.call(this) }, visit: function() { this._gridProxy.visit() }, easeActionWithAction: function(a) { return new cc.EaseInOut(a, 3) }, action: function() { return cc.splitCols(this._duration / 2, 3) } }); cc.TransitionSplitCols.create = function(a, b) { return new cc.TransitionSplitCols(a, b) }; cc.TransitionSplitRows = cc.TransitionSplitCols.extend({ ctor: function(a, b) { cc.TransitionSplitCols.prototype.ctor.call(this); b && this.initWithDuration(a, b) }, action: function() { return cc.splitRows(this._duration / 2, 3) } }); cc.TransitionSplitRows.create = function(a, b) { return new cc.TransitionSplitRows(a, b) }; cc.TransitionFadeTR = cc.TransitionScene.extend({ _gridProxy: null, ctor: function(a, b) { cc.TransitionScene.prototype.ctor.call(this); this._gridProxy = new cc.NodeGrid; b && this.initWithDuration(a, b) }, _sceneOrder: function() { this._isInSceneOnTop = !1 }, onEnter: function() { cc.TransitionScene.prototype.onEnter.call(this); this._gridProxy.setTarget(this._outScene); this._gridProxy.onEnter(); var a = cc.director.getWinSize(), a = this.actionWithSize(cc.size(0 | a.width / a.height * 12, 12)); this._gridProxy.runAction(cc.sequence(this.easeActionWithAction(a), cc.callFunc(this.finish, this), cc.stopGrid())) }, visit: function() { this._inScene.visit(); this._gridProxy.visit() }, easeActionWithAction: function(a) { return a }, actionWithSize: function(a) { return cc.fadeOutTRTiles(this._duration, a) } }); cc.TransitionFadeTR.create = function(a, b) { return new cc.TransitionFadeTR(a, b) }; cc.TransitionFadeBL = cc.TransitionFadeTR.extend({ ctor: function(a, b) { cc.TransitionFadeTR.prototype.ctor.call(this); b && this.initWithDuration(a, b) }, actionWithSize: function(a) { return cc.fadeOutBLTiles(this._duration, a) } }); cc.TransitionFadeBL.create = function(a, b) { return new cc.TransitionFadeBL(a, b) }; cc.TransitionFadeUp = cc.TransitionFadeTR.extend({ ctor: function(a, b) { cc.TransitionFadeTR.prototype.ctor.call(this); b && this.initWithDuration(a, b) }, actionWithSize: function(a) { return new cc.FadeOutUpTiles(this._duration, a) } }); cc.TransitionFadeUp.create = function(a, b) { return new cc.TransitionFadeUp(a, b) }; cc.TransitionFadeDown = cc.TransitionFadeTR.extend({ ctor: function(a, b) { cc.TransitionFadeTR.prototype.ctor.call(this); b && this.initWithDuration(a, b) }, actionWithSize: function(a) { return cc.fadeOutDownTiles(this._duration, a) } }); cc.TransitionFadeDown.create = function(a, b) { return new cc.TransitionFadeDown(a, b) }; cc.SCENE_RADIAL = 49153; cc.TransitionProgress = cc.TransitionScene.extend({ _to: 0, _from: 0, _sceneToBeModified: null, _className: "TransitionProgress", ctor: function(a, b) { cc.TransitionScene.prototype.ctor.call(this); b && this.initWithDuration(a, b) }, _setAttrs: function(a, b, c) { a.attr({ x: b, y: c, anchorX: 0.5, anchorY: 0.5 }) }, onEnter: function() { cc.TransitionScene.prototype.onEnter.call(this); this._setupTransition(); var a = cc.director.getWinSize(), b = new cc.RenderTexture(a.width, a.height); b.sprite.anchorX = 0.5; b.sprite.anchorY = 0.5; this._setAttrs(b, a.width / 2, a.height / 2); b.clear(0, 0, 0, 1); b.begin(); this._sceneToBeModified.visit(); b.end(); this._sceneToBeModified === this._outScene && this.hideOutShowIn(); a = this._progressTimerNodeWithRenderTexture(b); b = cc.sequence(cc.progressFromTo(this._duration, this._from, this._to), cc.callFunc(this.finish, this)); a.runAction(b); this.addChild(a, 2, cc.SCENE_RADIAL) }, onExit: function() { this.removeChildByTag(cc.SCENE_RADIAL, !0); cc.TransitionScene.prototype.onExit.call(this) }, _setupTransition: function() { this._sceneToBeModified = this._outScene; this._from = 100; this._to = 0 }, _progressTimerNodeWithRenderTexture: function(a) { cc.log("cc.TransitionProgress._progressTimerNodeWithRenderTexture(): should be overridden in subclass"); return null }, _sceneOrder: function() { this._isInSceneOnTop = !1 } }); cc.TransitionProgress.create = function(a, b) { return new cc.TransitionProgress(a, b) }; cc.TransitionProgressRadialCCW = cc.TransitionProgress.extend({ ctor: function(a, b) { cc.TransitionProgress.prototype.ctor.call(this); b && this.initWithDuration(a, b) }, _progressTimerNodeWithRenderTexture: function(a) { var b = cc.director.getWinSize(); a = new cc.ProgressTimer(a.sprite); cc._renderType === cc._RENDER_TYPE_WEBGL && (a.sprite.flippedY = !0); a.type = cc.ProgressTimer.TYPE_RADIAL; a.reverseDir = !1; a.percentage = 100; this._setAttrs(a, b.width / 2, b.height / 2); return a } }); cc.TransitionProgressRadialCCW.create = function(a, b) { return new cc.TransitionProgressRadialCCW(a, b) }; cc.TransitionProgressRadialCW = cc.TransitionProgress.extend({ ctor: function(a, b) { cc.TransitionProgress.prototype.ctor.call(this); b && this.initWithDuration(a, b) }, _progressTimerNodeWithRenderTexture: function(a) { var b = cc.director.getWinSize(); a = new cc.ProgressTimer(a.sprite); cc._renderType === cc._RENDER_TYPE_WEBGL && (a.sprite.flippedY = !0); a.type = cc.ProgressTimer.TYPE_RADIAL; a.reverseDir = !0; a.percentage = 100; this._setAttrs(a, b.width / 2, b.height / 2); return a } }); cc.TransitionProgressRadialCW.create = function(a, b) { var c = new cc.TransitionProgressRadialCW; return null !== c && c.initWithDuration(a, b) ? c : new cc.TransitionProgressRadialCW(a, b) }; cc.TransitionProgressHorizontal = cc.TransitionProgress.extend({ ctor: function(a, b) { cc.TransitionProgress.prototype.ctor.call(this); b && this.initWithDuration(a, b) }, _progressTimerNodeWithRenderTexture: function(a) { var b = cc.director.getWinSize(); a = new cc.ProgressTimer(a.sprite); cc._renderType === cc._RENDER_TYPE_WEBGL && (a.sprite.flippedY = !0); a.type = cc.ProgressTimer.TYPE_BAR; a.midPoint = cc.p(1, 0); a.barChangeRate = cc.p(1, 0); a.percentage = 100; this._setAttrs(a, b.width / 2, b.height / 2); return a } }); cc.TransitionProgressHorizontal.create = function(a, b) { return new cc.TransitionProgressHorizontal(a, b) }; cc.TransitionProgressVertical = cc.TransitionProgress.extend({ ctor: function(a, b) { cc.TransitionProgress.prototype.ctor.call(this); b && this.initWithDuration(a, b) }, _progressTimerNodeWithRenderTexture: function(a) { var b = cc.director.getWinSize(); a = new cc.ProgressTimer(a.sprite); cc._renderType === cc._RENDER_TYPE_WEBGL && (a.sprite.flippedY = !0); a.type = cc.ProgressTimer.TYPE_BAR; a.midPoint = cc.p(0, 0); a.barChangeRate = cc.p(0, 1); a.percentage = 100; this._setAttrs(a, b.width / 2, b.height / 2); return a } }); cc.TransitionProgressVertical.create = function(a, b) { return new cc.TransitionProgressVertical(a, b) }; cc.TransitionProgressInOut = cc.TransitionProgress.extend({ ctor: function(a, b) { cc.TransitionProgress.prototype.ctor.call(this); b && this.initWithDuration(a, b) }, _progressTimerNodeWithRenderTexture: function(a) { var b = cc.director.getWinSize(); a = new cc.ProgressTimer(a.sprite); cc._renderType === cc._RENDER_TYPE_WEBGL && (a.sprite.flippedY = !0); a.type = cc.ProgressTimer.TYPE_BAR; a.midPoint = cc.p(0.5, 0.5); a.barChangeRate = cc.p(1, 1); a.percentage = 0; this._setAttrs(a, b.width / 2, b.height / 2); return a }, _sceneOrder: function() { this._isInSceneOnTop = !1 }, _setupTransition: function() { this._sceneToBeModified = this._inScene; this._from = 0; this._to = 100 } }); cc.TransitionProgressInOut.create = function(a, b) { return new cc.TransitionProgressInOut(a, b) }; cc.TransitionProgressOutIn = cc.TransitionProgress.extend({ ctor: function(a, b) { cc.TransitionProgress.prototype.ctor.call(this); b && this.initWithDuration(a, b) }, _progressTimerNodeWithRenderTexture: function(a) { var b = cc.director.getWinSize(); a = new cc.ProgressTimer(a.sprite); cc._renderType === cc._RENDER_TYPE_WEBGL && (a.sprite.flippedY = !0); a.type = cc.ProgressTimer.TYPE_BAR; a.midPoint = cc.p(0.5, 0.5); a.barChangeRate = cc.p(1, 1); a.percentage = 100; this._setAttrs(a, b.width / 2, b.height / 2); return a } }); cc.TransitionProgressOutIn.create = function(a, b) { return new cc.TransitionProgressOutIn(a, b) }; cc.TransitionPageTurn = cc.TransitionScene.extend({ ctor: function(a, b, c) { cc.TransitionScene.prototype.ctor.call(this); this._gridProxy = new cc.NodeGrid; this.initWithDuration(a, b, c) }, _back: !0, _gridProxy: null, _className: "TransitionPageTurn", initWithDuration: function(a, b, c) { this._back = c; cc.TransitionScene.prototype.initWithDuration.call(this, a, b); return !0 }, actionWithSize: function(a) { return this._back ? cc.reverseTime(cc.pageTurn3D(this._duration, a)) : cc.pageTurn3D(this._duration, a) }, onEnter: function() { cc.TransitionScene.prototype.onEnter.call(this); var a = cc.director.getWinSize(), b; a.width > a.height ? (a = 16, b = 12) : (a = 12, b = 16); a = this.actionWithSize(cc.size(a, b)); b = this._gridProxy; this._back ? (b.setTarget(this._inScene), b.onEnter(), this._inScene.visible = !1, b.runAction(cc.sequence(a, cc.callFunc(this.finish, this), cc.stopGrid())), this._inScene.runAction(cc.show())) : (b.setTarget(this._outScene), b.onEnter(), b.runAction(cc.sequence(a, cc.callFunc(this.finish, this), cc.stopGrid()))) }, visit: function() { this._back ? this._outScene.visit() : this._inScene.visit(); this._gridProxy.visit() }, _sceneOrder: function() { this._isInSceneOnTop = this._back } }); cc.TransitionPageTurn.create = function(a, b, c) { return new cc.TransitionPageTurn(a, b, c) }; cc.Codec = { name: "Jacob__Codec" }; cc.unzip = function() { return cc.Codec.GZip.gunzip.apply(cc.Codec.GZip, arguments) }; cc.unzipBase64 = function() { var a = cc.Codec.Base64.decode.apply(cc.Codec.Base64, arguments); return cc.Codec.GZip.gunzip.apply(cc.Codec.GZip, [a]) }; cc.unzipBase64AsArray = function(a, b) { b = b || 1; var c = this.unzipBase64(a), d = [], e, f, g; e = 0; for (g = c.length / b; e < g; e++) for (d[e] = 0, f = b - 1; 0 <= f; --f) d[e] += c.charCodeAt(e * b + f) << 8 * f; return d }; cc.unzipAsArray = function(a, b) { b = b || 1; var c = this.unzip(a), d = [], e, f, g; e = 0; for (g = c.length / b; e < g; e++) for (d[e] = 0, f = b - 1; 0 <= f; --f) d[e] += c.charCodeAt(e * b + f) << 8 * f; return d }; cc.StringToArray = function(a) { a = a.split(","); var b = [], c; for (c = 0; c < a.length; c++) b.push(parseInt(a[c])); return b }; cc.Codec.Base64 = { name: "Jacob__Codec__Base64" }; cc.Codec.Base64._keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\x3d"; cc.Codec.Base64.decode = function(a) { var b = [], c, d, e, f, g, h = 0; for (a = a.replace(/[^A-Za-z0-9\+\/\=]/g, ""); h < a.length;) c = this._keyStr.indexOf(a.charAt(h++)), d = this._keyStr.indexOf(a.charAt(h++)), f = this._keyStr.indexOf(a.charAt(h++)), g = this._keyStr.indexOf(a.charAt(h++)), c = c << 2 | d >> 4, d = (d & 15) << 4 | f >> 2, e = (f & 3) << 6 | g, b.push(String.fromCharCode(c)), 64 !== f && b.push(String.fromCharCode(d)), 64 !== g && b.push(String.fromCharCode(e)); return b = b.join("") }; cc.Codec.Base64.decodeAsArray = function(a, b) { var c = this.decode(a), d = [], e, f, g; e = 0; for (g = c.length / b; e < g; e++) for (d[e] = 0, f = b - 1; 0 <= f; --f) d[e] += c.charCodeAt(e * b + f) << 8 * f; return d }; cc.uint8ArrayToUint32Array = function(a) { if (0 !== a.length % 4) return null; for (var b = a.length / 4, c = window.Uint32Array ? new Uint32Array(b) : [], d = 0; d < b; d++) { var e = 4 * d; c[d] = a[e] + 256 * a[e + 1] + 65536 * a[e + 2] + 16777216 * a[e + 3] } return c }; cc.Codec.GZip = function(a) { this.data = a; this.debug = !1; this.gpflags = void 0; this.files = 0; this.unzipped = []; this.buf32k = Array(32768); this.bIdx = 0; this.modeZIP = !1; this.bytepos = 0; this.bb = 1; this.bits = 0; this.nameBuf = []; this.fileout = void 0; this.literalTree = Array(cc.Codec.GZip.LITERALS); this.distanceTree = Array(32); this.treepos = 0; this.Places = null; this.len = 0; this.fpos = Array(17); this.fpos[0] = 0; this.fmax = this.flens = void 0 }; cc.Codec.GZip.gunzip = function(a) { return (new cc.Codec.GZip(a)).gunzip()[0][0] }; cc.Codec.GZip.HufNode = function() { this.b1 = this.b0 = 0; this.jump = null; this.jumppos = -1 }; cc.Codec.GZip.LITERALS = 288; cc.Codec.GZip.NAMEMAX = 256; cc.Codec.GZip.bitReverse = [0, 128, 64, 192, 32, 160, 96, 224, 16, 144, 80, 208, 48, 176, 112, 240, 8, 136, 72, 200, 40, 168, 104, 232, 24, 152, 88, 216, 56, 184, 120, 248, 4, 132, 68, 196, 36, 164, 100, 228, 20, 148, 84, 212, 52, 180, 116, 244, 12, 140, 76, 204, 44, 172, 108, 236, 28, 156, 92, 220, 60, 188, 124, 252, 2, 130, 66, 194, 34, 162, 98, 226, 18, 146, 82, 210, 50, 178, 114, 242, 10, 138, 74, 202, 42, 170, 106, 234, 26, 154, 90, 218, 58, 186, 122, 250, 6, 134, 70, 198, 38, 166, 102, 230, 22, 150, 86, 214, 54, 182, 118, 246, 14, 142, 78, 206, 46, 174, 110, 238, 30, 158, 94, 222, 62, 190, 126, 254, 1, 129, 65, 193, 33, 161, 97, 225, 17, 145, 81, 209, 49, 177, 113, 241, 9, 137, 73, 201, 41, 169, 105, 233, 25, 153, 89, 217, 57, 185, 121, 249, 5, 133, 69, 197, 37, 165, 101, 229, 21, 149, 85, 213, 53, 181, 117, 245, 13, 141, 77, 205, 45, 173, 109, 237, 29, 157, 93, 221, 61, 189, 125, 253, 3, 131, 67, 195, 35, 163, 99, 227, 19, 147, 83, 211, 51, 179, 115, 243, 11, 139, 75, 203, 43, 171, 107, 235, 27, 155, 91, 219, 59, 187, 123, 251, 7, 135, 71, 199, 39, 167, 103, 231, 23, 151, 87, 215, 55, 183, 119, 247, 15, 143, 79, 207, 47, 175, 111, 239, 31, 159, 95, 223, 63, 191, 127, 255 ]; cc.Codec.GZip.cplens = [3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0]; cc.Codec.GZip.cplext = [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 99, 99]; cc.Codec.GZip.cpdist = [1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577]; cc.Codec.GZip.cpdext = [0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13]; cc.Codec.GZip.border = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]; cc.Codec.GZip.prototype.gunzip = function() { this.outputArr = []; this.nextFile(); return this.unzipped }; cc.Codec.GZip.prototype.readByte = function() { this.bits += 8; return this.bytepos < this.data.length ? this.data.charCodeAt(this.bytepos++) : -1 }; cc.Codec.GZip.prototype.byteAlign = function() { this.bb = 1 }; cc.Codec.GZip.prototype.readBit = function() { var a; this.bits++; a = this.bb & 1; this.bb >>= 1; 0 === this.bb && (this.bb = this.readByte(), a = this.bb & 1, this.bb = this.bb >> 1 | 128); return a }; cc.Codec.GZip.prototype.readBits = function(a) { for (var b = 0, c = a; c--;) b = b << 1 | this.readBit(); a && (b = cc.Codec.GZip.bitReverse[b] >> 8 - a); return b }; cc.Codec.GZip.prototype.flushBuffer = function() { this.bIdx = 0 }; cc.Codec.GZip.prototype.addBuffer = function(a) { this.buf32k[this.bIdx++] = a; this.outputArr.push(String.fromCharCode(a)); 32768 === this.bIdx && (this.bIdx = 0) }; cc.Codec.GZip.prototype.IsPat = function() { for (;;) { if (this.fpos[this.len] >= this.fmax) return -1; if (this.flens[this.fpos[this.len]] === this.len) return this.fpos[this.len]++; this.fpos[this.len]++ } }; cc.Codec.GZip.prototype.Rec = function() { var a = this.Places[this.treepos], b; if (17 === this.len) return -1; this.treepos++; this.len++; b = this.IsPat(); if (0 <= b) a.b0 = b; else if (a.b0 = 32768, this.Rec()) return -1; b = this.IsPat(); if (0 <= b) a.b1 = b, a.jump = null; else if (a.b1 = 32768, a.jump = this.Places[this.treepos], a.jumppos = this.treepos, this.Rec()) return -1; this.len--; return 0 }; cc.Codec.GZip.prototype.CreateTree = function(a, b, c, d) { this.Places = a; this.treepos = 0; this.flens = c; this.fmax = b; for (a = 0; 17 > a; a++) this.fpos[a] = 0; this.len = 0; return this.Rec() ? -1 : 0 }; cc.Codec.GZip.prototype.DecodeValue = function(a) { for (var b, c, d = 0, e = a[d];;) if (b = this.readBit()) { if (!(e.b1 & 32768)) return e.b1; e = e.jump; b = a.length; for (c = 0; c < b; c++) if (a[c] === e) { d = c; break } } else { if (!(e.b0 & 32768)) return e.b0; d++; e = a[d] } return -1 }; cc.Codec.GZip.prototype.DeflateLoop = function() { var a, b, c, d, e; do if (a = this.readBit(), c = this.readBits(2), 0 === c) for (this.byteAlign(), c = this.readByte(), c |= this.readByte() << 8, b = this.readByte(), b |= this.readByte() << 8, (c ^ ~b) & 65535 && document.write("BlockLen checksum mismatch\n"); c--;) b = this.readByte(), this.addBuffer(b); else if (1 === c) for (;;) if (c = cc.Codec.GZip.bitReverse[this.readBits(7)] >> 1, 23 < c ? (c = c << 1 | this.readBit(), 199 < c ? (c -= 128, c = c << 1 | this.readBit()) : (c -= 48, 143 < c && (c += 136))) : c += 256, 256 > c) this.addBuffer(c); else if (256 === c) break; else { var f; c -= 257; e = this.readBits(cc.Codec.GZip.cplext[c]) + cc.Codec.GZip.cplens[c]; c = cc.Codec.GZip.bitReverse[this.readBits(5)] >> 3; 8 < cc.Codec.GZip.cpdext[c] ? (f = this.readBits(8), f |= this.readBits(cc.Codec.GZip.cpdext[c] - 8) << 8) : f = this.readBits(cc.Codec.GZip.cpdext[c]); f += cc.Codec.GZip.cpdist[c]; for (c = 0; c < e; c++) b = this.buf32k[this.bIdx - f & 32767], this.addBuffer(b) } else if (2 === c) { var g = Array(320); b = 257 + this.readBits(5); f = 1 + this.readBits(5); d = 4 + this.readBits(4); for (c = 0; 19 > c; c++) g[c] = 0; for (c = 0; c < d; c++) g[cc.Codec.GZip.border[c]] = this.readBits(3); e = this.distanceTree.length; for (d = 0; d < e; d++) this.distanceTree[d] = new cc.Codec.GZip.HufNode; if (this.CreateTree(this.distanceTree, 19, g, 0)) return this.flushBuffer(), 1; e = b + f; d = 0; for (var h = -1; d < e;) if (h++, c = this.DecodeValue(this.distanceTree), 16 > c) g[d++] = c; else if (16 === c) { var k; c = 3 + this.readBits(2); if (d + c > e) return this.flushBuffer(), 1; for (k = d ? g[d - 1] : 0; c--;) g[d++] = k } else { c = 17 === c ? 3 + this.readBits(3) : 11 + this.readBits(7); if (d + c > e) return this.flushBuffer(), 1; for (; c--;) g[d++] = 0 } e = this.literalTree.length; for (d = 0; d < e; d++) this.literalTree[d] = new cc.Codec.GZip.HufNode; if (this.CreateTree(this.literalTree, b, g, 0)) return this.flushBuffer(), 1; e = this.literalTree.length; for (d = 0; d < e; d++) this.distanceTree[d] = new cc.Codec.GZip.HufNode; c = []; for (d = b; d < g.length; d++) c[d - b] = g[d]; if (this.CreateTree(this.distanceTree, f, c, 0)) return this.flushBuffer(), 1; for (;;) if (c = this.DecodeValue(this.literalTree), 256 <= c) { c -= 256; if (0 === c) break; c--; e = this.readBits(cc.Codec.GZip.cplext[c]) + cc.Codec.GZip.cplens[c]; c = this.DecodeValue(this.distanceTree); 8 < cc.Codec.GZip.cpdext[c] ? (f = this.readBits(8), f |= this.readBits(cc.Codec.GZip.cpdext[c] - 8) << 8) : f = this.readBits(cc.Codec.GZip.cpdext[c]); for (f += cc.Codec.GZip.cpdist[c]; e--;) b = this.buf32k[this.bIdx - f & 32767], this.addBuffer(b) } else this.addBuffer(c) } while (!a); this.flushBuffer(); this.byteAlign(); return 0 }; cc.Codec.GZip.prototype.unzipFile = function(a) { var b; this.gunzip(); for (b = 0; b < this.unzipped.length; b++) if (this.unzipped[b][1] === a) return this.unzipped[b][0] }; cc.Codec.GZip.prototype.nextFile = function() { this.outputArr = []; this.modeZIP = !1; var a = []; a[0] = this.readByte(); a[1] = this.readByte(); 120 === a[0] && 218 === a[1] && (this.DeflateLoop(), this.unzipped[this.files] = [this.outputArr.join(""), "geonext.gxt"], this.files++); 31 === a[0] && 139 === a[1] && (this.skipdir(), this.unzipped[this.files] = [this.outputArr.join(""), "file"], this.files++); if (80 === a[0] && 75 === a[1] && (this.modeZIP = !0, a[2] = this.readByte(), a[3] = this.readByte(), 3 === a[2] && 4 === a[3])) { a[0] = this.readByte(); a[1] = this.readByte(); this.gpflags = this.readByte(); this.gpflags |= this.readByte() << 8; a = this.readByte(); a |= this.readByte() << 8; this.readByte(); this.readByte(); this.readByte(); this.readByte(); this.readByte(); this.readByte(); this.readByte(); this.readByte(); this.readByte(); this.readByte(); this.readByte(); this.readByte(); var b = this.readByte(), b = b | this.readByte() << 8, c = this.readByte(), c = c | this.readByte() << 8, d = 0; for (this.nameBuf = []; b--;) { var e = this.readByte(); "/" === e | ":" === e ? d = 0 : d < cc.Codec.GZip.NAMEMAX - 1 && (this.nameBuf[d++] = String.fromCharCode(e)) } this.fileout || (this.fileout = this.nameBuf); for (var d = 0; d < c;) this.readByte(), d++; 8 === a && (this.DeflateLoop(), this.unzipped[this.files] = [this.outputArr.join(""), this.nameBuf.join("")], this.files++); this.skipdir() } }; cc.Codec.GZip.prototype.skipdir = function() { var a = [], b; this.gpflags & 8 && (a[0] = this.readByte(), a[1] = this.readByte(), a[2] = this.readByte(), a[3] = this.readByte(), this.readByte(), this.readByte(), this.readByte(), this.readByte(), this.readByte(), this.readByte(), this.readByte(), this.readByte()); this.modeZIP && this.nextFile(); a[0] = this.readByte(); if (8 !== a[0]) return 0; this.gpflags = this.readByte(); this.readByte(); this.readByte(); this.readByte(); this.readByte(); this.readByte(); this.readByte(); if (this.gpflags & 4) for (a[0] = this.readByte(), a[2] = this.readByte(), this.len = a[0] + 256 * a[1], a = 0; a < this.len; a++) this.readByte(); if (this.gpflags & 8) for (a = 0, this.nameBuf = []; b = this.readByte();) { if ("7" === b || ":" === b) a = 0; a < cc.Codec.GZip.NAMEMAX - 1 && (this.nameBuf[a++] = b) } if (this.gpflags & 16) for (; this.readByte();); this.gpflags & 2 && (this.readByte(), this.readByte()); this.DeflateLoop(); this.readByte(); this.readByte(); this.readByte(); this.readByte(); this.modeZIP && this.nextFile() }; /* zlib.js 2012 - imaya [ https://github.com/imaya/zlib.js ] The MIT License */ (function() { function a(a) { throw a; } function b(a, b) { var c = a.split("."), d = A; c[0] in d || !d.execScript || d.execScript("var " + c[0]); for (var e; c.length && (e = c.shift());) c.length || b === D ? d = d[e] ? d[e] : d[e] = {} : d[e] = b } function c(a) { if ("string" === typeof a) { a = a.split(""); var b, c; b = 0; for (c = a.length; b < c; b++) a[b] = (a[b].charCodeAt(0) & 255) >>> 0 } b = 1; c = 0; for (var d = a.length, e, f = 0; 0 < d;) { e = 1024 < d ? 1024 : d; d -= e; do b += a[f++], c += b; while (--e); b %= 65521; c %= 65521 } return (c << 16 | b) >>> 0 } function d(b, c) { this.index = "number" === typeof c ? c : 0; this.i = 0; this.buffer = b instanceof(w ? Uint8Array : Array) ? b : new(w ? Uint8Array : Array)(32768); 2 * this.buffer.length <= this.index && a(Error("invalid index")); this.buffer.length <= this.index && this.f() } function e(a) { this.buffer = new(w ? Uint16Array : Array)(2 * a); this.length = 0 } function f(a) { var b = a.length, c = 0, d = Number.POSITIVE_INFINITY, e, f, g, h, k, m, n, p, t; for (p = 0; p < b; ++p) a[p] > c && (c = a[p]), a[p] < d && (d = a[p]); e = 1 << c; f = new(w ? Uint32Array : Array)(e); g = 1; h = 0; for (k = 2; g <= c;) { for (p = 0; p < b; ++p) if (a[p] === g) { m = 0; n = h; for (t = 0; t < g; ++t) m = m << 1 | n & 1, n >>= 1; for (t = m; t < e; t += k) f[t] = g << 16 | p; ++h }++g; h <<= 1; k <<= 1 } return [f, c, d] } function g(a, b) { this.h = N; this.w = 0; this.input = a; this.b = 0; b && (b.lazy && (this.w = b.lazy), "number" === typeof b.compressionType && (this.h = b.compressionType), b.outputBuffer && (this.a = w && b.outputBuffer instanceof Array ? new Uint8Array(b.outputBuffer) : b.outputBuffer), "number" === typeof b.outputIndex && (this.b = b.outputIndex)); this.a || (this.a = new(w ? Uint8Array : Array)(32768)) } function h(a, b) { this.length = a; this.G = b } function k() { var b = P; switch (E) { case 3 === b: return [257, b - 3, 0]; case 4 === b: return [258, b - 4, 0]; case 5 === b: return [259, b - 5, 0]; case 6 === b: return [260, b - 6, 0]; case 7 === b: return [261, b - 7, 0]; case 8 === b: return [262, b - 8, 0]; case 9 === b: return [263, b - 9, 0]; case 10 === b: return [264, b - 10, 0]; case 12 >= b: return [265, b - 11, 1]; case 14 >= b: return [266, b - 13, 1]; case 16 >= b: return [267, b - 15, 1]; case 18 >= b: return [268, b - 17, 1]; case 22 >= b: return [269, b - 19, 2]; case 26 >= b: return [270, b - 23, 2]; case 30 >= b: return [271, b - 27, 2]; case 34 >= b: return [272, b - 31, 2]; case 42 >= b: return [273, b - 35, 3]; case 50 >= b: return [274, b - 43, 3]; case 58 >= b: return [275, b - 51, 3]; case 66 >= b: return [276, b - 59, 3]; case 82 >= b: return [277, b - 67, 4]; case 98 >= b: return [278, b - 83, 4]; case 114 >= b: return [279, b - 99, 4]; case 130 >= b: return [280, b - 115, 4]; case 162 >= b: return [281, b - 131, 5]; case 194 >= b: return [282, b - 163, 5]; case 226 >= b: return [283, b - 195, 5]; case 257 >= b: return [284, b - 227, 5]; case 258 === b: return [285, b - 258, 0]; default: a("invalid length: " + b) } } function m(b, c) { function d(b, c) { var e = b.G, f = [], g = 0, h; h = S[b.length]; f[g++] = h & 65535; f[g++] = h >> 16 & 255; f[g++] = h >> 24; var k; switch (E) { case 1 === e: k = [0, e - 1, 0]; break; case 2 === e: k = [1, e - 2, 0]; break; case 3 === e: k = [2, e - 3, 0]; break; case 4 === e: k = [3, e - 4, 0]; break; case 6 >= e: k = [4, e - 5, 1]; break; case 8 >= e: k = [5, e - 7, 1]; break; case 12 >= e: k = [6, e - 9, 2]; break; case 16 >= e: k = [7, e - 13, 2]; break; case 24 >= e: k = [8, e - 17, 3]; break; case 32 >= e: k = [9, e - 25, 3]; break; case 48 >= e: k = [10, e - 33, 4]; break; case 64 >= e: k = [11, e - 49, 4]; break; case 96 >= e: k = [12, e - 65, 5]; break; case 128 >= e: k = [13, e - 97, 5]; break; case 192 >= e: k = [14, e - 129, 6]; break; case 256 >= e: k = [15, e - 193, 6]; break; case 384 >= e: k = [16, e - 257, 7]; break; case 512 >= e: k = [17, e - 385, 7]; break; case 768 >= e: k = [18, e - 513, 8]; break; case 1024 >= e: k = [19, e - 769, 8]; break; case 1536 >= e: k = [20, e - 1025, 9]; break; case 2048 >= e: k = [21, e - 1537, 9]; break; case 3072 >= e: k = [22, e - 2049, 10]; break; case 4096 >= e: k = [23, e - 3073, 10]; break; case 6144 >= e: k = [24, e - 4097, 11]; break; case 8192 >= e: k = [25, e - 6145, 11]; break; case 12288 >= e: k = [26, e - 8193, 12]; break; case 16384 >= e: k = [27, e - 12289, 12]; break; case 24576 >= e: k = [28, e - 16385, 13]; break; case 32768 >= e: k = [29, e - 24577, 13]; break; default: a("invalid distance") } h = k; f[g++] = h[0]; f[g++] = h[1]; f[g++] = h[2]; e = 0; for (g = f.length; e < g; ++e) t[r++] = f[e]; u[f[0]]++; x[f[3]]++; s = b.length + c - 1; p = null } var e, f, g, k, m, n = {}, p, t = w ? new Uint16Array(2 * c.length) : [], r = 0, s = 0, u = new(w ? Uint32Array : Array)(286), x = new(w ? Uint32Array : Array)(30), y = b.w, v; if (!w) { for (g = 0; 285 >= g;) u[g++] = 0; for (g = 0; 29 >= g;) x[g++] = 0 } u[256] = 1; e = 0; for (f = c.length; e < f; ++e) { g = m = 0; for (k = 3; g < k && e + g !== f; ++g) m = m << 8 | c[e + g]; n[m] === D && (n[m] = []); g = n[m]; if (!(0 < s--)) { for (; 0 < g.length && 32768 < e - g[0];) g.shift(); if (e + 3 >= f) { p && d(p, -1); g = 0; for (k = f - e; g < k; ++g) v = c[e + g], t[r++] = v, ++u[v]; break } if (0 < g.length) { m = k = D; var A = 0, B = D, z = D, C = B = D, I = c.length, z = 0, C = g.length; a: for (; z < C; z++) { k = g[C - z - 1]; B = 3; if (3 < A) { for (B = A; 3 < B; B--) if (c[k + B - 1] !== c[e + B - 1]) continue a; B = A } for (; 258 > B && e + B < I && c[k + B] === c[e + B];)++B; B > A && (m = k, A = B); if (258 === B) break } k = new h(A, e - m); p ? p.length < k.length ? (v = c[e - 1], t[r++] = v, ++u[v], d(k, 0)) : d(p, -1) : k.length < y ? p = k : d(k, 0) } else p ? d(p, -1) : (v = c[e], t[r++] = v, ++u[v]) } g.push(e) } t[r++] = 256; u[256]++; b.L = u; b.K = x; return w ? t.subarray(0, r) : t } function n(a, b) { function c(a) { var b = t[a][r[a]]; b === n ? (c(a + 1), c(a + 1)) : --p[b]; ++r[a] } var d = a.length, f = new e(572), g = new(w ? Uint8Array : Array)(d), h, k, m; if (!w) for (k = 0; k < d; k++) g[k] = 0; for (k = 0; k < d; ++k) 0 < a[k] && f.push(k, a[k]); d = Array(f.length / 2); h = new(w ? Uint32Array : Array)(f.length / 2); if (1 === d.length) return g[f.pop().index] = 1, g; k = 0; for (m = f.length / 2; k < m; ++k) d[k] = f.pop(), h[k] = d[k].value; var n = h.length; k = new(w ? Uint16Array : Array)(b); var f = new(w ? Uint8Array : Array)(b), p = new(w ? Uint8Array : Array)(n); m = Array(b); var t = Array(b), r = Array(b), s = (1 << b) - n, u = 1 << b - 1, v, x, y; k[b - 1] = n; for (v = 0; v < b; ++v) s < u ? f[v] = 0 : (f[v] = 1, s -= u), s <<= 1, k[b - 2 - v] = (k[b - 1 - v] / 2 | 0) + n; k[0] = f[0]; m[0] = Array(k[0]); t[0] = Array(k[0]); for (v = 1; v < b; ++v) k[v] > 2 * k[v - 1] + f[v] && (k[v] = 2 * k[v - 1] + f[v]), m[v] = Array(k[v]), t[v] = Array(k[v]); for (s = 0; s < n; ++s) p[s] = b; for (u = 0; u < k[b - 1]; ++u) m[b - 1][u] = h[u], t[b - 1][u] = u; for (s = 0; s < b; ++s) r[s] = 0; 1 === f[b - 1] && (--p[0], ++r[b - 1]); for (v = b - 2; 0 <= v; --v) { x = s = 0; y = r[v + 1]; for (u = 0; u < k[v]; u++) x = m[v + 1][y] + m[v + 1][y + 1], x > h[s] ? (m[v][u] = x, t[v][u] = n, y += 2) : (m[v][u] = h[s], t[v][u] = s, ++s); r[v] = 0; 1 === f[v] && c(v) } h = p; k = 0; for (m = d.length; k < m; ++k) g[d[k].index] = h[k]; return g } function p(b) { var c = new(w ? Uint16Array : Array)(b.length), d = [], e = [], f = 0, g, h, k; g = 0; for (h = b.length; g < h; g++) d[b[g]] = (d[b[g]] | 0) + 1; g = 1; for (h = 16; g <= h; g++) e[g] = f, f += d[g] | 0, f > 1 << g && a("overcommitted"), f <<= 1; 65536 > f && a("undercommitted"); g = 0; for (h = b.length; g < h; g++) for (f = e[b[g]], e[b[g]] += 1, d = c[g] = 0, k = b[g]; d < k; d++) c[g] = c[g] << 1 | f & 1, f >>>= 1; return c } function t(a, b) { this.input = a; this.a = new(w ? Uint8Array : Array)(32768); this.h = I.j; var c = {}, d; !b && (b = {}) || "number" !== typeof b.compressionType || (this.h = b.compressionType); for (d in b) c[d] = b[d]; c.outputBuffer = this.a; this.z = new g(this.input, c) } function r(b, c) { this.k = []; this.l = 32768; this.e = this.g = this.c = this.q = 0; this.input = w ? new Uint8Array(b) : b; this.s = !1; this.m = K; this.B = !1; if (c || !(c = {})) c.index && (this.c = c.index), c.bufferSize && (this.l = c.bufferSize), c.bufferType && (this.m = c.bufferType), c.resize && (this.B = c.resize); switch (this.m) { case T: this.b = 32768; this.a = new(w ? Uint8Array : Array)(32768 + this.l + 258); break; case K: this.b = 0; this.a = new(w ? Uint8Array : Array)(this.l); this.f = this.J; this.t = this.H; this.o = this.I; break; default: a(Error("invalid inflate mode")) } } function u(b, c) { for (var d = b.g, e = b.e, f = b.input, g = b.c, h; e < c;) h = f[g++], h === D && a(Error("input buffer is broken")), d |= h << e, e += 8; b.g = d >>> c; b.e = e - c; b.c = g; return d & (1 << c) - 1 } function s(b, c) { for (var d = b.g, e = b.e, f = b.input, g = b.c, h = c[0], k = c[1], m; e < k;) m = f[g++], m === D && a(Error("input buffer is broken")), d |= m << e, e += 8; f = h[d & (1 << k) - 1]; h = f >>> 16; b.g = d >> h; b.e = e - h; b.c = g; return f & 65535 } function v(a) { function b(a, c, d) { var e, f, g, h; for (h = 0; h < a;) switch (e = s(this, c), e) { case 16: for (g = 3 + u(this, 2); g--;) d[h++] = f; break; case 17: for (g = 3 + u(this, 3); g--;) d[h++] = 0; f = 0; break; case 18: for (g = 11 + u(this, 7); g--;) d[h++] = 0; f = 0; break; default: f = d[h++] = e } return d } var c = u(a, 5) + 257, d = u(a, 5) + 1, e = u(a, 4) + 4, g = new(w ? Uint8Array : Array)(U.length), h; for (h = 0; h < e; ++h) g[U[h]] = u(a, 3); e = f(g); g = new(w ? Uint8Array : Array)(c); h = new(w ? Uint8Array : Array)(d); a.o(f(b.call(a, c, e, g)), f(b.call(a, d, e, h))) } function x(b, c) { var d, e; this.input = b; this.c = 0; if (c || !(c = {})) c.index && (this.c = c.index), c.verify && (this.M = c.verify); d = b[this.c++]; e = b[this.c++]; switch (d & 15) { case ia: this.method = ia; break; default: a(Error("unsupported compression method")) } 0 !== ((d << 8) + e) % 31 && a(Error("invalid fcheck flag:" + ((d << 8) + e) % 31)); e & 32 && a(Error("fdict flag is not supported")); this.A = new r(b, { index: this.c, bufferSize: c.bufferSize, bufferType: c.bufferType, resize: c.resize }) } var D = void 0, E = !0, A = this, w = "undefined" !== typeof Uint8Array && "undefined" !== typeof Uint16Array && "undefined" !== typeof Uint32Array; d.prototype.f = function() { var a = this.buffer, b, c = a.length, d = new(w ? Uint8Array : Array)(c << 1); if (w) d.set(a); else for (b = 0; b < c; ++b) d[b] = a[b]; return this.buffer = d }; d.prototype.d = function(a, b, c) { var d = this.buffer, e = this.index, f = this.i, g = d[e]; c && 1 < b && (a = 8 < b ? (C[a & 255] << 24 | C[a >>> 8 & 255] << 16 | C[a >>> 16 & 255] << 8 | C[a >>> 24 & 255]) >> 32 - b : C[a] >> 8 - b); if (8 > b + f) g = g << b | a, f += b; else for (c = 0; c < b; ++c) g = g << 1 | a >> b - c - 1 & 1, 8 === ++f && (f = 0, d[e++] = C[g], g = 0, e === d.length && (d = this.f())); d[e] = g; this.buffer = d; this.i = f; this.index = e }; d.prototype.finish = function() { var a = this.buffer, b = this.index, c; 0 < this.i && (a[b] <<= 8 - this.i, a[b] = C[a[b]], b++); w ? c = a.subarray(0, b) : (a.length = b, c = a); return c }; var B = new(w ? Uint8Array : Array)(256), y; for (y = 0; 256 > y; ++y) { for (var z = y, F = z, J = 7, z = z >>> 1; z; z >>>= 1) F <<= 1, F |= z & 1, --J; B[y] = (F << J & 255) >>> 0 } var C = B, B = [0, 1996959894, 3993919788, 2567524794, 124634137, 1886057615, 3915621685, 2657392035, 249268274, 2044508324, 3772115230, 2547177864, 162941995, 2125561021, 3887607047, 2428444049, 498536548, 1789927666, 4089016648, 2227061214, 450548861, 1843258603, 4107580753, 2211677639, 325883990, 1684777152, 4251122042, 2321926636, 335633487, 1661365465, 4195302755, 2366115317, 997073096, 1281953886, 3579855332, 2724688242, 1006888145, 1258607687, 3524101629, 2768942443, 901097722, 1119000684, 3686517206, 2898065728, 853044451, 1172266101, 3705015759, 2882616665, 651767980, 1373503546, 3369554304, 3218104598, 565507253, 1454621731, 3485111705, 3099436303, 671266974, 1594198024, 3322730930, 2970347812, 795835527, 1483230225, 3244367275, 3060149565, 1994146192, 31158534, 2563907772, 4023717930, 1907459465, 112637215, 2680153253, 3904427059, 2013776290, 251722036, 2517215374, 3775830040, 2137656763, 141376813, 2439277719, 3865271297, 1802195444, 476864866, 2238001368, 4066508878, 1812370925, 453092731, 2181625025, 4111451223, 1706088902, 314042704, 2344532202, 4240017532, 1658658271, 366619977, 2362670323, 4224994405, 1303535960, 984961486, 2747007092, 3569037538, 1256170817, 1037604311, 2765210733, 3554079995, 1131014506, 879679996, 2909243462, 3663771856, 1141124467, 855842277, 2852801631, 3708648649, 1342533948, 654459306, 3188396048, 3373015174, 1466479909, 544179635, 3110523913, 3462522015, 1591671054, 702138776, 2966460450, 3352799412, 1504918807, 783551873, 3082640443, 3233442989, 3988292384, 2596254646, 62317068, 1957810842, 3939845945, 2647816111, 81470997, 1943803523, 3814918930, 2489596804, 225274430, 2053790376, 3826175755, 2466906013, 167816743, 2097651377, 4027552580, 2265490386, 503444072, 1762050814, 4150417245, 2154129355, 426522225, 1852507879, 4275313526, 2312317920, 282753626, 1742555852, 4189708143, 2394877945, 397917763, 1622183637, 3604390888, 2714866558, 953729732, 1340076626, 3518719985, 2797360999, 1068828381, 1219638859, 3624741850, 2936675148, 906185462, 1090812512, 3747672003, 2825379669, 829329135, 1181335161, 3412177804, 3160834842, 628085408, 1382605366, 3423369109, 3138078467, 570562233, 1426400815, 3317316542, 2998733608, 733239954, 1555261956, 3268935591, 3050360625, 752459403, 1541320221, 2607071920, 3965973030, 1969922972, 40735498, 2617837225, 3943577151, 1913087877, 83908371, 2512341634, 3803740692, 2075208622, 213261112, 2463272603, 3855990285, 2094854071, 198958881, 2262029012, 4057260610, 1759359992, 534414190, 2176718541, 4139329115, 1873836001, 414664567, 2282248934, 4279200368, 1711684554, 285281116, 2405801727, 4167216745, 1634467795, 376229701, 2685067896, 3608007406, 1308918612, 956543938, 2808555105, 3495958263, 1231636301, 1047427035, 2932959818, 3654703836, 1088359270, 936918E3, 2847714899, 3736837829, 1202900863, 817233897, 3183342108, 3401237130, 1404277552, 615818150, 3134207493, 3453421203, 1423857449, 601450431, 3009837614, 3294710456, 1567103746, 711928724, 3020668471, 3272380065, 1510334235, 755167117 ]; w && new Uint32Array(B); e.prototype.getParent = function(a) { return 2 * ((a - 2) / 4 | 0) }; e.prototype.push = function(a, b) { var c, d, e = this.buffer, f; c = this.length; e[this.length++] = b; for (e[this.length++] = a; 0 < c;) if (d = this.getParent(c), e[c] > e[d]) f = e[c], e[c] = e[d], e[d] = f, f = e[c + 1], e[c + 1] = e[d + 1], e[d + 1] = f, c = d; else break; return this.length }; e.prototype.pop = function() { var a, b, c = this.buffer, d, e, f; b = c[0]; a = c[1]; this.length -= 2; c[0] = c[this.length]; c[1] = c[this.length + 1]; for (f = 0;;) { e = 2 * f + 2; if (e >= this.length) break; e + 2 < this.length && c[e + 2] > c[e] && (e += 2); if (c[e] > c[f]) d = c[f], c[f] = c[e], c[e] = d, d = c[f + 1], c[f + 1] = c[e + 1], c[e + 1] = d; else break; f = e } return { index: a, value: b, length: this.length } }; var N = 2, B = { NONE: 0, r: 1, j: N, N: 3 }, L = []; for (y = 0; 288 > y; y++) switch (E) { case 143 >= y: L.push([y + 48, 8]); break; case 255 >= y: L.push([y - 144 + 400, 9]); break; case 279 >= y: L.push([y - 256 + 0, 7]); break; case 287 >= y: L.push([y - 280 + 192, 8]); break; default: a("invalid literal: " + y) } g.prototype.n = function() { var b, c, e, f, g = this.input; switch (this.h) { case 0: e = 0; for (f = g.length; e < f;) { c = w ? g.subarray(e, e + 65535) : g.slice(e, e + 65535); e += c.length; var h = e === f, k = D, t = k = D, t = k = D, r = this.a, s = this.b; if (w) { for (r = new Uint8Array(this.a.buffer); r.length <= s + c.length + 5;) r = new Uint8Array(r.length << 1); r.set(this.a) } k = h ? 1 : 0; r[s++] = k | 0; k = c.length; t = ~k + 65536 & 65535; r[s++] = k & 255; r[s++] = k >>> 8 & 255; r[s++] = t & 255; r[s++] = t >>> 8 & 255; if (w) r.set(c, s), s += c.length, r = r.subarray(0, s); else { k = 0; for (t = c.length; k < t; ++k) r[s++] = c[k]; r.length = s } this.b = s; this.a = r } break; case 1: e = new d(new Uint8Array(this.a.buffer), this.b); e.d(1, 1, E); e.d(1, 2, E); g = m(this, g); c = 0; for (h = g.length; c < h; c++) if (f = g[c], d.prototype.d.apply(e, L[f]), 256 < f) e.d(g[++c], g[++c], E), e.d(g[++c], 5), e.d(g[++c], g[++c], E); else if (256 === f) break; this.a = e.finish(); this.b = this.a.length; break; case N: f = new d(new Uint8Array(this.a), this.b); var u, v, x, y = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15], A, B, k = Array(19), z, r = N; f.d(1, 1, E); f.d(r, 2, E); g = m(this, g); t = n(this.L, 15); A = p(t); r = n(this.K, 7); s = p(r); for (u = 286; 257 < u && 0 === t[u - 1]; u--); for (v = 30; 1 < v && 0 === r[v - 1]; v--); var C = u, I = v; b = new(w ? Uint32Array : Array)(C + I); var F = new(w ? Uint32Array : Array)(316), J, K; B = new(w ? Uint8Array : Array)(19); for (z = x = 0; z < C; z++) b[x++] = t[z]; for (z = 0; z < I; z++) b[x++] = r[z]; if (!w) for (z = 0, I = B.length; z < I; ++z) B[z] = 0; z = J = 0; for (I = b.length; z < I; z += x) { for (x = 1; z + x < I && b[z + x] === b[z]; ++x); C = x; if (0 === b[z]) if (3 > C) for (; 0 < C--;) F[J++] = 0, B[0]++; else for (; 0 < C;) K = 138 > C ? C : 138, K > C - 3 && K < C && (K = C - 3), 10 >= K ? (F[J++] = 17, F[J++] = K - 3, B[17]++) : (F[J++] = 18, F[J++] = K - 11, B[18]++), C -= K; else if (F[J++] = b[z], B[b[z]]++, C--, 3 > C) for (; 0 < C--;) F[J++] = b[z], B[b[z]]++; else for (; 0 < C;) K = 6 > C ? C : 6, K > C - 3 && K < C && (K = C - 3), F[J++] = 16, F[J++] = K - 3, B[16]++, C -= K } b = w ? F.subarray(0, J) : F.slice(0, J); B = n(B, 7); for (z = 0; 19 > z; z++) k[z] = B[y[z]]; for (x = 19; 4 < x && 0 === k[x - 1]; x--); y = p(B); f.d(u - 257, 5, E); f.d(v - 1, 5, E); f.d(x - 4, 4, E); for (z = 0; z < x; z++) f.d(k[z], 3, E); z = 0; for (k = b.length; z < k; z++) if (c = b[z], f.d(y[c], B[c], E), 16 <= c) { z++; switch (c) { case 16: h = 2; break; case 17: h = 3; break; case 18: h = 7; break; default: a("invalid code: " + c) } f.d(b[z], h, E) } h = [A, t]; s = [s, r ]; c = h[0]; h = h[1]; r = s[0]; A = s[1]; s = 0; for (k = g.length; s < k; ++s) if (e = g[s], f.d(c[e], h[e], E), 256 < e) f.d(g[++s], g[++s], E), t = g[++s], f.d(r[t], A[t], E), f.d(g[++s], g[++s], E); else if (256 === e) break; this.a = f.finish(); this.b = this.a.length; break; default: a("invalid compression type") } return this.a }; y = []; var P; for (P = 3; 258 >= P; P++) z = k(), y[P] = z[2] << 24 | z[1] << 16 | z[0]; var S = w ? new Uint32Array(y) : y, I = B; t.prototype.n = function() { var b, d, e, f, g = 0; f = this.a; b = ia; switch (b) { case ia: d = Math.LOG2E * Math.log(32768) - 8; break; default: a(Error("invalid compression method")) } d = d << 4 | b; f[g++] = d; switch (b) { case ia: switch (this.h) { case I.NONE: e = 0; break; case I.r: e = 1; break; case I.j: e = 2; break; default: a(Error("unsupported compression type")) } break; default: a(Error("invalid compression method")) } b = e << 6 | 0; f[g++] = b | 31 - (256 * d + b) % 31; b = c(this.input); this.z.b = g; f = this.z.n(); g = f.length; w && (f = new Uint8Array(f.buffer), f.length <= g + 4 && (this.a = new Uint8Array(f.length + 4), this.a.set(f), f = this.a), f = f.subarray(0, g + 4)); f[g++] = b >> 24 & 255; f[g++] = b >> 16 & 255; f[g++] = b >> 8 & 255; f[g++] = b & 255; return f }; b("Zlib.Deflate", t); b("Zlib.Deflate.compress", function(a, b) { return (new t(a, b)).n() }); b("Zlib.Deflate.CompressionType", I); b("Zlib.Deflate.CompressionType.NONE", I.NONE); b("Zlib.Deflate.CompressionType.FIXED", I.r); b("Zlib.Deflate.CompressionType.DYNAMIC", I.j); var T = 0, K = 1, B = { D: T, C: K }; r.prototype.p = function() { for (; !this.s;) { var b = u(this, 3); b & 1 && (this.s = E); b >>>= 1; switch (b) { case 0: var b = this.input, c = this.c, d = this.a, e = this.b, f = D, g = D, h = D, k = d.length, f = D; this.e = this.g = 0; f = b[c++]; f === D && a(Error("invalid uncompressed block header: LEN (first byte)")); g = f; f = b[c++]; f === D && a(Error("invalid uncompressed block header: LEN (second byte)")); g |= f << 8; f = b[c++]; f === D && a(Error("invalid uncompressed block header: NLEN (first byte)")); h = f; f = b[c++]; f === D && a(Error("invalid uncompressed block header: NLEN (second byte)")); h |= f << 8; g === ~h && a(Error("invalid uncompressed block header: length verify")); c + g > b.length && a(Error("input buffer is broken")); switch (this.m) { case T: for (; e + g > d.length;) { f = k - e; g -= f; if (w) d.set(b.subarray(c, c + f), e), e += f, c += f; else for (; f--;) d[e++] = b[c++]; this.b = e; d = this.f(); e = this.b } break; case K: for (; e + g > d.length;) d = this.f({ v: 2 }); break; default: a(Error("invalid inflate mode")) } if (w) d.set(b.subarray(c, c + g), e), e += g, c += g; else for (; g--;) d[e++] = b[c++]; this.c = c; this.b = e; this.a = d; break; case 1: this.o(xa, ya); break; case 2: v(this); break; default: a(Error("unknown BTYPE: " + b)) } } return this.t() }; y = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]; var U = w ? new Uint16Array(y) : y; y = [3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 258, 258 ]; var V = w ? new Uint16Array(y) : y; y = [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 0, 0]; var aa = w ? new Uint8Array(y) : y; y = [1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577]; var za = w ? new Uint16Array(y) : y; y = [0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13]; var X = w ? new Uint8Array(y) : y; y = new(w ? Uint8Array : Array)(288); z = 0; for (F = y.length; z < F; ++z) y[z] = 143 >= z ? 8 : 255 >= z ? 9 : 279 >= z ? 7 : 8; var xa = f(y); y = new(w ? Uint8Array : Array)(30); z = 0; for (F = y.length; z < F; ++z) y[z] = 5; var ya = f(y); r.prototype.o = function(a, b) { var c = this.a, d = this.b; this.u = a; for (var e = c.length - 258, f, g, h; 256 !== (f = s(this, a));) if (256 > f) d >= e && (this.b = d, c = this.f(), d = this.b), c[d++] = f; else for (f -= 257, h = V[f], 0 < aa[f] && (h += u(this, aa[f])), f = s(this, b), g = za[f], 0 < X[f] && (g += u(this, X[f])), d >= e && (this.b = d, c = this.f(), d = this.b); h--;) c[d] = c[d++-g]; for (; 8 <= this.e;) this.e -= 8, this.c--; this.b = d }; r.prototype.I = function(a, b) { var c = this.a, d = this.b; this.u = a; for (var e = c.length, f, g, h; 256 !== (f = s(this, a));) if (256 > f) d >= e && (c = this.f(), e = c.length), c[d++] = f; else for (f -= 257, h = V[f], 0 < aa[f] && (h += u(this, aa[f])), f = s(this, b), g = za[f], 0 < X[f] && (g += u(this, X[f])), d + h > e && (c = this.f(), e = c.length); h--;) c[d] = c[d++-g]; for (; 8 <= this.e;) this.e -= 8, this.c--; this.b = d }; r.prototype.f = function() { var a = new(w ? Uint8Array : Array)(this.b - 32768), b = this.b - 32768, c, d, e = this.a; if (w) a.set(e.subarray(32768, a.length)); else for (c = 0, d = a.length; c < d; ++c) a[c] = e[c + 32768]; this.k.push(a); this.q += a.length; if (w) e.set(e.subarray(b, b + 32768)); else for (c = 0; 32768 > c; ++c) e[c] = e[b + c]; this.b = 32768; return e }; r.prototype.J = function(a) { var b, c = this.input.length / this.c + 1 | 0, d, e, f, g = this.input, h = this.a; a && ("number" === typeof a.v && (c = a.v), "number" === typeof a.F && (c += a.F)); 2 > c ? (d = (g.length - this.c) / this.u[2], f = d / 2 * 258 | 0, e = f < h.length ? h.length + f : h.length << 1) : e = h.length * c; w ? (b = new Uint8Array(e), b.set(h)) : b = h; return this.a = b }; r.prototype.t = function() { var a = 0, b = this.a, c = this.k, d, e = new(w ? Uint8Array : Array)(this.q + (this.b - 32768)), f, g, h, k; if (0 === c.length) return w ? this.a.subarray(32768, this.b) : this.a.slice(32768, this.b); f = 0; for (g = c.length; f < g; ++f) for (d = c[f], h = 0, k = d.length; h < k; ++h) e[a++] = d[h]; f = 32768; for (g = this.b; f < g; ++f) e[a++] = b[f]; this.k = []; return this.buffer = e }; r.prototype.H = function() { var a, b = this.b; w ? this.B ? (a = new Uint8Array(b), a.set(this.a.subarray(0, b))) : a = this.a.subarray(0, b) : (this.a.length > b && (this.a.length = b), a = this.a); return this.buffer = a }; x.prototype.p = function() { var b = this.input, d, e; d = this.A.p(); this.c = this.A.c; this.M && (e = (b[this.c++] << 24 | b[this.c++] << 16 | b[this.c++] << 8 | b[this.c++]) >>> 0, e !== c(d) && a(Error("invalid adler-32 checksum"))); return d }; b("Zlib.Inflate", x); b("Zlib.Inflate.BufferType", B); B.ADAPTIVE = B.C; B.BLOCK = B.D; b("Zlib.Inflate.prototype.decompress", x.prototype.p); B = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]; w && new Uint16Array(B); B = [3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 258, 258]; w && new Uint16Array(B); B = [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 0, 0]; w && new Uint8Array(B); B = [1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577]; w && new Uint16Array(B); B = [0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13]; w && new Uint8Array(B); B = new(w ? Uint8Array : Array)(288); y = 0; for (z = B.length; y < z; ++y) B[y] = 143 >= y ? 8 : 255 >= y ? 9 : 279 >= y ? 7 : 8; f(B); B = new(w ? Uint8Array : Array)(30); y = 0; for (z = B.length; y < z; ++y) B[y] = 5; f(B); var ia = 8 }).call(this); _p = window; _p = _p.Zlib = _p.Zlib; _p.Deflate = _p.Deflate; _p.Deflate.compress = _p.Deflate.compress; _p.Inflate = _p.Inflate; _p.Inflate.BufferType = _p.Inflate.BufferType; _p.Inflate.prototype.decompress = _p.Inflate.prototype.decompress; cc.PNGReader = cc.Class.extend({ ctor: function(a) { var b, c, d, e; this.data = a; this.pos = 8; this.palette = []; this.imgData = []; this.transparency = {}; this.animation = null; this.text = {}; for (d = null;;) { b = this.readUInt32(); e = a = void 0; e = []; for (a = 0; 4 > a; ++a) e.push(String.fromCharCode(this.data[this.pos++])); a = e.join(""); switch (a) { case "IHDR": this.width = this.readUInt32(); this.height = this.readUInt32(); this.bits = this.data[this.pos++]; this.colorType = this.data[this.pos++]; this.compressionMethod = this.data[this.pos++]; this.filterMethod = this.data[this.pos++]; this.interlaceMethod = this.data[this.pos++]; break; case "acTL": this.animation = { numFrames: this.readUInt32(), numPlays: this.readUInt32() || Infinity, frames: [] }; break; case "PLTE": this.palette = this.read(b); break; case "fcTL": d && this.animation.frames.push(d); this.pos += 4; d = { width: this.readUInt32(), height: this.readUInt32(), xOffset: this.readUInt32(), yOffset: this.readUInt32() }; a = this.readUInt16(); b = this.readUInt16() || 100; d.delay = 1E3 * a / b; d.disposeOp = this.data[this.pos++]; d.blendOp = this.data[this.pos++]; d.data = []; break; case "IDAT": case "fdAT": "fdAT" === a && (this.pos += 4, b -= 4); a = (null != d ? d.data : void 0) || this.imgData; for (e = 0; 0 <= b ? e < b : e > b; 0 <= b ? ++e : --e) a.push(this.data[this.pos++]); break; case "tRNS": this.transparency = {}; switch (this.colorType) { case 3: this.transparency.indexed = this.read(b); b = 255 - this.transparency.indexed.length; if (0 < b) for (a = 0; 0 <= b ? a < b : a > b; 0 <= b ? ++a : --a) this.transparency.indexed.push(255); break; case 0: this.transparency.grayscale = this.read(b)[0]; break; case 2: this.transparency.rgb = this.read(b) } break; case "tEXt": e = this.read(b); b = e.indexOf(0); a = String.fromCharCode.apply(String, e.slice(0, b)); this.text[a] = String.fromCharCode.apply(String, e.slice(b + 1)); break; case "IEND": d && this.animation.frames.push(d); a: { switch (this.colorType) { case 0: case 3: case 4: d = 1; break a; case 2: case 6: d = 3; break a } d = void 0 } this.colors = d; this.hasAlphaChannel = 4 === (c = this.colorType) || 6 === c; c = this.colors + (this.hasAlphaChannel ? 1 : 0); this.pixelBitlength = this.bits * c; a: { switch (this.colors) { case 1: c = "DeviceGray"; break a; case 3: c = "DeviceRGB"; break a } c = void 0 } this.colorSpace = c; Uint8Array != Array && (this.imgData = new Uint8Array(this.imgData)); return; default: this.pos += b } this.pos += 4; if (this.pos > this.data.length) throw Error("Incomplete or corrupt PNG file"); } }, read: function(a) { var b, c; c = []; for (b = 0; 0 <= a ? b < a : b > a; 0 <= a ? ++b : --b) c.push(this.data[this.pos++]); return c }, readUInt32: function() { var a, b, c, d; a = this.data[this.pos++] << 24; b = this.data[this.pos++] << 16; c = this.data[this.pos++] << 8; d = this.data[this.pos++]; return a | b | c | d }, readUInt16: function() { var a, b; a = this.data[this.pos++] << 8; b = this.data[this.pos++]; return a | b }, decodePixels: function(a) { var b, c, d, e, f, g, h, k, m, n, p, t, r, u, s; null == a && (a = this.imgData); if (0 === a.length) return new Uint8Array(0); a = (new Zlib.Inflate(a, { index: 0, verify: !1 })).decompress(); k = this.pixelBitlength / 8; t = k * this.width; m = new Uint8Array(t * this.height); g = a.length; for (c = n = p = 0; n < g;) { switch (a[n++]) { case 0: for (b = 0; b < t; b += 1) m[c++] = a[n++]; break; case 1: for (e = r = 0; r < t; e = r += 1) b = a[n++], f = e < k ? 0 : m[c - k], m[c++] = (b + f) % 256; break; case 2: for (e = f = 0; f < t; e = f += 1) b = a[n++], d = (e - e % k) / k, r = p && m[(p - 1) * t + d * k + e % k], m[c++] = (r + b) % 256; break; case 3: for (e = s = 0; s < t; e = s += 1) b = a[n++], d = (e - e % k) / k, f = e < k ? 0 : m[c - k], r = p && m[(p - 1) * t + d * k + e % k], m[c++] = (b + Math.floor((f + r) / 2)) % 256; break; case 4: for (e = s = 0; s < t; e = s += 1) b = a[n++], d = (e - e % k) / k, f = e < k ? 0 : m[c - k], 0 === p ? r = u = 0 : (r = m[(p - 1) * t + d * k + e % k], u = d && m[(p - 1) * t + (d - 1) * k + e % k]), h = f + r - u, e = Math.abs(h - f), d = Math.abs(h - r), h = Math.abs(h - u), f = e <= d && e <= h ? f : d <= h ? r : u, m[c++] = (b + f) % 256; break; default: throw Error("Invalid filter algorithm: " + a[n - 1]); } p++ } return m }, copyToImageData: function(a, b) { var c, d, e, f, g, h, k, m; d = this.colors; m = null; c = this.hasAlphaChannel; this.palette.length && (m = null != (e = this._decodedPalette) ? e : this._decodedPalette = this.decodePalette(), d = 4, c = !0); e = a.data || a; k = e.length; g = m || b; f = h = 0; if (1 === d) for (; f < k;) d = m ? 4 * b[f / 4] : h, h = g[d++], e[f++] = h, e[f++] = h, e[f++] = h, e[f++] = c ? g[d++] : 255, h = d; else for (; f < k;) d = m ? 4 * b[f / 4] : h, e[f++] = g[d++], e[f++] = g[d++], e[f++] = g[d++], e[f++] = c ? g[d++] : 255, h = d }, decodePalette: function() { var a, b, c, d, e, f, g, h, k; c = this.palette; f = this.transparency.indexed || []; e = new Uint8Array((f.length || 0) + c.length); b = g = a = d = 0; for (h = c.length; g < h; b = g += 3) e[d++] = c[b], e[d++] = c[b + 1], e[d++] = c[b + 2], e[d++] = null != (k = f[a++]) ? k : 255; return e }, render: function(a) { var b; a.width = this.width; a.height = this.height; a = a.getContext("2d"); b = a.createImageData(this.width, this.height); this.copyToImageData(b, this.decodePixels()); return a.putImageData(b, 0, 0) } }); cc.tiffReader = { _littleEndian: !1, _tiffData: null, _fileDirectories: [], getUint8: function(a) { return this._tiffData[a] }, getUint16: function(a) { return this._littleEndian ? this._tiffData[a + 1] << 8 | this._tiffData[a] : this._tiffData[a] << 8 | this._tiffData[a + 1] }, getUint32: function(a) { var b = this._tiffData; return this._littleEndian ? b[a + 3] << 24 | b[a + 2] << 16 | b[a + 1] << 8 | b[a] : b[a] << 24 | b[a + 1] << 16 | b[a + 2] << 8 | b[a + 3] }, checkLittleEndian: function() { var a = this.getUint16(0); if (18761 === a) this.littleEndian = !0; else if (19789 === a) this.littleEndian = !1; else throw console.log(a), TypeError("Invalid byte order value."); return this.littleEndian }, hasTowel: function() { if (42 !== this.getUint16(2)) throw RangeError("You forgot your towel!"); return !0 }, getFieldTypeName: function(a) { var b = this.fieldTypeNames; return a in b ? b[a] : null }, getFieldTagName: function(a) { var b = this.fieldTagNames; if (a in b) return b[a]; console.log("Unknown Field Tag:", a); return "Tag" + a }, getFieldTypeLength: function(a) { return -1 !== ["BYTE", "ASCII", "SBYTE", "UNDEFINED"].indexOf(a) ? 1 : -1 !== ["SHORT", "SSHORT" ].indexOf(a) ? 2 : -1 !== ["LONG", "SLONG", "FLOAT"].indexOf(a) ? 4 : -1 !== ["RATIONAL", "SRATIONAL", "DOUBLE"].indexOf(a) ? 8 : null }, getFieldValues: function(a, b, c, d) { a = []; var e = this.getFieldTypeLength(b); if (4 >= e * c)!1 === this.littleEndian ? a.push(d >>> 8 * (4 - e)) : a.push(d); else for (var f = 0; f < c; f++) { var g = e * f; 8 <= e ? -1 !== ["RATIONAL", "SRATIONAL"].indexOf(b) ? (a.push(this.getUint32(d + g)), a.push(this.getUint32(d + g + 4))) : cc.log("Can't handle this field type or size") : a.push(this.getBytes(e, d + g)) } "ASCII" === b && a.forEach(function(a, b, c) { c[b] = String.fromCharCode(a) }); return a }, getBytes: function(a, b) { if (0 >= a) cc.log("No bytes requested"); else { if (1 >= a) return this.getUint8(b); if (2 >= a) return this.getUint16(b); if (3 >= a) return this.getUint32(b) >>> 8; if (4 >= a) return this.getUint32(b); cc.log("Too many bytes requested") } }, getBits: function(a, b, c) { c = c || 0; b += Math.floor(c / 8); var d = c + a; a = 32 - a; var e, f; 0 >= d ? console.log("No bits requested") : 8 >= d ? (e = 24 + c, f = this.getUint8(b)) : 16 >= d ? (e = 16 + c, f = this.getUint16(b)) : 32 >= d ? (e = c, f = this.getUint32(b)) : console.log("Too many bits requested"); return { bits: f << e >>> a, byteOffset: b + Math.floor(d / 8), bitOffset: d % 8 } }, parseFileDirectory: function(a) { var b = this.getUint16(a), c = []; a += 2; for (var d = 0; d < b; a += 12, d++) { var e = this.getUint16(a), f = this.getUint16(a + 2), g = this.getUint32(a + 4), h = this.getUint32(a + 8), e = this.getFieldTagName(e), f = this.getFieldTypeName(f), g = this.getFieldValues(e, f, g, h); c[e] = { type: f, values: g } } this._fileDirectories.push(c); b = this.getUint32(a); 0 !== b && this.parseFileDirectory(b) }, clampColorSample: function(a, b) { var c = Math.pow(2, 8 - b); return Math.floor(a * c + (c - 1)) }, parseTIFF: function(a, b) { b = b || cc.newElement("canvas"); this._tiffData = a; this.canvas = b; this.checkLittleEndian(); if (this.hasTowel()) { var c = this.getUint32(4); this._fileDirectories.length = 0; this.parseFileDirectory(c); var d = this._fileDirectories[0], c = d.ImageWidth.values[0], e = d.ImageLength.values[0]; this.canvas.width = c; this.canvas.height = e; var f = [], g = d.Compression ? d.Compression.values[0] : 1, h = d.SamplesPerPixel.values[0], k = [], m = 0, n = !1; d.BitsPerSample.values.forEach(function(a, b, c) { k[b] = { bitsPerSample: a, hasBytesPerSample: !1, bytesPerSample: void 0 }; 0 === a % 8 && (k[b].hasBytesPerSample = !0, k[b].bytesPerSample = a / 8); m += a }, this); if (0 === m % 8) var n = !0, p = m / 8; var t = d.StripOffsets.values, r = t.length; if (d.StripByteCounts) var u = d.StripByteCounts.values; else if (cc.log("Missing StripByteCounts!"), 1 === r) u = [Math.ceil(c * e * m / 8)]; else throw Error("Cannot recover from missing StripByteCounts"); for (var s = 0; s < r; s++) { var v = t[s]; f[s] = []; for (var x = u[s], D = 0, E = 0, A = 1, w = !0, B = [], y = 0, z = 0, F = 0; D < x; D += A) switch (g) { case 1: A = 0; for (B = []; A < h; A++) if (k[A].hasBytesPerSample) B.push(this.getBytes(k[A].bytesPerSample, v + D + k[A].bytesPerSample * A)); else { var J = this.getBits(k[A].bitsPerSample, v + D, E); B.push(J.bits); D = J.byteOffset - v; E = J.bitOffset; throw RangeError("Cannot handle sub-byte bits per sample"); } f[s].push(B); if (n) A = p; else throw A = 0, RangeError("Cannot handle sub-byte bits per pixel"); break; case 32773: if (w) { var w = !1, C = 1, N = 1, A = this.getInt8(v + D); 0 <= A && 127 >= A ? C = A + 1 : -127 <= A && -1 >= A ? N = -A + 1 : w = !0 } else { for (var L = this.getUint8(v + D), A = 0; A < N; A++) { if (k[z].hasBytesPerSample) F = F << 8 * y | L, y++, y === k[z].bytesPerSample && (B.push(F), F = y = 0, z++); else throw RangeError("Cannot handle sub-byte bits per sample"); z === h && (f[s].push(B), B = [], z = 0) } C--; 0 === C && (w = !0) } A = 1 } } if (b.getContext) { p = this.canvas.getContext("2d"); p.fillStyle = "rgba(255, 255, 255, 0)"; s = d.RowsPerStrip ? d.RowsPerStrip.values[0] : e; v = f.length; e %= s; e = 0 === e ? s : e; D = s; g = 0; B = d.PhotometricInterpretation.values[0]; C = []; N = 0; d.ExtraSamples && (C = d.ExtraSamples.values, N = C.length); if (d.ColorMap) var J = d.ColorMap.values, P = Math.pow(2, k[0].bitsPerSample); for (s = 0; s < v; s++) { s + 1 === v && (D = e); d = f[s].length; g *= s; for (n = h = 0; h < D, n < d; h++) for (t = 0; t < c; t++, n++) { u = f[s][n]; w = E = x = 0; r = 1; if (0 < N) for (x = 0; x < N; x++) if (1 === C[x] || 2 === C[x]) { r = u[3 + x] / 256; break } switch (B) { case 0: if (k[0].hasBytesPerSample) var S = Math.pow(16, 2 * k[0].bytesPerSample); u.forEach(function(a, b, c) { c[b] = S - a }); case 1: x = E = w = this.clampColorSample(u[0], k[0].bitsPerSample); break; case 2: x = this.clampColorSample(u[0], k[0].bitsPerSample); E = this.clampColorSample(u[1], k[1].bitsPerSample); w = this.clampColorSample(u[2], k[2].bitsPerSample); break; case 3: if (void 0 === J) throw Error("Palette image missing color map"); u = u[0]; x = this.clampColorSample(J[u], 16); E = this.clampColorSample(J[P + u], 16); w = this.clampColorSample(J[2 * P + u], 16); break; default: throw RangeError("Unknown Photometric Interpretation:", B); } p.fillStyle = "rgba(" + x + ", " + E + ", " + w + ", " + r + ")"; p.fillRect(t, g + h, 1, 1) } g = D } } return this.canvas } }, fieldTagNames: { 315: "Artist", 258: "BitsPerSample", 265: "CellLength", 264: "CellWidth", 320: "ColorMap", 259: "Compression", 33432: "Copyright", 306: "DateTime", 338: "ExtraSamples", 266: "FillOrder", 289: "FreeByteCounts", 288: "FreeOffsets", 291: "GrayResponseCurve", 290: "GrayResponseUnit", 316: "HostComputer", 270: "ImageDescription", 257: "ImageLength", 256: "ImageWidth", 271: "Make", 281: "MaxSampleValue", 280: "MinSampleValue", 272: "Model", 254: "NewSubfileType", 274: "Orientation", 262: "PhotometricInterpretation", 284: "PlanarConfiguration", 296: "ResolutionUnit", 278: "RowsPerStrip", 277: "SamplesPerPixel", 305: "Software", 279: "StripByteCounts", 273: "StripOffsets", 255: "SubfileType", 263: "Threshholding", 282: "XResolution", 283: "YResolution", 326: "BadFaxLines", 327: "CleanFaxData", 343: "ClipPath", 328: "ConsecutiveBadFaxLines", 433: "Decode", 434: "DefaultImageColor", 269: "DocumentName", 336: "DotRange", 321: "HalftoneHints", 346: "Indexed", 347: "JPEGTables", 285: "PageName", 297: "PageNumber", 317: "Predictor", 319: "PrimaryChromaticities", 532: "ReferenceBlackWhite", 339: "SampleFormat", 559: "StripRowCounts", 330: "SubIFDs", 292: "T4Options", 293: "T6Options", 325: "TileByteCounts", 323: "TileLength", 324: "TileOffsets", 322: "TileWidth", 301: "TransferFunction", 318: "WhitePoint", 344: "XClipPathUnits", 286: "XPosition", 529: "YCbCrCoefficients", 531: "YCbCrPositioning", 530: "YCbCrSubSampling", 345: "YClipPathUnits", 287: "YPosition", 37378: "ApertureValue", 40961: "ColorSpace", 36868: "DateTimeDigitized", 36867: "DateTimeOriginal", 34665: "Exif IFD", 36864: "ExifVersion", 33434: "ExposureTime", 41728: "FileSource", 37385: "Flash", 40960: "FlashpixVersion", 33437: "FNumber", 42016: "ImageUniqueID", 37384: "LightSource", 37500: "MakerNote", 37377: "ShutterSpeedValue", 37510: "UserComment", 33723: "IPTC", 34675: "ICC Profile", 700: "XMP", 42112: "GDAL_METADATA", 42113: "GDAL_NODATA", 34377: "Photoshop" }, fieldTypeNames: { 1: "BYTE", 2: "ASCII", 3: "SHORT", 4: "LONG", 5: "RATIONAL", 6: "SBYTE", 7: "UNDEFINED", 8: "SSHORT", 9: "SLONG", 10: "SRATIONAL", 11: "FLOAT", 12: "DOUBLE" } }; cc.Particle = function(a, b, c, d, e, f, g, h, k, m, n, p) { this.pos = a ? a : cc.p(0, 0); this.startPos = b ? b : cc.p(0, 0); this.color = c ? c : { r: 0, g: 0, b: 0, a: 255 }; this.deltaColor = d ? d : { r: 0, g: 0, b: 0, a: 255 }; this.size = e || 0; this.deltaSize = f || 0; this.rotation = g || 0; this.deltaRotation = h || 0; this.timeToLive = k || 0; this.atlasIndex = m || 0; this.modeA = n ? n : new cc.Particle.ModeA; this.modeB = p ? p : new cc.Particle.ModeB; this.isChangeColor = !1; this.drawPos = cc.p(0, 0) }; cc.Particle.ModeA = function(a, b, c) { this.dir = a ? a : cc.p(0, 0); this.radialAccel = b || 0; this.tangentialAccel = c || 0 }; cc.Particle.ModeB = function(a, b, c, d) { this.angle = a || 0; this.degreesPerSecond = b || 0; this.radius = c || 0; this.deltaRadius = d || 0 }; cc.Particle.TemporaryPoints = [cc.p(), cc.p(), cc.p(), cc.p()]; cc.ParticleSystem = cc.Node.extend({ _className: "ParticleSystem", _plistFile: "", _elapsed: 0, _dontTint: !1, modeA: null, modeB: null, _pointZeroForParticle: cc.p(0, 0), _particles: null, _emitCounter: 0, _particleIdx: 0, _batchNode: null, atlasIndex: 0, _transformSystemDirty: !1, _allocatedParticles: 0, _isActive: !1, particleCount: 0, duration: 0, _sourcePosition: null, _posVar: null, life: 0, lifeVar: 0, angle: 0, angleVar: 0, startSize: 0, startSizeVar: 0, endSize: 0, endSizeVar: 0, _startColor: null, _startColorVar: null, _endColor: null, _endColorVar: null, startSpin: 0, startSpinVar: 0, endSpin: 0, endSpinVar: 0, emissionRate: 0, _totalParticles: 0, _texture: null, _blendFunc: null, _opacityModifyRGB: !1, positionType: null, autoRemoveOnFinish: !1, emitterMode: 0, _textureLoaded: null, ctor: function(a) { cc.Node.prototype.ctor.call(this); this.emitterMode = cc.ParticleSystem.MODE_GRAVITY; this.modeA = new cc.ParticleSystem.ModeA; this.modeB = new cc.ParticleSystem.ModeB; this._blendFunc = { src: cc.BLEND_SRC, dst: cc.BLEND_DST }; this._particles = []; this._sourcePosition = cc.p(0, 0); this._posVar = cc.p(0, 0); this._startColor = cc.color(255, 255, 255, 255); this._startColorVar = cc.color(255, 255, 255, 255); this._endColor = cc.color(255, 255, 255, 255); this._endColorVar = cc.color(255, 255, 255, 255); this._plistFile = ""; this._elapsed = 0; this._dontTint = !1; this._pointZeroForParticle = cc.p(0, 0); this._particleIdx = this._emitCounter = 0; this._batchNode = null; this.atlasIndex = 0; this._transformSystemDirty = !1; this._allocatedParticles = 0; this._isActive = !1; this._totalParticles = this.emissionRate = this.endSpinVar = this.endSpin = this.startSpinVar = this.startSpin = this.endSizeVar = this.endSize = this.startSizeVar = this.startSize = this.angleVar = this.angle = this.lifeVar = this.life = this.duration = this.particleCount = 0; this._texture = null; this._opacityModifyRGB = !1; this.positionType = cc.ParticleSystem.TYPE_FREE; this.autoRemoveOnFinish = !1; this._textureLoaded = !0; !a || cc.isNumber(a) ? (a = a || 100, this.setDrawMode(cc.ParticleSystem.TEXTURE_MODE), this.initWithTotalParticles(a)) : cc.isString(a) ? this.initWithFile(a) : cc.isObject(a) && this.initWithDictionary(a, "") }, _createRenderCmd: function() { return cc._renderType === cc._RENDER_TYPE_CANVAS ? new cc.ParticleSystem.CanvasRenderCmd(this) : new cc.ParticleSystem.WebGLRenderCmd(this) }, ignoreColor: function(a) { this._dontTint = a }, initTexCoordsWithRect: function(a) { this._renderCmd.initTexCoordsWithRect(a) }, getBatchNode: function() { return this._batchNode }, setBatchNode: function(a) { this._renderCmd.setBatchNode(a) }, getAtlasIndex: function() { return this.atlasIndex }, setAtlasIndex: function(a) { this.atlasIndex = a }, getDrawMode: function() { return this._renderCmd.getDrawMode() }, setDrawMode: function(a) { this._renderCmd.setDrawMode(a) }, getShapeType: function() { return this._renderCmd.getShapeType() }, setShapeType: function(a) { this._renderCmd.setShapeType(a) }, isActive: function() { return this._isActive }, getParticleCount: function() { return this.particleCount }, setParticleCount: function(a) { this.particleCount = a }, getDuration: function() { return this.duration }, setDuration: function(a) { this.duration = a }, getSourcePosition: function() { return { x: this._sourcePosition.x, y: this._sourcePosition.y } }, setSourcePosition: function(a) { this._sourcePosition = a }, getPosVar: function() { return { x: this._posVar.x, y: this._posVar.y } }, setPosVar: function(a) { this._posVar = a }, getLife: function() { return this.life }, setLife: function(a) { this.life = a }, getLifeVar: function() { return this.lifeVar }, setLifeVar: function(a) { this.lifeVar = a }, getAngle: function() { return this.angle }, setAngle: function(a) { this.angle = a }, getAngleVar: function() { return this.angleVar }, setAngleVar: function(a) { this.angleVar = a }, getGravity: function() { this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.getGravity() : Particle Mode should be Gravity"); var a = this.modeA.gravity; return cc.p(a.x, a.y) }, setGravity: function(a) { this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.setGravity() : Particle Mode should be Gravity"); this.modeA.gravity = a }, getSpeed: function() { this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.getSpeed() : Particle Mode should be Gravity"); return this.modeA.speed }, setSpeed: function(a) { this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.setSpeed() : Particle Mode should be Gravity"); this.modeA.speed = a }, getSpeedVar: function() { this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.getSpeedVar() : Particle Mode should be Gravity"); return this.modeA.speedVar }, setSpeedVar: function(a) { this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.setSpeedVar() : Particle Mode should be Gravity"); this.modeA.speedVar = a }, getTangentialAccel: function() { this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.getTangentialAccel() : Particle Mode should be Gravity"); return this.modeA.tangentialAccel }, setTangentialAccel: function(a) { this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.setTangentialAccel() : Particle Mode should be Gravity"); this.modeA.tangentialAccel = a }, getTangentialAccelVar: function() { this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.getTangentialAccelVar() : Particle Mode should be Gravity"); return this.modeA.tangentialAccelVar }, setTangentialAccelVar: function(a) { this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.setTangentialAccelVar() : Particle Mode should be Gravity"); this.modeA.tangentialAccelVar = a }, getRadialAccel: function() { this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.getRadialAccel() : Particle Mode should be Gravity"); return this.modeA.radialAccel }, setRadialAccel: function(a) { this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.setRadialAccel() : Particle Mode should be Gravity"); this.modeA.radialAccel = a }, getRadialAccelVar: function() { this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.getRadialAccelVar() : Particle Mode should be Gravity"); return this.modeA.radialAccelVar }, setRadialAccelVar: function(a) { this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.setRadialAccelVar() : Particle Mode should be Gravity"); this.modeA.radialAccelVar = a }, getRotationIsDir: function() { this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.getRotationIsDir() : Particle Mode should be Gravity"); return this.modeA.rotationIsDir }, setRotationIsDir: function(a) { this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.setRotationIsDir() : Particle Mode should be Gravity"); this.modeA.rotationIsDir = a }, getStartRadius: function() { this.emitterMode !== cc.ParticleSystem.MODE_RADIUS && cc.log("cc.ParticleBatchNode.getStartRadius() : Particle Mode should be Radius"); return this.modeB.startRadius }, setStartRadius: function(a) { this.emitterMode !== cc.ParticleSystem.MODE_RADIUS && cc.log("cc.ParticleBatchNode.setStartRadius() : Particle Mode should be Radius"); this.modeB.startRadius = a }, getStartRadiusVar: function() { this.emitterMode !== cc.ParticleSystem.MODE_RADIUS && cc.log("cc.ParticleBatchNode.getStartRadiusVar() : Particle Mode should be Radius"); return this.modeB.startRadiusVar }, setStartRadiusVar: function(a) { this.emitterMode !== cc.ParticleSystem.MODE_RADIUS && cc.log("cc.ParticleBatchNode.setStartRadiusVar() : Particle Mode should be Radius"); this.modeB.startRadiusVar = a }, getEndRadius: function() { this.emitterMode !== cc.ParticleSystem.MODE_RADIUS && cc.log("cc.ParticleBatchNode.getEndRadius() : Particle Mode should be Radius"); return this.modeB.endRadius }, setEndRadius: function(a) { this.emitterMode !== cc.ParticleSystem.MODE_RADIUS && cc.log("cc.ParticleBatchNode.setEndRadius() : Particle Mode should be Radius"); this.modeB.endRadius = a }, getEndRadiusVar: function() { this.emitterMode !== cc.ParticleSystem.MODE_RADIUS && cc.log("cc.ParticleBatchNode.getEndRadiusVar() : Particle Mode should be Radius"); return this.modeB.endRadiusVar }, setEndRadiusVar: function(a) { this.emitterMode !== cc.ParticleSystem.MODE_RADIUS && cc.log("cc.ParticleBatchNode.setEndRadiusVar() : Particle Mode should be Radius"); this.modeB.endRadiusVar = a }, getRotatePerSecond: function() { this.emitterMode !== cc.ParticleSystem.MODE_RADIUS && cc.log("cc.ParticleBatchNode.getRotatePerSecond() : Particle Mode should be Radius"); return this.modeB.rotatePerSecond }, setRotatePerSecond: function(a) { this.emitterMode !== cc.ParticleSystem.MODE_RADIUS && cc.log("cc.ParticleBatchNode.setRotatePerSecond() : Particle Mode should be Radius"); this.modeB.rotatePerSecond = a }, getRotatePerSecondVar: function() { this.emitterMode !== cc.ParticleSystem.MODE_RADIUS && cc.log("cc.ParticleBatchNode.getRotatePerSecondVar() : Particle Mode should be Radius"); return this.modeB.rotatePerSecondVar }, setRotatePerSecondVar: function(a) { this.emitterMode !== cc.ParticleSystem.MODE_RADIUS && cc.log("cc.ParticleBatchNode.setRotatePerSecondVar() : Particle Mode should be Radius"); this.modeB.rotatePerSecondVar = a }, setScale: function(a, b) { this._transformSystemDirty = !0; cc.Node.prototype.setScale.call(this, a, b) }, setRotation: function(a) { this._transformSystemDirty = !0; cc.Node.prototype.setRotation.call(this, a) }, setScaleX: function(a) { this._transformSystemDirty = !0; cc.Node.prototype.setScaleX.call(this, a) }, setScaleY: function(a) { this._transformSystemDirty = !0; cc.Node.prototype.setScaleY.call(this, a) }, getStartSize: function() { return this.startSize }, setStartSize: function(a) { this.startSize = a }, getStartSizeVar: function() { return this.startSizeVar }, setStartSizeVar: function(a) { this.startSizeVar = a }, getEndSize: function() { return this.endSize }, setEndSize: function(a) { this.endSize = a }, getEndSizeVar: function() { return this.endSizeVar }, setEndSizeVar: function(a) { this.endSizeVar = a }, getStartColor: function() { return cc.color(this._startColor.r, this._startColor.g, this._startColor.b, this._startColor.a) }, setStartColor: function(a) { this._startColor = cc.color(a) }, getStartColorVar: function() { return cc.color(this._startColorVar.r, this._startColorVar.g, this._startColorVar.b, this._startColorVar.a) }, setStartColorVar: function(a) { this._startColorVar = cc.color(a) }, getEndColor: function() { return cc.color(this._endColor.r, this._endColor.g, this._endColor.b, this._endColor.a) }, setEndColor: function(a) { this._endColor = cc.color(a) }, getEndColorVar: function() { return cc.color(this._endColorVar.r, this._endColorVar.g, this._endColorVar.b, this._endColorVar.a) }, setEndColorVar: function(a) { this._endColorVar = cc.color(a) }, getStartSpin: function() { return this.startSpin }, setStartSpin: function(a) { this.startSpin = a }, getStartSpinVar: function() { return this.startSpinVar }, setStartSpinVar: function(a) { this.startSpinVar = a }, getEndSpin: function() { return this.endSpin }, setEndSpin: function(a) { this.endSpin = a }, getEndSpinVar: function() { return this.endSpinVar }, setEndSpinVar: function(a) { this.endSpinVar = a }, getEmissionRate: function() { return this.emissionRate }, setEmissionRate: function(a) { this.emissionRate = a }, getTotalParticles: function() { return this._totalParticles }, setTotalParticles: function(a) { this._renderCmd.setTotalParticles(a) }, getTexture: function() { return this._texture }, setTexture: function(a) { a && (a.isLoaded() ? this.setTextureWithRect(a, cc.rect(0, 0, a.width, a.height)) : (this._textureLoaded = !1, a.addEventListener("load", function(a) { this._textureLoaded = !0; this.setTextureWithRect(a, cc.rect(0, 0, a.width, a.height)) }, this))) }, getBlendFunc: function() { return this._blendFunc }, setBlendFunc: function(a, b) { if (void 0 === b) this._blendFunc !== a && (this._blendFunc = a, this._updateBlendFunc()); else if (this._blendFunc.src !== a || this._blendFunc.dst !== b) this._blendFunc = { src: a, dst: b }, this._updateBlendFunc() }, isOpacityModifyRGB: function() { return this._opacityModifyRGB }, setOpacityModifyRGB: function(a) { this._opacityModifyRGB = a }, isBlendAdditive: function() { return this._blendFunc.src === cc.SRC_ALPHA && this._blendFunc.dst === cc.ONE || this._blendFunc.src === cc.ONE && this._blendFunc.dst === cc.ONE }, setBlendAdditive: function(a) { var b = this._blendFunc; a ? (b.src = cc.SRC_ALPHA, b.dst = cc.ONE) : this._renderCmd._setBlendAdditive() }, getPositionType: function() { return this.positionType }, setPositionType: function(a) { this.positionType = a }, isAutoRemoveOnFinish: function() { return this.autoRemoveOnFinish }, setAutoRemoveOnFinish: function(a) { this.autoRemoveOnFinish = a }, getEmitterMode: function() { return this.emitterMode }, setEmitterMode: function(a) { this.emitterMode = a }, init: function() { return this.initWithTotalParticles(150) }, initWithFile: function(a) { this._plistFile = a; a = cc.loader.getRes(a); return a ? this.initWithDictionary(a, "") : (cc.log("cc.ParticleSystem.initWithFile(): Particles: file not found"), !1) }, getBoundingBoxToWorld: function() { return cc.rect(0, 0, cc._canvas.width, cc._canvas.height) }, initWithDictionary: function(a, b) { var c = !1, d = null, d = this._valueForKey, e = parseInt(d("maxParticles", a)); if (this.initWithTotalParticles(e)) { this.angle = parseFloat(d("angle", a)); this.angleVar = parseFloat(d("angleVariance", a)); this.duration = parseFloat(d("duration", a)); this._blendFunc.src = parseInt(d("blendFuncSource", a)); this._blendFunc.dst = parseInt(d("blendFuncDestination", a)); c = this._startColor; c.r = 255 * parseFloat(d("startColorRed", a)); c.g = 255 * parseFloat(d("startColorGreen", a)); c.b = 255 * parseFloat(d("startColorBlue", a)); c.a = 255 * parseFloat(d("startColorAlpha", a)); c = this._startColorVar; c.r = 255 * parseFloat(d("startColorVarianceRed", a)); c.g = 255 * parseFloat(d("startColorVarianceGreen", a)); c.b = 255 * parseFloat(d("startColorVarianceBlue", a)); c.a = 255 * parseFloat(d("startColorVarianceAlpha", a)); c = this._endColor; c.r = 255 * parseFloat(d("finishColorRed", a)); c.g = 255 * parseFloat(d("finishColorGreen", a)); c.b = 255 * parseFloat(d("finishColorBlue", a)); c.a = 255 * parseFloat(d("finishColorAlpha", a)); c = this._endColorVar; c.r = 255 * parseFloat(d("finishColorVarianceRed", a)); c.g = 255 * parseFloat(d("finishColorVarianceGreen", a)); c.b = 255 * parseFloat(d("finishColorVarianceBlue", a)); c.a = 255 * parseFloat(d("finishColorVarianceAlpha", a)); this.startSize = parseFloat(d("startParticleSize", a)); this.startSizeVar = parseFloat(d("startParticleSizeVariance", a)); this.endSize = parseFloat(d("finishParticleSize", a)); this.endSizeVar = parseFloat(d("finishParticleSizeVariance", a)); this.setPosition(parseFloat(d("sourcePositionx", a)), parseFloat(d("sourcePositiony", a))); this._posVar.x = parseFloat(d("sourcePositionVariancex", a)); this._posVar.y = parseFloat(d("sourcePositionVariancey", a)); this.startSpin = parseFloat(d("rotationStart", a)); this.startSpinVar = parseFloat(d("rotationStartVariance", a)); this.endSpin = parseFloat(d("rotationEnd", a)); this.endSpinVar = parseFloat(d("rotationEndVariance", a)); this.emitterMode = parseInt(d("emitterType", a)); if (this.emitterMode === cc.ParticleSystem.MODE_GRAVITY) c = this.modeA, c.gravity.x = parseFloat(d("gravityx", a)), c.gravity.y = parseFloat(d("gravityy", a)), c.speed = parseFloat(d("speed", a)), c.speedVar = parseFloat(d("speedVariance", a)), e = d("radialAcceleration", a), c.radialAccel = e ? parseFloat(e) : 0, e = d("radialAccelVariance", a), c.radialAccelVar = e ? parseFloat(e) : 0, e = d("tangentialAcceleration", a), c.tangentialAccel = e ? parseFloat(e) : 0, e = d("tangentialAccelVariance", a), c.tangentialAccelVar = e ? parseFloat(e) : 0, e = d("rotationIsDir", a).toLowerCase(), c.rotationIsDir = null != e && ("true" === e || "1" === e); else if (this.emitterMode === cc.ParticleSystem.MODE_RADIUS) c = this.modeB, c.startRadius = parseFloat(d("maxRadius", a)), c.startRadiusVar = parseFloat(d("maxRadiusVariance", a)), c.endRadius = parseFloat(d("minRadius", a)), c.endRadiusVar = 0, c.rotatePerSecond = parseFloat(d("rotatePerSecond", a)), c.rotatePerSecondVar = parseFloat(d("rotatePerSecondVariance", a)); else return cc.log("cc.ParticleSystem.initWithDictionary(): Invalid emitterType in config file"), !1; this.life = parseFloat(d("particleLifespan", a)); this.lifeVar = parseFloat(d("particleLifespanVariance", a)); this.emissionRate = this._totalParticles / this.life; if (!this._batchNode) if (this._opacityModifyRGB = !1, c = d("textureFileName", a), c = cc.path.changeBasename(this._plistFile, c), e = cc.textureCache.getTextureForKey(c)) this.setTexture(e); else if ((d = d("textureImageData", a)) && 0 !== d.length) { d = cc.unzipBase64AsArray(d, 1); if (!d) return cc.log("cc.ParticleSystem: error decoding or ungzipping textureImageData"), !1; e = cc.getImageFormatByData(d); if (e !== cc.FMT_TIFF && e !== cc.FMT_PNG) return cc.log("cc.ParticleSystem: unknown image format with Data"), !1; var f = cc.newElement("canvas"); e === cc.FMT_PNG ? (new cc.PNGReader(d)).render(f) : cc.tiffReader.parseTIFF(d, f); cc.textureCache.cacheImage(c, f); (d = cc.textureCache.getTextureForKey(c)) || cc.log("cc.ParticleSystem.initWithDictionary() : error loading the texture"); this.setTexture(d) } else { e = cc.textureCache.addImage(c); if (!e) return !1; this.setTexture(e) } c = !0 } return c }, initWithTotalParticles: function(a) { this._totalParticles = a; var b, c = this._particles; for (b = c.length = 0; b < a; b++) c[b] = new cc.Particle; if (!c) return cc.log("Particle system: not enough memory"), !1; this._allocatedParticles = a; if (this._batchNode) for (b = 0; b < this._totalParticles; b++) c[b].atlasIndex = b; this._isActive = !0; this._blendFunc.src = cc.BLEND_SRC; this._blendFunc.dst = cc.BLEND_DST; this.positionType = cc.ParticleSystem.TYPE_FREE; this.emitterMode = cc.ParticleSystem.MODE_GRAVITY; this._transformSystemDirty = this.autoRemoveOnFinish = !1; this.scheduleUpdateWithPriority(1); this._renderCmd._initWithTotalParticles(a); return !0 }, destroyParticleSystem: function() { this.unscheduleUpdate() }, addParticle: function() { if (this.isFull()) return !1; var a = this._renderCmd.addParticle(); this.initParticle(a); ++this.particleCount; return !0 }, initParticle: function(a) { var b = cc.randomMinus1To1; a.timeToLive = this.life + this.lifeVar * b(); a.timeToLive = Math.max(0, a.timeToLive); a.pos.x = this._sourcePosition.x + this._posVar.x * b(); a.pos.y = this._sourcePosition.y + this._posVar.y * b(); var c, d; c = this._startColor; var e = this._startColorVar, f = this._endColor; d = this._endColorVar; c = { r: cc.clampf(c.r + e.r * b(), 0, 255), g: cc.clampf(c.g + e.g * b(), 0, 255), b: cc.clampf(c.b + e.b * b(), 0, 255), a: cc.clampf(c.a + e.a * b(), 0, 255) }; d = { r: cc.clampf(f.r + d.r * b(), 0, 255), g: cc.clampf(f.g + d.g * b(), 0, 255), b: cc.clampf(f.b + d.b * b(), 0, 255), a: cc.clampf(f.a + d.a * b(), 0, 255) }; a.color = c; e = a.deltaColor; f = a.timeToLive; e.r = (d.r - c.r) / f; e.g = (d.g - c.g) / f; e.b = (d.b - c.b) / f; e.a = (d.a - c.a) / f; c = this.startSize + this.startSizeVar * b(); c = Math.max(0, c); a.size = c; this.endSize === cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE ? a.deltaSize = 0 : (d = this.endSize + this.endSizeVar * b(), d = Math.max(0, d), a.deltaSize = (d - c) / f); c = this.startSpin + this.startSpinVar * b(); d = this.endSpin + this.endSpinVar * b(); a.rotation = c; a.deltaRotation = (d - c) / f; this.positionType === cc.ParticleSystem.TYPE_FREE ? a.startPos = this.convertToWorldSpace(this._pointZeroForParticle) : this.positionType === cc.ParticleSystem.TYPE_RELATIVE && (a.startPos.x = this._position.x, a.startPos.y = this._position.y); c = cc.degreesToRadians(this.angle + this.angleVar * b()); if (this.emitterMode === cc.ParticleSystem.MODE_GRAVITY) f = this.modeA, d = a.modeA, e = f.speed + f.speedVar * b(), d.dir.x = Math.cos(c), d.dir.y = Math.sin(c), cc.pMultIn(d.dir, e), d.radialAccel = f.radialAccel + f.radialAccelVar * b(), d.tangentialAccel = f.tangentialAccel + f.tangentialAccelVar * b(), f.rotationIsDir && (a.rotation = -cc.radiansToDegrees(cc.pToAngle(d.dir))); else { d = this.modeB; a = a.modeB; var e = d.startRadius + d.startRadiusVar * b(), g = d.endRadius + d.endRadiusVar * b(); a.radius = e; a.deltaRadius = d.endRadius === cc.ParticleSystem.START_RADIUS_EQUAL_TO_END_RADIUS ? 0 : (g - e) / f; a.angle = c; a.degreesPerSecond = cc.degreesToRadians(d.rotatePerSecond + d.rotatePerSecondVar * b()) } }, stopSystem: function() { this._isActive = !1; this._elapsed = this.duration; this._emitCounter = 0 }, resetSystem: function() { this._isActive = !0; this._elapsed = 0; var a = this._particles; for (this._particleIdx = 0; this._particleIdx < this.particleCount; ++this._particleIdx) a[this._particleIdx].timeToLive = 0 }, isFull: function() { return this.particleCount >= this._totalParticles }, updateQuadWithParticle: function(a, b) { this._renderCmd.updateQuadWithParticle(a, b) }, postStep: function() { this._renderCmd.postStep() }, update: function(a) { if (this._isActive && this.emissionRate) { var b = 1 / this.emissionRate; this.particleCount < this._totalParticles && (this._emitCounter += a); for (; this.particleCount < this._totalParticles && this._emitCounter > b;) this.addParticle(), this._emitCounter -= b; this._elapsed += a; - 1 !== this.duration && this.duration < this._elapsed && this.stopSystem() } this._particleIdx = 0; b = cc.Particle.TemporaryPoints[0]; this.positionType === cc.ParticleSystem.TYPE_FREE ? cc.pIn(b, this.convertToWorldSpace(this._pointZeroForParticle)) : this.positionType === cc.ParticleSystem.TYPE_RELATIVE && (b.x = this._position.x, b.y = this._position.y); if (this._visible) { for (var c = cc.Particle.TemporaryPoints[1], d = cc.Particle.TemporaryPoints[2], e = cc.Particle.TemporaryPoints[3], f = this._particles; this._particleIdx < this.particleCount;) { cc.pZeroIn(c); cc.pZeroIn(d); cc.pZeroIn(e); var g = f[this._particleIdx]; g.timeToLive -= a; if (0 < g.timeToLive) { if (this.emitterMode === cc.ParticleSystem.MODE_GRAVITY) { var h = e, k = c, m = d; g.pos.x || g.pos.y ? (cc.pIn(k, g.pos), cc.pNormalizeIn(k)) : cc.pZeroIn(k); cc.pIn(m, k); cc.pMultIn(k, g.modeA.radialAccel); var n = m.x; m.x = -m.y; m.y = n; cc.pMultIn(m, g.modeA.tangentialAccel); cc.pIn(h, k); cc.pAddIn(h, m); cc.pAddIn(h, this.modeA.gravity); cc.pMultIn(h, a); cc.pAddIn(g.modeA.dir, h); cc.pIn(h, g.modeA.dir); cc.pMultIn(h, a); cc.pAddIn(g.pos, h) } else h = g.modeB, h.angle += h.degreesPerSecond * a, h.radius += h.deltaRadius * a, g.pos.x = -Math.cos(h.angle) * h.radius, g.pos.y = -Math.sin(h.angle) * h.radius; this._renderCmd._updateDeltaColor(g, a); g.size += g.deltaSize * a; g.size = Math.max(0, g.size); g.rotation += g.deltaRotation * a; h = c; this.positionType === cc.ParticleSystem.TYPE_FREE || this.positionType === cc.ParticleSystem.TYPE_RELATIVE ? (k = d, cc.pIn(k, b), cc.pSubIn(k, g.startPos), cc.pIn(h, g.pos), cc.pSubIn(h, k)) : cc.pIn(h, g.pos); this._batchNode && (h.x += this._position.x, h.y += this._position.y); this._renderCmd.updateParticlePosition(g, h); ++this._particleIdx } else if (g = g.atlasIndex, this._particleIdx !== this.particleCount - 1 && (h = f[this._particleIdx], f[this._particleIdx] = f[this.particleCount - 1], f[this.particleCount - 1] = h), this._batchNode && (this._batchNode.disableParticle(this.atlasIndex + g), f[this.particleCount - 1].atlasIndex = g), --this.particleCount, 0 === this.particleCount && this.autoRemoveOnFinish) { this.unscheduleUpdate(); this._parent.removeChild(this, !0); return } } this._transformSystemDirty = !1 } this._batchNode || this.postStep() }, updateWithNoTime: function() { this.update(0) }, _valueForKey: function(a, b) { if (b) { var c = b[a]; return null != c ? c : "" } return "" }, _updateBlendFunc: function() { if (this._batchNode) cc.log("Can't change blending functions when the particle is being batched"); else { var a = this._texture; if (a && a instanceof cc.Texture2D) { this._opacityModifyRGB = !1; var b = this._blendFunc; b.src === cc.BLEND_SRC && b.dst === cc.BLEND_DST && (a.hasPremultipliedAlpha() ? this._opacityModifyRGB = !0 : (b.src = cc.SRC_ALPHA, b.dst = cc.ONE_MINUS_SRC_ALPHA)) } } }, clone: function() { var a = new cc.ParticleSystem; if (a.initWithTotalParticles(this.getTotalParticles())) { a.setAngle(this.getAngle()); a.setAngleVar(this.getAngleVar()); a.setDuration(this.getDuration()); var b = this.getBlendFunc(); a.setBlendFunc(b.src, b.dst); a.setStartColor(this.getStartColor()); a.setStartColorVar(this.getStartColorVar()); a.setEndColor(this.getEndColor()); a.setEndColorVar(this.getEndColorVar()); a.setStartSize(this.getStartSize()); a.setStartSizeVar(this.getStartSizeVar()); a.setEndSize(this.getEndSize()); a.setEndSizeVar(this.getEndSizeVar()); a.setPosition(cc.p(this.x, this.y)); a.setPosVar(cc.p(this.getPosVar().x, this.getPosVar().y)); a.setStartSpin(this.getStartSpin() || 0); a.setStartSpinVar(this.getStartSpinVar() || 0); a.setEndSpin(this.getEndSpin() || 0); a.setEndSpinVar(this.getEndSpinVar() || 0); a.setEmitterMode(this.getEmitterMode()); this.getEmitterMode() === cc.ParticleSystem.MODE_GRAVITY ? (b = this.getGravity(), a.setGravity(cc.p(b.x, b.y)), a.setSpeed(this.getSpeed()), a.setSpeedVar(this.getSpeedVar()), a.setRadialAccel(this.getRadialAccel()), a.setRadialAccelVar(this.getRadialAccelVar()), a.setTangentialAccel(this.getTangentialAccel()), a.setTangentialAccelVar(this.getTangentialAccelVar())) : this.getEmitterMode() === cc.ParticleSystem.MODE_RADIUS && (a.setStartRadius(this.getStartRadius()), a.setStartRadiusVar(this.getStartRadiusVar()), a.setEndRadius(this.getEndRadius()), a.setEndRadiusVar(this.getEndRadiusVar()), a.setRotatePerSecond(this.getRotatePerSecond()), a.setRotatePerSecondVar(this.getRotatePerSecondVar())); a.setLife(this.getLife()); a.setLifeVar(this.getLifeVar()); a.setEmissionRate(this.getEmissionRate()); if (!this.getBatchNode() && (a.setOpacityModifyRGB(this.isOpacityModifyRGB()), b = this.getTexture())) { var c = b.getContentSize(); a.setTextureWithRect(b, cc.rect(0, 0, c.width, c.height)) } } return a }, setDisplayFrame: function(a) { if (a) { var b = a.getOffsetInPixels(); 0 === b.x && 0 === b.y || cc.log("cc.ParticleSystem.setDisplayFrame(): QuadParticle only supports SpriteFrames with no offsets"); a = a.getTexture(); this._texture !== a && this.setTexture(a) } }, setTextureWithRect: function(a, b) { this._texture !== a && (this._texture = a, this._updateBlendFunc()); this.initTexCoordsWithRect(b) }, listenBackToForeground: function(a) {} }); _p = cc.ParticleSystem.prototype; cc.defineGetterSetter(_p, "opacityModifyRGB", _p.isOpacityModifyRGB, _p.setOpacityModifyRGB); cc.defineGetterSetter(_p, "batchNode", _p.getBatchNode, _p.setBatchNode); cc.defineGetterSetter(_p, "drawMode", _p.getDrawMode, _p.setDrawMode); cc.defineGetterSetter(_p, "shapeType", _p.getShapeType, _p.setShapeType); cc.defineGetterSetter(_p, "active", _p.isActive); cc.defineGetterSetter(_p, "sourcePos", _p.getSourcePosition, _p.setSourcePosition); cc.defineGetterSetter(_p, "posVar", _p.getPosVar, _p.setPosVar); cc.defineGetterSetter(_p, "gravity", _p.getGravity, _p.setGravity); cc.defineGetterSetter(_p, "speed", _p.getSpeed, _p.setSpeed); cc.defineGetterSetter(_p, "speedVar", _p.getSpeedVar, _p.setSpeedVar); cc.defineGetterSetter(_p, "tangentialAccel", _p.getTangentialAccel, _p.setTangentialAccel); cc.defineGetterSetter(_p, "tangentialAccelVar", _p.getTangentialAccelVar, _p.setTangentialAccelVar); cc.defineGetterSetter(_p, "radialAccel", _p.getRadialAccel, _p.setRadialAccel); cc.defineGetterSetter(_p, "radialAccelVar", _p.getRadialAccelVar, _p.setRadialAccelVar); cc.defineGetterSetter(_p, "rotationIsDir", _p.getRotationIsDir, _p.setRotationIsDir); cc.defineGetterSetter(_p, "startRadius", _p.getStartRadius, _p.setStartRadius); cc.defineGetterSetter(_p, "startRadiusVar", _p.getStartRadiusVar, _p.setStartRadiusVar); cc.defineGetterSetter(_p, "endRadius", _p.getEndRadius, _p.setEndRadius); cc.defineGetterSetter(_p, "endRadiusVar", _p.getEndRadiusVar, _p.setEndRadiusVar); cc.defineGetterSetter(_p, "rotatePerS", _p.getRotatePerSecond, _p.setRotatePerSecond); cc.defineGetterSetter(_p, "rotatePerSVar", _p.getRotatePerSecondVar, _p.setRotatePerSecondVar); cc.defineGetterSetter(_p, "startColor", _p.getStartColor, _p.setStartColor); cc.defineGetterSetter(_p, "startColorVar", _p.getStartColorVar, _p.setStartColorVar); cc.defineGetterSetter(_p, "endColor", _p.getEndColor, _p.setEndColor); cc.defineGetterSetter(_p, "endColorVar", _p.getEndColorVar, _p.setEndColorVar); cc.defineGetterSetter(_p, "totalParticles", _p.getTotalParticles, _p.setTotalParticles); cc.defineGetterSetter(_p, "texture", _p.getTexture, _p.setTexture); cc.ParticleSystem.create = function(a) { return new cc.ParticleSystem(a) }; cc.ParticleSystem.createWithTotalParticles = cc.ParticleSystem.create; cc.ParticleSystem.ModeA = function(a, b, c, d, e, f, g, h) { this.gravity = a ? a : cc.p(0, 0); this.speed = b || 0; this.speedVar = c || 0; this.tangentialAccel = d || 0; this.tangentialAccelVar = e || 0; this.radialAccel = f || 0; this.radialAccelVar = g || 0; this.rotationIsDir = h || !1 }; cc.ParticleSystem.ModeB = function(a, b, c, d, e, f) { this.startRadius = a || 0; this.startRadiusVar = b || 0; this.endRadius = c || 0; this.endRadiusVar = d || 0; this.rotatePerSecond = e || 0; this.rotatePerSecondVar = f || 0 }; cc.ParticleSystem.SHAPE_MODE = 0; cc.ParticleSystem.TEXTURE_MODE = 1; cc.ParticleSystem.STAR_SHAPE = 0; cc.ParticleSystem.BALL_SHAPE = 1; cc.ParticleSystem.DURATION_INFINITY = -1; cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE = -1; cc.ParticleSystem.START_RADIUS_EQUAL_TO_END_RADIUS = -1; cc.ParticleSystem.MODE_GRAVITY = 0; cc.ParticleSystem.MODE_RADIUS = 1; cc.ParticleSystem.TYPE_FREE = 0; cc.ParticleSystem.TYPE_RELATIVE = 1; cc.ParticleSystem.TYPE_GROUPED = 2; (function() { cc.ParticleSystem.CanvasRenderCmd = function(a) { cc.Node.CanvasRenderCmd.call(this, a); this._needDraw = !0; this._drawMode = cc.ParticleSystem.TEXTURE_MODE; this._shapeType = cc.ParticleSystem.BALL_SHAPE; this._pointRect = cc.rect(0, 0, 0, 0) }; var a = cc.ParticleSystem.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); a.constructor = cc.ParticleSystem.CanvasRenderCmd; a.getDrawMode = function() { return this._drawMode }; a.setDrawMode = function(a) { this._drawMode = a }; a.getShapeType = function() { return this._shapeType }; a.setShapeType = function(a) { this._shapeType = a }; a.setBatchNode = function(a) { this._batchNode !== a && (this._node._batchNode = a) }; a.updateQuadWithParticle = function(a, c) {}; a.updateParticlePosition = function(a, c) { cc.pIn(a.drawPos, c) }; a.rendering = function(a, c, d) { a = a || cc._renderContext; var e = a.getContext(), f = this._node, g = this._pointRect; a.setTransform(this._worldTransform, c, d); a.save(); f.isBlendAdditive() ? e.globalCompositeOperation = "lighter" : e.globalCompositeOperation = "source-over"; var h, k; d = this._node.particleCount; var m = this._node._particles; if (f.drawMode !== cc.ParticleSystem.SHAPE_MODE && f._texture) { if (!f._texture._textureLoaded) { a.restore(); return } f = f._texture.getHtmlElementObj(); if (!f.width || !f.height) { a.restore(); return } h = f; for (c = 0; c < d; c++) if (h = m[c], k = h.color.a / 255, 0 !== k) { e.globalAlpha = k; e.save(); e.translate(0 | h.drawPos.x, -(0 | h.drawPos.y)); var n = 4 * Math.floor(h.size / 4); k = g.width; var p = g.height; e.scale(Math.max(1 / k * n, 1E-6), Math.max(1 / p * n, 1E-6)); h.rotation && e.rotate(cc.degreesToRadians(h.rotation)); h = h.isChangeColor ? this._changeTextureColor(f, h.color, this._pointRect) : f; e.drawImage(h, -(0 | k / 2), -(0 | p / 2)); e.restore() } } else for (p = cc._drawingUtil, c = 0; c < d; c++) h = m[c], g = 0 | 0.5 * h.size, k = h.color.a / 255, 0 !== k && (e.globalAlpha = k, e.save(), e.translate(0 | h.drawPos.x, -(0 | h.drawPos.y)), f.shapeType === cc.ParticleSystem.STAR_SHAPE ? (h.rotation && e.rotate(cc.degreesToRadians(h.rotation)), p.drawStar(a, g, h.color)) : p.drawColorBall(a, g, h.color), e.restore()); a.restore(); cc.g_NumberOfDraws++ }; a._changeTextureColor = cc.sys._supportCanvasNewBlendModes ? function(a, c, d) { a.tintCache || (a.tintCache = document.createElement("canvas"), a.tintCache.width = a.width, a.tintCache.height = a.height); return cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(a, c, d, a.tintCache) } : function(a, c, d) { var e = cc.textureCache.getTextureColors(a); return e ? (e.tintCache || (e.tintCache = document.createElement("canvas"), e.tintCache.width = a.width, e.tintCache.height = a.height), cc.Sprite.CanvasRenderCmd._generateTintImage(a, e, c, d, e.tintCache), e.tintCache) : null }; a.initTexCoordsWithRect = function(a) { this._pointRect = a }; a.setTotalParticles = function(a) { this._node._totalParticles = 200 > a ? a : 200 }; a.addParticle = function() { var a = this._node, c = a._particles; a.particleCount < c.length ? a = c[a.particleCount] : (a = new cc.Particle, c.push(a)); return a }; a._setupVBO = function() {}; a._allocMemory = function() { return !0 }; a.postStep = function() {}; a._setBlendAdditive = function() { var a = this._node._blendFunc; a.src = cc.BLEND_SRC; a.dst = cc.BLEND_DST }; a._initWithTotalParticles = function(a) {}; a._updateDeltaColor = function(a, c) { this._node._dontTint || (a.color.r += a.deltaColor.r * c, a.color.g += a.deltaColor.g * c, a.color.b += a.deltaColor.b * c, a.color.a += a.deltaColor.a * c, a.isChangeColor = !0) } })(); (function() { cc.ParticleSystem.WebGLRenderCmd = function(a) { cc.Node.WebGLRenderCmd.call(this, a); this._needDraw = !0; this._buffersVBO = [0, 0]; this._quads = []; this._indices = []; this._quadsArrayBuffer = null }; var a = cc.ParticleSystem.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); a.constructor = cc.ParticleSystem.WebGLRenderCmd; a.getDrawMode = function() {}; a.setDrawMode = function(a) {}; a.getShapeType = function() {}; a.setShapeType = function(a) {}; a.setBatchNode = function(a) { var c = this._node; if (c._batchNode !== a) { var d = c._batchNode; if (c._batchNode = a) for (var e = c._particles, f = 0; f < c._totalParticles; f++) e[f].atlasIndex = f; a ? d || (c._batchNode.textureAtlas._copyQuadsToTextureAtlas(this._quads, c.atlasIndex), cc._renderContext.deleteBuffer(this._buffersVBO[1])) : (this._allocMemory(), this.initIndices(c._totalParticles), c.setTexture(d.getTexture()), this._setupVBO()) } }; a.initIndices = function(a) { for (var c = this._indices, d = 0; d < a; ++d) { var e = 6 * d, f = 4 * d; c[e + 0] = f + 0; c[e + 1] = f + 1; c[e + 2] = f + 2; c[e + 5] = f + 1; c[e + 4] = f + 2; c[e + 3] = f + 3 } }; a.isDifferentTexture = function(a, c) { return a === c }; a.updateParticlePosition = function(a, c) { this.updateQuadWithParticle(a, c) }; a.updateQuadWithParticle = function(a, c) { var d = null, e = this._node; e._batchNode ? (d = e._batchNode.textureAtlas.quads[e.atlasIndex + a.atlasIndex], e._batchNode.textureAtlas.dirty = !0) : d = this._quads[e._particleIdx]; var f, g, h; e._opacityModifyRGB ? (e = 0 | a.color.r * a.color.a / 255, f = 0 | a.color.g * a.color.a / 255, g = 0 | a.color.b * a.color.a / 255) : (e = 0 | a.color.r, f = 0 | a.color.g, g = 0 | a.color.b); h = 0 | a.color.a; var k = d.bl.colors, m = d.br.colors, n = d.tl.colors, p = d.tr.colors; k.r = m.r = n.r = p.r = e; k.g = m.g = n.g = p.g = f; k.b = m.b = n.b = p.b = g; k.a = m.a = n.a = p.a = h; e = a.size / 2; a.rotation ? (f = -e, g = -e, h = c.x, k = c.y, n = -cc.degreesToRadians(a.rotation), m = Math.cos(n), n = Math.sin(n), d.bl.vertices.x = f * m - g * n + h, d.bl.vertices.y = f * n + g * m + k, d.br.vertices.x = e * m - g * n + h, d.br.vertices.y = e * n + g * m + k, d.tl.vertices.x = f * m - e * n + h, d.tl.vertices.y = f * n + e * m + k, d.tr.vertices.x = e * m - e * n + h, d.tr.vertices.y = e * n + e * m + k) : (d.bl.vertices.x = c.x - e, d.bl.vertices.y = c.y - e, d.br.vertices.x = c.x + e, d.br.vertices.y = c.y - e, d.tl.vertices.x = c.x - e, d.tl.vertices.y = c.y + e, d.tr.vertices.x = c.x + e, d.tr.vertices.y = c.y + e) }; a.rendering = function(a) { var c = this._node; c._texture && (a = a || cc._renderContext, this._shaderProgram.use(), this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix), cc.glBindTexture2D(c._texture), cc.glBlendFuncForParticle(c._blendFunc.src, c._blendFunc.dst), cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX), a.bindBuffer(a.ARRAY_BUFFER, this._buffersVBO[0]), a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 3, a.FLOAT, !1, 24, 0), a.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, a.UNSIGNED_BYTE, !0, 24, 12), a.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, a.FLOAT, !1, 24, 16), a.bindBuffer(a.ELEMENT_ARRAY_BUFFER, this._buffersVBO[1]), a.drawElements(a.TRIANGLES, 6 * c._particleIdx, a.UNSIGNED_SHORT, 0)) }; a.initTexCoordsWithRect = function(a) { var c = this._node, d = c.texture, e = cc.contentScaleFactor(), f = cc.rect(a.x * e, a.y * e, a.width * e, a.height * e), e = a.width, g = a.height; d && (e = d.pixelsWidth, g = d.pixelsHeight); cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL ? (d = (2 * f.x + 1) / (2 * e), a = (2 * f.y + 1) / (2 * g), e = d + (2 * f.width - 2) / (2 * e), f = a + (2 * f.height - 2) / (2 * g)) : (d = f.x / e, a = f.y / g, e = d + f.width / e, f = a + f.height / g); g = f; f = a; a = g; var h = 0, k = 0; c._batchNode ? (g = c._batchNode.textureAtlas.quads, h = c.atlasIndex, k = c.atlasIndex + c._totalParticles) : (g = this._quads, h = 0, k = c._totalParticles); for (c = h; c < k; c++) g[c] || (g[c] = cc.V3F_C4B_T2F_QuadZero()), h = g[c], h.bl.texCoords.u = d, h.bl.texCoords.v = a, h.br.texCoords.u = e, h.br.texCoords.v = a, h.tl.texCoords.u = d, h.tl.texCoords.v = f, h.tr.texCoords.u = e, h.tr.texCoords.v = f }; a.setTotalParticles = function(a) { var c = this._node; if (a > c._allocatedParticles) { var d = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT; this._indices = new Uint16Array(6 * a); var e = new ArrayBuffer(a * d), f = c._particles; f.length = 0; for (var g = this._quads, h = g.length = 0; h < a; h++) f[h] = new cc.Particle, g[h] = new cc.V3F_C4B_T2F_Quad(null, null, null, null, e, h * d); c._allocatedParticles = a; c._totalParticles = a; if (c._batchNode) for (d = 0; d < a; d++) f[d].atlasIndex = d; this._quadsArrayBuffer = e; this.initIndices(a); this._setupVBO(); c._texture && this.initTexCoordsWithRect(cc.rect(0, 0, c._texture.width, c._texture.height)) } else c._totalParticles = a; c.resetSystem() }; a.addParticle = function() { var a = this._node; return a._particles[a.particleCount] }; a._setupVBO = function() { var a = cc._renderContext; this._buffersVBO[0] = a.createBuffer(); a.bindBuffer(a.ARRAY_BUFFER, this._buffersVBO[0]); a.bufferData(a.ARRAY_BUFFER, this._quadsArrayBuffer, a.DYNAMIC_DRAW); this._buffersVBO[1] = a.createBuffer(); a.bindBuffer(a.ELEMENT_ARRAY_BUFFER, this._buffersVBO[1]); a.bufferData(a.ELEMENT_ARRAY_BUFFER, this._indices, a.STATIC_DRAW) }; a._allocMemory = function() { var a = this._node; if (a._batchNode) return cc.log("cc.ParticleSystem._allocMemory(): Memory should not be allocated when not using batchNode"), !1; var c = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT, a = a._totalParticles, d = this._quads; d.length = 0; this._indices = new Uint16Array(6 * a); for (var e = new ArrayBuffer(c * a), f = 0; f < a; f++) d[f] = new cc.V3F_C4B_T2F_Quad(null, null, null, null, e, f * c); if (!d || !this._indices) return cc.log("cocos2d: Particle system: not enough memory"), !1; this._quadsArrayBuffer = e; return !0 }; a.postStep = function() { var a = cc._renderContext; a.bindBuffer(a.ARRAY_BUFFER, this._buffersVBO[0]); a.bufferData(a.ARRAY_BUFFER, this._quadsArrayBuffer, a.DYNAMIC_DRAW) }; a._setBlendAdditive = function() { var a = this._node._blendFunc; this._texture && !this._texture.hasPremultipliedAlpha() ? (a.src = cc.SRC_ALPHA, a.dst = cc.ONE_MINUS_SRC_ALPHA) : (a.src = cc.BLEND_SRC, a.dst = cc.BLEND_DST) }; a._initWithTotalParticles = function(a) { if (!this._allocMemory()) return !1; this.initIndices(a); this._setupVBO(); this._shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR) }; a._updateDeltaColor = function(a, c) { a.color.r += a.deltaColor.r * c; a.color.g += a.deltaColor.g * c; a.color.b += a.deltaColor.b * c; a.color.a += a.deltaColor.a * c; a.isChangeColor = !0 } })(); cc.ParticleFire = cc.ParticleSystem.extend({ ctor: function() { cc.ParticleSystem.prototype.ctor.call(this, cc._renderType === cc._RENDER_TYPE_WEBGL ? 300 : 150) }, initWithTotalParticles: function(a) { return cc.ParticleSystem.prototype.initWithTotalParticles.call(this, a) ? (this.setDuration(cc.ParticleSystem.DURATION_INFINITY), this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY), this.setGravity(cc.p(0, 0)), this.setRadialAccel(0), this.setRadialAccelVar(0), this.setSpeed(60), this.setSpeedVar(20), this.setAngle(90), this.setAngleVar(10), a = cc.director.getWinSize(), this.setPosition(a.width / 2, 60), this.setPosVar(cc.p(40, 20)), this.setLife(3), this.setLifeVar(0.25), this.setStartSize(54), this.setStartSizeVar(10), this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE), this.setEmissionRate(this.getTotalParticles() / this.getLife()), this.setStartColor(cc.color(194, 64, 31, 255)), this.setStartColorVar(cc.color(0, 0, 0, 0)), this.setEndColor(cc.color(0, 0, 0, 255)), this.setEndColorVar(cc.color(0, 0, 0, 0)), this.setBlendAdditive(!0), !0) : !1 } }); cc.ParticleFire.create = function() { return new cc.ParticleFire }; cc.ParticleFireworks = cc.ParticleSystem.extend({ ctor: function() { cc.ParticleSystem.prototype.ctor.call(this, cc._renderType === cc._RENDER_TYPE_WEBGL ? 1500 : 150) }, initWithTotalParticles: function(a) { return cc.ParticleSystem.prototype.initWithTotalParticles.call(this, a) ? (this.setDuration(cc.ParticleSystem.DURATION_INFINITY), this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY), this.setGravity(cc.p(0, -90)), this.setRadialAccel(0), this.setRadialAccelVar(0), this.setSpeed(180), this.setSpeedVar(50), a = cc.director.getWinSize(), this.setPosition(a.width / 2, a.height / 2), this.setAngle(90), this.setAngleVar(20), this.setLife(3.5), this.setLifeVar(1), this.setEmissionRate(this.getTotalParticles() / this.getLife()), this.setStartColor(cc.color(128, 128, 128, 255)), this.setStartColorVar(cc.color(128, 128, 128, 255)), this.setEndColor(cc.color(26, 26, 26, 51)), this.setEndColorVar(cc.color(26, 26, 26, 51)), this.setStartSize(8), this.setStartSizeVar(2), this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE), this.setBlendAdditive(!1), !0) : !1 } }); cc.ParticleFireworks.create = function() { return new cc.ParticleFireworks }; cc.ParticleSun = cc.ParticleSystem.extend({ ctor: function() { cc.ParticleSystem.prototype.ctor.call(this, cc._renderType === cc._RENDER_TYPE_WEBGL ? 350 : 150) }, initWithTotalParticles: function(a) { return cc.ParticleSystem.prototype.initWithTotalParticles.call(this, a) ? (this.setBlendAdditive(!0), this.setDuration(cc.ParticleSystem.DURATION_INFINITY), this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY), this.setGravity(cc.p(0, 0)), this.setRadialAccel(0), this.setRadialAccelVar(0), this.setSpeed(20), this.setSpeedVar(5), this.setAngle(90), this.setAngleVar(360), a = cc.director.getWinSize(), this.setPosition(a.width / 2, a.height / 2), this.setPosVar(cc.p(0, 0)), this.setLife(1), this.setLifeVar(0.5), this.setStartSize(30), this.setStartSizeVar(10), this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE), this.setEmissionRate(this.getTotalParticles() / this.getLife()), this.setStartColor(cc.color(194, 64, 31, 255)), this.setStartColorVar(cc.color(0, 0, 0, 0)), this.setEndColor(cc.color(0, 0, 0, 255)), this.setEndColorVar(cc.color(0, 0, 0, 0)), !0) : !1 } }); cc.ParticleSun.create = function() { return new cc.ParticleSun }; cc.ParticleGalaxy = cc.ParticleSystem.extend({ ctor: function() { cc.ParticleSystem.prototype.ctor.call(this, cc._renderType === cc._RENDER_TYPE_WEBGL ? 200 : 100) }, initWithTotalParticles: function(a) { return cc.ParticleSystem.prototype.initWithTotalParticles.call(this, a) ? (this.setDuration(cc.ParticleSystem.DURATION_INFINITY), this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY), this.setGravity(cc.p(0, 0)), this.setSpeed(60), this.setSpeedVar(10), this.setRadialAccel(-80), this.setRadialAccelVar(0), this.setTangentialAccel(80), this.setTangentialAccelVar(0), this.setAngle(90), this.setAngleVar(360), a = cc.director.getWinSize(), this.setPosition(a.width / 2, a.height / 2), this.setPosVar(cc.p(0, 0)), this.setLife(4), this.setLifeVar(1), this.setStartSize(37), this.setStartSizeVar(10), this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE), this.setEmissionRate(this.getTotalParticles() / this.getLife()), this.setStartColor(cc.color(31, 64, 194, 255)), this.setStartColorVar(cc.color(0, 0, 0, 0)), this.setEndColor(cc.color(0, 0, 0, 255)), this.setEndColorVar(cc.color(0, 0, 0, 0)), this.setBlendAdditive(!0), !0) : !1 } }); cc.ParticleGalaxy.create = function() { return new cc.ParticleGalaxy }; cc.ParticleFlower = cc.ParticleSystem.extend({ ctor: function() { cc.ParticleSystem.prototype.ctor.call(this, cc._renderType === cc._RENDER_TYPE_WEBGL ? 250 : 100) }, initWithTotalParticles: function(a) { return cc.ParticleSystem.prototype.initWithTotalParticles.call(this, a) ? (this.setDuration(cc.ParticleSystem.DURATION_INFINITY), this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY), this.setGravity(cc.p(0, 0)), this.setSpeed(80), this.setSpeedVar(10), this.setRadialAccel(-60), this.setRadialAccelVar(0), this.setTangentialAccel(15), this.setTangentialAccelVar(0), this.setAngle(90), this.setAngleVar(360), a = cc.director.getWinSize(), this.setPosition(a.width / 2, a.height / 2), this.setPosVar(cc.p(0, 0)), this.setLife(4), this.setLifeVar(1), this.setStartSize(30), this.setStartSizeVar(10), this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE), this.setEmissionRate(this.getTotalParticles() / this.getLife()), this.setStartColor(cc.color(128, 128, 128, 255)), this.setStartColorVar(cc.color(128, 128, 128, 128)), this.setEndColor(cc.color(0, 0, 0, 255)), this.setEndColorVar(cc.color(0, 0, 0, 0)), this.setBlendAdditive(!0), !0) : !1 } }); cc.ParticleFlower.create = function() { return new cc.ParticleFlower }; cc.ParticleMeteor = cc.ParticleSystem.extend({ ctor: function() { cc.ParticleSystem.prototype.ctor.call(this, cc._renderType === cc._RENDER_TYPE_WEBGL ? 150 : 100) }, initWithTotalParticles: function(a) { return cc.ParticleSystem.prototype.initWithTotalParticles.call(this, a) ? (this.setDuration(cc.ParticleSystem.DURATION_INFINITY), this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY), this.setGravity(cc.p(-200, 200)), this.setSpeed(15), this.setSpeedVar(5), this.setRadialAccel(0), this.setRadialAccelVar(0), this.setTangentialAccel(0), this.setTangentialAccelVar(0), this.setAngle(90), this.setAngleVar(360), a = cc.director.getWinSize(), this.setPosition(a.width / 2, a.height / 2), this.setPosVar(cc.p(0, 0)), this.setLife(2), this.setLifeVar(1), this.setStartSize(60), this.setStartSizeVar(10), this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE), this.setEmissionRate(this.getTotalParticles() / this.getLife()), this.setStartColor(cc.color(51, 102, 179)), this.setStartColorVar(cc.color(0, 0, 51, 26)), this.setEndColor(cc.color(0, 0, 0, 255)), this.setEndColorVar(cc.color(0, 0, 0, 0)), this.setBlendAdditive(!0), !0) : !1 } }); cc.ParticleMeteor.create = function() { return new cc.ParticleMeteor }; cc.ParticleSpiral = cc.ParticleSystem.extend({ ctor: function() { cc.ParticleSystem.prototype.ctor.call(this, cc._renderType === cc._RENDER_TYPE_WEBGL ? 500 : 100) }, initWithTotalParticles: function(a) { return cc.ParticleSystem.prototype.initWithTotalParticles.call(this, a) ? (this.setDuration(cc.ParticleSystem.DURATION_INFINITY), this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY), this.setGravity(cc.p(0, 0)), this.setSpeed(150), this.setSpeedVar(0), this.setRadialAccel(-380), this.setRadialAccelVar(0), this.setTangentialAccel(45), this.setTangentialAccelVar(0), this.setAngle(90), this.setAngleVar(0), a = cc.director.getWinSize(), this.setPosition(a.width / 2, a.height / 2), this.setPosVar(cc.p(0, 0)), this.setLife(12), this.setLifeVar(0), this.setStartSize(20), this.setStartSizeVar(0), this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE), this.setEmissionRate(this.getTotalParticles() / this.getLife()), this.setStartColor(cc.color(128, 128, 128, 255)), this.setStartColorVar(cc.color(128, 128, 128, 0)), this.setEndColor(cc.color(128, 128, 128, 255)), this.setEndColorVar(cc.color(128, 128, 128, 0)), this.setBlendAdditive(!1), !0) : !1 } }); cc.ParticleSpiral.create = function() { return new cc.ParticleSpiral }; cc.ParticleExplosion = cc.ParticleSystem.extend({ ctor: function() { cc.ParticleSystem.prototype.ctor.call(this, cc._renderType === cc._RENDER_TYPE_WEBGL ? 700 : 300) }, initWithTotalParticles: function(a) { return cc.ParticleSystem.prototype.initWithTotalParticles.call(this, a) ? (this.setDuration(0.1), this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY), this.setGravity(cc.p(0, 0)), this.setSpeed(70), this.setSpeedVar(40), this.setRadialAccel(0), this.setRadialAccelVar(0), this.setTangentialAccel(0), this.setTangentialAccelVar(0), this.setAngle(90), this.setAngleVar(360), a = cc.director.getWinSize(), this.setPosition(a.width / 2, a.height / 2), this.setPosVar(cc.p(0, 0)), this.setLife(5), this.setLifeVar(2), this.setStartSize(15), this.setStartSizeVar(10), this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE), this.setEmissionRate(this.getTotalParticles() / this.getDuration()), this.setStartColor(cc.color(179, 26, 51, 255)), this.setStartColorVar(cc.color(128, 128, 128, 0)), this.setEndColor(cc.color(128, 128, 128, 0)), this.setEndColorVar(cc.color(128, 128, 128, 0)), this.setBlendAdditive(!1), !0) : !1 } }); cc.ParticleExplosion.create = function() { return new cc.ParticleExplosion }; cc.ParticleSmoke = cc.ParticleSystem.extend({ ctor: function() { cc.ParticleSystem.prototype.ctor.call(this, cc._renderType === cc._RENDER_TYPE_WEBGL ? 200 : 100) }, initWithTotalParticles: function(a) { return cc.ParticleSystem.prototype.initWithTotalParticles.call(this, a) ? (this.setDuration(cc.ParticleSystem.DURATION_INFINITY), this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY), this.setGravity(cc.p(0, 0)), this.setRadialAccel(0), this.setRadialAccelVar(0), this.setSpeed(25), this.setSpeedVar(10), this.setAngle(90), this.setAngleVar(5), a = cc.director.getWinSize(), this.setPosition(a.width / 2, 0), this.setPosVar(cc.p(20, 0)), this.setLife(4), this.setLifeVar(1), this.setStartSize(60), this.setStartSizeVar(10), this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE), this.setEmissionRate(this.getTotalParticles() / this.getLife()), this.setStartColor(cc.color(204, 204, 204, 255)), this.setStartColorVar(cc.color(5, 5, 5, 0)), this.setEndColor(cc.color(0, 0, 0, 255)), this.setEndColorVar(cc.color(0, 0, 0, 0)), this.setBlendAdditive(!1), !0) : !1 } }); cc.ParticleSmoke.create = function() { return new cc.ParticleSmoke }; cc.ParticleSnow = cc.ParticleSystem.extend({ ctor: function() { cc.ParticleSystem.prototype.ctor.call(this, cc._renderType === cc._RENDER_TYPE_WEBGL ? 700 : 250) }, initWithTotalParticles: function(a) { return cc.ParticleSystem.prototype.initWithTotalParticles.call(this, a) ? (this.setDuration(cc.ParticleSystem.DURATION_INFINITY), this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY), this.setGravity(cc.p(0, -1)), this.setSpeed(5), this.setSpeedVar(1), this.setRadialAccel(0), this.setRadialAccelVar(1), this.setTangentialAccel(0), this.setTangentialAccelVar(1), a = cc.director.getWinSize(), this.setPosition(a.width / 2, a.height + 10), this.setPosVar(cc.p(a.width / 2, 0)), this.setAngle(-90), this.setAngleVar(5), this.setLife(45), this.setLifeVar(15), this.setStartSize(10), this.setStartSizeVar(5), this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE), this.setEmissionRate(10), this.setStartColor(cc.color(255, 255, 255, 255)), this.setStartColorVar(cc.color(0, 0, 0, 0)), this.setEndColor(cc.color(255, 255, 255, 0)), this.setEndColorVar(cc.color(0, 0, 0, 0)), this.setBlendAdditive(!1), !0) : !1 } }); cc.ParticleSnow.create = function() { return new cc.ParticleSnow }; cc.ParticleRain = cc.ParticleSystem.extend({ ctor: function() { cc.ParticleSystem.prototype.ctor.call(this, cc._renderType === cc._RENDER_TYPE_WEBGL ? 1E3 : 300) }, initWithTotalParticles: function(a) { return cc.ParticleSystem.prototype.initWithTotalParticles.call(this, a) ? (this.setDuration(cc.ParticleSystem.DURATION_INFINITY), this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY), this.setGravity(cc.p(10, -10)), this.setRadialAccel(0), this.setRadialAccelVar(1), this.setTangentialAccel(0), this.setTangentialAccelVar(1), this.setSpeed(130), this.setSpeedVar(30), this.setAngle(-90), this.setAngleVar(5), a = cc.director.getWinSize(), this.setPosition(a.width / 2, a.height), this.setPosVar(cc.p(a.width / 2, 0)), this.setLife(4.5), this.setLifeVar(0), this.setStartSize(4), this.setStartSizeVar(2), this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE), this.setEmissionRate(20), this.setStartColor(cc.color(179, 204, 255, 255)), this.setStartColorVar(cc.color(0, 0, 0, 0)), this.setEndColor(cc.color(179, 204, 255, 128)), this.setEndColorVar(cc.color(0, 0, 0, 0)), this.setBlendAdditive(!1), !0) : !1 } }); cc.ParticleRain.create = function() { return new cc.ParticleRain }; cc.PARTICLE_DEFAULT_CAPACITY = 500; cc.ParticleBatchNode = cc.Node.extend({ textureAtlas: null, _blendFunc: null, _className: "ParticleBatchNode", ctor: function(a, b) { cc.Node.prototype.ctor.call(this); this._blendFunc = { src: cc.BLEND_SRC, dst: cc.BLEND_DST }; cc.isString(a) ? this.init(a, b) : a instanceof cc.Texture2D && this.initWithTexture(a, b) }, _createRenderCmd: function() { return cc._renderType === cc._RENDER_TYPE_CANVAS ? new cc.ParticleBatchNode.CanvasRenderCmd(this) : new cc.ParticleBatchNode.WebGLRenderCmd(this) }, initWithTexture: function(a, b) { this.textureAtlas = new cc.TextureAtlas; this.textureAtlas.initWithTexture(a, b); this._children.length = 0; this._renderCmd._initWithTexture(); return !0 }, initWithFile: function(a, b) { var c = cc.textureCache.addImage(a); return this.initWithTexture(c, b) }, init: function(a, b) { var c = cc.textureCache.addImage(a); return this.initWithTexture(c, b) }, addChild: function(a, b, c) { if (!a) throw "cc.ParticleBatchNode.addChild() : child should be non-null"; if (!(a instanceof cc.ParticleSystem)) throw "cc.ParticleBatchNode.addChild() : only supports cc.ParticleSystem as children"; b = null == b ? a.zIndex : b; c = null == c ? a.tag : c; if (a.getTexture() !== this.textureAtlas.texture) throw "cc.ParticleSystem.addChild() : the child is not using the same texture id"; var d = a.getBlendFunc(); if (0 === this._children.length) this.setBlendFunc(d); else if (d.src !== this._blendFunc.src || d.dst !== this._blendFunc.dst) { cc.log("cc.ParticleSystem.addChild() : Can't add a ParticleSystem that uses a different blending function"); return } b = this._addChildHelper(a, b, c); c = 0; 0 !== b ? (b = this._children[b - 1], c = b.getAtlasIndex() + b.getTotalParticles()) : c = 0; this.insertChild(a, c); a.setBatchNode(this) }, insertChild: function(a, b) { var c = a.getTotalParticles(), d = this.textureAtlas, e = d.totalQuads; a.setAtlasIndex(b); e + c > d.getCapacity() && (this._increaseAtlasCapacityTo(e + c), d.fillWithEmptyQuadsFromIndex(d.getCapacity() - c, c)); a.getAtlasIndex() + c !== e && d.moveQuadsFromIndex(b, b + c); d.increaseTotalQuadsWith(c); this._updateAllAtlasIndexes() }, removeChild: function(a, b) { if (null != a) { if (!(a instanceof cc.ParticleSystem)) throw "cc.ParticleBatchNode.removeChild(): only supports cc.ParticleSystem as children"; if (-1 === this._children.indexOf(a)) cc.log("cc.ParticleBatchNode.removeChild(): doesn't contain the sprite. Can't remove it"); else { cc.Node.prototype.removeChild.call(this, a, b); var c = this.textureAtlas; c.removeQuadsAtIndex(a.getAtlasIndex(), a.getTotalParticles()); c.fillWithEmptyQuadsFromIndex(c.totalQuads, a.getTotalParticles()); a.setBatchNode(null); this._updateAllAtlasIndexes() } } }, reorderChild: function(a, b) { if (!a) throw "cc.ParticleBatchNode.reorderChild(): child should be non-null"; if (!(a instanceof cc.ParticleSystem)) throw "cc.ParticleBatchNode.reorderChild(): only supports cc.QuadParticleSystems as children"; if (-1 === this._children.indexOf(a)) cc.log("cc.ParticleBatchNode.reorderChild(): Child doesn't belong to batch"); else if (b !== a.zIndex) { if (1 < this._children.length) { var c = this._getCurrentIndex(a, b); if (c.oldIndex !== c.newIndex) { this._children.splice(c.oldIndex, 1); this._children.splice(c.newIndex, 0, a); c = a.getAtlasIndex(); this._updateAllAtlasIndexes(); for (var d = 0, e = this._children, f = 0; f < e.length; f++) if (e[f] === a) { d = a.getAtlasIndex(); break } this.textureAtlas.moveQuadsFromIndex(c, a.getTotalParticles(), d); a.updateWithNoTime() } } a._setLocalZOrder(b) } }, removeChildAtIndex: function(a, b) { this.removeChild(this._children[i], b) }, removeAllChildren: function(a) { for (var b = this._children, c = 0; c < b.length; c++) b[c].setBatchNode(null); cc.Node.prototype.removeAllChildren.call(this, a); this.textureAtlas.removeAllQuads() }, disableParticle: function(a) { a = this.textureAtlas.quads[a]; a.br.vertices.x = a.br.vertices.y = a.tr.vertices.x = a.tr.vertices.y = a.tl.vertices.x = a.tl.vertices.y = a.bl.vertices.x = a.bl.vertices.y = 0; this.textureAtlas._setDirty(!0) }, getTexture: function() { return this.textureAtlas.texture }, setTexture: function(a) { this.textureAtlas.texture = a; var b = this._blendFunc; a && !a.hasPremultipliedAlpha() && b.src === cc.BLEND_SRC && b.dst === cc.BLEND_DST && (b.src = cc.SRC_ALPHA, b.dst = cc.ONE_MINUS_SRC_ALPHA) }, setBlendFunc: function(a, b) { void 0 === b ? (this._blendFunc.src = a.src, this._blendFunc.dst = a.dst) : (this._blendFunc.src = a, this._blendFunc.src = b) }, getBlendFunc: function() { return new cc.BlendFunc(this._blendFunc.src, this._blendFunc.dst) }, _updateAllAtlasIndexes: function() { for (var a = 0, b = this._children, c = 0; c < b.length; c++) { var d = b[c]; d.setAtlasIndex(a); a += d.getTotalParticles() } }, _increaseAtlasCapacityTo: function(a) { cc.log("cocos2d: cc.ParticleBatchNode: resizing TextureAtlas capacity from [" + this.textureAtlas.getCapacity() + "] to [" + a + "]."); this.textureAtlas.resizeCapacity(a) || cc.log("cc.ParticleBatchNode._increaseAtlasCapacityTo() : WARNING: Not enough memory to resize the atlas") }, _searchNewPositionInChildrenForZ: function(a) { for (var b = this._children, c = b.length, d = 0; d < c; d++) if (b[d].zIndex > a) return d; return c }, _getCurrentIndex: function(a, b) { for (var c = !1, d = !1, e = 0, f = 0, g = 0, h = this._children, k = h.length, m = 0; m < k; m++) { var n = h[m]; if (n.zIndex > b && !d && (e = m, d = !0, c && d)) break; if (a === n && (f = m, c = !0, d || (g = -1), c && d)) break } d || (e = k); return { newIndex: e + g, oldIndex: f } }, _addChildHelper: function(a, b, c) { if (!a) throw "cc.ParticleBatchNode._addChildHelper(): child should be non-null"; if (a.parent) return cc.log("cc.ParticleBatchNode._addChildHelper(): child already added. It can't be added again"), null; this._children || (this._children = []); var d = this._searchNewPositionInChildrenForZ(b); this._children.splice(d, 0, a); a.tag = c; a._setLocalZOrder(b); a.parent = this; this._running && (a.onEnter(), a.onEnterTransitionDidFinish()); return d }, _updateBlendFunc: function() { this.textureAtlas.texture.hasPremultipliedAlpha() || (this._blendFunc.src = cc.SRC_ALPHA, this._blendFunc.dst = cc.ONE_MINUS_SRC_ALPHA) }, getTextureAtlas: function() { return this.textureAtlas }, setTextureAtlas: function(a) { this.textureAtlas = a } }); _p = cc.ParticleBatchNode.prototype; cc.defineGetterSetter(_p, "texture", _p.getTexture, _p.setTexture); cc.ParticleBatchNode.create = function(a, b) { return new cc.ParticleBatchNode(a, b) }; (function() { cc.ParticleBatchNode.CanvasRenderCmd = function(a) { cc.Node.CanvasRenderCmd.call(this, a); this._needDraw = !1 }; var a = cc.ParticleBatchNode.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); a.constructor = cc.ParticleBatchNode.CanvasRenderCmd; a._initWithTexture = function() {} })(); (function() { cc.ParticleBatchNode.WebGLRenderCmd = function(a) { cc.Node.WebGLRenderCmd.call(this, a); this._needDraw = !0 }; var a = cc.ParticleBatchNode.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); a.constructor = cc.ParticleBatchNode.WebGLRenderCmd; a.rendering = function(a) { a = this._node; 0 !== a.textureAtlas.totalQuads && (this._shaderProgram.use(), this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix), cc.glBlendFuncForParticle(a._blendFunc.src, a._blendFunc.dst), a.textureAtlas.drawQuads()) }; a._initWithTexture = function() { this._shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR) }; a.visit = function(a) { if (this._node._visible) { var c = cc.current_stack; c.stack.push(c.top); this._syncStatus(a); c.top = this._stackMatrix; cc.renderer.pushRenderCommand(this); this._dirtyFlag = 0; cc.kmGLPopMatrix() } } })(); cc.IMEKeyboardNotificationInfo = function(a, b, c) { this.begin = a || cc.rect(0, 0, 0, 0); this.end = b || cc.rect(0, 0, 0, 0); this.duration = c || 0 }; cc.IMEDelegate = cc.Class.extend({ ctor: function() { cc.imeDispatcher.addDelegate(this) }, removeDelegate: function() { cc.imeDispatcher.removeDelegate(this) }, attachWithIME: function() { return cc.imeDispatcher.attachDelegateWithIME(this) }, detachWithIME: function() { return cc.imeDispatcher.detachDelegateWithIME(this) }, canAttachWithIME: function() { return !1 }, didAttachWithIME: function() {}, canDetachWithIME: function() { return !1 }, didDetachWithIME: function() {}, insertText: function(a, b) {}, deleteBackward: function() {}, getContentText: function() { return "" }, keyboardWillShow: function(a) {}, keyboardDidShow: function(a) {}, keyboardWillHide: function(a) {}, keyboardDidHide: function(a) {} }); cc.IMEDispatcher = cc.Class.extend({ _domInputControl: null, impl: null, _currentInputString: "", _lastClickPosition: null, ctor: function() { this.impl = new cc.IMEDispatcher.Impl; this._lastClickPosition = cc.p(0, 0) }, init: function() { if (!cc.sys.isMobile) { this._domInputControl = cc.$("#imeDispatcherInput"); this._domInputControl || (this._domInputControl = cc.$new("input"), this._domInputControl.setAttribute("type", "text"), this._domInputControl.setAttribute("id", "imeDispatcherInput"), this._domInputControl.resize(0, 0), this._domInputControl.translates(0, 0), this._domInputControl.style.opacity = "0", this._domInputControl.style.fontSize = "1px", this._domInputControl.setAttribute("tabindex", 2), this._domInputControl.style.position = "absolute", this._domInputControl.style.top = 0, this._domInputControl.style.left = 0, document.body.appendChild(this._domInputControl)); var a = this; cc._addEventListener(this._domInputControl, "input", function() { a._processDomInputString(a._domInputControl.value) }, !1); cc._addEventListener(this._domInputControl, "keydown", function(b) { b.keyCode === cc.KEY.tab ? (b.stopPropagation(), b.preventDefault()) : b.keyCode === cc.KEY.enter && (a.dispatchInsertText("\n", 1), b.stopPropagation(), b.preventDefault()) }, !1); /msie/i.test(navigator.userAgent) && cc._addEventListener(this._domInputControl, "keyup", function(b) { b.keyCode === cc.KEY.backspace && a._processDomInputString(a._domInputControl.value) }, !1); cc._addEventListener(window, "mousedown", function(b) { var c = b.pageY || 0; a._lastClickPosition.x = b.pageX || 0; a._lastClickPosition.y = c }, !1) } }, _processDomInputString: function(a) { var b, c; b = this._currentInputString.length < a.length ? this._currentInputString.length : a.length; for (c = 0; c < b && a[c] === this._currentInputString[c]; c++); var d = this._currentInputString.length - c, e = a.length - c; for (b = 0; b < d; b++) this.dispatchDeleteBackward(); for (b = 0; b < e; b++) this.dispatchInsertText(a[c + b], 1); this._currentInputString = a }, dispatchInsertText: function(a, b) { !this.impl || !a || 0 >= b || this.impl._delegateWithIme && this.impl._delegateWithIme.insertText(a, b) }, dispatchDeleteBackward: function() { this.impl && this.impl._delegateWithIme && this.impl._delegateWithIme.deleteBackward() }, getContentText: function() { if (this.impl && this.impl._delegateWithIme) { var a = this.impl._delegateWithIme.getContentText(); return a ? a : "" } return "" }, dispatchKeyboardWillShow: function(a) { if (this.impl) for (var b = 0; b < this.impl._delegateList.length; b++) { var c = this.impl._delegateList[b]; c && c.keyboardWillShow(a) } }, dispatchKeyboardDidShow: function(a) { if (this.impl) for (var b = 0; b < this.impl._delegateList.length; b++) { var c = this.impl._delegateList[b]; c && c.keyboardDidShow(a) } }, dispatchKeyboardWillHide: function(a) { if (this.impl) for (var b = 0; b < this.impl._delegateList.length; b++) { var c = this.impl._delegateList[b]; c && c.keyboardWillHide(a) } }, dispatchKeyboardDidHide: function(a) { if (this.impl) for (var b = 0; b < this.impl._delegateList.length; b++) { var c = this.impl._delegateList[b]; c && c.keyboardDidHide(a) } }, addDelegate: function(a) { a && this.impl && (-1 < this.impl._delegateList.indexOf(a) || this.impl._delegateList.splice(0, 0, a)) }, attachDelegateWithIME: function(a) { if (!this.impl || !a || -1 === this.impl._delegateList.indexOf(a)) return !1; if (this.impl._delegateWithIme) { if (!this.impl._delegateWithIme.canDetachWithIME() || !a.canAttachWithIME()) return !1; var b = this.impl._delegateWithIme; this.impl._delegateWithIme = null; b.didDetachWithIME(); this._focusDomInput(a); return !0 } if (!a.canAttachWithIME()) return !1; this._focusDomInput(a); return !0 }, _focusDomInput: function(a) { cc.sys.isMobile ? (this.impl._delegateWithIme = a, a.didAttachWithIME(), this._currentInputString = a.string || "", a = a.getTipMessage ? a.getTipMessage() : "please enter your word:", a = prompt(a, this._currentInputString), null != a && this._processDomInputString(a), this.dispatchInsertText("\n", 1)) : (this.impl._delegateWithIme = a, this._currentInputString = a.string || "", a.didAttachWithIME(), this._domInputControl.focus(), this._domInputControl.value = this._currentInputString, this._domInputControlTranslate()) }, _domInputControlTranslate: function() { /msie/i.test(navigator.userAgent) ? (this._domInputControl.style.left = this._lastClickPosition.x + "px", this._domInputControl.style.top = this._lastClickPosition.y + "px") : this._domInputControl.translates(this._lastClickPosition.x, this._lastClickPosition.y) }, detachDelegateWithIME: function(a) { if (!this.impl || !a || this.impl._delegateWithIme !== a || !a.canDetachWithIME()) return !1; this.impl._delegateWithIme = null; a.didDetachWithIME(); cc._canvas.focus(); return !0 }, removeDelegate: function(a) { this.impl && a && -1 !== this.impl._delegateList.indexOf(a) && (this.impl._delegateWithIme && a === this.impl._delegateWithIme && (this.impl._delegateWithIme = null), cc.arrayRemoveObject(this.impl._delegateList, a)) }, processKeycode: function(a) { 32 > a ? a === cc.KEY.backspace ? this.dispatchDeleteBackward() : a === cc.KEY.enter && this.dispatchInsertText("\n", 1) : 255 > a && this.dispatchInsertText(String.fromCharCode(a), 1) } }); cc.IMEDispatcher.Impl = cc.Class.extend({ _delegateWithIme: null, _delegateList: null, ctor: function() { this._delegateList = [] }, findDelegate: function(a) { for (var b = 0; b < this._delegateList.length; b++) if (this._delegateList[b] === a) return b; return null } }); cc.imeDispatcher = new cc.IMEDispatcher; document.body ? cc.imeDispatcher.init() : cc._addEventListener(window, "load", function() { cc.imeDispatcher.init() }, !1); cc.TextFieldDelegate = cc.Class.extend({ onTextFieldAttachWithIME: function(a) { return !1 }, onTextFieldDetachWithIME: function(a) { return !1 }, onTextFieldInsertText: function(a, b, c) { return !1 }, onTextFieldDeleteBackward: function(a, b, c) { return !1 }, onDraw: function(a) { return !1 } }); cc.TextFieldTTF = cc.LabelTTF.extend({ delegate: null, colorSpaceHolder: null, _colorText: null, _lens: null, _inputText: "", _placeHolder: "", _charCount: 0, _className: "TextFieldTTF", ctor: function(a, b, c, d, e) { this.colorSpaceHolder = cc.color(127, 127, 127); this._colorText = cc.color(255, 255, 255, 255); cc.imeDispatcher.addDelegate(this); cc.LabelTTF.prototype.ctor.call(this); void 0 !== e ? (this.initWithPlaceHolder("", b, c, d, e), a && this.setPlaceHolder(a)) : void 0 === d && void 0 !== c && (this.initWithString("", b, c), a && this.setPlaceHolder(a)) }, getDelegate: function() { return this.delegate }, setDelegate: function(a) { this.delegate = a }, getCharCount: function() { return this._charCount }, getColorSpaceHolder: function() { return cc.color(this.colorSpaceHolder) }, setColorSpaceHolder: function(a) { this.colorSpaceHolder.r = a.r; this.colorSpaceHolder.g = a.g; this.colorSpaceHolder.b = a.b; this.colorSpaceHolder.a = cc.isUndefined(a.a) ? 255 : a.a; this._inputText.length || this.setColor(this.colorSpaceHolder) }, setTextColor: function(a) { this._colorText.r = a.r; this._colorText.g = a.g; this._colorText.b = a.b; this._colorText.a = cc.isUndefined(a.a) ? 255 : a.a; this._inputText.length && this.setColor(this._colorText) }, initWithPlaceHolder: function(a, b, c, d, e) { switch (arguments.length) { case 5: return a && this.setPlaceHolder(a), this.initWithString(this._placeHolder, d, e, b, c); case 3: return a && this.setPlaceHolder(a), this.initWithString(this._placeHolder, arguments[1], arguments[2]); default: throw "Argument must be non-nil "; } }, setString: function(a) { this._inputText = (a = String(a)) || ""; this._inputText.length ? (cc.LabelTTF.prototype.setString.call(this, this._inputText), this.setColor(this._colorText)) : (cc.LabelTTF.prototype.setString.call(this, this._placeHolder), this.setColor(this.colorSpaceHolder)); cc._renderType === cc._RENDER_TYPE_CANVAS && this._renderCmd._updateTexture(); this._charCount = this._inputText.length }, getString: function() { return this._inputText }, setPlaceHolder: function(a) { this._placeHolder = a || ""; this._inputText.length || (cc.LabelTTF.prototype.setString.call(this, this._placeHolder), this.setColor(this.colorSpaceHolder)) }, getPlaceHolder: function() { return this._placeHolder }, draw: function(a) { a = a || cc._renderContext; this.delegate && this.delegate.onDraw(this) || cc.LabelTTF.prototype.draw.call(this, a) }, visit: function(a) { this._super(a) }, attachWithIME: function() { return cc.imeDispatcher.attachDelegateWithIME(this) }, detachWithIME: function() { return cc.imeDispatcher.detachDelegateWithIME(this) }, canAttachWithIME: function() { return this.delegate ? !this.delegate.onTextFieldAttachWithIME(this) : !0 }, didAttachWithIME: function() {}, canDetachWithIME: function() { return this.delegate ? !this.delegate.onTextFieldDetachWithIME(this) : !0 }, didDetachWithIME: function() {}, deleteBackward: function() { var a = this._inputText.length; 0 === a || this.delegate && this.delegate.onTextFieldDeleteBackward(this, this._inputText[a - 1], 1) || (1 >= a ? (this._inputText = "", this._charCount = 0, cc.LabelTTF.prototype.setString.call(this, this._placeHolder), this.setColor(this.colorSpaceHolder)) : this.string = this._inputText.substring(0, a - 1)) }, removeDelegate: function() { cc.imeDispatcher.removeDelegate(this) }, _tipMessage: "please enter your word:", setTipMessage: function(a) { null != a && (this._tipMessage = a) }, getTipMessage: function() { return this._tipMessage }, insertText: function(a, b) { var c = a, d = c.indexOf("\n"); - 1 < d && (c = c.substring(0, d)); if (0 < c.length) { if (this.delegate && this.delegate.onTextFieldInsertText(this, c, c.length)) return; c = this._inputText + c; this._charCount = c.length; this.string = c } - 1 !== d && (this.delegate && this.delegate.onTextFieldInsertText(this, "\n", 1) || this.detachWithIME()) }, getContentText: function() { return this._inputText }, keyboardWillShow: function(a) {}, keyboardDidShow: function(a) {}, keyboardWillHide: function(a) {}, keyboardDidHide: function(a) {} }); _p = cc.TextFieldTTF.prototype; cc.defineGetterSetter(_p, "charCount", _p.getCharCount); cc.defineGetterSetter(_p, "placeHolder", _p.getPlaceHolder, _p.setPlaceHolder); cc.TextFieldTTF.create = function(a, b, c, d, e) { return new cc.TextFieldTTF(a, b, c, d, e) }; cc._globalFontSize = cc.ITEM_SIZE; cc._globalFontName = "Arial"; cc._globalFontNameRelease = !1; cc.MenuItem = cc.Node.extend({ _enabled: !1, _target: null, _callback: null, _isSelected: !1, _className: "MenuItem", ctor: function(a, b) { var c = cc.Node.prototype; c.ctor.call(this); this._callback = this._target = null; this._enabled = this._isSelected = !1; c.setAnchorPoint.call(this, 0.5, 0.5); this._target = b || null; if (this._callback = a || null) this._enabled = !0 }, isSelected: function() { return this._isSelected }, setOpacityModifyRGB: function(a) {}, isOpacityModifyRGB: function() { return !1 }, setTarget: function(a, b) { this._target = b; this._callback = a }, isEnabled: function() { return this._enabled }, setEnabled: function(a) { this._enabled = a }, initWithCallback: function(a, b) { this.anchorY = this.anchorX = 0.5; this._target = b; this._callback = a; this._enabled = !0; this._isSelected = !1; return !0 }, rect: function() { var a = this._position, b = this._contentSize, c = this._anchorPoint; return cc.rect(a.x - b.width * c.x, a.y - b.height * c.y, b.width, b.height) }, selected: function() { this._isSelected = !0 }, unselected: function() { this._isSelected = !1 }, setCallback: function(a, b) { this._target = b; this._callback = a }, activate: function() { if (this._enabled) { var a = this._target, b = this._callback; if (b) if (a && cc.isString(b)) a[b](this); else a && cc.isFunction(b) ? b.call(a, this) : b(this) } } }); _p = cc.MenuItem.prototype; cc.defineGetterSetter(_p, "enabled", _p.isEnabled, _p.setEnabled); cc.MenuItem.create = function(a, b) { return new cc.MenuItem(a, b) }; cc.MenuItemLabel = cc.MenuItem.extend({ _disabledColor: null, _label: null, _originalScale: 0, _colorBackup: null, ctor: function(a, b, c) { cc.MenuItem.prototype.ctor.call(this, b, c); this._colorBackup = this._label = this._disabledColor = null; a && (this._originalScale = 1, this._colorBackup = cc.color.WHITE, this._disabledColor = cc.color(126, 126, 126), this.setLabel(a), this.cascadeOpacity = this.cascadeColor = !0) }, getDisabledColor: function() { return this._disabledColor }, setDisabledColor: function(a) { this._disabledColor = a }, getLabel: function() { return this._label }, setLabel: function(a) { a && (this.addChild(a), a.anchorX = 0, a.anchorY = 0, this.width = a.width, this.height = a.height); this._label && this.removeChild(this._label, !0); this._label = a }, setEnabled: function(a) { if (this._enabled !== a) { var b = this._label; a ? b.color = this._colorBackup : (this._colorBackup = b.color, b.color = this._disabledColor) } cc.MenuItem.prototype.setEnabled.call(this, a) }, setOpacity: function(a) { this._label.opacity = a }, getOpacity: function() { return this._label.opacity }, setColor: function(a) { this._label.color = a }, getColor: function() { return this._label.color }, initWithLabel: function(a, b, c) { this.initWithCallback(b, c); this._originalScale = 1; this._colorBackup = cc.color.WHITE; this._disabledColor = cc.color(126, 126, 126); this.setLabel(a); return this.cascadeOpacity = this.cascadeColor = !0 }, setString: function(a) { this._label.string = a; this.width = this._label.width; this.height = this._label.height }, getString: function() { return this._label.string }, activate: function() { this._enabled && (this.stopAllActions(), this.scale = this._originalScale, cc.MenuItem.prototype.activate.call(this)) }, selected: function() { if (this._enabled) { cc.MenuItem.prototype.selected.call(this); var a = this.getActionByTag(cc.ZOOM_ACTION_TAG); a ? this.stopAction(a) : this._originalScale = this.scale; a = cc.scaleTo(0.1, 1.2 * this._originalScale); a.setTag(cc.ZOOM_ACTION_TAG); this.runAction(a) } }, unselected: function() { if (this._enabled) { cc.MenuItem.prototype.unselected.call(this); this.stopActionByTag(cc.ZOOM_ACTION_TAG); var a = cc.scaleTo(0.1, this._originalScale); a.setTag(cc.ZOOM_ACTION_TAG); this.runAction(a) } } }); _p = cc.MenuItemLabel.prototype; cc.defineGetterSetter(_p, "string", _p.getString, _p.setString); cc.defineGetterSetter(_p, "disabledColor", _p.getDisabledColor, _p.setDisabledColor); cc.defineGetterSetter(_p, "label", _p.getLabel, _p.setLabel); cc.MenuItemLabel.create = function(a, b, c) { return new cc.MenuItemLabel(a, b, c) }; cc.MenuItemAtlasFont = cc.MenuItemLabel.extend({ ctor: function(a, b, c, d, e, f, g) { var h; a && 0 < a.length && (h = new cc.LabelAtlas(a, b, c, d, e)); cc.MenuItemLabel.prototype.ctor.call(this, h, f, g) }, initWithString: function(a, b, c, d, e, f, g) { if (!a || 0 === a.length) throw "cc.MenuItemAtlasFont.initWithString(): value should be non-null and its length should be greater than 0"; var h = new cc.LabelAtlas; h.initWithString(a, b, c, d, e); this.initWithLabel(h, f, g); return !0 } }); cc.MenuItemAtlasFont.create = function(a, b, c, d, e, f, g) { return new cc.MenuItemAtlasFont(a, b, c, d, e, f, g) }; cc.MenuItemFont = cc.MenuItemLabel.extend({ _fontSize: null, _fontName: null, ctor: function(a, b, c) { var d; a && 0 < a.length ? (this._fontName = cc._globalFontName, this._fontSize = cc._globalFontSize, d = new cc.LabelTTF(a, this._fontName, this._fontSize)) : (this._fontSize = 0, this._fontName = ""); cc.MenuItemLabel.prototype.ctor.call(this, d, b, c) }, initWithString: function(a, b, c) { if (!a || 0 === a.length) throw "Value should be non-null and its length should be greater than 0"; this._fontName = cc._globalFontName; this._fontSize = cc._globalFontSize; a = new cc.LabelTTF(a, this._fontName, this._fontSize); this.initWithLabel(a, b, c); return !0 }, setFontSize: function(a) { this._fontSize = a; this._recreateLabel() }, getFontSize: function() { return this._fontSize }, setFontName: function(a) { this._fontName = a; this._recreateLabel() }, getFontName: function() { return this._fontName }, _recreateLabel: function() { var a = new cc.LabelTTF(this._label.string, this._fontName, this._fontSize); this.setLabel(a) } }); cc.MenuItemFont.setFontSize = function(a) { cc._globalFontSize = a }; cc.MenuItemFont.fontSize = function() { return cc._globalFontSize }; cc.MenuItemFont.setFontName = function(a) { cc._globalFontNameRelease && (cc._globalFontName = ""); cc._globalFontName = a; cc._globalFontNameRelease = !0 }; _p = cc.MenuItemFont.prototype; cc.defineGetterSetter(_p, "fontSize", _p.getFontSize, _p.setFontSize); cc.defineGetterSetter(_p, "fontName", _p.getFontName, _p.setFontName); cc.MenuItemFont.fontName = function() { return cc._globalFontName }; cc.MenuItemFont.create = function(a, b, c) { return new cc.MenuItemFont(a, b, c) }; cc.MenuItemSprite = cc.MenuItem.extend({ _normalImage: null, _selectedImage: null, _disabledImage: null, ctor: function(a, b, c, d, e) { cc.MenuItem.prototype.ctor.call(this); this._disabledImage = this._selectedImage = this._normalImage = null; if (void 0 !== b) { var f, g, h; void 0 !== e ? (f = c, h = d, g = e) : void 0 !== d && cc.isFunction(d) ? (f = c, h = d) : void 0 !== d && cc.isFunction(c) ? (g = d, h = c, f = null) : void 0 === c && (f = null); this.initWithNormalSprite(a, b, f, h, g) } }, getNormalImage: function() { return this._normalImage }, setNormalImage: function(a) { this._normalImage !== a && (a && (this.addChild(a, 0, cc.NORMAL_TAG), a.anchorX = 0, a.anchorY = 0), this._normalImage && this.removeChild(this._normalImage, !0), this._normalImage = a, this.width = this._normalImage.width, this.height = this._normalImage.height, this._updateImagesVisibility(), a.textureLoaded && !a.textureLoaded() && a.addEventListener("load", function(a) { this.width = a.width; this.height = a.height }, this)) }, getSelectedImage: function() { return this._selectedImage }, setSelectedImage: function(a) { this._selectedImage !== a && (a && (this.addChild(a, 0, cc.SELECTED_TAG), a.anchorX = 0, a.anchorY = 0), this._selectedImage && this.removeChild(this._selectedImage, !0), this._selectedImage = a, this._updateImagesVisibility()) }, getDisabledImage: function() { return this._disabledImage }, setDisabledImage: function(a) { this._disabledImage !== a && (a && (this.addChild(a, 0, cc.DISABLE_TAG), a.anchorX = 0, a.anchorY = 0), this._disabledImage && this.removeChild(this._disabledImage, !0), this._disabledImage = a, this._updateImagesVisibility()) }, initWithNormalSprite: function(a, b, c, d, e) { this.initWithCallback(d, e); this.setNormalImage(a); this.setSelectedImage(b); this.setDisabledImage(c); if (a = this._normalImage) this.width = a.width, this.height = a.height, a.textureLoaded && !a.textureLoaded() && a.addEventListener("load", function(a) { this.width = a.width; this.height = a.height; this.cascadeOpacity = this.cascadeColor = !0 }, this); return this.cascadeOpacity = this.cascadeColor = !0 }, setColor: function(a) { this._normalImage.color = a; this._selectedImage && (this._selectedImage.color = a); this._disabledImage && (this._disabledImage.color = a) }, getColor: function() { return this._normalImage.color }, setOpacity: function(a) { this._normalImage.opacity = a; this._selectedImage && (this._selectedImage.opacity = a); this._disabledImage && (this._disabledImage.opacity = a) }, getOpacity: function() { return this._normalImage.opacity }, selected: function() { cc.MenuItem.prototype.selected.call(this); this._normalImage && (this._disabledImage && (this._disabledImage.visible = !1), this._selectedImage ? (this._normalImage.visible = !1, this._selectedImage.visible = !0) : this._normalImage.visible = !0) }, unselected: function() { cc.MenuItem.prototype.unselected.call(this); this._normalImage && (this._normalImage.visible = !0, this._selectedImage && (this._selectedImage.visible = !1), this._disabledImage && (this._disabledImage.visible = !1)) }, setEnabled: function(a) { this._enabled !== a && (cc.MenuItem.prototype.setEnabled.call(this, a), this._updateImagesVisibility()) }, _updateImagesVisibility: function() { var a = this._normalImage, b = this._selectedImage, c = this._disabledImage; this._enabled ? (a && (a.visible = !0), b && (b.visible = !1), c && (c.visible = !1)) : c ? (a && (a.visible = !1), b && (b.visible = !1), c && (c.visible = !0)) : (a && (a.visible = !0), b && (b.visible = !1)) } }); _p = cc.MenuItemSprite.prototype; cc.defineGetterSetter(_p, "normalImage", _p.getNormalImage, _p.setNormalImage); cc.defineGetterSetter(_p, "selectedImage", _p.getSelectedImage, _p.setSelectedImage); cc.defineGetterSetter(_p, "disabledImage", _p.getDisabledImage, _p.setDisabledImage); cc.MenuItemSprite.create = function(a, b, c, d, e) { return new cc.MenuItemSprite(a, b, c, d, e || void 0) }; cc.MenuItemImage = cc.MenuItemSprite.extend({ ctor: function(a, b, c, d, e) { var f = null, g = null, h = null, k = null, m = null; void 0 === a ? cc.MenuItemSprite.prototype.ctor.call(this) : (f = new cc.Sprite(a), b && (g = new cc.Sprite(b)), void 0 === d ? k = c : void 0 === e ? (k = c, m = d) : e && (h = new cc.Sprite(c), k = d, m = e), cc.MenuItemSprite.prototype.ctor.call(this, f, g, h, k, m)) }, setNormalSpriteFrame: function(a) { this.setNormalImage(new cc.Sprite(a)) }, setSelectedSpriteFrame: function(a) { this.setSelectedImage(new cc.Sprite(a)) }, setDisabledSpriteFrame: function(a) { this.setDisabledImage(new cc.Sprite(a)) }, initWithNormalImage: function(a, b, c, d, e) { var f = null, g = null, h = null; a && (f = new cc.Sprite(a)); b && (g = new cc.Sprite(b)); c && (h = new cc.Sprite(c)); return this.initWithNormalSprite(f, g, h, d, e) } }); cc.MenuItemImage.create = function(a, b, c, d, e) { return new cc.MenuItemImage(a, b, c, d, e) }; cc.MenuItemToggle = cc.MenuItem.extend({ subItems: null, _selectedIndex: 0, _opacity: null, _color: null, ctor: function() { cc.MenuItem.prototype.ctor.call(this); this._selectedIndex = 0; this.subItems = []; this._opacity = 0; this._color = cc.color.WHITE; 0 < arguments.length && this.initWithItems(Array.prototype.slice.apply(arguments)) }, getOpacity: function() { return this._opacity }, setOpacity: function(a) { this._opacity = a; if (this.subItems && 0 < this.subItems.length) for (var b = 0; b < this.subItems.length; b++) this.subItems[b].opacity = a; this._color.a = a }, getColor: function() { var a = this._color; return cc.color(a.r, a.g, a.b, a.a) }, setColor: function(a) { var b = this._color; b.r = a.r; b.g = a.g; b.b = a.b; if (this.subItems && 0 < this.subItems.length) for (b = 0; b < this.subItems.length; b++) this.subItems[b].setColor(a); void 0 === a.a || a.a_undefined || this.setOpacity(a.a) }, getSelectedIndex: function() { return this._selectedIndex }, setSelectedIndex: function(a) { if (a !== this._selectedIndex) { this._selectedIndex = a; (a = this.getChildByTag(cc.CURRENT_ITEM)) && a.removeFromParent(!1); a = this.subItems[this._selectedIndex]; this.addChild(a, 0, cc.CURRENT_ITEM); var b = a.width, c = a.height; this.width = b; this.height = c; a.setPosition(b / 2, c / 2) } }, getSubItems: function() { return this.subItems }, setSubItems: function(a) { this.subItems = a }, initWithItems: function(a) { var b = a.length; cc.isFunction(a[a.length - 2]) ? (this.initWithCallback(a[a.length - 2], a[a.length - 1]), b -= 2) : cc.isFunction(a[a.length - 1]) ? (this.initWithCallback(a[a.length - 1], null), b -= 1) : this.initWithCallback(null, null); for (var c = this.subItems, d = c.length = 0; d < b; d++) a[d] && c.push(a[d]); this._selectedIndex = cc.UINT_MAX; this.setSelectedIndex(0); return this.cascadeOpacity = this.cascadeColor = !0 }, addSubItem: function(a) { this.subItems.push(a) }, activate: function() { this._enabled && this.setSelectedIndex((this._selectedIndex + 1) % this.subItems.length); cc.MenuItem.prototype.activate.call(this) }, selected: function() { cc.MenuItem.prototype.selected.call(this); this.subItems[this._selectedIndex].selected() }, unselected: function() { cc.MenuItem.prototype.unselected.call(this); this.subItems[this._selectedIndex].unselected() }, setEnabled: function(a) { if (this._enabled !== a) { cc.MenuItem.prototype.setEnabled.call(this, a); var b = this.subItems; if (b && 0 < b.length) for (var c = 0; c < b.length; c++) b[c].enabled = a } }, selectedItem: function() { return this.subItems[this._selectedIndex] }, getSelectedItem: function() { return this.subItems[this._selectedIndex] }, onEnter: function() { cc.Node.prototype.onEnter.call(this); this.setSelectedIndex(this._selectedIndex) } }); _p = cc.MenuItemToggle.prototype; cc.defineGetterSetter(_p, "selectedIndex", _p.getSelectedIndex, _p.setSelectedIndex); cc.MenuItemToggle.create = function() { 0 < arguments.length && null == arguments[arguments.length - 1] && cc.log("parameters should not be ending with null in Javascript"); var a = new cc.MenuItemToggle; a.initWithItems(Array.prototype.slice.apply(arguments)); return a }; cc.MENU_STATE_WAITING = 0; cc.MENU_STATE_TRACKING_TOUCH = 1; cc.MENU_HANDLER_PRIORITY = -128; cc.DEFAULT_PADDING = 5; cc.Menu = cc.Layer.extend({ enabled: !1, _selectedItem: null, _state: -1, _touchListener: null, _className: "Menu", ctor: function(a) { cc.Layer.prototype.ctor.call(this); this._color = cc.color.WHITE; this.enabled = !1; this._opacity = 255; this._selectedItem = null; this._state = -1; this._touchListener = cc.EventListener.create({ event: cc.EventListener.TOUCH_ONE_BY_ONE, swallowTouches: !0, onTouchBegan: this._onTouchBegan, onTouchMoved: this._onTouchMoved, onTouchEnded: this._onTouchEnded, onTouchCancelled: this._onTouchCancelled }); 0 < arguments.length && null == arguments[arguments.length - 1] && cc.log("parameters should not be ending with null in Javascript"); var b = arguments.length, c; if (0 === b) c = []; else if (1 === b) c = a instanceof Array ? a : [a]; else if (1 < b) { c = []; for (var d = 0; d < b; d++) arguments[d] && c.push(arguments[d]) } this.initWithArray(c) }, onEnter: function() { var a = this._touchListener; a._isRegistered() || cc.eventManager.addListener(a, this); cc.Node.prototype.onEnter.call(this) }, isEnabled: function() { return this.enabled }, setEnabled: function(a) { this.enabled = a }, initWithItems: function(a) { var b = []; if (a) for (var c = 0; c < a.length; c++) a[c] && b.push(a[c]); return this.initWithArray(b) }, initWithArray: function(a) { if (cc.Layer.prototype.init.call(this)) { this.enabled = !0; var b = cc.winSize; this.setPosition(b.width / 2, b.height / 2); this.setContentSize(b); this.setAnchorPoint(0.5, 0.5); this.ignoreAnchorPointForPosition(!0); if (a) for (b = 0; b < a.length; b++) this.addChild(a[b], b); this._selectedItem = null; this._state = cc.MENU_STATE_WAITING; return this.cascadeOpacity = this.cascadeColor = !0 } return !1 }, addChild: function(a, b, c) { if (!(a instanceof cc.MenuItem)) throw "cc.Menu.addChild() : Menu only supports MenuItem objects as children"; cc.Layer.prototype.addChild.call(this, a, b, c) }, alignItemsVertically: function() { this.alignItemsVerticallyWithPadding(cc.DEFAULT_PADDING) }, alignItemsVerticallyWithPadding: function(a) { var b = -a, c = this._children, d, e, f, g; if (c && 0 < c.length) { e = 0; for (d = c.length; e < d; e++) b += c[e].height * c[e].scaleY + a; var h = b / 2; e = 0; for (d = c.length; e < d; e++) g = c[e], f = g.height, b = g.scaleY, g.setPosition(0, h - f * b / 2), h -= f * b + a } }, alignItemsHorizontally: function() { this.alignItemsHorizontallyWithPadding(cc.DEFAULT_PADDING) }, alignItemsHorizontallyWithPadding: function(a) { var b = -a, c = this._children, d, e, f, g; if (c && 0 < c.length) { d = 0; for (e = c.length; d < e; d++) b += c[d].width * c[d].scaleX + a; var h = -b / 2; d = 0; for (e = c.length; d < e; d++) g = c[d], b = g.scaleX, f = c[d].width, g.setPosition(h + f * b / 2, 0), h += f * b + a } }, alignItemsInColumns: function() { 0 < arguments.length && null == arguments[arguments.length - 1] && cc.log("parameters should not be ending with null in Javascript"); for (var a = [], b = 0; b < arguments.length; b++) a.push(arguments[b]); var c = -5, d = 0, e = 0, f = 0, g, h, k, m = this._children; if (m && 0 < m.length) for (b = 0, k = m.length; b < k; b++) d >= a.length || !(g = a[d]) || (h = m[b].height, e = e >= h || isNaN(h) ? e : h, ++f, f >= g && (c += e + 5, e = f = 0, ++d)); var n = cc.director.getWinSize(), p = g = e = d = 0, t = 0, c = c / 2; if (m && 0 < m.length) for (b = 0, k = m.length; b < k; b++) { var r = m[b]; 0 === g && (g = a[d], t = p = n.width / (1 + g)); h = r._getHeight(); e = e >= h || isNaN(h) ? e : h; r.setPosition(t - n.width / 2, c - h / 2); t += p; ++f; f >= g && (c -= e + 5, e = g = f = 0, ++d) } }, alignItemsInRows: function() { 0 < arguments.length && null == arguments[arguments.length - 1] && cc.log("parameters should not be ending with null in Javascript"); var a = [], b; for (b = 0; b < arguments.length; b++) a.push(arguments[b]); var c = [], d = [], e = -10, f = -5, g = 0, h = 0, k = 0, m, n, p, t, r = this._children; if (r && 0 < r.length) for (b = 0, p = r.length; b < p; b++)(n = r[b], g >= a.length || !(m = a[g])) || (t = n.width, h = h >= t || isNaN(t) ? h : t, f += n.height + 5, ++k, k >= m && (c.push(h), d.push(f), e += h + 10, h = k = 0, f = -5, ++g)); f = cc.director.getWinSize(); m = h = g = 0; var e = -e / 2, u = 0; if (r && 0 < r.length) for (b = 0, p = r.length; b < p; b++) n = r[b], 0 === m && (m = a[g], u = d[g]), t = n._getWidth(), h = h >= t || isNaN(t) ? h : t, n.setPosition(e + c[g] / 2, u - f.height / 2), u -= n.height + 10, ++k, k >= m && (e += h + 5, h = m = k = 0, ++g) }, removeChild: function(a, b) { null != a && (a instanceof cc.MenuItem ? (this._selectedItem === a && (this._selectedItem = null), cc.Node.prototype.removeChild.call(this, a, b)) : cc.log("cc.Menu.removeChild():Menu only supports MenuItem objects as children")) }, _onTouchBegan: function(a, b) { var c = b.getCurrentTarget(); if (c._state !== cc.MENU_STATE_WAITING || !c._visible || !c.enabled) return !1; for (var d = c.parent; null != d; d = d.parent) if (!d.isVisible()) return !1; c._selectedItem = c._itemForTouch(a); return c._selectedItem ? (c._state = cc.MENU_STATE_TRACKING_TOUCH, c._selectedItem.selected(), c._selectedItem.setNodeDirty(), !0) : !1 }, _onTouchEnded: function(a, b) { var c = b.getCurrentTarget(); c._state !== cc.MENU_STATE_TRACKING_TOUCH ? cc.log("cc.Menu.onTouchEnded(): invalid state") : (c._selectedItem && (c._selectedItem.unselected(), c._selectedItem.setNodeDirty(), c._selectedItem.activate()), c._state = cc.MENU_STATE_WAITING) }, _onTouchCancelled: function(a, b) { var c = b.getCurrentTarget(); c._state !== cc.MENU_STATE_TRACKING_TOUCH ? cc.log("cc.Menu.onTouchCancelled(): invalid state") : (this._selectedItem && (c._selectedItem.unselected(), c._selectedItem.setNodeDirty()), c._state = cc.MENU_STATE_WAITING) }, _onTouchMoved: function(a, b) { var c = b.getCurrentTarget(); if (c._state !== cc.MENU_STATE_TRACKING_TOUCH) cc.log("cc.Menu.onTouchMoved(): invalid state"); else { var d = c._itemForTouch(a); d !== c._selectedItem && (c._selectedItem && (c._selectedItem.unselected(), c._selectedItem.setNodeDirty()), c._selectedItem = d, c._selectedItem && (c._selectedItem.selected(), c._selectedItem.setNodeDirty())) } }, onExit: function() { this._state === cc.MENU_STATE_TRACKING_TOUCH && (this._selectedItem && (this._selectedItem.unselected(), this._selectedItem = null), this._state = cc.MENU_STATE_WAITING); cc.Node.prototype.onExit.call(this) }, setOpacityModifyRGB: function(a) {}, isOpacityModifyRGB: function() { return !1 }, _itemForTouch: function(a) { a = a.getLocation(); var b = this._children, c; if (b && 0 < b.length) for (var d = b.length - 1; 0 <= d; d--) if (c = b[d], c.isVisible() && c.isEnabled()) { var e = c.convertToNodeSpace(a), f = c.rect(); f.x = 0; f.y = 0; if (cc.rectContainsPoint(f, e)) return c } return null } }); _p = cc.Menu.prototype; cc.Menu.create = function(a) { var b = arguments.length; 0 < b && null == arguments[b - 1] && cc.log("parameters should not be ending with null in Javascript"); return 0 === b ? new cc.Menu : 1 === b ? new cc.Menu(a) : new cc.Menu(Array.prototype.slice.call(arguments, 0)) }; cc.TGA_OK = 0; cc.TGA_ERROR_FILE_OPEN = 1; cc.TGA_ERROR_READING_FILE = 2; cc.TGA_ERROR_INDEXED_COLOR = 3; cc.TGA_ERROR_MEMORY = 4; cc.TGA_ERROR_COMPRESSED_FILE = 5; cc.ImageTGA = function(a, b, c, d, e, f, g) { this.status = a || 0; this.type = b || 0; this.pixelDepth = c || 0; this.width = d || 0; this.height = e || 0; this.imageData = f || []; this.flipped = g || 0 }; cc.tgaLoadHeader = function(a, b, c) { var d = 2; if (d + 1 > b) return !1; a = new cc.BinaryStreamReader(a); a.setOffset(d); c.type = a.readByte(); d += 10; if (d + 4 + 1 > b) return !1; a.setOffset(d); c.width = a.readUnsignedShort(); c.height = a.readUnsignedInteger(); c.pixelDepth = a.readByte(); if (d + 5 + 1 > b) return !1; b = a.readByte(); c.flipped = 0; b & 32 && (c.flipped = 1); return !0 }; cc.tgaLoadImageData = function(a, b, c) { var d, e; d = 0 | c.pixelDepth / 2; e = c.height * c.width * d; if (18 + e > b) return !1; c.imageData = cc.__getSubArray(a, 18, 18 + e); if (3 <= d) for (a = 0; a < e; a += d) b = c.imageData[a], c.imageData[a] = c.imageData[a + 2], c.imageData[a + 2] = b; return !0 }; cc.tgaRGBtogreyscale = function(a) { var b, c; if (8 !== a.pixelDepth) { var d = a.pixelDepth / 8, e = new Uint8Array(a.height * a.width); if (null !== e) { for (c = b = 0; c < a.width * a.height; b += d, c++) e[c] = 0.3 * a.imageData[b] + 0.59 * a.imageData[b + 1] + 0.11 * a.imageData[b + 2]; a.pixelDepth = 8; a.type = 3; a.imageData = e } } }; cc.tgaDestroy = function(a) { a && (a.imageData = null) }; cc.tgaLoadRLEImageData = function(a, b, c) { var d, e, f, g = 0, h = 0, k = 0, m = [], n = 0, p = 18; d = c.pixelDepth / 8; e = c.height * c.width; for (f = 0; f < e; f++) { if (0 !== n) n--, h = 0 !== k; else { if (p + 1 > b) break; n = a[p]; p += 1; (k = n & 128) && (n -= 128); h = 0 } if (!h) { if (p + d > b) break; m = cc.__getSubArray(a, p, p + d); p += d; 3 <= d && (h = m[0], m[0] = m[2], m[2] = h) } for (h = 0; h < d; h++) c.imageData[g + h] = m[h]; g += d } return !0 }; cc.tgaFlipImage = function(a) { for (var b = a.pixelDepth / 8 * a.width, c = 0; c < a.height / 2; c++) { var d = cc.__getSubArray(a.imageData, c * b, c * b + b); cc.__setDataToArray(cc.__getSubArray(a.imageData, (a.height - (c + 1)) * b, b), a.imageData, c * b); cc.__setDataToArray(d, a.imageData, (a.height - (c + 1)) * b) } a.flipped = 0 }; cc.__getSubArray = function(a, b, c) { return a instanceof Array ? a.slice(b, c) : a.subarray(b, c) }; cc.__setDataToArray = function(a, b, c) { for (var d = 0; d < a.length; d++) b[c + d] = a[d] }; cc.BinaryStreamReader = cc.Class.extend({ _binaryData: null, _offset: 0, ctor: function(a) { this._binaryData = a }, setBinaryData: function(a) { this._binaryData = a; this._offset = 0 }, getBinaryData: function() { return this._binaryData }, _checkSize: function(a) { if (!(this._offset + Math.ceil(a / 8) < this._data.length)) throw Error("Index out of bound"); }, _decodeFloat: function(a, b) { var c = a + b + 1, d = c >> 3; this._checkSize(c); var c = Math.pow(2, b - 1) - 1, e = this._readBits(a + b, 1, d), f = this._readBits(a, b, d), g = 0, h = 2, k = 0; do for (var m = this._readByte(++k, d), n = a % 8 || 8, p = 1 << n; p >>= 1;) m & p && (g += 1 / h), h *= 2; while (a -= n); this._offset += d; return f === (c << 1) + 1 ? g ? NaN : e ? -Infinity : Infinity : (1 + -2 * e) * (f || g ? f ? Math.pow(2, f - c) * (1 + g) : Math.pow(2, -c + 1) * g : 0) }, _readByte: function(a, b) { return this._data[this._offset + b - a - 1] }, _decodeInt: function(a, b) { var c = this._readBits(0, a, a / 8), d = Math.pow(2, a); this._offset += a / 8; return b && c >= d / 2 ? c - d : c }, _shl: function(a, b) { for (++b; --b; a = 1073741824 === ((a %= 2147483648) & 1073741824) ? 2 * a : 2 * (a - 1073741824) + 2147483648); return a }, _readBits: function(a, b, c) { var d = (a + b) % 8, e = a % 8, f = c - (a >> 3) - 1; a = c + (-(a + b) >> 3); var g = f - a; b = this._readByte(f, c) >> e & (1 << (g ? 8 - e : b)) - 1; for (g && d && (b += (this._readByte(a++, c) & (1 << d) - 1) << (g-- << 3) - e); g;) b += this._shl(this._readByte(a++, c), (g-- << 3) - e); return b }, readInteger: function() { return this._decodeInt(32, !0) }, readUnsignedInteger: function() { return this._decodeInt(32, !1) }, readSingle: function() { return this._decodeFloat(23, 8) }, readShort: function() { return this._decodeInt(16, !0) }, readUnsignedShort: function() { return this._decodeInt(16, !1) }, readByte: function() { var a = this._data[this._offset]; this._offset += 1; return a }, readData: function(a, b) { return this._binaryData instanceof Array ? this._binaryData.slice(a, b) : this._binaryData.subarray(a, b) }, setOffset: function(a) { this._offset = a }, getOffset: function() { return this._offset } }); cc.TMX_ORIENTATION_ORTHO = 0; cc.TMX_ORIENTATION_HEX = 1; cc.TMX_ORIENTATION_ISO = 2; cc.TMXTiledMap = cc.Node.extend({ properties: null, mapOrientation: null, objectGroups: null, _mapSize: null, _tileSize: null, _tileProperties: null, _className: "TMXTiledMap", ctor: function(a, b) { cc.Node.prototype.ctor.call(this); this._mapSize = cc.size(0, 0); this._tileSize = cc.size(0, 0); void 0 !== b ? this.initWithXML(a, b) : void 0 !== a && this.initWithTMXFile(a) }, getMapSize: function() { return cc.size(this._mapSize.width, this._mapSize.height) }, setMapSize: function(a) { this._mapSize.width = a.width; this._mapSize.height = a.height }, _getMapWidth: function() { return this._mapSize.width }, _setMapWidth: function(a) { this._mapSize.width = a }, _getMapHeight: function() { return this._mapSize.height }, _setMapHeight: function(a) { this._mapSize.height = a }, getTileSize: function() { return cc.size(this._tileSize.width, this._tileSize.height) }, setTileSize: function(a) { this._tileSize.width = a.width; this._tileSize.height = a.height }, _getTileWidth: function() { return this._tileSize.width }, _setTileWidth: function(a) { this._tileSize.width = a }, _getTileHeight: function() { return this._tileSize.height }, _setTileHeight: function(a) { this._tileSize.height = a }, getMapOrientation: function() { return this.mapOrientation }, setMapOrientation: function(a) { this.mapOrientation = a }, getObjectGroups: function() { return this.objectGroups }, setObjectGroups: function(a) { this.objectGroups = a }, getProperties: function() { return this.properties }, setProperties: function(a) { this.properties = a }, initWithTMXFile: function(a) { if (!a || 0 === a.length) throw "cc.TMXTiledMap.initWithTMXFile(): tmxFile should be non-null or non-empty string."; this.height = this.width = 0; a = new cc.TMXMapInfo(a); if (!a) return !1; var b = a.getTilesets(); b && 0 !== b.length || cc.log("cc.TMXTiledMap.initWithTMXFile(): Map not found. Please check the filename."); this._buildWithMapInfo(a); return !0 }, initWithXML: function(a, b) { this.height = this.width = 0; var c = new cc.TMXMapInfo(a, b), d = c.getTilesets(); d && 0 !== d.length || cc.log("cc.TMXTiledMap.initWithXML(): Map not found. Please check the filename."); this._buildWithMapInfo(c); return !0 }, _buildWithMapInfo: function(a) { this._mapSize = a.getMapSize(); this._tileSize = a.getTileSize(); this.mapOrientation = a.orientation; this.objectGroups = a.getObjectGroups(); this.properties = a.properties; this._tileProperties = a.getTileProperties(); var b = 0, c = a.getLayers(); if (c) for (var d = null, e = 0, f = c.length; e < f; e++)(d = c[e]) && d.visible && (d = this._parseLayer(d, a), this.addChild(d, b, b), this.width = Math.max(this.width, d.width), this.height = Math.max(this.height, d.height), b++) }, allLayers: function() { for (var a = [], b = this._children, c = 0, d = b.length; c < d; c++) { var e = b[c]; e && e instanceof cc.TMXLayer && a.push(e) } return a }, getLayer: function(a) { if (!a || 0 === a.length) throw "cc.TMXTiledMap.getLayer(): layerName should be non-null or non-empty string."; for (var b = this._children, c = 0; c < b.length; c++) { var d = b[c]; if (d && d.layerName === a) return d } return null }, getObjectGroup: function(a) { if (!a || 0 === a.length) throw "cc.TMXTiledMap.getObjectGroup(): groupName should be non-null or non-empty string."; if (this.objectGroups) for (var b = 0; b < this.objectGroups.length; b++) { var c = this.objectGroups[b]; if (c && c.groupName === a) return c } return null }, getProperty: function(a) { return this.properties[a.toString()] }, propertiesForGID: function(a) { cc.log("propertiesForGID is deprecated. Please use getPropertiesForGID instead."); return this.getPropertiesForGID[a] }, getPropertiesForGID: function(a) { return this._tileProperties[a] }, _parseLayer: function(a, b) { var c = this._tilesetForLayer(a, b), c = new cc.TMXLayer(c, a, b); a.ownTiles = !1; c.setupTiles(); return c }, _tilesetForLayer: function(a, b) { var c = a._layerSize, d = b.getTilesets(); if (d) for (var e = d.length - 1; 0 <= e; e--) { var f = d[e]; if (f) for (var g = 0; g < c.height; g++) for (var h = 0; h < c.width; h++) { var k = a._tiles[h + c.width * g]; if (0 !== k && (k & cc.TMX_TILE_FLIPPED_MASK) >>> 0 >= f.firstGid) return f } } cc.log("cocos2d: Warning: TMX Layer " + a.name + " has no tiles"); return null } }); _p = cc.TMXTiledMap.prototype; cc.defineGetterSetter(_p, "mapWidth", _p._getMapWidth, _p._setMapWidth); cc.defineGetterSetter(_p, "mapHeight", _p._getMapHeight, _p._setMapHeight); cc.defineGetterSetter(_p, "tileWidth", _p._getTileWidth, _p._setTileWidth); cc.defineGetterSetter(_p, "tileHeight", _p._getTileHeight, _p._setTileHeight); cc.TMXTiledMap.create = function(a, b) { return new cc.TMXTiledMap(a, b) }; cc.TMX_PROPERTY_NONE = 0; cc.TMX_PROPERTY_MAP = 1; cc.TMX_PROPERTY_LAYER = 2; cc.TMX_PROPERTY_OBJECTGROUP = 3; cc.TMX_PROPERTY_OBJECT = 4; cc.TMX_PROPERTY_TILE = 5; cc.TMX_TILE_HORIZONTAL_FLAG = 2147483648; cc.TMX_TILE_VERTICAL_FLAG = 1073741824; cc.TMX_TILE_DIAGONAL_FLAG = 536870912; cc.TMX_TILE_FLIPPED_ALL = (cc.TMX_TILE_HORIZONTAL_FLAG | cc.TMX_TILE_VERTICAL_FLAG | cc.TMX_TILE_DIAGONAL_FLAG) >>> 0; cc.TMX_TILE_FLIPPED_MASK = ~cc.TMX_TILE_FLIPPED_ALL >>> 0; cc.TMXLayerInfo = cc.Class.extend({ properties: null, name: "", _layerSize: null, _tiles: null, visible: null, _opacity: null, ownTiles: !0, _minGID: 1E5, _maxGID: 0, offset: null, ctor: function() { this.properties = []; this.name = ""; this._layerSize = null; this._tiles = []; this.visible = !0; this._opacity = 0; this.ownTiles = !0; this._minGID = 1E5; this._maxGID = 0; this.offset = cc.p(0, 0) }, getProperties: function() { return this.properties }, setProperties: function(a) { this.properties = a } }); cc.TMXTilesetInfo = cc.Class.extend({ name: "", firstGid: 0, _tileSize: null, spacing: 0, margin: 0, sourceImage: "", imageSize: null, ctor: function() { this._tileSize = cc.size(0, 0); this.imageSize = cc.size(0, 0) }, rectForGID: function(a) { var b = cc.rect(0, 0, 0, 0); b.width = this._tileSize.width; b.height = this._tileSize.height; a &= cc.TMX_TILE_FLIPPED_MASK; a -= parseInt(this.firstGid, 10); var c = parseInt((this.imageSize.width - 2 * this.margin + this.spacing) / (this._tileSize.width + this.spacing), 10); b.x = parseInt(a % c * (this._tileSize.width + this.spacing) + this.margin, 10); b.y = parseInt(parseInt(a / c, 10) * (this._tileSize.height + this.spacing) + this.margin, 10); return b } }); cc.TMXMapInfo = cc.SAXParser.extend({ properties: null, orientation: null, parentElement: null, parentGID: null, layerAttrs: 0, storingCharacters: !1, tmxFileName: null, currentString: null, _objectGroups: null, _mapSize: null, _tileSize: null, _layers: null, _tilesets: null, _tileProperties: null, _resources: "", _currentFirstGID: 0, ctor: function(a, b) { cc.SAXParser.prototype.ctor.apply(this); this._mapSize = cc.size(0, 0); this._tileSize = cc.size(0, 0); this._layers = []; this._tilesets = []; this._objectGroups = []; this.properties = []; this._tileProperties = {}; this._currentFirstGID = 0; void 0 !== b ? this.initWithXML(a, b) : void 0 !== a && this.initWithTMXFile(a) }, getOrientation: function() { return this.orientation }, setOrientation: function(a) { this.orientation = a }, getMapSize: function() { return cc.size(this._mapSize.width, this._mapSize.height) }, setMapSize: function(a) { this._mapSize.width = a.width; this._mapSize.height = a.height }, _getMapWidth: function() { return this._mapSize.width }, _setMapWidth: function(a) { this._mapSize.width = a }, _getMapHeight: function() { return this._mapSize.height }, _setMapHeight: function(a) { this._mapSize.height = a }, getTileSize: function() { return cc.size(this._tileSize.width, this._tileSize.height) }, setTileSize: function(a) { this._tileSize.width = a.width; this._tileSize.height = a.height }, _getTileWidth: function() { return this._tileSize.width }, _setTileWidth: function(a) { this._tileSize.width = a }, _getTileHeight: function() { return this._tileSize.height }, _setTileHeight: function(a) { this._tileSize.height = a }, getLayers: function() { return this._layers }, setLayers: function(a) { this._layers.push(a) }, getTilesets: function() { return this._tilesets }, setTilesets: function(a) { this._tilesets.push(a) }, getObjectGroups: function() { return this._objectGroups }, setObjectGroups: function(a) { this._objectGroups.push(a) }, getParentElement: function() { return this.parentElement }, setParentElement: function(a) { this.parentElement = a }, getParentGID: function() { return this.parentGID }, setParentGID: function(a) { this.parentGID = a }, getLayerAttribs: function() { return this.layerAttrs }, setLayerAttribs: function(a) { this.layerAttrs = a }, getStoringCharacters: function() { return this.storingCharacters }, setStoringCharacters: function(a) { this.storingCharacters = a }, getProperties: function() { return this.properties }, setProperties: function(a) { this.properties = a }, initWithTMXFile: function(a) { this._internalInit(a, null); return this.parseXMLFile(a) }, initWithXML: function(a, b) { this._internalInit(null, b); return this.parseXMLString(a) }, parseXMLFile: function(a, b) { var c = (b = b || !1) ? a : cc.loader.getRes(a); if (!c) throw "Please load the resource first : " + a; var d, e, c = this._parseXML(c).documentElement; d = c.getAttribute("version"); e = c.getAttribute("orientation"); if ("map" === c.nodeName && ("1.0" !== d && null !== d && cc.log("cocos2d: TMXFormat: Unsupported TMX version:" + d), "orthogonal" === e ? this.orientation = cc.TMX_ORIENTATION_ORTHO : "isometric" === e ? this.orientation = cc.TMX_ORIENTATION_ISO : "hexagonal" === e ? this.orientation = cc.TMX_ORIENTATION_HEX : null !== e && cc.log("cocos2d: TMXFomat: Unsupported orientation:" + e), d = cc.size(0, 0), d.width = parseFloat(c.getAttribute("width")), d.height = parseFloat(c.getAttribute("height")), this.setMapSize(d), d = cc.size(0, 0), d.width = parseFloat(c.getAttribute("tilewidth")), d.height = parseFloat(c.getAttribute("tileheight")), this.setTileSize(d), e = c.querySelectorAll("map \x3e properties \x3e property"))) { var f = {}; for (d = 0; d < e.length; d++) f[e[d].getAttribute("name")] = e[d].getAttribute("value"); this.properties = f } f = c.getElementsByTagName("tileset"); "map" !== c.nodeName && (f = [], f.push(c)); for (d = 0; d < f.length; d++) { e = f[d]; var g = e.getAttribute("source"); if (g) e = b ? cc.path.join(this._resources, g) : cc.path.changeBasename(a, g), this.parseXMLFile(e); else { g = new cc.TMXTilesetInfo; g.name = e.getAttribute("name") || ""; g.firstGid = parseInt(e.getAttribute("firstgid")) || 0; g.spacing = parseInt(e.getAttribute("spacing")) || 0; g.margin = parseInt(e.getAttribute("margin")) || 0; var h = cc.size(0, 0); h.width = parseFloat(e.getAttribute("tilewidth")); h.height = parseFloat(e.getAttribute("tileheight")); g._tileSize = h; var h = e.getElementsByTagName("image")[0].getAttribute("source"), k = -1; this.tmxFileName && (k = this.tmxFileName.lastIndexOf("/")); - 1 !== k ? (k = this.tmxFileName.substr(0, k + 1), g.sourceImage = k + h) : g.sourceImage = this._resources + (this._resources ? "/" : "") + h; this.setTilesets(g); if (h = e.getElementsByTagName("tile")) for (k = 0; k < h.length; k++) { e = h[k]; this.parentGID = parseInt(g.firstGid) + parseInt(e.getAttribute("id") || 0); var m = e.querySelectorAll("properties \x3e property"); if (m) { var n = {}; for (e = 0; e < m.length; e++) { var p = m[e].getAttribute("name"); n[p] = m[e].getAttribute("value") } this._tileProperties[this.parentGID] = n } } } } if (f = c.getElementsByTagName("layer")) for (d = 0; d < f.length; d++) { h = f[d]; k = h.getElementsByTagName("data")[0]; g = new cc.TMXLayerInfo; g.name = h.getAttribute("name"); e = cc.size(0, 0); e.width = parseFloat(h.getAttribute("width")); e.height = parseFloat(h.getAttribute("height")); g._layerSize = e; e = h.getAttribute("visible"); g.visible = "0" != e; e = h.getAttribute("opacity") || 1; g._opacity = e ? parseInt(255 * parseFloat(e)) : 255; g.offset = cc.p(parseFloat(h.getAttribute("x")) || 0, parseFloat(h.getAttribute("y")) || 0); m = ""; for (e = 0; e < k.childNodes.length; e++) m += k.childNodes[e].nodeValue; m = m.trim(); e = k.getAttribute("compression"); n = k.getAttribute("encoding"); if (e && "gzip" !== e && "zlib" !== e) return cc.log("cc.TMXMapInfo.parseXMLFile(): unsupported compression method"), null; switch (e) { case "gzip": g._tiles = cc.unzipBase64AsArray(m, 4); break; case "zlib": e = new Zlib.Inflate(cc.Codec.Base64.decodeAsArray(m, 1)); g._tiles = cc.uint8ArrayToUint32Array(e.decompress()); break; case null: case "": if ("base64" === n) g._tiles = cc.Codec.Base64.decodeAsArray(m, 4); else if ("csv" === n) for (g._tiles = [], e = m.split(","), k = 0; k < e.length; k++) g._tiles.push(parseInt(e[k])); else for (e = k.getElementsByTagName("tile"), g._tiles = [], k = 0; k < e.length; k++) g._tiles.push(parseInt(e[k].getAttribute("gid"))); break; default: this.layerAttrs === cc.TMXLayerInfo.ATTRIB_NONE && cc.log("cc.TMXMapInfo.parseXMLFile(): Only base64 and/or gzip/zlib maps are supported") } if (h = h.querySelectorAll("properties \x3e property")) { k = {}; for (e = 0; e < h.length; e++) k[h[e].getAttribute("name")] = h[e].getAttribute("value"); g.properties = k } this.setLayers(g) } if (f = c.getElementsByTagName("objectgroup")) for (d = 0; d < f.length; d++) { h = f[d]; g = new cc.TMXObjectGroup; g.groupName = h.getAttribute("name"); g.setPositionOffset(cc.p(parseFloat(h.getAttribute("x")) * this.getTileSize().width || 0, parseFloat(h.getAttribute("y")) * this.getTileSize().height || 0)); if (k = h.querySelectorAll("objectgroup \x3e properties \x3e property")) for (e = 0; e < k.length; e++) m = {}, m[k[e].getAttribute("name")] = k[e].getAttribute("value"), g.properties = m; if (h = h.querySelectorAll("object")) for (e = 0; e < h.length; e++) { m = h[e]; k = {}; k.name = m.getAttribute("name") || ""; k.type = m.getAttribute("type") || ""; k.x = parseInt(m.getAttribute("x") || 0) + g.getPositionOffset().x; n = parseInt(m.getAttribute("y") || 0) + g.getPositionOffset().y; k.width = parseInt(m.getAttribute("width")) || 0; k.height = parseInt(m.getAttribute("height")) || 0; k.y = parseInt(this.getMapSize().height * this.getTileSize().height) - n - k.height; k.rotation = parseInt(m.getAttribute("rotation")) || 0; if (n = m.querySelectorAll("properties \x3e property")) for (p = 0; p < n.length; p++) k[n[p].getAttribute("name")] = n[p].getAttribute("value"); (n = m.querySelectorAll("polygon")) && 0 < n.length && (n = n[0].getAttribute("points")) && (k.polygonPoints = this._parsePointsString(n)); (m = m.querySelectorAll("polyline")) && 0 < m.length && (m = m[0].getAttribute("points")) && (k.polylinePoints = this._parsePointsString(m)); g.setObjects(k) } this.setObjectGroups(g) } return c }, _parsePointsString: function(a) { if (!a) return null; var b = []; a = a.split(" "); for (var c = 0; c < a.length; c++) { var d = a[c].split(","); b.push({ x: d[0], y: d[1] }) } return b }, parseXMLString: function(a) { return this.parseXMLFile(a, !0) }, getTileProperties: function() { return this._tileProperties }, setTileProperties: function(a) { this._tileProperties.push(a) }, getCurrentString: function() { return this.currentString }, setCurrentString: function(a) { this.currentString = a }, getTMXFileName: function() { return this.tmxFileName }, setTMXFileName: function(a) { this.tmxFileName = a }, _internalInit: function(a, b) { this._tilesets.length = 0; this._layers.length = 0; this.tmxFileName = a; b && (this._resources = b); this._objectGroups.length = 0; this.properties.length = 0; this._tileProperties.length = 0; this.currentString = ""; this.storingCharacters = !1; this.layerAttrs = cc.TMXLayerInfo.ATTRIB_NONE; this.parentElement = cc.TMX_PROPERTY_NONE; this._currentFirstGID = 0 } }); _p = cc.TMXMapInfo.prototype; cc.defineGetterSetter(_p, "mapWidth", _p._getMapWidth, _p._setMapWidth); cc.defineGetterSetter(_p, "mapHeight", _p._getMapHeight, _p._setMapHeight); cc.defineGetterSetter(_p, "tileWidth", _p._getTileWidth, _p._setTileWidth); cc.defineGetterSetter(_p, "tileHeight", _p._getTileHeight, _p._setTileHeight); cc.TMXMapInfo.create = function(a, b) { return new cc.TMXMapInfo(a, b) }; cc.loader.register(["tmx", "tsx"], cc._txtLoader); cc.TMXLayerInfo.ATTRIB_NONE = 1; cc.TMXLayerInfo.ATTRIB_BASE64 = 2; cc.TMXLayerInfo.ATTRIB_GZIP = 4; cc.TMXLayerInfo.ATTRIB_ZLIB = 8; cc.TMXObjectGroup = cc.Class.extend({ properties: null, groupName: "", _positionOffset: null, _objects: null, ctor: function() { this.groupName = ""; this._positionOffset = cc.p(0, 0); this.properties = []; this._objects = [] }, getPositionOffset: function() { return cc.p(this._positionOffset) }, setPositionOffset: function(a) { this._positionOffset.x = a.x; this._positionOffset.y = a.y }, getProperties: function() { return this.properties }, setProperties: function(a) { this.properties.push(a) }, getGroupName: function() { return this.groupName.toString() }, setGroupName: function(a) { this.groupName = a }, propertyNamed: function(a) { return this.properties[a] }, objectNamed: function(a) { this.getObject(a) }, getObject: function(a) { if (this._objects && 0 < this._objects.length) for (var b = this._objects, c = 0, d = b.length; c < d; c++) { var e = b[c].name; if (e && e === a) return b[c] } return null }, getObjects: function() { return this._objects }, setObjects: function(a) { this._objects.push(a) } }); cc.TMXLayer = cc.SpriteBatchNode.extend({ tiles: null, tileset: null, layerOrientation: null, properties: null, layerName: "", _layerSize: null, _mapTileSize: null, _opacity: 255, _minGID: null, _maxGID: null, _vertexZvalue: null, _useAutomaticVertexZ: null, _reusedTile: null, _atlasIndexArray: null, _contentScaleFactor: null, _className: "TMXLayer", ctor: function(a, b, c) { cc.SpriteBatchNode.prototype.ctor.call(this); this._descendants = []; this._layerSize = cc.size(0, 0); this._mapTileSize = cc.size(0, 0); void 0 !== c && this.initWithTilesetInfo(a, b, c) }, _createRenderCmd: function() { return cc._renderType === cc._RENDER_TYPE_CANVAS ? new cc.TMXLayer.CanvasRenderCmd(this) : new cc.TMXLayer.WebGLRenderCmd(this) }, setContentSize: function(a, b) { cc.Node.prototype.setContentSize.call(this, a, b); this._renderCmd._updateCacheContext(a, b) }, getTexture: function() { return this._renderCmd.getTexture() }, getLayerSize: function() { return cc.size(this._layerSize.width, this._layerSize.height) }, setLayerSize: function(a) { this._layerSize.width = a.width; this._layerSize.height = a.height }, _getLayerWidth: function() { return this._layerSize.width }, _setLayerWidth: function(a) { this._layerSize.width = a }, _getLayerHeight: function() { return this._layerSize.height }, _setLayerHeight: function(a) { this._layerSize.height = a }, getMapTileSize: function() { return cc.size(this._mapTileSize.width, this._mapTileSize.height) }, setMapTileSize: function(a) { this._mapTileSize.width = a.width; this._mapTileSize.height = a.height }, _getTileWidth: function() { return this._mapTileSize.width }, _setTileWidth: function(a) { this._mapTileSize.width = a }, _getTileHeight: function() { return this._mapTileSize.height }, _setTileHeight: function(a) { this._mapTileSize.height = a }, getTiles: function() { return this.tiles }, setTiles: function(a) { this.tiles = a }, getTileset: function() { return this.tileset }, setTileset: function(a) { this.tileset = a }, getLayerOrientation: function() { return this.layerOrientation }, setLayerOrientation: function(a) { this.layerOrientation = a }, getProperties: function() { return this.properties }, setProperties: function(a) { this.properties = a }, initWithTilesetInfo: function(a, b, c) { var d = b._layerSize, e = 0.35 * parseInt(d.width * d.height) + 1, f; a && (f = cc.textureCache.addImage(a.sourceImage)); return this.initWithTexture(f, e) ? (this.layerName = b.name, this._layerSize = d, this.tiles = b._tiles, this._minGID = b._minGID, this._maxGID = b._maxGID, this._opacity = b._opacity, this.properties = b.properties, this._contentScaleFactor = cc.director.getContentScaleFactor(), this.tileset = a, this._mapTileSize = c.getTileSize(), this.layerOrientation = c.orientation, a = this._calculateLayerOffset(b.offset), this.setPosition(cc.pointPixelsToPoints(a)), this._atlasIndexArray = [], this.setContentSize(cc.sizePixelsToPoints(cc.size(this._layerSize.width * this._mapTileSize.width, this._layerSize.height * this._mapTileSize.height))), this._useAutomaticVertexZ = !1, this._vertexZvalue = 0, !0) : !1 }, releaseMap: function() { this.tiles && (this.tiles = null); this._atlasIndexArray && (this._atlasIndexArray = null) }, getTileAt: function(a, b) { if (!a) throw "cc.TMXLayer.getTileAt(): pos should be non-null"; void 0 !== b && (a = cc.p(a, b)); if (a.x >= this._layerSize.width || a.y >= this._layerSize.height || 0 > a.x || 0 > a.y) throw "cc.TMXLayer.getTileAt(): invalid position"; if (!this.tiles || !this._atlasIndexArray) return cc.log("cc.TMXLayer.getTileAt(): TMXLayer: the tiles map has been released"), null; var c = null, d = this.getTileGIDAt(a); if (0 === d) return c; var e = 0 | a.x + a.y * this._layerSize.width, c = this.getChildByTag(e); c || (d = this.tileset.rectForGID(d), d = cc.rectPixelsToPoints(d), c = new cc.Sprite, c.initWithTexture(this.texture, d), c.batchNode = this, c.setPosition(this.getPositionAt(a)), c.vertexZ = this._vertexZForPos(a), c.anchorX = 0, c.anchorY = 0, c.opacity = this._opacity, d = this._atlasIndexForExistantZ(e), this.addSpriteWithoutQuad(c, d, e)); return c }, getTileGIDAt: function(a, b) { if (null == a) throw "cc.TMXLayer.getTileGIDAt(): pos should be non-null"; void 0 !== b && (a = cc.p(a, b)); if (a.x >= this._layerSize.width || a.y >= this._layerSize.height || 0 > a.x || 0 > a.y) throw "cc.TMXLayer.getTileGIDAt(): invalid position"; return this.tiles && this._atlasIndexArray ? (this.tiles[0 | a.x + a.y * this._layerSize.width] & cc.TMX_TILE_FLIPPED_MASK) >>> 0 : (cc.log("cc.TMXLayer.getTileGIDAt(): TMXLayer: the tiles map has been released"), null) }, getTileFlagsAt: function(a, b) { if (!a) throw "cc.TMXLayer.getTileFlagsAt(): pos should be non-null"; void 0 !== b && (a = cc.p(a, b)); if (a.x >= this._layerSize.width || a.y >= this._layerSize.height || 0 > a.x || 0 > a.y) throw "cc.TMXLayer.getTileFlagsAt(): invalid position"; return this.tiles && this._atlasIndexArray ? (this.tiles[0 | a.x + a.y * this._layerSize.width] & cc.TMX_TILE_FLIPPED_ALL) >>> 0 : (cc.log("cc.TMXLayer.getTileFlagsAt(): TMXLayer: the tiles map has been released"), null) }, setTileGID: function(a, b, c, d) { if (!b) throw "cc.TMXLayer.setTileGID(): pos should be non-null"; void 0 !== d ? b = cc.p(b, c) : d = c; if (b.x >= this._layerSize.width || b.y >= this._layerSize.height || 0 > b.x || 0 > b.y) throw "cc.TMXLayer.setTileGID(): invalid position"; if (this.tiles && this._atlasIndexArray) if (0 !== a && a < this.tileset.firstGid) cc.log("cc.TMXLayer.setTileGID(): invalid gid:" + a); else { d = d || 0; this._setNodeDirtyForCache(); c = this.getTileFlagsAt(b); var e = this.getTileGIDAt(b); if (e !== a || c !== d) if (c = (a | d) >>> 0, 0 === a) this.removeTileAt(b); else if (0 === e) this._insertTileForGID(c, b); else { var e = b.x + b.y * this._layerSize.width, f = this.getChildByTag(e); f ? (a = this.tileset.rectForGID(a), a = cc.rectPixelsToPoints(a), f.setTextureRect(a, !1), null != d && this._setupTileSprite(f, b, c), this.tiles[e] = c) : this._updateTileForGID(c, b) } } else cc.log("cc.TMXLayer.setTileGID(): TMXLayer: the tiles map has been released") }, removeTileAt: function(a, b) { if (!a) throw "cc.TMXLayer.removeTileAt(): pos should be non-null"; void 0 !== b && (a = cc.p(a, b)); if (a.x >= this._layerSize.width || a.y >= this._layerSize.height || 0 > a.x || 0 > a.y) throw "cc.TMXLayer.removeTileAt(): invalid position"; if (!this.tiles || !this._atlasIndexArray) cc.log("cc.TMXLayer.removeTileAt(): TMXLayer: the tiles map has been released"); else if (0 !== this.getTileGIDAt(a)) { cc._renderType === cc._RENDER_TYPE_CANVAS && this._setNodeDirtyForCache(); var c = 0 | a.x + a.y * this._layerSize.width, d = this._atlasIndexForExistantZ(c); this.tiles[c] = 0; this._atlasIndexArray.splice(d, 1); if (c = this.getChildByTag(c)) cc.SpriteBatchNode.prototype.removeChild.call(this, c, !0); else if (cc._renderType === cc._RENDER_TYPE_WEBGL && this.textureAtlas.removeQuadAtIndex(d), this._children) for (var c = this._children, e = 0, f = c.length; e < f; e++) { var g = c[e]; if (g) { var h = g.atlasIndex; h >= d && (g.atlasIndex = h - 1) } } } }, getPositionAt: function(a, b) { void 0 !== b && (a = cc.p(a, b)); var c = cc.p(0, 0); switch (this.layerOrientation) { case cc.TMX_ORIENTATION_ORTHO: c = this._positionForOrthoAt(a); break; case cc.TMX_ORIENTATION_ISO: c = this._positionForIsoAt(a); break; case cc.TMX_ORIENTATION_HEX: c = this._positionForHexAt(a) } return cc.pointPixelsToPoints(c) }, getProperty: function(a) { return this.properties[a] }, setupTiles: function() { this._renderCmd.initImageSize(); this._parseInternalProperties(); cc._renderType === cc._RENDER_TYPE_CANVAS && this._setNodeDirtyForCache(); for (var a = this._layerSize.height, b = this._layerSize.width, c = 0; c < a; c++) for (var d = 0; d < b; d++) { var e = this.tiles[d + b * c]; 0 !== e && (this._appendTileForGID(e, cc.p(d, c)), this._minGID = Math.min(e, this._minGID), this._maxGID = Math.max(e, this._maxGID)) } this._maxGID >= this.tileset.firstGid && this._minGID >= this.tileset.firstGid || cc.log("cocos2d:TMX: Only 1 tileset per layer is supported") }, addChild: function(a, b, c) { cc.log("addChild: is not supported on cc.TMXLayer. Instead use setTileGID or tileAt.") }, removeChild: function(a, b) { if (a) if (-1 === this._children.indexOf(a)) cc.log("cc.TMXLayer.removeChild(): Tile does not belong to TMXLayer"); else { cc._renderType === cc._RENDER_TYPE_CANVAS && this._setNodeDirtyForCache(); var c = a.atlasIndex; this.tiles[this._atlasIndexArray[c]] = 0; this._atlasIndexArray.splice(c, 1); cc.SpriteBatchNode.prototype.removeChild.call(this, a, b); cc.renderer.childrenOrderDirty = !0 } }, getLayerName: function() { return this.layerName }, setLayerName: function(a) { this.layerName = a }, _positionForIsoAt: function(a) { return cc.p(this._mapTileSize.width / 2 * (this._layerSize.width + a.x - a.y - 1), this._mapTileSize.height / 2 * (2 * this._layerSize.height - a.x - a.y - 2)) }, _positionForOrthoAt: function(a) { return cc.p(a.x * this._mapTileSize.width, (this._layerSize.height - a.y - 1) * this._mapTileSize.height) }, _positionForHexAt: function(a) { return cc.p(a.x * this._mapTileSize.width * 3 / 4, (this._layerSize.height - a.y - 1) * this._mapTileSize.height + (1 === a.x % 2 ? -this._mapTileSize.height / 2 : 0)) }, _calculateLayerOffset: function(a) { var b = cc.p(0, 0); switch (this.layerOrientation) { case cc.TMX_ORIENTATION_ORTHO: b = cc.p(a.x * this._mapTileSize.width, -a.y * this._mapTileSize.height); break; case cc.TMX_ORIENTATION_ISO: b = cc.p(this._mapTileSize.width / 2 * (a.x - a.y), this._mapTileSize.height / 2 * (-a.x - a.y)); break; case cc.TMX_ORIENTATION_HEX: 0 === a.x && 0 === a.y || cc.log("offset for hexagonal map not implemented yet") } return b }, _appendTileForGID: function(a, b) { var c = this.tileset.rectForGID(a), c = cc.rectPixelsToPoints(c), d = 0 | b.x + b.y * this._layerSize.width, c = this._renderCmd._reusedTileWithRect(c); this._setupTileSprite(c, b, a); var e = this._atlasIndexArray.length; this.insertQuadFromSprite(c, e); this._atlasIndexArray.splice(e, 0, d); return c }, _insertTileForGID: function(a, b) { var c = this.tileset.rectForGID(a), c = cc.rectPixelsToPoints(c), d = 0 | b.x + b.y * this._layerSize.width, c = this._renderCmd._reusedTileWithRect(c); this._setupTileSprite(c, b, a); var e = this._atlasIndexForNewZ(d); this.insertQuadFromSprite(c, e); this._atlasIndexArray.splice(e, 0, d); if (this._children) for (var f = this._children, g = 0, h = f.length; g < h; g++) { var k = f[g]; if (k) { var m = k.atlasIndex; m >= e && (k.atlasIndex = m + 1) } } this.tiles[d] = a; return c }, _updateTileForGID: function(a, b) { var c = this.tileset.rectForGID(a), d = this._contentScaleFactor, c = cc.rect(c.x / d, c.y / d, c.width / d, c.height / d), d = b.x + b.y * this._layerSize.width, c = this._renderCmd._reusedTileWithRect(c); this._setupTileSprite(c, b, a); c.atlasIndex = this._atlasIndexForExistantZ(d); c.dirty = !0; c.updateTransform(); this.tiles[d] = a; return c }, _parseInternalProperties: function() { var a = this.getProperty("cc_vertexz"); if (a) if ("automatic" === a) { this._useAutomaticVertexZ = !0; var b = this.getProperty("cc_alpha_func"), a = 0; b && (a = parseFloat(b)); cc._renderType === cc._RENDER_TYPE_WEBGL && (this.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLORALPHATEST), b = cc._renderContext.getUniformLocation(this.shaderProgram.getProgram(), cc.UNIFORM_ALPHA_TEST_VALUE_S), this.shaderProgram.use(), this.shaderProgram.setUniformLocationWith1f(b, a)) } else this._vertexZvalue = parseInt(a, 10) }, _setupTileSprite: function(a, b, c) { var d = b.x + b.y * this._layerSize.width; a.setPosition(this.getPositionAt(b)); cc._renderType === cc._RENDER_TYPE_WEBGL ? a.vertexZ = this._vertexZForPos(b) : a.tag = d; a.anchorX = 0; a.anchorY = 0; a.opacity = this._opacity; cc._renderType === cc._RENDER_TYPE_WEBGL && (a.rotation = 0); a.setFlippedX(!1); a.setFlippedY(!1); (c & cc.TMX_TILE_DIAGONAL_FLAG) >>> 0 ? (a.anchorX = 0.5, a.anchorY = 0.5, a.x = this.getPositionAt(b).x + a.width / 2, a.y = this.getPositionAt(b).y + a.height / 2, b = (c & (cc.TMX_TILE_HORIZONTAL_FLAG | cc.TMX_TILE_VERTICAL_FLAG) >>> 0) >>> 0, b === cc.TMX_TILE_HORIZONTAL_FLAG ? a.rotation = 90 : b === cc.TMX_TILE_VERTICAL_FLAG ? a.rotation = 270 : (a.rotation = b === (cc.TMX_TILE_VERTICAL_FLAG | cc.TMX_TILE_HORIZONTAL_FLAG) >>> 0 ? 90 : 270, a.setFlippedX(!0))) : ((c & cc.TMX_TILE_HORIZONTAL_FLAG) >>> 0 && a.setFlippedX(!0), (c & cc.TMX_TILE_VERTICAL_FLAG) >>> 0 && a.setFlippedY(!0)) }, _vertexZForPos: function(a) { var b = 0, c = 0; if (this._useAutomaticVertexZ) switch (this.layerOrientation) { case cc.TMX_ORIENTATION_ISO: c = this._layerSize.width + this._layerSize.height; b = -(c - (a.x + a.y)); break; case cc.TMX_ORIENTATION_ORTHO: b = -(this._layerSize.height - a.y); break; case cc.TMX_ORIENTATION_HEX: cc.log("TMX Hexa zOrder not supported"); break; default: cc.log("TMX invalid value") } else b = this._vertexZvalue; return b }, _atlasIndexForExistantZ: function(a) { var b; if (this._atlasIndexArray) for (var c = this._atlasIndexArray, d = 0, e = c.length; d < e && (b = c[d], b !== a); d++); cc.isNumber(b) || cc.log("cc.TMXLayer._atlasIndexForExistantZ(): TMX atlas index not found. Shall not happen"); return d }, _atlasIndexForNewZ: function(a) { for (var b = this._atlasIndexArray, c = 0, d = b.length; c < d && !(a < b[c]); c++); return c } }); _p = cc.TMXLayer.prototype; cc.defineGetterSetter(_p, "texture", _p.getTexture, _p.setTexture); cc.defineGetterSetter(_p, "layerWidth", _p._getLayerWidth, _p._setLayerWidth); cc.defineGetterSetter(_p, "layerHeight", _p._getLayerHeight, _p._setLayerHeight); cc.defineGetterSetter(_p, "tileWidth", _p._getTileWidth, _p._setTileWidth); cc.defineGetterSetter(_p, "tileHeight", _p._getTileHeight, _p._setTileHeight); cc.TMXLayer.create = function(a, b, c) { return new cc.TMXLayer(a, b, c) }; (function() { cc.TMXLayer.CanvasRenderCmd = function(a) { cc.SpriteBatchNode.CanvasRenderCmd.call(this, a); this._needDraw = !0; this._realWorldTransform = { a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0 }; var c = cc._canvas; a = cc.newElement("canvas"); a.width = c.width; a.height = c.height; this._cacheCanvas = a; this._cacheContext = new cc.CanvasContextWrapper(this._cacheCanvas.getContext("2d")); c = new cc.Texture2D; c.initWithElement(a); c.handleLoadedTexture(); this._cacheTexture = c; this._cacheDirty = !1 }; var a = cc.TMXLayer.CanvasRenderCmd.prototype = Object.create(cc.SpriteBatchNode.CanvasRenderCmd.prototype); a.constructor = cc.TMXLayer.CanvasRenderCmd; a._setNodeDirtyForCache = function() { this._cacheDirty = !0 }; a._renderingChildToCache = function() { if (this._cacheDirty) { var a = this._cacheContext, c = a.getContext(), d = this._cacheCanvas; c.setTransform(1, 0, 0, 1, 0, 0); c.clearRect(0, 0, d.width, d.height); for (var c = this._node._children, d = 0, e = c.length; d < e; d++) if (c[d]) { var f = c[d]._renderCmd; f && (f.rendering(a, 1, 1), f._cacheDirty = !1) } this._cacheDirty = !1 } }; a.rendering = function(a, c, d) { var e = this._displayedOpacity / 255; if (!(0 >= e)) { var f = this._node; this._renderingChildToCache(); var g = a || cc._renderContext; a = g.getContext(); g.setGlobalAlpha(e); var e = 0 | -this._anchorPointInPoints.x, h = 0 | -this._anchorPointInPoints.y, k = this._cacheCanvas; k && 0 !== k.width && 0 !== k.height && (g.setTransform(this._realWorldTransform, c, d), g = k.height * d, f.layerOrientation === cc.TMX_ORIENTATION_HEX ? a.drawImage(k, 0, 0, k.width, k.height, e, -(h + g) + 0.5 * f._mapTileSize.height * d, k.width * c, g) : a.drawImage(k, 0, 0, k.width, k.height, e, -(h + g), k.width * c, g)); cc.g_NumberOfDraws++ } }; a._updateCacheContext = function(a, c) { var d = this._node, e = d._contentSize, f = this._cacheCanvas, g = cc.contentScaleFactor(); f.width = 0 | 1.5 * e.width * g; f.height = 0 | 1.5 * e.height * g; d.layerOrientation === cc.TMX_ORIENTATION_HEX ? this._cacheContext.setOffset(0, 0.5 * -d._mapTileSize.height) : this._cacheContext.setOffset(0, 0); d = this._cacheTexture._contentSize; d.width = f.width; d.height = f.height }; a.getTexture = function() { return this._cacheTexture }; a.visit = function(a) { var c = this._node, d, e = c._children; if (c._visible && e && 0 !== e.length) { if (a = a || this.getParentRenderCmd()) this._curLevel = a._curLevel + 1; this._syncStatus(a); if (this._cacheDirty) { a = this._cacheContext; var f = this._cacheCanvas, g = a.getContext(), h = c.__instanceId, k = cc.renderer; k._turnToCacheMode(h); c.sortAllChildren(); c = 0; for (d = e.length; c < d; c++) if (e[c]) { var m = e[c]._renderCmd; m && (m.visit(this), m._cacheDirty = !1) } g.setTransform(1, 0, 0, 1, 0, 0); g.clearRect(0, 0, f.width, f.height); k._renderingToCacheCanvas(a, h); this._cacheDirty = !1 } cc.renderer.pushRenderCommand(this); this._dirtyFlag = 0 } }; a.transform = function(a, c) { var d = this.getNodeToParentTransform(), e = this._realWorldTransform; if (a) { var f = a._worldTransform; e.a = d.a * f.a + d.b * f.c; e.b = d.a * f.b + d.b * f.d; e.c = d.c * f.a + d.d * f.c; e.d = d.c * f.b + d.d * f.d; var g = a._transform, h = -(g.b + g.c) * d.tx; e.tx = d.tx * f.a + d.ty * f.c + f.tx + -(g.b + g.c) * d.ty; e.ty = d.tx * f.b + d.ty * f.d + f.ty + h } else e.a = d.a, e.b = d.b, e.c = d.c, e.d = d.d, e.tx = d.tx, e.ty = d.ty; if (c && (d = this._node._children) && 0 !== d.length) for (e = 0, f = d.length; e < f; e++) d[e]._renderCmd.transform(this, c) }; a.initImageSize = function() { this._node.tileset.imageSize = this._originalTexture.getContentSizeInPixels() }; a._reusedTileWithRect = function(a) { var c = this._node; c._reusedTile = new cc.Sprite; c._reusedTile.initWithTexture(c._renderCmd._texture, a, !1); c._reusedTile.batchNode = c; c._reusedTile.parent = c; c._reusedTile._renderCmd._cachedParent = c._renderCmd; return c._reusedTile } })(); (function() { cc.TMXLayer.WebGLRenderCmd = function(a) { cc.SpriteBatchNode.WebGLRenderCmd.call(this, a); this._needDraw = !0 }; var a = cc.TMXLayer.WebGLRenderCmd.prototype = Object.create(cc.SpriteBatchNode.WebGLRenderCmd.prototype); a.constructor = cc.TMXLayer.WebGLRenderCmd; a._updateCacheContext = function() {}; a.initImageSize = function() { this._node.tileset.imageSize = this._textureAtlas.texture.getContentSizeInPixels(); this._textureAtlas.texture.setAliasTexParameters() }; a._reusedTileWithRect = function(a) { var c = this._node; c._reusedTile ? (c._reusedTile.batchNode = null, c._reusedTile.setTextureRect(a, !1)) : (c._reusedTile = new cc.Sprite, c._reusedTile.initWithTexture(c.texture, a, !1)); c._reusedTile.batchNode = c; return c._reusedTile } })(); cc.PointObject = cc.Class.extend({ _ratio: null, _offset: null, _child: null, ctor: function(a, b) { this.initWithCCPoint(a, b) }, getRatio: function() { return this._ratio }, setRatio: function(a) { this._ratio = a }, getOffset: function() { return this._offset }, setOffset: function(a) { this._offset = a }, getChild: function() { return this._child }, setChild: function(a) { this._child = a }, initWithCCPoint: function(a, b) { this._ratio = a; this._offset = b; this._child = null; return !0 } }); cc.PointObject.create = function(a, b) { return new cc.PointObject(a, b) }; cc.ParallaxNode = cc.Node.extend({ parallaxArray: null, _lastPosition: null, _className: "ParallaxNode", getParallaxArray: function() { return this.parallaxArray }, setParallaxArray: function(a) { this.parallaxArray = a }, ctor: function() { cc.Node.prototype.ctor.call(this); this.parallaxArray = []; this._lastPosition = cc.p(-100, -100) }, addChild: function(a, b, c, d) { if (3 === arguments.length) cc.log("ParallaxNode: use addChild(child, z, ratio, offset) instead"); else { if (!a) throw "cc.ParallaxNode.addChild(): child should be non-null"; var e = new cc.PointObject(c, d); e.setChild(a); this.parallaxArray.push(e); a.setPosition(this._position.x * c.x + d.x, this._position.y * c.y + d.y); cc.Node.prototype.addChild.call(this, a, b, a.tag) } }, removeChild: function(a, b) { for (var c = this.parallaxArray, d = 0; d < c.length; d++) if (c[d].getChild() === a) { c.splice(d, 1); break } cc.Node.prototype.removeChild.call(this, a, b) }, removeAllChildren: function(a) { this.parallaxArray.length = 0; cc.Node.prototype.removeAllChildren.call(this, a) }, _updateParallaxPosition: function() { var a = this._absolutePosition(); if (!cc.pointEqualToPoint(a, this._lastPosition)) { for (var b = this.parallaxArray, c = 0, d = b.length; c < d; c++) { var e = b[c]; e.getChild().setPosition(-a.x + a.x * e.getRatio().x + e.getOffset().x, -a.y + a.y * e.getRatio().y + e.getOffset().y) } this._lastPosition = a } }, _absolutePosition: function() { for (var a = this._position, b = this; null !== b.parent;) b = b.parent, a = cc.pAdd(a, b.getPosition()); return a }, _createRenderCmd: function() { return cc._renderType === cc._RENDER_TYPE_CANVAS ? new cc.ParallaxNode.CanvasRenderCmd(this) : new cc.ParallaxNode.WebGLRenderCmd(this) } }); cc.ParallaxNode.create = function() { return new cc.ParallaxNode }; (function() { cc.ParallaxNode.CanvasRenderCmd = function(a) { cc.Node.CanvasRenderCmd.call(this, a); this._needDraw = !1 }; var a = cc.ParallaxNode.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); a.constructor = cc.ParallaxNode.CanvasRenderCmd; a.updateStatus = function() { this._node._updateParallaxPosition(); cc.Node.CanvasRenderCmd.prototype.updateStatus.call(this) }; a._syncStatus = function(a) { this._node._updateParallaxPosition(); cc.Node.CanvasRenderCmd.prototype._syncStatus.call(this, a) } })(); (function() { if (cc._renderType === cc._RENDER_TYPE_WEBGL) { cc.ParallaxNode.WebGLRenderCmd = function(a) { cc.Node.WebGLRenderCmd.call(this, a); this._needDraw = !1 }; var a = cc.ParallaxNode.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); a.constructor = cc.ParallaxNode.WebGLRenderCmd; a.updateStatus = function() { this._node._updateParallaxPosition(); cc.Node.WebGLRenderCmd.prototype.updateStatus.call(this) }; a._syncStatus = function(a) { this._node._updateParallaxPosition(); cc.Node.WebGLRenderCmd.prototype._syncStatus.call(this, a) } } })(); (function() { var a = cc.sys, b = { common: { multichannel: !0, webAudio: cc.sys._supportWebAudio, auto: !0 } }; b[a.BROWSER_TYPE_IE] = { multichannel: !0, webAudio: cc.sys._supportWebAudio, auto: !0, emptied: !0 }; b[a.BROWSER_TYPE_ANDROID] = { multichannel: !1, webAudio: !1, auto: !1 }; b[a.BROWSER_TYPE_CHROME] = { multichannel: !0, webAudio: !0, auto: !1 }; b[a.BROWSER_TYPE_FIREFOX] = { multichannel: !0, webAudio: !0, auto: !0, delay: !0 }; b[a.BROWSER_TYPE_UC] = { multichannel: !0, webAudio: !1, auto: !1 }; b[a.BROWSER_TYPE_QQ] = { multichannel: !1, webAudio: !1, auto: !0 }; b[a.BROWSER_TYPE_OUPENG] = { multichannel: !1, webAudio: !1, auto: !1, replay: !0, emptied: !0 }; b[a.BROWSER_TYPE_WECHAT] = { multichannel: !1, webAudio: !1, auto: !1, replay: !0, emptied: !0 }; b[a.BROWSER_TYPE_360] = { multichannel: !1, webAudio: !1, auto: !0 }; b[a.BROWSER_TYPE_MIUI] = { multichannel: !1, webAudio: !1, auto: !0 }; b[a.BROWSER_TYPE_LIEBAO] = { multichannel: !1, webAudio: !1, auto: !1, replay: !0, emptied: !0 }; b[a.BROWSER_TYPE_SOUGOU] = { multichannel: !1, webAudio: !1, auto: !1, replay: !0, emptied: !0 }; b[a.BROWSER_TYPE_BAIDU] = { multichannel: !1, webAudio: !1, auto: !1, replay: !0, emptied: !0 }; b[a.BROWSER_TYPE_BAIDU_APP] = { multichannel: !1, webAudio: !1, auto: !1, replay: !0, emptied: !0 }; b[a.BROWSER_TYPE_SAFARI] = { multichannel: !0, webAudio: !0, auto: !1, webAudioCallback: function(a) { document.createElement("audio").src = a } }; var c, d; try { var e = navigator.userAgent.toLowerCase(); switch (a.browserType) { case a.BROWSER_TYPE_IE: d = e.match(/(msie |rv:)([\d.]+)/); break; case a.BROWSER_TYPE_FIREFOX: d = e.match(/(firefox\/|rv:)([\d.]+)/); break; case a.BROWSER_TYPE_CHROME: d = e.match(/chrome\/([\d.]+)/); break; case a.BROWSER_TYPE_BAIDU: d = e.match(/baidubrowser\/([\d.]+)/); break; case a.BROWSER_TYPE_UC: d = e.match(/ucbrowser\/([\d.]+)/); break; case a.BROWSER_TYPE_QQ: d = e.match(/qqbrowser\/([\d.]+)/); break; case a.BROWSER_TYPE_OUPENG: d = e.match(/oupeng\/([\d.]+)/); break; case a.BROWSER_TYPE_WECHAT: d = e.match(/micromessenger\/([\d.]+)/); break; case a.BROWSER_TYPE_SAFARI: d = e.match(/safari\/([\d.]+)/); break; case a.BROWSER_TYPE_MIUI: d = e.match(/miuibrowser\/([\d.]+)/) } c = d ? d[1] : "" } catch (f) { console.log(f) } if (c) switch (a.browserType) { case a.BROWSER_TYPE_CHROME: 30 > parseInt(c) && (b[a.BROWSER_TYPE_CHROME] = { multichannel: !1, webAudio: !0, auto: !1 }); break; case a.BROWSER_TYPE_MIUI: if (c = c.match(/\d+/g), 2 > c[0] || 2 === c[0] && 0 === c[1] && 1 >= c[2]) b[a.BROWSER_TYPE_MIUI].auto = !1 } if (cc.sys.isMobile) cc.__audioSupport = cc.sys.os !== cc.sys.OS_IOS ? b[a.browserType] || b.common : b[a.BROWSER_TYPE_SAFARI]; else switch (a.browserType) { case a.BROWSER_TYPE_IE: cc.__audioSupport = b[a.BROWSER_TYPE_IE]; break; case a.BROWSER_TYPE_FIREFOX: cc.__audioSupport = b[a.BROWSER_TYPE_FIREFOX]; break; default: cc.__audioSupport = b.common } })(); cc.Audio = cc.Class.extend({ volume: 1, loop: !1, src: null, _touch: !1, _playing: !1, _AUDIO_TYPE: "AUDIO", _pause: !1, _buffer: null, _currentSource: null, _startTime: null, _currentTime: null, _context: null, _volume: null, _ignoreEnded: !1, _element: null, ctor: function(a, b, c) { a && (this._context = a); b && (this._volume = b); a && b && (this._AUDIO_TYPE = "WEBAUDIO"); this.src = c }, _setBufferCallback: null, setBuffer: function(a) { if (a) { var b = this._playing; this._AUDIO_TYPE = "WEBAUDIO"; this._buffer && this._buffer !== a && this.getPlaying() && this.stop(); this._buffer = a; b && this.play(); this._volume.gain.value = this.volume; this._setBufferCallback && this._setBufferCallback(a) } }, _setElementCallback: null, setElement: function(a) { if (a) { var b = this._playing; this._AUDIO_TYPE = "AUDIO"; this._element && this._element !== a && this.getPlaying() && this.stop(); this._element = a; b && this.play(); a.volume = this.volume; a.loop = this.loop; this._setElementCallback && this._setElementCallback(a) } }, play: function(a, b) { this._playing = !0; this.loop = void 0 === b ? this.loop : b; "AUDIO" === this._AUDIO_TYPE ? this._playOfAudio(a) : this._playOfWebAudio(a) }, getPlaying: function() { if (!this._playing) return this._playing; if ("AUDIO" === this._AUDIO_TYPE) { var a = this._element; return !a || this._pause || a.ended ? this._playing = !1 : !0 } return (a = this._currentSource) ? null == a.playbackState ? this._playing : this._currentTime + this._context.currentTime - this._startTime < this._currentSource.buffer.duration : !0 }, _playOfWebAudio: function(a) { var b = this._currentSource; if (this._buffer) { if (!this._pause && b) if (0 === this._context.currentTime || this._currentTime + this._context.currentTime - this._startTime > this._currentSource.buffer.duration) this._stopOfWebAudio(); else return; b = this._context.createBufferSource(); b.buffer = this._buffer; b.connect(this._volume); b.loop = this.loop; this._startTime = this._context.currentTime; this._currentTime = 0; if (b.start) b.start(0, a || 0); else if (b.noteGrainOn) { var c = b.buffer.duration; this.loop ? b.noteGrainOn(0, a, c) : b.noteGrainOn(0, a, c - a) } else b.noteOn(0); this._currentSource = b; var d = this; b.onended = function() { d._ignoreEnded ? d._ignoreEnded = !1 : d._playing = !1 } } }, _playOfAudio: function() { var a = this._element; a && (a.loop = this.loop, a.play()) }, stop: function() { this._playing = !1; "AUDIO" === this._AUDIO_TYPE ? this._stopOfAudio() : this._stopOfWebAudio() }, _stopOfWebAudio: function() { var a = this._currentSource; this._ignoreEnded = !0; a && (a.stop(0), this._currentSource = null) }, _stopOfAudio: function() { var a = this._element; a && (a.pause(), a.duration && Infinity !== a.duration && (a.currentTime = 0)) }, pause: function() { this._playing = !1; this._pause = !0; "AUDIO" === this._AUDIO_TYPE ? this._pauseOfAudio() : this._pauseOfWebAudio() }, _pauseOfWebAudio: function() { this._currentTime += this._context.currentTime - this._startTime; var a = this._currentSource; a && a.stop(0) }, _pauseOfAudio: function() { var a = this._element; a && a.pause() }, resume: function() { this._pause && ("AUDIO" === this._AUDIO_TYPE ? this._resumeOfAudio() : this._resumeOfWebAudio(), this._pause = !1, this._playing = !0) }, _resumeOfWebAudio: function() { var a = this._currentSource; a && (this._startTime = this._context.currentTime, this._playOfWebAudio(this._currentTime % a.buffer.duration)) }, _resumeOfAudio: function() { var a = this._element; a && a.play() }, setVolume: function(a) { 1 < a && (a = 1); 0 > a && (a = 0); this.volume = a; "AUDIO" === this._AUDIO_TYPE ? this._element && (this._element.volume = a) : this._volume && (this._volume.gain.value = a) }, getVolume: function() { return this.volume }, cloneNode: function() { var a, b; if ("AUDIO" === this._AUDIO_TYPE) { a = new cc.Audio; var c = document.createElement("audio"); c.src = this.src; a.setElement(c) } else c = this._context.createGain(), c.gain.value = 1, c.connect(this._context.destination), a = new cc.Audio(this._context, c, this.src), this._buffer ? a.setBuffer(this._buffer) : (b = this, this._setBufferCallback = function(c) { a.setBuffer(c); b._setBufferCallback = null }); a._AUDIO_TYPE = this._AUDIO_TYPE; return a } }); (function(a) { var b = a.webAudio, c = a.multichannel, d = a.auto, e = []; (function() { var a = document.createElement("audio"); if (a.canPlayType) { var b = a.canPlayType('audio/ogg; codecs\x3d"vorbis"'); b && "" !== b && e.push(".ogg"); (b = a.canPlayType("audio/mpeg")) && "" !== b && e.push(".mp3"); (b = a.canPlayType('audio/wav; codecs\x3d"1"')) && "" !== b && e.push(".wav"); (b = a.canPlayType("audio/mp4")) && "" !== b && e.push(".mp4"); (a = a.canPlayType("audio/x-m4a")) && "" !== a && e.push(".m4a") } })(); try { if (b) { var f = new(window.AudioContext || window.webkitAudioContext || window.mozAudioContext); a.delay && setTimeout(function() { f = new(window.AudioContext || window.webkitAudioContext || window.mozAudioContext) }, 0) } } catch (g) { b = !1, cc.log("browser don't support webAudio") } var h = { cache: {}, load: function(a, c, d, g) { if (0 === e.length) return g("can not support audio!"); var k = cc.path.extname(a), u = [k]; for (d = 0; d < e.length; d++) k !== e[d] && u.push(e[d]); var s; if (h.cache[c]) return g(null, h.cache[c]); if (b) try { var v = f.createGain(); v.gain.value = 1; v.connect(f.destination); s = new cc.Audio(f, v, a) } catch (x) { b = !1, cc.log("browser don't support webAudio"), s = new cc.Audio(null, null, a) } else s = new cc.Audio(null, null, a); this.loadAudioFromExtList(a, u, s, g); h.cache[c] = s }, loadAudioFromExtList: function(c, d, g, k) { if (0 === d.length) { var r = "can not found the resource of audio! Last match url is : ", r = r + c.replace(/\.(.*)?$/, "("); e.forEach(function(a) { r += a + "|" }); r = r.replace(/\|$/, ")"); return k(r) } c = cc.path.changeExtname(c, d.splice(0, 1)); if (b) { a.webAudioCallback && a.webAudioCallback(c); var u = new XMLHttpRequest; u.open("GET", c, !0); u.responseType = "arraybuffer"; u.onload = function() { f.decodeAudioData(u.response, function(a) { g.setBuffer(a); k(null, g) }, function() { h.loadAudioFromExtList(c, d, g, k) }) }; u.send() } else { var s = document.createElement("audio"), v = !1, x = !1, D = setTimeout(function() { 0 === s.readyState ? w() : (x = !0, k("audio load timeout : " + c, g)) }, 1E4), E = function() { v || (g.setElement(s), s.removeEventListener("canplaythrough", E, !1), s.removeEventListener("error", A, !1), s.removeEventListener("emptied", w, !1), !x && k(null, g), v = !0, clearTimeout(D)) }, A = function() { v && (s.removeEventListener("canplaythrough", E, !1), s.removeEventListener("error", A, !1), s.removeEventListener("emptied", w, !1), !x && h.loadAudioFromExtList(c, d, g, k), v = !0, clearTimeout(D)) }, w = function() { x = !0; E(); k(null, g) }; cc._addEventListener(s, "canplaythrough", E, !1); cc._addEventListener(s, "error", A, !1); a.emptied && cc._addEventListener(s, "emptied", w, !1); s.src = c; s.load() } } }; cc.loader.register(["mp3", "ogg", "wav", "mp4", "m4a"], h); cc.audioEngine = { _currMusic: null, _musicVolume: 1, willPlayMusic: function() { return !1 }, playMusic: function(a, b) { var c = this._currMusic; c && c.src !== a && c.getPlaying() && c.stop(); c = h.cache[a]; c || (cc.loader.load(a), c = h.cache[a]); c.play(0, b); c.setVolume(this._musicVolume); this._currMusic = c }, stopMusic: function(a) { var b = this._currMusic; b && (b.stop(), a && cc.loader.release(b.src)) }, pauseMusic: function() { var a = this._currMusic; a && a.pause() }, resumeMusic: function() { var a = this._currMusic; a && a.resume() }, rewindMusic: function() { var a = this._currMusic; a && (a.stop(), a.play()) }, getMusicVolume: function() { return this._musicVolume }, setMusicVolume: function(a) { a -= 0; isNaN(a) && (a = 1); 1 < a && (a = 1); 0 > a && (a = 0); this._musicVolume = a; var b = this._currMusic; b && b.setVolume(a) }, isMusicPlaying: function() { var a = this._currMusic; return a ? a.getPlaying() : !1 }, _audioPool: {}, _maxAudioInstance: 5, _effectVolume: 1, playEffect: function(a, d) { if (!c) return null; var e = this._audioPool[a]; e || (e = this._audioPool[a] = []); var f; for (f = 0; f < e.length && e[f].getPlaying(); f++); if (e[f]) g = e[f], g.setVolume(this._effectVolume), g.play(0, d); else if (!b && f > this._maxAudioInstance) cc.log("Error: %s greater than %d", a, this._maxAudioInstance); else { var g = h.cache[a]; g || (cc.loader.load(a), g = h.cache[a]); g = g.cloneNode(); g.setVolume(this._effectVolume); g.loop = d || !1; g.play(); e.push(g) } return g }, setEffectsVolume: function(a) { a -= 0; isNaN(a) && (a = 1); 1 < a && (a = 1); 0 > a && (a = 0); this._effectVolume = a; var b = this._audioPool, c; for (c in b) { var d = b[c]; if (Array.isArray(d)) for (var e = 0; e < d.length; e++) d[e].setVolume(a) } }, getEffectsVolume: function() { return this._effectVolume }, pauseEffect: function(a) { a && a.pause() }, pauseAllEffects: function() { var a = this._audioPool, b; for (b in a) for (var c = a[b], d = 0; d < a[b].length; d++) c[d].getPlaying() && c[d].pause() }, resumeEffect: function(a) { a && a.resume() }, resumeAllEffects: function() { var a = this._audioPool, b; for (b in a) for (var c = a[b], d = 0; d < a[b].length; d++) c[d].resume() }, stopEffect: function(a) { a && a.stop() }, stopAllEffects: function() { var a = this._audioPool, b; for (b in a) for (var c = a[b], d = 0; d < a[b].length; d++) c[d].stop() }, unloadEffect: function(a) { if (a) { cc.loader.release(a); var b = this._audioPool[a]; b && (b.length = 0); delete this._audioPool[a]; delete h.cache[a] } }, end: function() { this.stopMusic(); this.stopAllEffects() }, _pauseCache: [], _pausePlaying: function() { var a = this._currMusic; a && a.getPlaying() && (a.pause(), this._pauseCache.push(a)); var a = this._audioPool, b; for (b in a) for (var c = a[b], d = 0; d < a[b].length; d++) c[d].getPlaying() && (c[d].pause(), this._pauseCache.push(c[d])) }, _resumePlaying: function() { for (var a = this._pauseCache, b = 0; b < a.length; b++) a[b].resume(); a.length = 0 } }; if (!d) { var k = function() { var b = cc.audioEngine._currMusic; b && !1 === b._touch && b._playing && b.getPlaying() && (b._touch = !0, b.play(0, b.loop), !a.replay && cc._canvas.removeEventListener("touchstart", k)) }; setTimeout(function() { cc._canvas && cc._canvas.addEventListener("touchstart", k, !1) }, 150) } cc.eventManager.addCustomListener(cc.game.EVENT_HIDE, function() { cc.audioEngine._pausePlaying() }); cc.eventManager.addCustomListener(cc.game.EVENT_SHOW, function() { cc.audioEngine._resumePlaying() }) })(cc.__audioSupport); (function() { cc.PhysicsSprite = cc.Sprite.extend({ _ignoreBodyRotation: !1, _body: null, _rotation: 1, ctor: function(a, c) { cc.Sprite.prototype.ctor.call(this); if (void 0 === a) cc.PhysicsSprite.prototype.init.call(this); else if (cc.isString(a)) if ("#" === a[0]) { var d = a.substr(1, a.length - 1), d = cc.spriteFrameCache.getSpriteFrame(d); this.initWithSpriteFrame(d) } else this.init(a, c); else cc.isObject(a) && (a instanceof cc.Texture2D ? this.initWithTexture(a, c) : a instanceof cc.SpriteFrame && this.initWithSpriteFrame(a)); cc.renderer.pushRenderCommand(this._renderCmd) }, visit: function() { cc.renderer.pushRenderCommand(this._renderCmd); cc.Sprite.prototype.visit.call(this) }, setBody: function(a) { this._body = a }, getBody: function() { return this._body }, getPosition: function() { var a = this._body; return { x: a.p.x, y: a.p.y } }, getPositionX: function() { return this._body.p.x }, getPositionY: function() { return this._body.p.y }, setPosition: function(a, c) { void 0 === c ? (this._body.p.x = a.x, this._body.p.y = a.y) : (this._body.p.x = a, this._body.p.y = c) }, setPositionX: function(a) { this._body.p.x = a }, setPositionY: function(a) { this._body.p.y = a }, _syncPosition: function() { var a = this._position, c = this._body; a.x === c.p.x && a.y === c.p.y || cc.Sprite.prototype.setPosition.call(this, c.p.x, c.p.y) }, getRotation: function() { return this._ignoreBodyRotation ? this._rotationX : -cc.radiansToDegrees(this._body.a) }, setRotation: function(a) { this._ignoreBodyRotation ? cc.Sprite.prototype.setRotation.call(this, a) : this._body.a = -cc.degreesToRadians(a) }, _syncRotation: function() { this._rotationX !== -cc.radiansToDegrees(this._body.a) && cc.Sprite.prototype.setRotation.call(this, -cc.radiansToDegrees(this._body.a)) }, getNodeToParentTransform: function() { return this._renderCmd.getNodeToParentTransform() }, isDirty: function() { return !this._body.isSleeping() }, setDirty: function() {}, setIgnoreBodyRotation: function(a) { this._ignoreBodyRotation = a }, _createRenderCmd: function() { return cc._renderType === cc._RENDER_TYPE_CANVAS ? new cc.PhysicsSprite.CanvasRenderCmd(this) : new cc.PhysicsSprite.WebGLRenderCmd(this) } }); cc.PhysicsSprite._className = "PhysicsSprite"; var a = cc.PhysicsSprite.prototype; cc.defineGetterSetter(a, "body", a.getBody, a.setBody); cc.defineGetterSetter(a, "dirty", a.isDirty, a.setDirty); cc.PhysicsSprite.create = function(a, c) { return new cc.PhysicsSprite(a, c) }; cc.PhysicsSprite.createWithSpriteFrameName = cc.PhysicsSprite.create; cc.PhysicsSprite.createWithSpriteFrame = cc.PhysicsSprite.create })(); cc.__convertVerts = function(a) { for (var b = [], c = 0; c < a.length / 2; c++) b[c] = { x: a[2 * c], y: a[2 * c + 1] }; return b }; cc.ColorForBody = function(a) { return a.isRogue() || a.isSleeping() ? cc.color(128, 128, 128, 128) : a.nodeIdleTime > a.space.sleepTimeThreshold ? cc.color(84, 84, 84, 128) : cc.color(255, 0, 0, 128) }; cc.DrawShape = function(a, b) { var c = a.body, d = cc.ColorForBody(c); switch (a.collisionCode) { case cp.CircleShape.prototype.collisionCode: this.drawDot(a.tc, Math.max(a.r, 1), d); this.drawSegment(a.tc, cp.v.add(a.tc, cp.v.mult(c.rot, a.r)), 1, d); break; case cp.SegmentShape.prototype.collisionCode: this.drawSegment(a.ta, a.tb, Math.max(a.r, 2), d); break; case cp.PolyShape.prototype.collisionCode: c = cc.color(d.r, d.g, d.b, cc.lerp(d.a, 255, 0.5)); this.drawPoly(cc.__convertVerts(a.tVerts), d, 1, c); break; default: cc.log("cc.DrawShape(): Bad assertion in DrawShape()") } }; cc.DrawConstraint = function(a, b) { var c = a.a, d = a.b, e; a instanceof cp.PinJoint ? (e = c.local2World(a.anchr1), c = d.local2World(a.anchr2), this.drawDot(e, 3, cc.CONSTRAINT_COLOR), this.drawDot(c, 3, cc.CONSTRAINT_COLOR), this.drawSegment(e, c, 1, cc.CONSTRAINT_COLOR)) : a instanceof cp.SlideJoint ? (e = c.local2World(a.anchr1), c = d.local2World(a.anchr2), this.drawDot(e, 3, cc.CONSTRAINT_COLOR), this.drawDot(c, 3, cc.CONSTRAINT_COLOR), this.drawSegment(e, c, 1, cc.CONSTRAINT_COLOR)) : a instanceof cp.PivotJoint ? (e = c.local2World(a.anchr1), c = d.local2World(a.anchr2), this.drawDot(e, 3, cc.CONSTRAINT_COLOR), this.drawDot(c, 3, cc.CONSTRAINT_COLOR)) : a instanceof cp.GrooveJoint && (e = c.local2World(a.grv_a), c = c.local2World(a.grv_b), d = d.local2World(a.anchr2), this.drawDot(d, 3, cc.CONSTRAINT_COLOR), this.drawSegment(e, c, 1, cc.CONSTRAINT_COLOR)) }; cc.CONSTRAINT_COLOR = cc.color(0, 255, 0, 128); cc.PhysicsDebugNode = cc.DrawNode.extend({ _space: null, _className: "PhysicsDebugNode", ctor: function(a) { cc.DrawNode.prototype.ctor.call(this); this._space = a }, getSpace: function() { return this._space }, setSpace: function(a) { this._space = a }, draw: function(a) { this._space && (this._space.eachShape(cc.DrawShape.bind(this)), this._space.eachConstraint(cc.DrawConstraint.bind(this)), cc.DrawNode.prototype.draw.call(this), this.clear()) }, _createRenderCmd: function() { return cc._renderType === cc._RENDER_TYPE_CANVAS ? new cc.PhysicsDebugNode.CanvasRenderCmd(this) : new cc.PhysicsDebugNode.WebGLRenderCmd(this) } }); cc.PhysicsDebugNode.create = function(a) { return new cc.PhysicsDebugNode(a) }; (function() { cc.PhysicsDebugNode.CanvasRenderCmd = function(a) { cc.Node.CanvasRenderCmd.call(this, a); this._buffer = a._buffer; this._needDraw = !0 }; var a = cc.PhysicsDebugNode.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); a.constructor = cc.PhysicsDebugNode.CanvasRenderCmd; a.rendering = function(a, c, d) { var e = this._node; e._space && (e._space.eachShape(cc.DrawShape.bind(e)), e._space.eachConstraint(cc.DrawConstraint.bind(e)), cc.DrawNode.CanvasRenderCmd.prototype.rendering.call(this, a, c, d), e.clear()) }; a._drawDot = cc.DrawNode.CanvasRenderCmd.prototype._drawDot; a._drawSegment = cc.DrawNode.CanvasRenderCmd.prototype._drawSegment; a._drawPoly = cc.DrawNode.CanvasRenderCmd.prototype._drawPoly })(); (function() { cc.PhysicsDebugNode.WebGLRenderCmd = function(a) { cc.Node.WebGLRenderCmd.call(this, a); this._needDraw = !0 }; cc.PhysicsDebugNode.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); cc.PhysicsDebugNode.WebGLRenderCmd.prototype.constructor = cc.PhysicsDebugNode.WebGLRenderCmd; cc.PhysicsDebugNode.WebGLRenderCmd.prototype.rendering = function(a) { a = this._node; a._space && (a._space.eachShape(cc.DrawShape.bind(a)), a._space.eachConstraint(cc.DrawConstraint.bind(a)), cc.glBlendFunc(a._blendFunc.src, a._blendFunc.dst), this._shaderProgram.use(), this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix), a._render(), a.clear()) } })(); (function() { cc.PhysicsSprite.CanvasRenderCmd = function(a) { cc.Sprite.CanvasRenderCmd.call(this, a); this._needDraw = !0 }; var a = cc.PhysicsSprite.CanvasRenderCmd.prototype = Object.create(cc.Sprite.CanvasRenderCmd.prototype); a.constructor = cc.PhysicsSprite.CanvasRenderCmd; a.rendering = function(a, c, d) { var e = this._node; e._syncPosition(); e._ignoreBodyRotation || e._syncRotation(); this.transform(this.getParentRenderCmd()); cc.Sprite.CanvasRenderCmd.prototype.rendering.call(this, a, c, d) }; a.getNodeToParentTransform = function() { var a = this._node, c = this._transform, d = a._body, e = a._scaleX, f = a._scaleY, g = this._anchorPointInPoints; c.tx = d.p.x; c.ty = d.p.y; var d = -d.a, h = 1, k = 0; d && !a._ignoreBodyRotation && (h = Math.cos(d), k = Math.sin(d)); c.a = c.d = h; c.b = -k; c.c = k; if (1 !== e || 1 !== f) c.a *= e, c.c *= e, c.b *= f, c.d *= f; c.tx += h * -g.x * e + -k * g.y * f; c.ty -= k * -g.x * e + h * g.y * f; this._ignoreAnchorPointForPosition && (c.tx += g.x, c.ty += g.y); return this._transform } })(); (function() { cc.PhysicsSprite.WebGLRenderCmd = function(a) { cc.Sprite.WebGLRenderCmd.call(this, a); this._needDraw = !0 }; var a = cc.PhysicsSprite.WebGLRenderCmd.prototype = Object.create(cc.Sprite.WebGLRenderCmd.prototype); a.constructor = cc.PhysicsSprite.WebGLRenderCmd; a.rendering = function(a) { var c = this._node; c._syncPosition(); c._ignoreBodyRotation || c._syncRotation(); this.transform(this.getParentRenderCmd()); cc.Sprite.WebGLRenderCmd.prototype.rendering.call(this, a) }; a.getNodeToParentTransform = function() { var a = this._node, c = a._body, d = this._anchorPointInPoints, e = a._scaleX, f = a._scaleY, g = c.p.x, h = c.p.y; this._ignoreAnchorPointForPosition && (g += d.x, h += d.y); var c = c.a, k = 1, m = 0; c && !a._ignoreBodyRotation && (k = Math.cos(c), m = Math.sin(c)); cc._rectEqualToZero(d) || (g += k * -d.x * e + -m * -d.y * f, h += m * -d.x * e + k * -d.y * f); return this._transform = cc.affineTransformMake(k * e, m * e, -m * f, k * f, g, h) }; a.updateTransform = function() { this._dirty = this._node.isDirty(); cc.Sprite.WebGLRenderCmd.prototype.updateTransform.call(this) } })(); (function() { Object.create = Object.create || function(a) { function b() {} b.prototype = a; return new b }; var a; "undefined" === typeof exports ? (a = {}, "object" === typeof window && (window.cp = a)) : a = exports; var b = function(a, b) { if (!a) throw Error("Assertion failed: " + b); }, c = function(a, b) { !a && console && console.warn && (console.warn("ASSERTION FAILED: " + b), console.trace && console.trace()) }, d = function(a, b) { return a < b ? a : b }, e = function(a, b) { return a > b ? a : b }, f, g; "object" === typeof window && -1 < window.navigator.userAgent.indexOf("Firefox") ? (f = Math.min, g = Math.max) : (f = d, g = e); var h = function(a, b) { return a < b ? a + " " + b : b + " " + a }, k = function(a, b) { for (var c = 0; c < a.length; c++) if (a[c] === b) { a[c] = a[a.length - 1]; a.length--; break } }; a.momentForCircle = function(a, b, c, d) { return a * (0.5 * (b * b + c * c) + L(d)) }; a.areaForCircle = function(a, b) { return Math.PI * Math.abs(a * a - b * b) }; a.momentForSegment = function(a, b, c) { var d = y(A(b, c), 0.5); return a * (V(c, b) / 12 + L(d)) }; a.areaForSegment = function(a, b, c) { return c * (Math.PI * c + 2 * U(a, b)) }; a.momentForPoly = function(a, b, c) { for (var d = 0, e = 0, f = b.length, g = 0; g < f; g += 2) var h = b[g] + c.x, k = b[g + 1] + c.y, m = b[(g + 2) % f] + c.x, n = b[(g + 3) % f] + c.y, p = m * k - n * h, d = d + p * (h * h + k * k + (h * m + k * n) + (m * m + n * n)), e = e + p; return a * d / (6 * e) }; a.areaForPoly = function(a) { for (var b = 0, c = 0, d = a.length; c < d; c += 2) b += z(new s(a[c], a[c + 1]), new s(a[(c + 2) % d], a[(c + 3) % d])); return -b / 2 }; a.centroidForPoly = function(a) { for (var b = 0, c = new s(0, 0), d = 0, e = a.length; d < e; d += 2) var f = new s(a[d], a[d + 1]), g = new s(a[(d + 2) % e], a[(d + 3) % e]), h = z(f, g), b = b + h, c = A(c, y(A(f, g), h)); return y(c, 1 / (3 * b)) }; a.recenterPoly = function(b) { for (var c = a.centroidForPoly(b), d = 0; d < b.length; d += 2) b[d] -= c.x, b[d + 1] -= c.y }; a.momentForBox = function(a, b, c) { return a * (b * b + c * c) / 12 }; a.momentForBox2 = function(b, c) { var d = c.r - c.l, e = c.t - c.b, f = y([c.l + c.r, c.b + c.t], 0.5); return a.momentForBox(b, d, e) + b * L(f) }; var m = a.loopIndexes = function(a) { var b = 0, c = 0, d, e, f, g; d = f = a[0]; e = g = a[1]; for (var h = a.length >> 1, k = 1; k < h; k++) { var m = a[2 * k], n = a[2 * k + 1]; if (m < d || m == d && n < e) d = m, e = n, b = k; else if (m > f || m == f && n > g) f = m, g = n, c = k } return [b, c] }, n = function(a, b, c) { var d = a[2 * b]; a[2 * b] = a[2 * c]; a[2 * c] = d; d = a[2 * b + 1]; a[2 * b + 1] = a[2 * c + 1]; a[2 * c + 1] = d }, p = function(a, b, c, d, e, f) { if (0 === c) return 0; var g = 0, h = b; e = w(e, d); f *= D(e); var k = b; for (c = b + c - 1; k <= c;) { var m = new s(a[2 * k], a[2 * k + 1]), m = z(e, w(m, d)); m > f ? (m > g && (g = m, h = k), k++) : (n(a, k, c), c--) } h != b && n(a, b, h); return k - b }, t = function(a, b, c, d, e, f, g, h) { if (0 > d) return 0; if (0 == d) return b[2 * h] = f.x, b[2 * h + 1] = f.y, 1; var k = p(b, c, d, e, f, a), m = new s(b[2 * c], b[2 * c + 1]); e = t(a, b, c + 1, k - 1, e, m, f, h); m = h + e++; b[2 * m] = f.x; b[2 * m + 1] = f.y; d = p(b, c + k, d - k, f, g, a); m = new s(b[2 * (c + k)], b[2 * (c + k) + 1]); return e + t(a, b, c + k + 1, d - 1, f, m, g, h + e) }; a.convexHull = function(a, b, d) { if (b) for (var e = 0; e < a.length; e++) b[e] = a[e]; else b = a; var f = m(a), e = f[0], f = f[1]; if (e == f) return b.length = 2, b; n(b, 0, e); n(b, 1, 0 == f ? e : f); e = new s(b[0], b[1]); f = new s(b[2], b[3]); a = t(d, b, 2, (a.length >> 1) - 2, e, f, e, 1) + 1; b.length = 2 * a; c(Ra(b), "Internal error: cpConvexHull() and cpPolyValidate() did not agree.Please report this error with as much info as you can."); return b }; var r = function(a, b, c) { return f(g(a, b), c) }, u = function(a) { return g(0, f(a, 1)) }, s = a.Vect = function(a, b) { this.x = a; this.y = b }; a.v = function(a, b) { return new s(a, b) }; var v = a.vzero = new s(0, 0), x = a.v.dot = function(a, b) { return a.x * b.x + a.y * b.y }, D = a.v.len = function(a) { return Math.sqrt(x(a, a)) }, E = a.v.len2 = function(a, b) { return Math.sqrt(a * a + b * b) }; a.v.eql = function(a, b) { return a.x === b.x && a.y === b.y }; var A = a.v.add = function(a, b) { return new s(a.x + b.x, a.y + b.y) }; s.prototype.add = function(a) { this.x += a.x; this.y += a.y; return this }; var w = a.v.sub = function(a, b) { return new s(a.x - b.x, a.y - b.y) }; s.prototype.sub = function(a) { this.x -= a.x; this.y -= a.y; return this }; var B = a.v.neg = function(a) { return new s(-a.x, -a.y) }; s.prototype.neg = function() { this.x = -this.x; this.y = -this.y; return this }; var y = a.v.mult = function(a, b) { return new s(a.x * b, a.y * b) }; s.prototype.mult = function(a) { this.x *= a; this.y *= a; return this }; var z = a.v.cross = function(a, b) { return a.x * b.y - a.y * b.x }, F = a.v.perp = function(a) { return new s(-a.y, a.x) }; a.v.pvrperp = function(a) { return new s(a.y, -a.x) }; var J = a.v.project = function(a, b) { return y(b, x(a, b) / L(b)) }; s.prototype.project = function(a) { this.mult(x(this, a) / L(a)); return this }; var C = a.v.rotate = function(a, b) { return new s(a.x * b.x - a.y * b.y, a.x * b.y + a.y * b.x) }; s.prototype.rotate = function(a) { this.x = this.x * a.x - this.y * a.y; this.y = this.x * a.y + this.y * a.x; return this }; var N = a.v.unrotate = function(a, b) { return new s(a.x * b.x + a.y * b.y, a.y * b.x - a.x * b.y) }, L = a.v.lengthsq = function(a) { return x(a, a) }, P = a.v.lengthsq2 = function(a, b) { return a * a + b * b }, S = a.v.lerp = function(a, b, c) { return A(y(a, 1 - c), y(b, c)) }, I = a.v.normalize = function(a) { return y(a, 1 / D(a)) }, T = a.v.normalize_safe = function(a) { return 0 === a.x && 0 === a.y ? v : I(a) }, K = a.v.clamp = function(a, b) { return x(a, a) > b * b ? y(I(a), b) : a }; a.v.lerpconst = function(a, b, c) { return A(a, K(w(b, a), c)) }; var U = a.v.dist = function(a, b) { return D(w(a, b)) }, V = a.v.distsq = function(a, b) { return L(w(a, b)) }; a.v.near = function(a, b, c) { return V(a, b) < c * c }; var aa = a.v.slerp = function(a, b, c) { var d = Math.acos(x(a, b)); if (d) { var e = 1 / Math.sin(d); return A(y(a, Math.sin((1 - c) * d) * e), y(b, Math.sin(c * d) * e)) } return a }; a.v.slerpconst = function(a, b, c) { var d = Math.acos(x(a, b)); return aa(a, b, f(c, d) / d) }; a.v.forangle = function(a) { return new s(Math.cos(a), Math.sin(a)) }; a.v.toangle = function(a) { return Math.atan2(a.y, a.x) }; a.v.str = function(a) { return "(" + a.x.toFixed(3) + ", " + a.y.toFixed(3) + ")" }; var za = 0, X = a.BB = function(a, b, c, d) { this.l = a; this.b = b; this.r = c; this.t = d; za++ }; a.bb = function(a, b, c, d) { return new X(a, b, c, d) }; var xa = function(a, b) { return new X(a.x - b, a.y - b, a.x + b, a.y + b) }, ya = 0; a.NO_GROUP = 0; var ia = a.ALL_LAYERS = -1; a.resetShapeIdCounter = function() { ya = 0 }; var R = a.Shape = function(a) { this.body = a; this.bb_l = this.bb_b = this.bb_r = this.bb_t = 0; this.hashid = ya++; this.sensor = !1; this.u = this.e = 0; this.surface_v = v; this.group = this.collision_type = 0; this.layers = ia; this.space = null; this.collisionCode = this.collisionCode }; R.prototype.setElasticity = function(a) { this.e = a }; R.prototype.setFriction = function(a) { this.body.activate(); this.u = a }; R.prototype.setLayers = function(a) { this.body.activate(); this.layers = a }; R.prototype.setSensor = function(a) { this.body.activate(); this.sensor = a }; R.prototype.setCollisionType = function(a) { this.body.activate(); this.collision_type = a }; R.prototype.getBody = function() { return this.body }; R.prototype.active = function() { return this.body && -1 !== this.body.shapeList.indexOf(this) }; R.prototype.setBody = function(a) { b(!this.active(), "You cannot change the body on an active shape. You must remove the shape from the space before changing the body."); this.body = a }; R.prototype.cacheBB = function() { return this.update(this.body.p, this.body.rot) }; R.prototype.update = function(a, c) { b(!isNaN(c.x), "Rotation is NaN"); b(!isNaN(a.x), "Position is NaN"); this.cacheData(a, c) }; R.prototype.pointQuery = function(a) { a = this.nearestPointQuery(a); if (0 > a.d) return a }; R.prototype.getBB = function() { return new X(this.bb_l, this.bb_b, this.bb_r, this.bb_t) }; var Aa = function(a, b, c) { this.shape = a; this.p = b; this.d = c }, ma = function(a, b, c) { this.shape = a; this.t = b; this.n = c }; ma.prototype.hitPoint = function(a, b) { return S(a, b, this.t) }; ma.prototype.hitDist = function(a, b) { return U(a, b) * this.t }; var ka = a.CircleShape = function(a, b, c) { this.c = this.tc = c; this.r = b; this.type = "circle"; R.call(this, a) }; ka.prototype = Object.create(R.prototype); ka.prototype.cacheData = function(a, b) { var c = this.tc = C(this.c, b).add(a), d = this.r; this.bb_l = c.x - d; this.bb_b = c.y - d; this.bb_r = c.x + d; this.bb_t = c.y + d }; ka.prototype.nearestPointQuery = function(a) { var b = a.x - this.tc.x, c = a.y - this.tc.y; a = E(b, c); var d = this.r, b = new s(this.tc.x + b * d / a, this.tc.y + c * d / a); return new Aa(this, b, a - d) }; var Ba = function(a, b, c, d, e, f) { d = w(d, b); e = w(e, b); b = x(d, d) - 2 * x(d, e) + x(e, e); f = -2 * x(d, d) + 2 * x(d, e); c = x(d, d) - c * c; c = f * f - 4 * b * c; if (0 <= c && (c = (-f - Math.sqrt(c)) / (2 * b), 0 <= c && 1 >= c)) return new ma(a, c, I(S(d, e, c))) }; ka.prototype.segmentQuery = function(a, b) { return Ba(this, this.tc, this.r, a, b) }; var fa = a.SegmentShape = function(a, b, c, d) { this.a = b; this.b = c; this.n = F(I(w(c, b))); this.ta = this.tb = this.tn = null; this.r = d; this.b_tangent = this.a_tangent = v; this.type = "segment"; R.call(this, a) }; fa.prototype = Object.create(R.prototype); fa.prototype.cacheData = function(a, b) { this.ta = A(a, C(this.a, b)); this.tb = A(a, C(this.b, b)); this.tn = C(this.n, b); var c, d, e, f; this.ta.x < this.tb.x ? (c = this.ta.x, d = this.tb.x) : (c = this.tb.x, d = this.ta.x); this.ta.y < this.tb.y ? (e = this.ta.y, f = this.tb.y) : (e = this.tb.y, f = this.ta.y); var g = this.r; this.bb_l = c - g; this.bb_b = e - g; this.bb_r = d + g; this.bb_t = f + g }; fa.prototype.nearestPointQuery = function(a) { var b; b = this.tb; var c = w(this.ta, b), d = u(x(c, w(a, b)) / L(c)); b = A(b, y(c, d)); var c = a.x - b.x, e = a.y - b.y; a = E(c, e); d = this.r; b = a ? A(b, y(new s(c, e), d / a)) : b; return new Aa(this, b, a - d) }; fa.prototype.segmentQuery = function(a, b) { var c = this.tn, d = x(w(this.ta, a), c), e = this.r, f = 0 < d ? B(c) : c, g = w(y(f, e), a), h = A(this.ta, g), k = A(this.tb, g), g = w(b, a); if (0 >= z(g, h) * z(g, k)) { if (e = d + (0 < d ? -e : e), d = -e, c = x(g, c) - e, 0 > d * c) return new ma(this, d / (d - c), f) } else if (0 !== e) return f = Ba(this, this.ta, this.r, a, b), c = Ba(this, this.tb, this.r, a, b), f ? c && c.t < f.t ? c : f : c }; fa.prototype.setNeighbors = function(a, b) { this.a_tangent = w(a, this.a); this.b_tangent = w(b, this.b) }; fa.prototype.setEndpoints = function(a, b) { this.a = a; this.b = b; this.n = F(I(w(b, a))) }; var Ra = function(a) { for (var b = a.length, c = 0; c < b; c += 2) { var d = a[(c + 2) % b], e = a[(c + 3) % b]; if (0 < (d - a[c]) * (a[(c + 5) % b] - e) - (e - a[c + 1]) * (a[(c + 4) % b] - d)) return !1 } return !0 }, W = a.PolyShape = function(a, b, c) { this.setVerts(b, c); this.type = "poly"; R.call(this, a) }; W.prototype = Object.create(R.prototype); var Ca = function(a, b) { this.n = a; this.d = b }; Ca.prototype.compare = function(a) { return x(this.n, a) - this.d }; W.prototype.setVerts = function(a, c) { b(4 <= a.length, "Polygons require some verts"); b("number" === typeof a[0], "Polygon verticies should be specified in a flattened list (eg [x1,y1,x2,y2,x3,y3,...])"); b(Ra(a), "Polygon is concave or has a reversed winding. Consider using cpConvexHull()"); var d = a.length, e = d >> 1; this.verts = Array(d); this.tVerts = Array(d); this.planes = Array(e); this.tPlanes = Array(e); for (e = 0; e < d; e += 2) { var f = a[e] + c.x, g = a[e + 1] + c.y, h = I(F(new s(a[(e + 2) % d] + c.x - f, a[(e + 3) % d] + c.y - g))); this.verts[e] = f; this.verts[e + 1] = g; this.planes[e >> 1] = new Ca(h, h.x * f + h.y * g); this.tPlanes[e >> 1] = new Ca(new s(0, 0), 0) } }; a.BoxShape = function(a, b, c) { b /= 2; c /= 2; return kb(a, new X(-b, -c, b, c)) }; var kb = a.BoxShape2 = function(a, b) { return new W(a, [b.l, b.b, b.l, b.t, b.r, b.t, b.r, b.b], v) }; W.prototype.transformVerts = function(a, b) { for (var c = this.verts, d = this.tVerts, e = Infinity, h = -Infinity, k = Infinity, m = -Infinity, n = 0; n < c.length; n += 2) { var p = c[n], r = c[n + 1], s = a.x + p * b.x - r * b.y, p = a.y + p * b.y + r * b.x; d[n] = s; d[n + 1] = p; e = f(e, s); h = g(h, s); k = f(k, p); m = g(m, p) } this.bb_l = e; this.bb_b = k; this.bb_r = h; this.bb_t = m }; W.prototype.transformAxes = function(a, b) { for (var c = this.planes, d = this.tPlanes, e = 0; e < c.length; e++) { var f = C(c[e].n, b); d[e].n = f; d[e].d = x(a, f) + c[e].d } }; W.prototype.cacheData = function(a, b) { this.transformAxes(a, b); this.transformVerts(a, b) }; W.prototype.nearestPointQuery = function(a) { for (var b = this.tPlanes, c = this.tVerts, d = c[c.length - 2], e = c[c.length - 1], f = Infinity, g = v, h = !1, k = 0; k < b.length; k++) { 0 < b[k].compare(a) && (h = !0); var m = c[2 * k], n = c[2 * k + 1], p; p = m; var r = n, d = d - p, e = e - r, t = u((d * (a.x - p) + e * (a.y - r)) / P(d, e)); p = new s(p + d * t, r + e * t); r = U(a, p); r < f && (f = r, g = p); d = m; e = n } return new Aa(this, g, h ? f : -f) }; W.prototype.segmentQuery = function(a, b) { for (var c = this.tPlanes, d = this.tVerts, e = c.length, f = 2 * e, g = 0; g < e; g++) { var h = c[g].n, k = x(a, h); if (!(c[g].d > k)) { var m = x(b, h), k = (c[g].d - k) / (m - k); if (!(0 > k || 1 < k)) { var m = S(a, b, k), m = -z(h, m), n = -(h.x * d[(2 * g + 3) % f] - h.y * d[(2 * g + 2) % f]); if (-(h.x * d[2 * g + 1] - h.y * d[2 * g]) <= m && m <= n) return new ma(this, k, h) } } } }; W.prototype.valueOnAxis = function(a, b) { for (var c = this.tVerts, d = a.x * c[0] + a.y * c[1], e = 2; e < c.length; e += 2) d = f(d, a.x * c[e] + a.y * c[e + 1]); return d - b }; W.prototype.containsVert = function(a, b) { for (var c = this.tPlanes, d = 0; d < c.length; d++) { var e = c[d].n; if (0 < e.x * a + e.y * b - c[d].d) return !1 } return !0 }; W.prototype.containsVertPartial = function(a, b, c) { for (var d = this.tPlanes, e = 0; e < d.length; e++) { var f = d[e].n; if (!(0 > x(f, c)) && 0 < f.x * a + f.y * b - d[e].d) return !1 } return !0 }; W.prototype.getNumVerts = function() { return this.verts.length / 2 }; W.prototype.getVert = function(a) { return new s(this.verts[2 * a], this.verts[2 * a + 1]) }; var H = a.Body = function(a, b) { this.p = new s(0, 0); this.vx = this.vy = 0; this.f = new s(0, 0); this.t = this.w = 0; this.w_limit = this.v_limit = Infinity; this.w_bias = this.v_biasx = this.v_biasy = 0; this.space = null; this.shapeList = []; this.nodeNext = this.nodeRoot = this.constraintList = this.arbiterList = null; this.nodeIdleTime = 0; this.setMass(a); this.setMoment(b); this.rot = new s(0, 0); this.setAngle(0) }; a.StaticBody = function() { var a = new H(Infinity, Infinity); a.nodeIdleTime = Infinity; return a }; if ("undefined" !== typeof DEBUG && DEBUG) { var Da = function(a, c) { b(a.x == a.x && a.y == a.y, c) }, Ea = function(a, c) { b(Infinity !== Math.abs(a.x) && Infinity !== Math.abs(a.y), c) }; H.prototype.sanityCheck = function() { b(this.m === this.m && this.m_inv === this.m_inv, "Body's mass is invalid."); b(this.i === this.i && this.i_inv === this.i_inv, "Body's moment is invalid."); var a = this.p; Da(a, "Body's position is invalid."); Ea(a, "Body's position is invalid."); a = this.f; Da(a, "Body's force is invalid."); Ea(a, "Body's force is invalid."); b(this.vx === this.vx && Infinity !== Math.abs(this.vx), "Body's velocity is invalid."); b(this.vy === this.vy && Infinity !== Math.abs(this.vy), "Body's velocity is invalid."); b(this.a === this.a && Infinity !== Math.abs(this.a), "Body's angle is invalid."); b(this.w === this.w && Infinity !== Math.abs(this.w), "Body's angular velocity is invalid."); b(this.t === this.t && Infinity !== Math.abs(this.t), "Body's torque is invalid."); a = this.rot; Da(a, "Body's rotation vector is invalid."); Ea(a, "Body's rotation vector is invalid."); b(this.v_limit === this.v_limit, "Body's velocity limit is invalid."); b(this.w_limit === this.w_limit, "Body's angular velocity limit is invalid.") } } else H.prototype.sanityCheck = function() {}; H.prototype.getPos = function() { return this.p }; H.prototype.getVel = function() { return new s(this.vx, this.vy) }; H.prototype.getAngVel = function() { return this.w }; H.prototype.isSleeping = function() { return null !== this.nodeRoot }; H.prototype.isStatic = function() { return Infinity === this.nodeIdleTime }; H.prototype.isRogue = function() { return null === this.space }; H.prototype.setMass = function(a) { b(0 < a, "Mass must be positive and non-zero."); this.activate(); this.m = a; this.m_inv = 1 / a }; H.prototype.setMoment = function(a) { b(0 < a, "Moment of Inertia must be positive and non-zero."); this.activate(); this.i = a; this.i_inv = 1 / a }; H.prototype.addShape = function(a) { this.shapeList.push(a) }; H.prototype.removeShape = function(a) { k(this.shapeList, a) }; var Ga = function(a, b, c) { if (a === c) return a.next(b); a.a === b ? a.next_a = Ga(a.next_a, b, c) : a.next_b = Ga(a.next_b, b, c); return a }; H.prototype.removeConstraint = function(a) { this.constraintList = Ga(this.constraintList, this, a) }; H.prototype.setPos = function(b) { this.activate(); this.sanityCheck(); b === v && (b = a.v(0, 0)); this.p = b }; H.prototype.setVel = function(a) { this.activate(); this.vx = a.x; this.vy = a.y }; H.prototype.setAngVel = function(a) { this.activate(); this.w = a }; H.prototype.setAngleInternal = function(a) { b(!isNaN(a), "Internal Error: Attempting to set body's angle to NaN"); this.a = a; this.rot.x = Math.cos(a); this.rot.y = Math.sin(a) }; H.prototype.setAngle = function(a) { this.activate(); this.sanityCheck(); this.setAngleInternal(a) }; H.prototype.velocity_func = function(a, b, c) { var d = this.vx * b + (a.x + this.f.x * this.m_inv) * c; a = this.vy * b + (a.y + this.f.y * this.m_inv) * c; var e = this.v_limit, f = d * d + a * a, e = f > e * e ? e / Math.sqrt(f) : 1; this.vx = d * e; this.vy = a * e; d = this.w_limit; this.w = r(this.w * b + this.t * this.i_inv * c, -d, d); this.sanityCheck() }; H.prototype.position_func = function(a) { this.p.x += (this.vx + this.v_biasx) * a; this.p.y += (this.vy + this.v_biasy) * a; this.setAngleInternal(this.a + (this.w + this.w_bias) * a); this.w_bias = this.v_biasx = this.v_biasy = 0; this.sanityCheck() }; H.prototype.resetForces = function() { this.activate(); this.f = new s(0, 0); this.t = 0 }; H.prototype.applyForce = function(a, b) { this.activate(); this.f = A(this.f, a); this.t += z(b, a) }; H.prototype.applyImpulse = function(a, b) { this.activate(); Ia(this, a.x, a.y, b) }; H.prototype.getVelAtPoint = function(a) { return A(new s(this.vx, this.vy), y(F(a), this.w)) }; H.prototype.getVelAtWorldPoint = function(a) { return this.getVelAtPoint(w(a, this.p)) }; H.prototype.getVelAtLocalPoint = function(a) { return this.getVelAtPoint(C(a, this.rot)) }; H.prototype.eachShape = function(a) { for (var b = 0, c = this.shapeList.length; b < c; b++) a(this.shapeList[b]) }; H.prototype.eachConstraint = function(a) { for (var b = this.constraintList; b;) { var c = b.next(this); a(b); b = c } }; H.prototype.eachArbiter = function(a) { for (var b = this.arbiterList; b;) { var c = b.next(this); b.swappedColl = this === b.body_b; a(b); b = c } }; H.prototype.local2World = function(a) { return A(this.p, C(a, this.rot)) }; H.prototype.world2Local = function(a) { return N(w(a, this.p), this.rot) }; H.prototype.kineticEnergy = function() { var a = this.vx * this.vx + this.vy * this.vy, b = this.w * this.w; return (a ? a * this.m : 0) + (b ? b * this.i : 0) }; var Ha = a.SpatialIndex = function(a) { if (this.staticIndex = a) { if (a.dynamicIndex) throw Error("This static index is already associated with a dynamic index."); a.dynamicIndex = this } }; Ha.prototype.collideStatic = function(a, b) { if (0 < a.count) { var c = a.query; this.each(function(a) { c(a, new X(a.bb_l, a.bb_b, a.bb_r, a.bb_t), b) }) } }; var O = a.BBTree = function(a) { Ha.call(this, a); this.velocityFunc = null; this.leaves = {}; this.count = 0; this.pooledPairs = this.pooledNodes = this.root = null; this.stamp = 0 }; O.prototype = Object.create(Ha.prototype); var lb = 0, ba = function(a, b, c) { this.obj = null; this.bb_l = f(b.bb_l, c.bb_l); this.bb_b = f(b.bb_b, c.bb_b); this.bb_r = g(b.bb_r, c.bb_r); this.bb_t = g(b.bb_t, c.bb_t); this.parent = null; this.setA(b); this.setB(c) }; O.prototype.makeNode = function(a, b) { var c = this.pooledNodes; if (c) return this.pooledNodes = c.parent, c.constructor(this, a, b), c; lb++; return new ba(this, a, b) }; var mb = 0, ca = function(a, b) { this.obj = b; a.getBB(b, this); this.parent = null; this.stamp = 1; this.pairs = null; mb++ }; O.prototype.getBB = function(a, b) { var c = this.velocityFunc; if (c) { var d = 0.1 * (a.bb_r - a.bb_l), e = 0.1 * (a.bb_t - a.bb_b), c = y(c(a), 0.1); b.bb_l = a.bb_l + f(-d, c.x); b.bb_b = a.bb_b + f(-e, c.y); b.bb_r = a.bb_r + g(d, c.x); b.bb_t = a.bb_t + g(e, c.y) } else b.bb_l = a.bb_l, b.bb_b = a.bb_b, b.bb_r = a.bb_r, b.bb_t = a.bb_t }; O.prototype.getStamp = function() { var a = this.dynamicIndex; return a && a.stamp ? a.stamp : this.stamp }; O.prototype.incrementStamp = function() { this.dynamicIndex && this.dynamicIndex.stamp ? this.dynamicIndex.stamp++ : this.stamp++ }; var nb = 0, Xa = function(a, b, c, d) { this.prevA = null; this.leafA = a; this.nextA = b; this.prevB = null; this.leafB = c; this.nextB = d }; O.prototype.makePair = function(a, b, c, d) { var e = this.pooledPairs; if (e) return this.pooledPairs = e.prevA, e.prevA = null, e.leafA = a, e.nextA = b, e.prevB = null, e.leafB = c, e.nextB = d, e; nb++; return new Xa(a, b, c, d) }; Xa.prototype.recycle = function(a) { this.prevA = a.pooledPairs; a.pooledPairs = this }; var Sa = function(a, b, c) { c && (c.leafA === b ? c.prevA = a : c.prevB = a); a ? a.leafA === b ? a.nextA = c : a.nextB = c : b.pairs = c }; ca.prototype.clearPairs = function(a) { var b = this.pairs, c; for (this.pairs = null; b;) b.leafA === this ? (c = b.nextA, Sa(b.prevB, b.leafB, b.nextB)) : (c = b.nextB, Sa(b.prevA, b.leafA, b.nextA)), b.recycle(a), b = c }; var Ta = function(a, b, c) { var d = a.pairs, e = b.pairs; c = c.makePair(a, d, b, e); a.pairs = b.pairs = c; d && (d.leafA === a ? d.prevA = c : d.prevB = c); e && (e.leafA === b ? e.prevA = c : e.prevB = c) }; ba.prototype.recycle = function(a) { this.parent = a.pooledNodes; a.pooledNodes = this }; ca.prototype.recycle = function(a) {}; ba.prototype.setA = function(a) { this.A = a; a.parent = this }; ba.prototype.setB = function(a) { this.B = a; a.parent = this }; ca.prototype.isLeaf = !0; ba.prototype.isLeaf = !1; ba.prototype.otherChild = function(a) { return this.A == a ? this.B : this.A }; ba.prototype.replaceChild = function(a, b, d) { c(a == this.A || a == this.B, "Node is not a child of parent."); this.A == a ? (this.A.recycle(d), this.setA(b)) : (this.B.recycle(d), this.setB(b)); for (a = this; a; a = a.parent) b = a.A, d = a.B, a.bb_l = f(b.bb_l, d.bb_l), a.bb_b = f(b.bb_b, d.bb_b), a.bb_r = g(b.bb_r, d.bb_r), a.bb_t = g(b.bb_t, d.bb_t) }; ba.prototype.bbArea = ca.prototype.bbArea = function() { return (this.bb_r - this.bb_l) * (this.bb_t - this.bb_b) }; var Ua = function(a, b) { return (g(a.bb_r, b.bb_r) - f(a.bb_l, b.bb_l)) * (g(a.bb_t, b.bb_t) - f(a.bb_b, b.bb_b)) }, Va = function(a, b) { return Math.abs(a.bb_l + a.bb_r - b.bb_l - b.bb_r) + Math.abs(a.bb_b + a.bb_t - b.bb_b - b.bb_t) }, na = function(a, b, c) { if (null == a) return b; if (a.isLeaf) return c.makeNode(b, a); var d = a.B.bbArea() + Ua(a.A, b), e = a.A.bbArea() + Ua(a.B, b); d === e && (d = Va(a.A, b), e = Va(a.B, b)); e < d ? a.setB(na(a.B, b, c)) : a.setA(na(a.A, b, c)); a.bb_l = f(a.bb_l, b.bb_l); a.bb_b = f(a.bb_b, b.bb_b); a.bb_r = g(a.bb_r, b.bb_r); a.bb_t = g(a.bb_t, b.bb_t); return a }; ba.prototype.intersectsBB = ca.prototype.intersectsBB = function(a) { return this.bb_l <= a.r && a.l <= this.bb_r && this.bb_b <= a.t && a.b <= this.bb_t }; var Fa = function(a, b, c) { a.intersectsBB(b) && (a.isLeaf ? c(a.obj) : (Fa(a.A, b, c), Fa(a.B, b, c))) }, Wa = function(a, b, c) { var d = 1 / (c.x - b.x), e = a.bb_l == b.x ? -Infinity : (a.bb_l - b.x) * d, h = a.bb_r == b.x ? Infinity : (a.bb_r - b.x) * d, d = f(e, h), e = g(e, h), h = 1 / (c.y - b.y); c = a.bb_b == b.y ? -Infinity : (a.bb_b - b.y) * h; b = a.bb_t == b.y ? Infinity : (a.bb_t - b.y) * h; a = f(c, b); b = g(c, b); return a <= e && d <= b && (d = g(d, a), 0 <= f(e, b) && 1 >= d) ? g(d, 0) : Infinity }, oa = function(a, b, c, d, e) { if (a.isLeaf) return e(a.obj); var g = Wa(a.A, b, c), h = Wa(a.B, b, c); g < h ? (g < d && (d = f(d, oa(a.A, b, c, d, e))), h < d && (d = f(d, oa(a.B, b, c, d, e)))) : (h < d && (d = f(d, oa(a.B, b, c, d, e))), g < d && (d = f(d, oa(a.A, b, c, d, e)))); return d }; O.prototype.subtreeRecycle = function(a) { a.isLeaf && (this.subtreeRecycle(a.A), this.subtreeRecycle(a.B), a.recycle(this)) }; var Ya = function(a, b, c) { if (b == a) return null; var d = b.parent; if (d == a) return b = a.otherChild(b), b.parent = a.parent, a.recycle(c), b; d.parent.replaceChild(d, d.otherChild(b), c); return a }, Za = function(a, b) { return a.bb_l <= b.bb_r && b.bb_l <= a.bb_r && a.bb_b <= b.bb_t && b.bb_b <= a.bb_t }; ca.prototype.markLeafQuery = function(a, b, c, d) { Za(a, this) && (b ? Ta(a, this, c) : (this.stamp < a.stamp && Ta(this, a, c), d && d(a.obj, this.obj))) }; ba.prototype.markLeafQuery = function(a, b, c, d) { Za(a, this) && (this.A.markLeafQuery(a, b, c, d), this.B.markLeafQuery(a, b, c, d)) }; ca.prototype.markSubtree = function(a, b, c) { if (this.stamp == a.getStamp()) for (b && b.markLeafQuery(this, !1, a, c), b = this; b.parent; b = b.parent) b == b.parent.A ? b.parent.B.markLeafQuery(this, !0, a, c) : b.parent.A.markLeafQuery(this, !1, a, c); else for (a = this.pairs; a;) this === a.leafB ? (c && c(a.leafA.obj, this.obj), a = a.nextB) : a = a.nextA }; ba.prototype.markSubtree = function(a, b, c) { this.A.markSubtree(a, b, c); this.B.markSubtree(a, b, c) }; ca.prototype.containsObj = function(a) { return this.bb_l <= a.bb_l && this.bb_r >= a.bb_r && this.bb_b <= a.bb_b && this.bb_t >= a.bb_t }; ca.prototype.update = function(a) { var b = a.root; return this.containsObj(this.obj) ? !1 : (a.getBB(this.obj, this), b = Ya(b, this, a), a.root = na(b, this, a), this.clearPairs(a), this.stamp = a.getStamp(), !0) }; ca.prototype.addPairs = function(a) { var b = a.dynamicIndex; b ? (a = b.root) && a.markLeafQuery(this, !0, b, null) : this.markSubtree(a, a.staticIndex.root, null) }; O.prototype.insert = function(a, b) { var c = new ca(this, a); this.leaves[b] = c; this.root = na(this.root, c, this); this.count++; c.stamp = this.getStamp(); c.addPairs(this); this.incrementStamp() }; O.prototype.remove = function(a, b) { var c = this.leaves[b]; delete this.leaves[b]; this.root = Ya(this.root, c, this); this.count--; c.clearPairs(this); c.recycle(this) }; O.prototype.contains = function(a, b) { return null != this.leaves[b] }; var ob = function(a, b) {}; O.prototype.reindexQuery = function(a) { if (this.root) { var b, c = this.leaves; for (b in c) c[b].update(this); c = (b = this.staticIndex) && b.root; this.root.markSubtree(this, c, a); b && !c && this.collideStatic(this, b, a); this.incrementStamp() } }; O.prototype.reindex = function() { this.reindexQuery(ob) }; O.prototype.reindexObject = function(a, b) { var c = this.leaves[b]; c && (c.update(this) && c.addPairs(this), this.incrementStamp()) }; O.prototype.pointQuery = function(a, b) { this.query(new X(a.x, a.y, a.x, a.y), b) }; O.prototype.segmentQuery = function(a, b, c, d) { this.root && oa(this.root, a, b, c, d) }; O.prototype.query = function(a, b) { this.root && Fa(this.root, a, b) }; O.prototype.count = function() { return this.count }; O.prototype.each = function(a) { for (var b in this.leaves) a(this.leaves[b].obj) }; var $a = function(a, b, c, d, e) { return (g(a.bb_r, d) - f(a.bb_l, b)) * (g(a.bb_t, e) - f(a.bb_b, c)) }, Ja = function(a, b, c, d) { if (1 == d) return b[c]; if (2 == d) return a.makeNode(b[c], b[c + 1]); for (var e = b[c], h = e.bb_l, k = e.bb_b, m = e.bb_r, n = e.bb_t, p = c + d, r = c + 1; r < p; r++) e = b[r], h = f(h, e.bb_l), k = f(k, e.bb_b), m = g(m, e.bb_r), n = g(n, e.bb_t); var e = m - h > n - k, s = Array(2 * d); if (e) for (r = c; r < p; r++) s[2 * r + 0] = b[r].bb_l, s[2 * r + 1] = b[r].bb_r; else for (r = c; r < p; r++) s[2 * r + 0] = b[r].bb_b, s[2 * r + 1] = b[r].bb_t; s.sort(function(a, b) { return a - b }); var t = 0.5 * (s[d - 1] + s[d]), r = h, s = k, u = m, v = n; e ? u = h = t : v = k = t; for (var t = p, w = c; w < t;) e = b[w], $a(e, h, k, m, n) < $a(e, r, s, u, v) ? (t--, b[w] = b[t], b[t] = e) : w++; if (t == d) { e = null; for (r = c; r < p; r++) e = na(e, b[r], a); return e } return NodeNew(a, Ja(a, b, c, t - c), Ja(a, b, t, p - t)) }; O.prototype.optimize = function() { var a = Array(this.count), b = 0, c; for (c in this.leaves) a[b++] = this.nodes[c]; tree.subtreeRecycle(root); this.root = Ja(tree, a, a.length) }; var Ka = function(a, b) { !a.isLeaf && 10 >= b && (Ka(a.A, b + 1), Ka(a.B, b + 1)); for (var c = "", d = 0; d < b; d++) c += " "; console.log(c + a.bb_b + " " + a.bb_t) }; O.prototype.log = function() { this.root && Ka(this.root, 0) }; var ja = a.CollisionHandler = function() { this.a = this.b = 0 }; ja.prototype.begin = function(a, b) { return !0 }; ja.prototype.preSolve = function(a, b) { return !0 }; ja.prototype.postSolve = function(a, b) {}; ja.prototype.separate = function(a, b) {}; var Q = function(a, b) { this.u = this.e = 0; this.surface_vr = v; this.a = a; this.body_a = a.body; this.b = b; this.body_b = b.body; this.contacts = this.thread_b_next = this.thread_b_prev = this.thread_a_next = this.thread_a_prev = null; this.stamp = 0; this.handler = null; this.swappedColl = !1; this.state = "first coll" }; Q.prototype.getShapes = function() { return this.swappedColl ? [this.b, this.a] : [this.a, this.b] }; Q.prototype.totalImpulse = function() { for (var a = this.contacts, b = new s(0, 0), c = 0, d = a.length; c < d; c++) { var e = a[c]; b.add(y(e.n, e.jnAcc)) } return this.swappedColl ? b : b.neg() }; Q.prototype.totalImpulseWithFriction = function() { for (var a = this.contacts, b = new s(0, 0), c = 0, d = a.length; c < d; c++) { var e = a[c]; b.add((new s(e.jnAcc, e.jtAcc)).rotate(e.n)) } return this.swappedColl ? b : b.neg() }; Q.prototype.totalKE = function() { for (var a = (1 - this.e) / (1 + this.e), b = 0, c = this.contacts, d = 0, e = c.length; d < e; d++) var f = c[d], g = f.jnAcc, h = f.jtAcc, b = b + (a * g * g / f.nMass + h * h / f.tMass); return b }; Q.prototype.ignore = function() { this.state = "ignore" }; Q.prototype.getA = function() { return this.swappedColl ? this.b : this.a }; Q.prototype.getB = function() { return this.swappedColl ? this.a : this.b }; Q.prototype.isFirstContact = function() { return "first coll" === this.state }; var ab = function(a, b, c) { this.point = a; this.normal = b; this.dist = c }; Q.prototype.getContactPointSet = function() { var a = Array(this.contacts.length), b; for (b = 0; b < a.length; b++) a[b] = new ab(this.contacts[b].p, this.contacts[b].n, this.contacts[b].dist); return a }; Q.prototype.getNormal = function(a) { a = this.contacts[a].n; return this.swappedColl ? B(a) : a }; Q.prototype.getPoint = function(a) { return this.contacts[a].p }; Q.prototype.getDepth = function(a) { return this.contacts[a].dist }; var bb = function(a, b, c, d) { c ? c.body_a === b ? c.thread_a_next = d : c.thread_b_next = d : b.arbiterList = d; d && (d.body_a === b ? d.thread_a_prev = c : d.thread_b_prev = c) }; Q.prototype.unthread = function() { bb(this, this.body_a, this.thread_a_prev, this.thread_a_next); bb(this, this.body_b, this.thread_b_prev, this.thread_b_next); this.thread_b_prev = this.thread_b_next = this.thread_a_prev = this.thread_a_next = null }; Q.prototype.update = function(a, b, c, d) { if (this.contacts) for (var e = 0; e < this.contacts.length; e++) for (var f = this.contacts[e], g = 0; g < a.length; g++) { var h = a[g]; h.hash === f.hash && (h.jnAcc = f.jnAcc, h.jtAcc = f.jtAcc) } this.contacts = a; this.handler = b; this.swappedColl = c.collision_type !== b.a; this.e = c.e * d.e; this.u = c.u * d.u; this.surface_vr = w(c.surface_v, d.surface_v); this.a = c; this.body_a = c.body; this.b = d; this.body_b = d.body; "cached" == this.state && (this.state = "first coll") }; Q.prototype.preStep = function(a, b, c) { for (var d = this.body_a, e = this.body_b, g = 0; g < this.contacts.length; g++) { var h = this.contacts[g]; h.r1 = w(h.p, d.p); h.r2 = w(h.p, e.p); h.nMass = 1 / pa(d, e, h.r1, h.r2, h.n); h.tMass = 1 / pa(d, e, h.r1, h.r2, F(h.n)); h.bias = -c * f(0, h.dist + b) / a; h.jBias = 0; h.bounce = La(d, e, h.r1, h.r2, h.n) * this.e } }; Q.prototype.applyCachedImpulse = function(a) { if (!this.isFirstContact()) for (var b = this.body_a, c = this.body_b, d = 0; d < this.contacts.length; d++) { var e = this.contacts[d], f = e.n.x, g = e.n.y; Y(b, c, e.r1, e.r2, (f * e.jnAcc - g * e.jtAcc) * a, (f * e.jtAcc + g * e.jnAcc) * a) } }; var pb = 0, qb = 0; Q.prototype.applyImpulse = function() { pb++; for (var a = this.body_a, b = this.body_b, c = this.surface_vr, d = this.u, e = 0; e < this.contacts.length; e++) { qb++; var f = this.contacts[e], h = f.nMass, k = f.n, m = f.r1, n = f.r2, p = b.vx - n.y * b.w - (a.vx - m.y * a.w), s = b.vy + n.x * b.w - (a.vy + m.x * a.w), t = p * k.x + s * k.y, u = (p + c.x) * -k.y + (s + c.y) * k.x, s = f.jBias; f.jBias = g(s + (f.bias - (k.x * (b.v_biasx - n.y * b.w_bias - a.v_biasx + m.y * a.w_bias) + k.y * (n.x * b.w_bias + b.v_biasy - m.x * a.w_bias - a.v_biasy))) * h, 0); p = f.jnAcc; f.jnAcc = g(p + -(f.bounce + t) * h, 0); t = d * f.jnAcc; h = f.jtAcc; f.jtAcc = r(h + -u * f.tMass, -t, t); t = k.x * (f.jBias - s); s = k.y * (f.jBias - s); cb(a, -t, -s, m); cb(b, t, s, n); p = f.jnAcc - p; f = f.jtAcc - h; Y(a, b, m, n, k.x * p - k.y * f, k.x * f + k.y * p) } }; Q.prototype.callSeparate = function(a) { a.lookupHandler(this.a.collision_type, this.b.collision_type).separate(this, a) }; Q.prototype.next = function(a) { return this.body_a == a ? this.thread_a_next : this.thread_b_next }; var rb = 0, ea = function(a, b, c, d) { this.p = a; this.n = b; this.dist = c; this.r1 = this.r2 = v; this.jnAcc = this.jtAcc = this.jBias = this.nMass = this.tMass = this.bounce = this.bias = 0; this.hash = d; rb++ }, Z = [], ga = function(a, b, c, d) { d = c + d; b = w(b, a); var e = L(b); if (!(e >= d * d)) return e = Math.sqrt(e), new ea(A(a, y(b, 0.5 + (c - 0.5 * d) / (e ? e : Infinity))), e ? y(b, 1 / e) : new s(1, 0), e - d, 0) }, Ma = 0, db = function(a, b) { var c = 0, d = a.valueOnAxis(b[0].n, b[0].d); if (0 < d) return -1; for (var e = 1; e < b.length; e++) { var f = a.valueOnAxis(b[e].n, b[e].d); if (0 < f) return -1; f > d && (d = f, c = e) } Ma = d; return c }, eb = function(a, b, c, d) { for (var e = [], f = a.tVerts, g = 0; g < f.length; g += 2) { var k = f[g], m = f[g + 1]; b.containsVert(k, m) && e.push(new ea(new s(k, m), c, d, h(a.hashid, g >> 1))) } f = b.tVerts; for (g = 0; g < f.length; g += 2) k = f[g], m = f[g + 1], a.containsVert(k, m) && e.push(new ea(new s(k, m), c, d, h(b.hashid, g >> 1))); if (!e.length) { e = []; f = a.tVerts; for (g = 0; g < f.length; g += 2) k = f[g], m = f[g + 1], b.containsVertPartial(k, m, B(c)) && e.push(new ea(new s(k, m), c, d, h(a.hashid, g))); f = b.tVerts; for (g = 0; g < f.length; g += 2) k = f[g], m = f[g + 1], a.containsVertPartial(k, m, c) && e.push(new ea(new s(k, m), c, d, h(b.hashid, g))) } return a = e }, fb = function(a, b, c) { var d = x(b, a.ta) - a.r; a = x(b, a.tb) - a.r; return f(d, a) - c }, gb = function(a, b, c, d, e) { for (var f = z(b.tn, b.ta), g = z(b.tn, b.tb), k = y(b.tn, e), m = c.tVerts, n = 0; n < m.length; n += 2) { var p = m[n], r = m[n + 1]; if (p * k.x + r * k.y < x(b.tn, b.ta) * e + b.r) { var t = b.tn.x * r - b.tn.y * p; f >= t && t >= g && a.push(new ea(new s(p, r), k, d, h(c.hashid, n))) } } }; ka.prototype.collisionCode = 0; fa.prototype.collisionCode = 1; W.prototype.collisionCode = 2; ka.prototype.collisionTable = [ function(a, b) { var c = ga(a.tc, b.tc, a.r, b.r); return c ? [c] : Z }, function(a, b) { var c = b.ta, d = a.tc, e = w(b.tb, c), f = u(x(e, w(d, c)) / L(e)), c = A(c, y(e, f)); return (d = ga(d, c, a.r, b.r)) ? (c = d.n, 0 === f && 0 > x(c, b.a_tangent) || 1 === f && 0 > x(c, b.b_tangent) ? Z : [d]) : Z }, function(a, b) { for (var c = b.tPlanes, d = 0, e = x(c[0].n, a.tc) - c[0].d - a.r, f = 0; f < c.length; f++) { var g = x(c[f].n, a.tc) - c[f].d - a.r; if (0 < g) return Z; g > e && (e = g, d = f) } var c = c[d].n, h = b.tVerts, k = h.length, m = d << 1, d = h[m], f = h[m + 1], g = h[(m + 2) % k], h = h[(m + 3) % k], k = c.x * f - c.y * d, m = c.x * h - c.y * g, n = z(c, a.tc); if (n < m) { var p = ga(a.tc, new s(g, h), a.r, 0, p); return p ? [p] : Z } return n < k ? [new ea(w(a.tc, y(c, a.r + e / 2)), B(c), e, 0)] : (p = ga(a.tc, new s(d, f), a.r, 0, p)) ? [p] : Z } ]; fa.prototype.collisionTable = [null, function(a, b) { return Z }, function(a, b) { var c = [], d = b.tPlanes, e = d.length, f = x(a.tn, a.ta), g = b.valueOnAxis(a.tn, f) - a.r, f = b.valueOnAxis(B(a.tn), -f) - a.r; if (0 < f || 0 < g) return Z; var k = 0, m = fb(a, d[0].n, d[0].d); if (0 < m) return Z; for (var n = 0; n < e; n++) { var p = fb(a, d[n].n, d[n].d); if (0 < p) return Z; p > m && (m = p, k = n) } d = B(d[k].n); n = A(a.ta, y(d, a.r)); p = A(a.tb, y(d, a.r)); b.containsVert(n.x, n.y) && c.push(new ea(n, d, m, h(a.hashid, 0))); b.containsVert(p.x, p.y) && c.push(new ea(p, d, m, h(a.hashid, 1))); if (g >= m || f >= m) g > f ? gb(c, a, b, g, 1) : gb(c, a, b, f, -1); if (0 === c.length) { g = 2 * k; f = b.tVerts; m = new s(f[g], f[g + 1]); if ((k = ga(a.ta, m, a.r, 0, c)) || (k = ga(a.tb, m, a.r, 0, c))) return [k]; e *= 2; e = new s(f[(g + 2) % e], f[(g + 3) % e]); if ((k = ga(a.ta, e, a.r, 0, c)) || (k = ga(a.tb, e, a.r, 0, c))) return [k] } return c } ]; W.prototype.collisionTable = [null, null, function(a, b) { var c = db(b, a.tPlanes); if (-1 == c) return Z; var d = Ma, e = db(a, b.tPlanes); if (-1 == e) return Z; var f = Ma; return d > f ? eb(a, b, a.tPlanes[c].n, d) : eb(a, b, B(b.tPlanes[e].n), f) } ]; var Na = a.collideShapes = function(a, c) { b(a.collisionCode <= c.collisionCode, "Collided shapes must be sorted by type"); return a.collisionTable[c.collisionCode](a, c) }, hb = new ja, G = a.Space = function() { this.curr_dt = this.stamp = 0; this.bodies = []; this.rousedBodies = []; this.sleepingComponents = []; this.staticShapes = new O(null); this.activeShapes = new O(this.staticShapes); this.arbiters = []; this.contactBuffersHead = null; this.cachedArbiters = {}; this.constraints = []; this.locked = 0; this.collisionHandlers = {}; this.defaultHandler = hb; this.postStepCallbacks = []; this.iterations = 10; this.gravity = v; this.damping = 1; this.idleSpeedThreshold = 0; this.sleepTimeThreshold = Infinity; this.collisionSlop = 0.1; this.collisionBias = Math.pow(0.9, 60); this.collisionPersistence = 3; this.enableContactGraph = !1; this.staticBody = new H(Infinity, Infinity); this.staticBody.nodeIdleTime = Infinity; this.collideShapes = this.makeCollideShapes() }; G.prototype.getCurrentTimeStep = function() { return this.curr_dt }; G.prototype.setIterations = function(a) { this.iterations = a }; G.prototype.isLocked = function() { return this.locked }; var da = function(a) { b(!a.locked, "This addition/removal cannot be done safely during a call to cpSpaceStep() or during a query. Put these calls into a post-step callback.") }; G.prototype.addCollisionHandler = function(a, b, c, d, e, f) { da(this); this.removeCollisionHandler(a, b); var g = new ja; g.a = a; g.b = b; c && (g.begin = c); d && (g.preSolve = d); e && (g.postSolve = e); f && (g.separate = f); this.collisionHandlers[h(a, b)] = g }; G.prototype.removeCollisionHandler = function(a, b) { da(this); delete this.collisionHandlers[h(a, b)] }; G.prototype.setDefaultCollisionHandler = function(a, b, c, d) { da(this); var e = new ja; a && (e.begin = a); b && (e.preSolve = b); c && (e.postSolve = c); d && (e.separate = d); this.defaultHandler = e }; G.prototype.lookupHandler = function(a, b) { return this.collisionHandlers[h(a, b)] || this.defaultHandler }; G.prototype.addShape = function(a) { var c = a.body; if (c.isStatic()) return this.addStaticShape(a); b(!a.space, "This shape is already added to a space and cannot be added to another."); da(this); c.activate(); c.addShape(a); a.update(c.p, c.rot); this.activeShapes.insert(a, a.hashid); a.space = this; return a }; G.prototype.addStaticShape = function(a) { b(!a.space, "This shape is already added to a space and cannot be added to another."); da(this); var c = a.body; c.addShape(a); a.update(c.p, c.rot); this.staticShapes.insert(a, a.hashid); a.space = this; return a }; G.prototype.addBody = function(a) { b(!a.isStatic(), "Static bodies cannot be added to a space as they are not meant to be simulated."); b(!a.space, "This body is already added to a space and cannot be added to another."); da(this); this.bodies.push(a); a.space = this; return a }; G.prototype.addConstraint = function(a) { b(!a.space, "This shape is already added to a space and cannot be added to another."); da(this); var c = a.a, d = a.b; c.activate(); d.activate(); this.constraints.push(a); a.next_a = c.constraintList; c.constraintList = a; a.next_b = d.constraintList; d.constraintList = a; a.space = this; return a }; G.prototype.filterArbiters = function(a, b) { for (var c in this.cachedArbiters) { var d = this.cachedArbiters[c]; if (a === d.body_a && (b === d.a || null === b) || a === d.body_b && (b === d.b || null === b)) b && "cached" !== d.state && d.callSeparate(this), d.unthread(), k(this.arbiters, d), delete this.cachedArbiters[c] } }; G.prototype.removeShape = function(a) { var c = a.body; c.isStatic() ? this.removeStaticShape(a) : (b(this.containsShape(a), "Cannot remove a shape that was not added to the space. (Removed twice maybe?)"), da(this), c.activate(), c.removeShape(a), this.filterArbiters(c, a), this.activeShapes.remove(a, a.hashid), a.space = null) }; G.prototype.removeStaticShape = function(a) { b(this.containsShape(a), "Cannot remove a static or sleeping shape that was not added to the space. (Removed twice maybe?)"); da(this); var c = a.body; c.isStatic() && c.activateStatic(a); c.removeShape(a); this.filterArbiters(c, a); this.staticShapes.remove(a, a.hashid); a.space = null }; G.prototype.removeBody = function(a) { b(this.containsBody(a), "Cannot remove a body that was not added to the space. (Removed twice maybe?)"); da(this); a.activate(); k(this.bodies, a); a.space = null }; G.prototype.removeConstraint = function(a) { b(this.containsConstraint(a), "Cannot remove a constraint that was not added to the space. (Removed twice maybe?)"); da(this); a.a.activate(); a.b.activate(); k(this.constraints, a); a.a.removeConstraint(a); a.b.removeConstraint(a); a.space = null }; G.prototype.containsShape = function(a) { return a.space === this }; G.prototype.containsBody = function(a) { return a.space == this }; G.prototype.containsConstraint = function(a) { return a.space == this }; G.prototype.uncacheArbiter = function(a) { delete this.cachedArbiters[h(a.a.hashid, a.b.hashid)]; k(this.arbiters, a) }; G.prototype.eachBody = function(a) { this.lock(); for (var b = this.bodies, c = 0; c < b.length; c++) a(b[c]); b = this.sleepingComponents; for (c = 0; c < b.length; c++) for (var d = b[c]; d;) { var e = d.nodeNext; a(d); d = e } this.unlock(!0) }; G.prototype.eachShape = function(a) { this.lock(); this.activeShapes.each(a); this.staticShapes.each(a); this.unlock(!0) }; G.prototype.eachConstraint = function(a) { this.lock(); for (var b = this.constraints, c = 0; c < b.length; c++) a(b[c]); this.unlock(!0) }; G.prototype.reindexStatic = function() { b(!this.locked, "You cannot manually reindex objects while the space is locked. Wait until the current query or step is complete."); this.staticShapes.each(function(a) { var b = a.body; a.update(b.p, b.rot) }); this.staticShapes.reindex() }; G.prototype.reindexShape = function(a) { b(!this.locked, "You cannot manually reindex objects while the space is locked. Wait until the current query or step is complete."); var c = a.body; a.update(c.p, c.rot); this.activeShapes.reindexObject(a, a.hashid); this.staticShapes.reindexObject(a, a.hashid) }; G.prototype.reindexShapesForBody = function(a) { for (a = a.shapeList; a; a = a.next) this.reindexShape(a) }; G.prototype.useSpatialHash = function(a, b) { throw Error("Spatial Hash not implemented."); }; G.prototype.activateBody = function(a) { b(!a.isRogue(), "Internal error: Attempting to activate a rogue body."); if (this.locked) - 1 === this.rousedBodies.indexOf(a) && this.rousedBodies.push(a); else { this.bodies.push(a); for (var c = 0; c < a.shapeList.length; c++) { var d = a.shapeList[c]; this.staticShapes.remove(d, d.hashid); this.activeShapes.insert(d, d.hashid) } for (c = a.arbiterList; c; c = c.next(a)) if (d = c.body_a, a === d || d.isStatic()) { var d = c.a, e = c.b; this.cachedArbiters[h(d.hashid, e.hashid)] = c; c.stamp = this.stamp; c.handler = this.lookupHandler(d.collision_type, e.collision_type); this.arbiters.push(c) } for (c = a.constraintList; c; c = c.nodeNext) d = c.a, (a === d || d.isStatic()) && this.constraints.push(c) } }; G.prototype.deactivateBody = function(a) { b(!a.isRogue(), "Internal error: Attempting to deactivate a rogue body."); k(this.bodies, a); for (var c = 0; c < a.shapeList.length; c++) { var d = a.shapeList[c]; this.activeShapes.remove(d, d.hashid); this.staticShapes.insert(d, d.hashid) } for (d = a.arbiterList; d; d = d.next(a)) c = d.body_a, (a === c || c.isStatic()) && this.uncacheArbiter(d); for (d = a.constraintList; d; d = d.nodeNext) c = d.a, (a === c || c.isStatic()) && k(this.constraints, d) }; H.prototype.activate = function() { if (!this.isRogue()) { this.nodeIdleTime = 0; var a = this ? this.nodeRoot : null; if (a && a.isSleeping(a)) { b(!a.isRogue(), "Internal Error: componentActivate() called on a rogue body."); for (var c = a.space, d = a; d;) { var e = d.nodeNext; d.nodeIdleTime = 0; d.nodeRoot = null; d.nodeNext = null; c.activateBody(d); d = e } k(c.sleepingComponents, a) } } }; H.prototype.activateStatic = function(a) { b(this.isStatic(), "Body.activateStatic() called on a non-static body."); for (var c = this.arbiterList; c; c = c.next(this)) a && a != c.a && a != c.b || (c.body_a == this ? c.body_b : c.body_a).activate() }; H.prototype.pushArbiter = function(a) { c(null === (a.body_a === this ? a.thread_a_next : a.thread_b_next), "Internal Error: Dangling contact graph pointers detected. (A)"); c(null === (a.body_a === this ? a.thread_a_prev : a.thread_b_prev), "Internal Error: Dangling contact graph pointers detected. (B)"); var b = this.arbiterList; c(null === b || null === (b.body_a === this ? b.thread_a_prev : b.thread_b_prev), "Internal Error: Dangling contact graph pointers detected. (C)"); a.body_a === this ? a.thread_a_next = b : a.thread_b_next = b; b && (b.body_a === this ? b.thread_a_prev = a : b.thread_b_prev = a); this.arbiterList = a }; var Oa = function(a, b) { if (!b.isRogue()) { var d = b ? b.nodeRoot : null; if (null == d) { b.nodeRoot = a; b !== a && (b.nodeNext = a.nodeNext, a.nodeNext = b); for (d = b.arbiterList; d; d = d.next(b)) Oa(a, b == d.body_a ? d.body_b : d.body_a); for (d = b.constraintList; d; d = d.next(b)) Oa(a, b == d.a ? d.b : d.a) } else c(d === a, "Internal Error: Inconsistency detected in the contact graph.") } }; G.prototype.processComponents = function(a) { for (var b = Infinity !== this.sleepTimeThreshold, d = this.bodies, e = 0; e < d.length; e++) { var f = d[e]; c(null === f.nodeNext, "Internal Error: Dangling next pointer detected in contact graph."); c(null === f.nodeRoot, "Internal Error: Dangling root pointer detected in contact graph.") } if (b) for (var g = (e = this.idleSpeedThreshold) ? e * e : L(this.gravity) * a * a, e = 0; e < d.length; e++) { var f = d[e], h = g ? f.m * g : 0; f.nodeIdleTime = f.kineticEnergy() > h ? 0 : f.nodeIdleTime + a } g = this.arbiters; e = 0; for (h = g.length; e < h; e++) { var k = g[e], f = k.body_a; a = k.body_b; b && ((a.isRogue() && !a.isStatic() || f.isSleeping()) && f.activate(), (f.isRogue() && !f.isStatic() || a.isSleeping()) && a.activate()); f.pushArbiter(k); a.pushArbiter(k) } if (b) { b = this.constraints; for (e = 0; e < b.length; e++) a = b[e], f = a.a, a = a.b, a.isRogue() && !a.isStatic() && f.activate(), f.isRogue() && !f.isStatic() && a.activate(); for (e = 0; e < d.length;) { f = d[e]; if (null === (f ? f.nodeRoot : null)) { Oa(f, f); a: { for (b = f; b; b = b.nodeNext) if (b.nodeIdleTime < this.sleepTimeThreshold) { b = !0; break a } b = !1 } if (!b) { this.sleepingComponents.push(f); for (b = f; b; b = b.nodeNext) this.deactivateBody(b); continue } } e++; f.nodeRoot = null; f.nodeNext = null } } }; H.prototype.sleep = function() { this.sleepWithGroup(null) }; H.prototype.sleepWithGroup = function(a) { b(!this.isStatic() && !this.isRogue(), "Rogue and static bodies cannot be put to sleep."); var c = this.space; b(c, "Cannot put a rogue body to sleep."); b(!c.locked, "Bodies cannot be put to sleep during a query or a call to cpSpaceStep(). Put these calls into a post-step callback."); b(null === a || a.isSleeping(), "Cannot use a non-sleeping body as a group identifier."); if (this.isSleeping()) b((this ? this.nodeRoot : null) === (a ? a.nodeRoot : null), "The body is already sleeping and it's group cannot be reassigned."); else { for (var d = 0; d < this.shapeList.length; d++) this.shapeList[d].update(this.p, this.rot); c.deactivateBody(this); a ? (this.nodeRoot = a = a ? a.nodeRoot : null, this.nodeNext = a.nodeNext, this.nodeIdleTime = 0, a.nodeNext = this) : (this.nodeRoot = this, this.nodeNext = null, this.nodeIdleTime = 0, c.sleepingComponents.push(this)); k(c.bodies, this) } }; G.prototype.activateShapesTouchingShape = function(a) { Infinity !== this.sleepTimeThreshold && this.shapeQuery(a, function(a, b) { a.body.activate() }) }; G.prototype.pointQuery = function(a, b, c, d) { var e = function(e) { (!e.group || c !== e.group) && b & e.layers && e.pointQuery(a) && d(e) }, f = new X(a.x, a.y, a.x, a.y); this.lock(); this.activeShapes.query(f, e); this.staticShapes.query(f, e); this.unlock(!0) }; G.prototype.pointQueryFirst = function(a, b, c) { var d = null; this.pointQuery(a, b, c, function(a) { a.sensor || (d = a) }); return d }; G.prototype.nearestPointQuery = function(a, b, c, d, e) { var f = function(f) { if ((!f.group || d !== f.group) && c & f.layers) { var g = f.nearestPointQuery(a); g.d < b && e(f, g.d, g.p) } }, g = xa(a, b); this.lock(); this.activeShapes.query(g, f); this.staticShapes.query(g, f); this.unlock(!0) }; G.prototype.nearestPointQueryNearest = function(a, b, c, d) { var e, f = function(f) { f.group && d === f.group || !(c & f.layers) || f.sensor || (f = f.nearestPointQuery(a), f.d < b && (!e || f.d < e.d) && (e = f)) }, g = xa(a, b); this.activeShapes.query(g, f); this.staticShapes.query(g, f); return e }; G.prototype.segmentQuery = function(a, b, c, d, e) { var f = function(f) { var g; (!f.group || d !== f.group) && c & f.layers && (g = f.segmentQuery(a, b)) && e(f, g.t, g.n); return 1 }; this.lock(); this.staticShapes.segmentQuery(a, b, 1, f); this.activeShapes.segmentQuery(a, b, 1, f); this.unlock(!0) }; G.prototype.segmentQueryFirst = function(a, b, c, d) { var e = null, f = function(f) { var g; (!f.group || d !== f.group) && c & f.layers && !f.sensor && (g = f.segmentQuery(a, b)) && (null === e || g.t < e.t) && (e = g); return e ? e.t : 1 }; this.staticShapes.segmentQuery(a, b, 1, f); this.activeShapes.segmentQuery(a, b, e ? e.t : 1, f); return e }; G.prototype.bbQuery = function(a, b, c, d) { var e = function(e) { (!e.group || c !== e.group) && b & e.layers && a.l <= e.bb_r && e.bb_l <= a.r && a.b <= e.bb_t && e.bb_b <= a.t && d(e) }; this.lock(); this.activeShapes.query(a, e); this.staticShapes.query(a, e); this.unlock(!0) }; G.prototype.shapeQuery = function(a, b) { var c = a.body; c && a.update(c.p, c.rot); var c = new X(a.bb_l, a.bb_b, a.bb_r, a.bb_t), d = !1, e = function(c) { if ((!a.group || a.group !== c.group) && a.layers & c.layers && a !== c) { var e; if (a.collisionCode <= c.collisionCode) e = Na(a, c); else { e = Na(c, a); for (var f = 0; f < e.length; f++) e[f].n = B(e[f].n) } if (e.length && (d = !(a.sensor || c.sensor), b)) { for (var g = Array(e.length), f = 0; f < e.length; f++) g[f] = new ab(e[f].p, e[f].n, e[f].dist); b(c, g) } } }; this.lock(); this.activeShapes.query(c, e); this.staticShapes.query(c, e); this.unlock(!0); return d }; G.prototype.addPostStepCallback = function(a) { c(this.locked, "Adding a post-step callback when the space is not locked is unnecessary. Post-step callbacks will not called until the end of the next call to cpSpaceStep() or the next query."); this.postStepCallbacks.push(a) }; G.prototype.runPostStepCallbacks = function() { for (var a = 0; a < this.postStepCallbacks.length; a++) this.postStepCallbacks[a](); this.postStepCallbacks = [] }; G.prototype.lock = function() { this.locked++ }; G.prototype.unlock = function(a) { this.locked--; b(0 <= this.locked, "Internal Error: Space lock underflow."); if (0 === this.locked && a) { a = this.rousedBodies; for (var c = 0; c < a.length; c++) this.activateBody(a[c]); a.length = 0; this.runPostStepCallbacks() } }; G.prototype.makeCollideShapes = function() { var a = this; return function(b, c) { if (b.bb_l <= c.bb_r && c.bb_l <= b.bb_r && b.bb_b <= c.bb_t && c.bb_b <= b.bb_t && b.body !== c.body && (!b.group || b.group !== c.group) && b.layers & c.layers) { var d = a.lookupHandler(b.collision_type, c.collision_type), e = b.sensor || c.sensor; if (!e || d !== hb) { if (b.collisionCode > c.collisionCode) { var f = b; b = c; c = f } f = Na(b, c); if (0 !== f.length) { var g = h(b.hashid, c.hashid), k = a.cachedArbiters[g]; k || (k = a.cachedArbiters[g] = new Q(b, c)); k.update(f, d, b, c); "first coll" != k.state || d.begin(k, a) || k.ignore(); "ignore" !== k.state && d.preSolve(k, a) && !e ? a.arbiters.push(k) : (k.contacts = null, "ignore" !== k.state && (k.state = "normal")); k.stamp = a.stamp } } } } }; G.prototype.arbiterSetFilter = function(a) { var b = this.stamp - a.stamp, c = a.body_a, d = a.body_b; if ((c.isStatic() || c.isSleeping()) && (d.isStatic() || d.isSleeping())) return !0; 1 <= b && "cached" != a.state && (a.callSeparate(this), a.state = "cached"); return b >= this.collisionPersistence ? (a.contacts = null, !1) : !0 }; var sb = function(a) { var b = a.body; a.update(b.p, b.rot) }; G.prototype.step = function(a) { if (0 !== a) { b(0 === v.x && 0 === v.y, "vzero is invalid"); this.stamp++; var c = this.curr_dt; this.curr_dt = a; var d, e, f = this.bodies, g = this.constraints, h = this.arbiters; for (d = 0; d < h.length; d++) { var k = h[d]; k.state = "normal"; k.body_a.isSleeping() || k.body_b.isSleeping() || k.unthread() } h.length = 0; this.lock(); for (d = 0; d < f.length; d++) f[d].position_func(a); this.activeShapes.each(sb); this.activeShapes.reindexQuery(this.collideShapes); this.unlock(!1); this.processComponents(a); this.lock(); for (e in this.cachedArbiters) this.arbiterSetFilter(this.cachedArbiters[e]) || delete this.cachedArbiters[e]; e = this.collisionSlop; k = 1 - Math.pow(this.collisionBias, a); for (d = 0; d < h.length; d++) h[d].preStep(a, e, k); for (d = 0; d < g.length; d++) e = g[d], e.preSolve(this), e.preStep(a); e = Math.pow(this.damping, a); k = this.gravity; for (d = 0; d < f.length; d++) f[d].velocity_func(k, e, a); a = 0 === c ? 0 : a / c; for (d = 0; d < h.length; d++) h[d].applyCachedImpulse(a); for (d = 0; d < g.length; d++) g[d].applyCachedImpulse(a); for (d = 0; d < this.iterations; d++) { for (a = 0; a < h.length; a++) h[a].applyImpulse(); for (a = 0; a < g.length; a++) g[a].applyImpulse() } for (d = 0; d < g.length; d++) g[d].postSolve(this); for (d = 0; d < h.length; d++) h[d].handler.postSolve(h[d], this); this.unlock(!0) } }; var Pa = function(a, b, c, d) { return new s(b.vx + -d.y * b.w - (a.vx + -c.y * a.w), b.vy + d.x * b.w - (a.vy + c.x * a.w)) }, La = function(a, b, c, d, e) { return (b.vx + -d.y * b.w - (a.vx + -c.y * a.w)) * e.x + (b.vy + d.x * b.w - (a.vy + c.x * a.w)) * e.y }, Ia = function(a, b, c, d) { a.vx += b * a.m_inv; a.vy += c * a.m_inv; a.w += a.i_inv * (d.x * c - d.y * b) }, Y = function(a, b, c, d, e, f) { Ia(a, -e, -f, c); Ia(b, e, f, d) }, cb = function(a, b, c, d) { a.v_biasx += b * a.m_inv; a.v_biasy += c * a.m_inv; a.w_bias += a.i_inv * (d.x * c - d.y * b) }, ib = function(a, b, c) { b = z(b, c); return a.m_inv + a.i_inv * b * b }, pa = function(a, b, d, e, f) { a = ib(a, d, f) + ib(b, e, f); c(0 !== a, "Unsolvable collision or constraint."); return a }, jb = function(a, b, d, e, f, g) { var h; h = a.m_inv + b.m_inv; var k = a.i_inv, m = d.x * d.x * k; a = -d.x * d.y * k; d = h + d.y * d.y * k; h += m; k = b.i_inv; b = e.x * e.x * k; m = -e.x * e.y * k; d += e.y * e.y * k; e = 0 + a + m; a = 0 + a + m; h += b; b = d * h - e * a; c(0 !== b, "Unsolvable constraint."); b = 1 / b; f.x = h * b; f.y = -e * b; g.x = -a * b; g.y = d * b }, M = a.Constraint = function(a, b) { this.a = a; this.b = b; this.next_b = this.next_a = this.space = null; this.maxForce = Infinity; this.errorBias = Math.pow(0.9, 60); this.maxBias = Infinity }; M.prototype.activateBodies = function() { this.a && this.a.activate(); this.b && this.b.activate() }; M.prototype.preStep = function(a) {}; M.prototype.applyCachedImpulse = function(a) {}; M.prototype.applyImpulse = function() {}; M.prototype.getImpulse = function() { return 0 }; M.prototype.preSolve = function(a) {}; M.prototype.postSolve = function(a) {}; M.prototype.next = function(a) { return this.a === a ? this.next_a : this.next_b }; var qa = a.PinJoint = function(a, b, d, e) { M.call(this, a, b); this.anchr1 = d; this.anchr2 = e; a = a ? A(a.p, C(d, a.rot)) : d; b = b ? A(b.p, C(e, b.rot)) : e; this.dist = D(w(b, a)); c(0 < this.dist, "You created a 0 length pin joint. A pivot joint will be much more stable."); this.n = this.r1 = this.r2 = null; this.bias = this.jnAcc = this.jnMax = this.nMass = 0 }; qa.prototype = Object.create(M.prototype); qa.prototype.preStep = function(a) { var b = this.a, c = this.b; this.r1 = C(this.anchr1, b.rot); this.r2 = C(this.anchr2, c.rot); var d = w(A(c.p, this.r2), A(b.p, this.r1)), e = D(d); this.n = y(d, 1 / (e ? e : Infinity)); this.nMass = 1 / pa(b, c, this.r1, this.r2, this.n); b = this.maxBias; this.bias = r(-(1 - Math.pow(this.errorBias, a)) * (e - this.dist) / a, -b, b); this.jnMax = this.maxForce * a }; qa.prototype.applyCachedImpulse = function(a) { a = y(this.n, this.jnAcc * a); Y(this.a, this.b, this.r1, this.r2, a.x, a.y) }; qa.prototype.applyImpulse = function() { var a = this.a, b = this.b, c = this.n, d = La(a, b, this.r1, this.r2, c), d = (this.bias - d) * this.nMass, e = this.jnAcc; this.jnAcc = r(e + d, -this.jnMax, this.jnMax); d = this.jnAcc - e; Y(a, b, this.r1, this.r2, c.x * d, c.y * d) }; qa.prototype.getImpulse = function() { return Math.abs(this.jnAcc) }; var ra = a.SlideJoint = function(a, b, c, d, e, f) { M.call(this, a, b); this.anchr1 = c; this.anchr2 = d; this.min = e; this.max = f; this.r1 = this.r2 = this.n = null; this.bias = this.jnAcc = this.jnMax = this.nMass = 0 }; ra.prototype = Object.create(M.prototype); ra.prototype.preStep = function(a) { var b = this.a, c = this.b; this.r1 = C(this.anchr1, b.rot); this.r2 = C(this.anchr2, c.rot); var d = w(A(c.p, this.r2), A(b.p, this.r1)), e = D(d), f = 0; e > this.max ? (f = e - this.max, this.n = T(d)) : e < this.min ? (f = this.min - e, this.n = B(T(d))) : (this.n = v, this.jnAcc = 0); this.nMass = 1 / pa(b, c, this.r1, this.r2, this.n); b = this.maxBias; this.bias = r(-(1 - Math.pow(this.errorBias, a)) * f / a, -b, b); this.jnMax = this.maxForce * a }; ra.prototype.applyCachedImpulse = function(a) { a *= this.jnAcc; Y(this.a, this.b, this.r1, this.r2, this.n.x * a, this.n.y * a) }; ra.prototype.applyImpulse = function() { if (0 !== this.n.x || 0 !== this.n.y) { var a = this.a, b = this.b, c = this.n, d = Pa(a, b, this.r1, this.r2), d = x(d, c), d = (this.bias - d) * this.nMass, e = this.jnAcc; this.jnAcc = r(e + d, -this.jnMax, 0); d = this.jnAcc - e; Y(a, b, this.r1, this.r2, c.x * d, c.y * d) } }; ra.prototype.getImpulse = function() { return Math.abs(this.jnAcc) }; var sa = a.PivotJoint = function(a, b, c, d) { M.call(this, a, b); "undefined" === typeof d && (d = c, c = a ? a.world2Local(d) : d, d = b ? b.world2Local(d) : d); this.anchr1 = c; this.anchr2 = d; this.r1 = this.r2 = v; this.k1 = new s(0, 0); this.k2 = new s(0, 0); this.jAcc = v; this.jMaxLen = 0; this.bias = v }; sa.prototype = Object.create(M.prototype); sa.prototype.preStep = function(a) { var b = this.a, c = this.b; this.r1 = C(this.anchr1, b.rot); this.r2 = C(this.anchr2, c.rot); jb(b, c, this.r1, this.r2, this.k1, this.k2); this.jMaxLen = this.maxForce * a; b = w(A(c.p, this.r2), A(b.p, this.r1)); this.bias = K(y(b, -(1 - Math.pow(this.errorBias, a)) / a), this.maxBias) }; sa.prototype.applyCachedImpulse = function(a) { Y(this.a, this.b, this.r1, this.r2, this.jAcc.x * a, this.jAcc.y * a) }; sa.prototype.applyImpulse = function() { var a = this.a, b = this.b, c = Pa(a, b, this.r1, this.r2), c = w(this.bias, c), d = this.k2, c = new s(x(c, this.k1), x(c, d)), d = this.jAcc; this.jAcc = K(A(this.jAcc, c), this.jMaxLen); Y(a, b, this.r1, this.r2, this.jAcc.x - d.x, this.jAcc.y - d.y) }; sa.prototype.getImpulse = function() { return D(this.jAcc) }; var ha = a.GrooveJoint = function(a, b, c, d, e) { M.call(this, a, b); this.grv_a = c; this.grv_b = d; this.grv_n = F(I(w(d, c))); this.anchr2 = e; this.grv_tn = null; this.clamp = 0; this.r1 = this.r2 = null; this.k1 = new s(0, 0); this.k2 = new s(0, 0); this.jAcc = v; this.jMaxLen = 0; this.bias = null }; ha.prototype = Object.create(M.prototype); ha.prototype.preStep = function(a) { var b = this.a, c = this.b, d = b.local2World(this.grv_a), e = b.local2World(this.grv_b), f = C(this.grv_n, b.rot), g = x(d, f); this.grv_tn = f; this.r2 = C(this.anchr2, c.rot); var h = z(A(c.p, this.r2), f); h <= z(d, f) ? (this.clamp = 1, this.r1 = w(d, b.p)) : h >= z(e, f) ? (this.clamp = -1, this.r1 = w(e, b.p)) : (this.clamp = 0, this.r1 = w(A(y(F(f), -h), y(f, g)), b.p)); jb(b, c, this.r1, this.r2, this.k1, this.k2); this.jMaxLen = this.maxForce * a; b = w(A(c.p, this.r2), A(b.p, this.r1)); this.bias = K(y(b, -(1 - Math.pow(this.errorBias, a)) / a), this.maxBias) }; ha.prototype.applyCachedImpulse = function(a) { Y(this.a, this.b, this.r1, this.r2, this.jAcc.x * a, this.jAcc.y * a) }; ha.prototype.grooveConstrain = function(a) { var b = this.grv_tn; a = 0 < this.clamp * z(a, b) ? a : J(a, b); return K(a, this.jMaxLen) }; ha.prototype.applyImpulse = function() { var a = this.a, b = this.b, c = Pa(a, b, this.r1, this.r2), c = w(this.bias, c), d = this.k2, c = new s(x(c, this.k1), x(c, d)), d = this.jAcc; this.jAcc = this.grooveConstrain(A(d, c)); Y(a, b, this.r1, this.r2, this.jAcc.x - d.x, this.jAcc.y - d.y) }; ha.prototype.getImpulse = function() { return D(this.jAcc) }; ha.prototype.setGrooveA = function(a) { this.grv_a = a; this.grv_n = F(I(w(this.grv_b, a))); this.activateBodies() }; ha.prototype.setGrooveB = function(a) { this.grv_b = a; this.grv_n = F(I(w(a, this.grv_a))); this.activateBodies() }; var tb = function(a, b) { return (a.restLength - b) * a.stiffness }, ta = a.DampedSpring = function(a, b, c, d, e, f, g) { M.call(this, a, b); this.anchr1 = c; this.anchr2 = d; this.restLength = e; this.stiffness = f; this.damping = g; this.springForceFunc = tb; this.target_vrn = this.v_coef = 0; this.r1 = this.r2 = null; this.nMass = 0; this.n = null }; ta.prototype = Object.create(M.prototype); ta.prototype.preStep = function(a) { var b = this.a, d = this.b; this.r1 = C(this.anchr1, b.rot); this.r2 = C(this.anchr2, d.rot); var e = w(A(d.p, this.r2), A(b.p, this.r1)), f = D(e); this.n = y(e, 1 / (f ? f : Infinity)); e = pa(b, d, this.r1, this.r2, this.n); c(0 !== e, "Unsolvable this."); this.nMass = 1 / e; this.target_vrn = 0; this.v_coef = 1 - Math.exp(-this.damping * a * e); f = this.springForceFunc(this, f); Y(b, d, this.r1, this.r2, this.n.x * f * a, this.n.y * f * a) }; ta.prototype.applyCachedImpulse = function(a) {}; ta.prototype.applyImpulse = function() { var a = this.a, b = this.b, c = La(a, b, this.r1, this.r2, this.n), d = (this.target_vrn - c) * this.v_coef; this.target_vrn = c + d; d *= this.nMass; Y(a, b, this.r1, this.r2, this.n.x * d, this.n.y * d) }; ta.prototype.getImpulse = function() { return 0 }; var ub = function(a, b) { return (b - a.restAngle) * a.stiffness }, Qa = a.DampedRotarySpring = function(a, b, c, d, e) { M.call(this, a, b); this.restAngle = c; this.stiffness = d; this.damping = e; this.springTorqueFunc = ub; this.iSum = this.w_coef = this.target_wrn = 0 }; Qa.prototype = Object.create(M.prototype); Qa.prototype.preStep = function(a) { var b = this.a, d = this.b, e = b.i_inv + d.i_inv; c(0 !== e, "Unsolvable spring."); this.iSum = 1 / e; this.w_coef = 1 - Math.exp(-this.damping * a * e); this.target_wrn = 0; a *= this.springTorqueFunc(this, b.a - d.a); b.w -= a * b.i_inv; d.w += a * d.i_inv }; Qa.prototype.applyImpulse = function() { var a = this.a, b = this.b, c = a.w - b.w, d = (this.target_wrn - c) * this.w_coef; this.target_wrn = c + d; c = d * this.iSum; a.w += c * a.i_inv; b.w -= c * b.i_inv }; var ua = a.RotaryLimitJoint = function(a, b, c, d) { M.call(this, a, b); this.min = c; this.max = d; this.iSum = this.bias = this.jMax = this.jAcc = 0 }; ua.prototype = Object.create(M.prototype); ua.prototype.preStep = function(a) { var b = this.a, c = this.b, d = c.a - b.a, e = 0; d > this.max ? e = this.max - d : d < this.min && (e = this.min - d); this.iSum = 1 / (1 / b.i + 1 / c.i); b = this.maxBias; this.bias = r(-(1 - Math.pow(this.errorBias, a)) * e / a, -b, b); this.jMax = this.maxForce * a; this.bias || (this.jAcc = 0) }; ua.prototype.applyCachedImpulse = function(a) { var b = this.a, c = this.b; a *= this.jAcc; b.w -= a * b.i_inv; c.w += a * c.i_inv }; ua.prototype.applyImpulse = function() { if (this.bias) { var a = this.a, b = this.b, c = -(this.bias + (b.w - a.w)) * this.iSum, d = this.jAcc; this.jAcc = 0 > this.bias ? r(d + c, 0, this.jMax) : r(d + c, -this.jMax, 0); c = this.jAcc - d; a.w -= c * a.i_inv; b.w += c * b.i_inv } }; ua.prototype.getImpulse = function() { return Math.abs(joint.jAcc) }; var va = a.RatchetJoint = function(a, b, c, d) { M.call(this, a, b); this.angle = 0; this.phase = c; this.ratchet = d; this.angle = (b ? b.a : 0) - (a ? a.a : 0); this.iSum = this.bias = this.jAcc = this.jMax = 0 }; va.prototype = Object.create(M.prototype); va.prototype.preStep = function(a) { var b = this.a, c = this.b, d = this.phase, e = this.ratchet, f = c.a - b.a, g = this.angle - f, h = 0; 0 < g * e ? h = g : this.angle = Math.floor((f - d) / e) * e + d; this.iSum = 1 / (b.i_inv + c.i_inv); b = this.maxBias; this.bias = r(-(1 - Math.pow(this.errorBias, a)) * h / a, -b, b); this.jMax = this.maxForce * a; this.bias || (this.jAcc = 0) }; va.prototype.applyCachedImpulse = function(a) { var b = this.a, c = this.b; a *= this.jAcc; b.w -= a * b.i_inv; c.w += a * c.i_inv }; va.prototype.applyImpulse = function() { if (this.bias) { var a = this.a, b = this.b, c = this.ratchet, d = -(this.bias + (b.w - a.w)) * this.iSum, e = this.jAcc; this.jAcc = r((e + d) * c, 0, this.jMax * Math.abs(c)) / c; d = this.jAcc - e; a.w -= d * a.i_inv; b.w += d * b.i_inv } }; va.prototype.getImpulse = function(a) { return Math.abs(a.jAcc) }; var la = a.GearJoint = function(a, b, c, d) { M.call(this, a, b); this.phase = c; this.ratio = d; this.ratio_inv = 1 / d; this.iSum = this.bias = this.jMax = this.jAcc = 0 }; la.prototype = Object.create(M.prototype); la.prototype.preStep = function(a) { var b = this.a, c = this.b; this.iSum = 1 / (b.i_inv * this.ratio_inv + this.ratio * c.i_inv); var d = this.maxBias; this.bias = r(-(1 - Math.pow(this.errorBias, a)) * (c.a * this.ratio - b.a - this.phase) / a, -d, d); this.jMax = this.maxForce * a }; la.prototype.applyCachedImpulse = function(a) { var b = this.a, c = this.b; a *= this.jAcc; b.w -= a * b.i_inv * this.ratio_inv; c.w += a * c.i_inv }; la.prototype.applyImpulse = function() { var a = this.a, b = this.b, c = (this.bias - (b.w * this.ratio - a.w)) * this.iSum, d = this.jAcc; this.jAcc = r(d + c, -this.jMax, this.jMax); c = this.jAcc - d; a.w -= c * a.i_inv * this.ratio_inv; b.w += c * b.i_inv }; la.prototype.getImpulse = function() { return Math.abs(this.jAcc) }; la.prototype.setRatio = function(a) { this.ratio = a; this.ratio_inv = 1 / a; this.activateBodies() }; var wa = a.SimpleMotor = function(a, b, c) { M.call(this, a, b); this.rate = c; this.iSum = this.jMax = this.jAcc = 0 }; wa.prototype = Object.create(M.prototype); wa.prototype.preStep = function(a) { this.iSum = 1 / (this.a.i_inv + this.b.i_inv); this.jMax = this.maxForce * a }; wa.prototype.applyCachedImpulse = function(a) { var b = this.a, c = this.b; a *= this.jAcc; b.w -= a * b.i_inv; c.w += a * c.i_inv }; wa.prototype.applyImpulse = function() { var a = this.a, b = this.b, c = -(b.w - a.w + this.rate) * this.iSum, d = this.jAcc; this.jAcc = r(d + c, -this.jMax, this.jMax); c = this.jAcc - d; a.w -= c * a.i_inv; b.w += c * b.i_inv }; wa.prototype.getImpulse = function() { return Math.abs(this.jAcc) } })(); var res = { Map_png: "res/background.png", Food_png: "res/Item_03_New.png", R_Get_Star_01_ogg: "res/r_get_star_01.ogg", Character_Ani_png: "res/ani.png", Food_Zuai1_png: "res/zuai1.png", Food_Zuai2_png: "res/zuai2.png", Food_Zuai3_png: "res/zuai3.png", Food_Zuai4_png: "res/zuai4.png", Food_Zuai5_png: "res/zuai5.png", Food_Zuai6_png: "res/zuai6.png", Food_Zuai7_png: "res/zuai7.png", Food_Zuai8_png: "res/zuai8.png", Food_Zuai9_png: "res/zuai9.png", Food_Zuai10_png: "res/zuai10.png", Btn_phbtn_png: "res/phbtn.png", Btn_rulebtn_png: "res/rulebtn.png", BackGround_mp3: "res/supermary.mp3" }, g_resources = [], i; for (i in res) g_resources.push(res[i]); var TagOfLayer = { Background: 0, Animation: 1, GameLayer: 2, Status: 3 }, RunnerState = { running: 0, jumpUp: 1, jumpDown: 2 }; var HelloWorldLayer = cc.Layer.extend({ sprite: null, ctor: function() { this._super(); var a = cc.winSize, b = new cc.MenuItemImage(res.CloseNormal_png, res.CloseSelected_png, function() { cc.log("Menu is clicked!") }, this); b.attr({ x: a.width - 20, y: 20, anchorX: 0.5, anchorY: 0.5 }); b = new cc.Menu(b); b.x = 0; b.y = 0; this.addChild(b, 1); b = new cc.LabelTTF("Hello World", "Arial", 38); b.x = a.width / 2; b.y = 0; this.addChild(b, 5); this.sprite = new cc.Sprite(res.HelloWorld_png); this.sprite.attr({ x: a.width / 2, y: a.height / 2, scale: 0.5, rotation: 180 }); this.addChild(this.sprite, 0); this.sprite.runAction(cc.sequence(cc.rotateTo(2, 0), cc.scaleTo(2, 1, 1))); b.runAction(cc.spawn(cc.moveBy(2.5, cc.p(0, a.height - 40)), cc.tintTo(2.5, 255, 125, 0))); return !0 } }), HelloWorldScene = cc.Scene.extend({ onEnter: function() { this._super(); var a = new HelloWorldLayer; this.addChild(a) } }); var AnimationLayer = cc.Layer.extend({ space: null, state: RunnerState.running, jumpUpAction: null, jumpDownAction: null, runningAction: null, recognizer: null, body: null, sprite: null, sy: null, startTouch: null, ctor: function(a) { this._super(); this.space = a; this.initAction(); this.init(); this.scheduleUpdate() }, init: function() { this._super(); this.sprite = new cc.PhysicsSprite(res.Character_Ani_png); var a = this.sprite.getContentSize(); this.body = new cp.Body(1, cp.momentForBox(1, a.width, a.height)); this.body.p = cc.p(80, 200); this.body.applyImpulse(cp.v(240, 0), cp.v(0, 0)); this.space.addBody(this.body); this.shape = new cp.BoxShape(this.body, a.width, a.height); this.shape.setElasticity(0); this.shape.setFriction(0); this.space.addShape(this.shape); this.sprite.setBody(this.body); this.sprite.attr({ x: 80, y: 200 }); this.addChild(this.sprite); cc.eventManager.addListener({ event: cc.EventListener.TOUCH_ONE_BY_ONE, swallowTouches: !0, onTouchBegan: this.onTouchBegan, onTouchMoved: this.onTouchMoved, onTouchEnded: this.onTouchEnded }, this) }, addScore: function(a) { var b = this; 0 < a ? (this.score = new cc.LabelTTF("+" + a, "Arial", 24), this.score.setColor(cc.color(255, 124, 8))) : (this.score = new cc.LabelTTF(a.toString(), "Arial", 24), this.score.setColor(cc.color(255, 8, 8))); this.score.attr({ x: 70, y: 80, anchorX: 0, anchorY: 0 }); this.sprite.addChild(this.score, 0, 100); this.score.runAction(cc.sequence(cc.spawn(cc.moveBy(2, cc.p(0, 50)), cc.fadeOut(2)), cc.callFunc(function() { b.sprite.getChildByTag(100).removeFromParent(!0) }))) }, initAction: function() {}, getEyeX: function() { return this.sprite.getPositionX() - 40 }, onTouchBegan: function(a, b) { b.getCurrentTarget().jump(); return !0 }, onTouchMoved: function(a, b) {}, onTouchEnded: function(a, b) {}, jump: function() { this.startTouch = 0; this.state == RunnerState.running && (this.body.applyImpulse(cp.v(0, 450), cp.v(0, 0)), this.state = RunnerState.jumpUp) }, update: function() { var a = this.body.getVel(); this.state == RunnerState.jumpUp ? 0 > a.y && (this.state = RunnerState.jumpDown) : this.state == RunnerState.jumpDown && (-450 >= a.y || 0 == a.y) && (this.state = RunnerState.running) } }); var FoodList = { 0: { src: "res/zuai1.png", score: 1 }, 1: { src: "res/zuai2.png", score: 2 }, 2: { src: "res/zuai3.png", score: 3 }, 3: { src: "res/zuai4.png", score: 4 }, 4: { src: "res/zuai5.png", score: 5 }, 5: { src: "res/zuai6.png", score: -1 }, 6: { src: "res/zuai8.png", score: -3 }, 7: { src: "res/zuai10.png", score: -5 } }, Food = cc.Class.extend({ space: null, sprite: null, shape: null, _mapIndex: 0, score: 0, mapIndex: function(a) { if (void 0 != a) this._mapIndex = a; else return this._mapIndex }, ctor: function(a, b, c) { this.space = b; b = Math.floor(8 * Math.random()); b = FoodList[b]; this.score = b.score; this.sprite = new cc.PhysicsSprite(b.src); b = 0.95 * this.sprite.getContentSize().width / 2; var d = new cp.StaticBody; d.setPos(c); this.sprite.setBody(d); this.shape = new cp.CircleShape(d, b, cp.vzero); this.shape.setCollisionType(1); this.shape.setSensor(!0); this.space.addStaticShape(this.shape); a.addChild(this.sprite, 1) }, removeFromParent: function() { this.space.removeStaticShape(this.shape); this.shape = null; this.sprite.removeFromParent(); this.sprite = null }, getShape: function() { return this.shape } }); var BackgroundLayer = cc.Layer.extend({ space: null, objects: null, foodIndex: 1, ctor: function(a) { this._super(); this.space = a; this.objects = []; this.mapIndex = 0; this.mapWidth = 3198; this.init() }, init: function() { this._super(); this.map = new cc.Sprite(res.Map_png); this.map.attr({ x: 0, y: 568, anchorX: 0, anchorY: 1 }); this.addChild(this.map); this.map1 = new cc.Sprite(res.Map_png); this.map1.attr({ x: this.mapWidth, y: 568, anchorX: 0, anchorY: 1 }); this.addChild(this.map1); var a = new cc.Sprite(res.Bottom_png, cc.rect(29, 5, 41, 300)), b = new cc.Sprite(res.Bottom_png, cc.rect(76, 5, 118, 300)), c = new cc.Sprite(res.Bottom_png, cc.rect(199, 5, 118, 300)), d = new cc.Sprite(res.Bottom_png, cc.rect(322, 5, 118, 300)), e = new cc.Sprite(res.Bottom_png, cc.rect(445, 5, 77, 300)), f = 10; a.attr({ x: f, y: 30, anchorX: 0 }); f += a.getContentSize().width; b.attr({ x: f, y: 30, anchorX: 0 }); f += b.getContentSize().width; c.attr({ x: f, y: 30, anchorX: 0 }); f += c.getContentSize().width; d.attr({ x: f, y: 30, anchorX: 0 }); f += d.getContentSize().width; e.attr({ x: f, y: 30, anchorX: 0 }); for (a = this.foodIndex + 5; this.foodIndex < a; this.foodIndex++) b = new Food(this, this.space, cc.p(640 * this.foodIndex, 110)), this.objects.push(b); this.scheduleUpdate() }, removeObjectByShape: function(a) { for (var b = 0, c = this.objects.length; b < c; b += 1) if (this.objects[b].getShape() == a) return a = this.objects[b].score, this.objects[b].removeFromParent(), this.objects.splice(b, 1), a }, loadObjects: function(a, b) { a.getObjectGroup("coin").getObjects() }, checkAndReload: function(a) { a = parseInt(a / this.mapWidth); if (this.mapIndex == a) return !1; cc.log("speed up"); this.getParent().getChildByTag(TagOfLayer.Animation).body.applyImpulse(cp.v(20, 0), cp.v(0, 0)); this.space.gravity = cp.v(0, -900 - 20 * this.mapIndex); a % 2 ? this.map.setPositionX(this.mapWidth * (a + 1)) : this.map1.setPositionX(this.mapWidth * (a + 1)); for (var b = this.foodIndex + 5; this.foodIndex < b; this.foodIndex++) { var c = new Food(this, this.space, cc.p(640 * this.foodIndex, 110)); this.objects.push(c) } this.mapIndex = a; return !0 }, addDistance: function() { this.distanceLabel = new cc.LabelTTF("0", "Arial", 25); this.distanceLabel.attr({ x: 150, y: 520 }); this.distanceLabel.setColor(cc.color(13, 110, 7)); this.addChild(this.distanceLabel) }, updateDistance: function(a) { this.distanceLabel.setPositionX(a + 150); this.distanceLabel.setString(Math.round(a / 20)) }, update: function() { var a = this.getParent().getChildByTag(TagOfLayer.Animation).getEyeX(); this.checkAndReload(a) } }); var PlayScene = cc.Scene.extend({ space: null, shapesToRemove: null, onEnter: function() { this._super(); this.shapesToRemove = []; this.initPhysics(); this.gameLayer = new cc.Layer; this.gameLayer.addChild(new BackgroundLayer(this.space), 0, TagOfLayer.Background); this.gameLayer.addChild(new AnimationLayer(this.space), 0, TagOfLayer.Animation); this.addChild(this.gameLayer); this.statusLayer = new cc.Layer; this.statusLayer.addChild(new StatusLayer, 0, TagOfLayer.Status); this.addChild(this.statusLayer); cc.audioEngine.playMusic(res.BackGround_mp3, !0); this.scheduleUpdate() }, initPhysics: function() { this.space = new cp.Space; this.space.gravity = cp.v(0, -900); var a = this.space.staticBody; a.set; for (var b = cc.director.getWinSize(), b = [new cp.SegmentShape(a, cp.v(1, 90), cp.v(cc.UINT_MAX, 90), 0), new cp.SegmentShape(a, cp.v(1, 100), cp.v(b.width, 100), 0), new cp.SegmentShape(a, cp.v(1, b.height), cp.v(b.width - 1, b.height - 1), 0), new cp.SegmentShape(a, cp.v(1, 1), cp.v(1, b.height - 1), 0), new cp.SegmentShape(a, cp.v(b.width - 1, 1), cp.v(b.width - 1, b.height - 1), 0)], c = 0; 4 > c; c += 1) { var d = b[c]; c || this.space.addStaticShape(d) } this.space.addStaticShape(new cp.SegmentShape(a, cp.v(1, 300), cp.v(cc.UINT_MAX, 300), 0)); this.space.addCollisionHandler(0, 1, this.collisionCoinBegin.bind(this), null, null, null) }, collisionCoinBegin: function(a, b) { var c = a.getShapes(); this.shapesToRemove.push(c[1]); cc.audioEngine.playEffect(res.R_Get_Star_01_ogg) }, update: function(a) { this.space.step(a); a = this.gameLayer.getChildByTag(TagOfLayer.Animation); for (var b = 0, c = this.shapesToRemove.length; b < c; b += 1) { var d = this.shapesToRemove[b], d = this.gameLayer.getChildByTag(TagOfLayer.Background).removeObjectByShape(d); this.statusLayer.getChildByTag(TagOfLayer.Status).updateScore(d); a.addScore(d) } this.shapesToRemove = []; a = a.getEyeX(); this.gameLayer.setPosition(cc.p(-a, 0)) } }); var StatusLayer = cc.Layer.extend({ labelScore: null, labelTimer: null, coins: 0, score: 0, timer: 60, ctor: function() { this._super(); this.init() }, init: function() { cc.director.getWinSize(); this.addScore(); this.addTimer(); this.schedule(this.updateTimer, 1, 60) }, addScore: function() { this.labelScore = new cc.LabelTTF("\u5f97\u5206:" + this.score.toString(), "Arial", 25); this.labelScore.attr({ x: 60, y: 540 }); this.addChild(this.labelScore) }, addTimer: function() { this.labelTimer = new cc.LabelTTF("\u5012\u8ba1\u65f6:" + this.timer.toString(), "Arial", 25); this.labelTimer.attr({ x: 240, y: 540 }); this.addChild(this.labelTimer) }, addBtn: function() { this.btnrule = new cc.Sprite(res.Btn_rulebtn_png); rule.attr({ x: 80, y: 37 }); var a = new cc.LabelTTF(res.Btn_phbtn_png); a.attr({ x: 240, y: 37 }); cc.eventManager.addListener({ event: cc.EventListener.TOUCH_ONE_BY_ONE, onTouchBegan: function() { isInGame = 1; cc.director.pause(); $(".dRule").removeClass("hide") } }, rule); cc.eventManager.addListener({ event: cc.EventListener.TOUCH_ONE_BY_ONE, onTouchBegan: function() { isInGame = 1; cc.director.pause(); $(".dList").removeClass("hide"); getList1() } }, a); this.addChild(rule) }, updateTimer: function() { 0 < this.timer ? (this.timer -= 1, this.labelTimer.setString("\u5012\u8ba1\u65f6:" + this.timer.toString())) : (cc.director.pause(), $(".divPM").addClass("hide"), $(".jifen").html(this.score), $("#num").val(this.score), $(".dGameOver").removeClass("hide"), postData()) }, updateScore: function(a) { this.score += a; this.score = 0 > this.score ? 0 : this.score; this.labelScore.setString("\u5f97\u5206:" + this.score.toString()) } }); var g_groundHight = 57, g_runnerStartX = 80, RunnerState = { running: 0, jumpUp: 1, jumpDown: 2 }; var isInGame; $("#cantest,#cantest1").val(_Mvar.cantest); $("#cantest1").val("can"); $("#wxid,#wxid1,#wxnum1,#wxnum").val(_Mvar.wxid); $("#headimgurl,#headimgurl1").val(_Mvar.headimgurl); $("#nickname,#nickname1").val(_Mvar.nickname); $(".headimgurl").attr("src", _Mvar.headimgurl); $(".nickname").html("\u4eb2\u7231\u7684" + _Mvar.nickname + ":"); $("#gid").val(_Mvar.gid); $("#gid1").val(196); function getdate(a) { return (new Function("date", "return new " + a.replace(/\//g, "")))() } var a={"success":1,"msg":{"UpCoinID":310,"IMG":"http://image.qqauto.cn/2/space/20150710142511.jpg","CountDown":0,"StartTime":"\/Date(1449200076000)\/","EndTime":"\/Date(1451034036000)\/","EachCoin":1,"MaxCoin":888888,"RegTime":"\/Date(1449200204357)\/","WxAccountID":15,"Rules":"奔跑吧soho星尚花园酒店","Title":"奔跑吧soho星尚花园酒店","Sts":"A","KeyWord":"http://wx.qqauto.cn/html/upcoin/kupao/2","DaylyCount":3,"TotalCount":0,"Intro":"奔跑吧soho星尚花园酒店","Photo":"http://image.qqauto.cn/2/space/20150710142511.jpg","Pwd":"DJB113644310","Remark":"","Share":3,"TimeSpan":86400,"Type":2,"ShareTimeSpan":0,"ShareCount":0,"ShareDaylyCount":888888,"ShareType":0,"SaveType":0},"user":{"UserListID":509608,"MyGroup":11,"GroupID":310,"WxNum":"o5QYUt7WjoXzzMEYpPyV3qKJimeI","RegTime":"\/Date(1450340767707)\/","Remark":"","Num":61,"Sts":"A","TrueName":"洪俊裕","Tel":"15623652365","NickName":"洪俊裕","HeadimgUrl":"http://wx.qlogo.cn/mmopen/krLSVZObVXNCeNOlorHq1aqjWiah2jmP37smTb4Caru4Opu2uKNVCMlicnMKkXib1cDwzC9F9Z10Ay7UUy155du6N54UIuia5Kjic/0","OtherID":0,"IsShare":0,"LastTime":"\/Date(1450340053830)\/","Prize":"","Remark1":"","Remark2":"","OtherID1":0,"OtherID2":0},"rank":159,"helper":null,"count":249,"hrank":0,"log":[]}; _Mvar.chance = a.msg.DaylyCount; if (a.user) { if (a.msg.DaylyCount) for (var b = (new Date).setHours(0, 0, 0, 0), c = 0, d = a.log.length; c < d; c++) getdate(a.log[c].RegTime) > b && ("A" == a.log[c].Sts ? _Mvar.times++ : "F" == a.log[c].Sts && (_Mvar.chance += a.msg.Share, _Mvar.share++)); _Mvar.countdown = a.msg.CountDown; $("#phone").val(a.user.Tel); $("#truename").val(a.user.TrueName); shareData.title = "\u6211\u5728\u5954\u8dd1\u5427\uff01soho \u6e38\u620f\u91cc\u62ff\u4e86" + a.user.Num + "\u79ef\u5206,\u76ee\u524d\u6392\u540d\u7b2c" + a.rank + ",\u5feb\u6765\u4e00\u8d77\u6311\u6218\u5427!"; // wxShare() } $(".tAll").html(a.count); $(".tMaxCoin").html(a.msg.MaxCoin); init(a) // $.ajax({ // url: _Mvar.domain + "/UpcoinMobile/PowerEveryDay" + _Mvar.jsoncallback, // type: "get", // data: $("#form1").serialize(), // dataType: "json", // success: function(a) { // if (a) // if (a.success) { // _Mvar.chance = a.msg.DaylyCount; // if (a.user) { // if (a.msg.DaylyCount) // for (var b = (new Date).setHours(0, 0, 0, 0), c = 0, d = a.log.length; c < d; c++) getdate(a.log[c].RegTime) > b && ("A" == a.log[c].Sts ? _Mvar.times++ : "F" == a.log[c].Sts && (_Mvar.chance += a.msg.Share, _Mvar.share++)); // _Mvar.countdown = a.msg.CountDown; // $("#phone").val(a.user.Tel); // $("#truename").val(a.user.TrueName); // shareData.title = "\u6211\u5728\u5954\u8dd1\u5427\uff01soho \u6e38\u620f\u91cc\u62ff\u4e86" + a.user.Num + "\u79ef\u5206,\u76ee\u524d\u6392\u540d\u7b2c" + a.rank + ",\u5feb\u6765\u4e00\u8d77\u6311\u6218\u5427!"; // wxShare() // } // $(".tAll").html(a.count); // $(".tMaxCoin").html(a.msg.MaxCoin); // init(a) // } else a.msg && alert(a.msg) // }, // error: function() {}, // complete: function() {} // }); function init(a) { console.log(a); var b; $(".iList").click(function() { $(".dList").removeClass("hide"); getList1() }); $(".iList1").click(function() { $(".dList").removeClass("hide"); getList1() }); $(".iAgain").click(function() { $(".dGameOver,.dGame").addClass("hide"); $(".dIndex").removeClass("hide") }); $(".iIndex").click(function() { $(".dRule,.dList,.dForm").addClass("hide"); isInGame && (isInGame = 0, cc.director.resume()) }); $(".iIndex1").click(function() { $(".dRule,.dList,.dForm,.dRule1,.dGameOver,.dGame").addClass("hide"); $(".dIndex").removeClass("hide") }); $(".iShare").click(function() { $(".dShare").removeClass("hide") }); $(".dShare").click(function() { $(this).addClass("hide") }); $(".iStart333").click(function() { location.href = "index.html" }); $(".iStartGame").click(function() { a.msg.DaylyCount && _Mvar.times >= a.msg.DaylyCount ? alert("\u60a8\u4eca\u5929\u7684\u6e38\u620f\u6b21\u6570\u5df2\u7ecf\u7528\u5b8c\u4e86\uff0c\u660e\u5929\u518d\u6765\u73a9\u5427\uff01") : $(".wfpop").removeClass("hide") }); $(".iStart").click(function() { a.user && a.user.Tel ? (b ? (cc.director.runScene(new PlayScene), cc.director.resume()) : (b = 1, cc.game.run(), $("#loading").removeClass("hide")), $(".dIndex,.dGameOver").addClass("hide"), $(".dGame").removeClass("hide")) : $(".dForm").removeClass("hide"); $(".wfpop").addClass("hide") }); $(".iGift").click(function() { _Mvar.go || (_Mvar.go = 1, a.data && a.data.Tel && 30 <= _Mvar.num ? a.data1 ? location.href = "share.html?uid\x3d" + a.data.UserListID : ($("#sts").val("H"), $("#wxnum").val("0"), $.ajax({ url: _Mvar.domain + "/UpCoinMobile/PowerRegiste" + _Mvar.jsoncallback, data: $("#form1").serialize(), dataType: "json", success: function(a) { a && a.success && (location.href = "share.html?uid\x3d" + a.msg) }, error: function() { alert("\u53ef\u80fd\u662f\u7f51\u7edc\u539f\u56e0\u5e26\u6765\u7684\u9519\u8bef,\u8bf7\u5237\u65b0\u9875\u9762\u91cd\u8bd5") }, complete: function() { _Mvar.go = 0 } })) : (_Mvar.go = 0, alert("\u60a8\u8fd8\u6ca1\u6709\u9886\u53d6\u81ea\u5df1\u7684\u793c\u76d2\uff0c\u5feb\u53bb\u73a9\u6e38\u620f\u9886\u53d6\u5c5e\u4e8e\u81ea\u5df1\u7684\u5e78\u8fd0\u793c\u76d2\u5427\uff01"))) }); $(".iStart1").click(function() { // if (a.msg.DaylyCount) // if (_Mvar.times < // a.msg.Share * _Mvar.share + a.msg.DaylyCount){ // _Mvar.times++; // }else { // a.msg.Share && _Mvar.times == a.msg.DaylyCount ? alert("\u60a8\u4eca\u5929\u7684\u6e38\u620f\u6b21\u6570\u5df2\u7ecf\u7528\u5b8c\u4e86,\u5206\u4eab\u5230\u670b\u53cb\u5708\u53ef\u4ee5\u83b7\u5f97\u989d\u5916" + a.msg.Share + "\u6b21\u673a\u4f1a") : alert("\u60a8\u4eca\u5929\u7684\u6e38\u620f\u6b21\u6570\u5df2\u7ecf\u7528\u5b8c\u4e86,\u660e\u5929\u518d\u6765\u73a9\u5427"); // return // } // alert(1); $(".synum").html(a.msg.Share * _Mvar.share + a.msg.DaylyCount - _Mvar.times); $(".wfpop").removeClass("hide") }); $(".iClose1").click(function() { $(".dGame_1").addClass("hide") }); $(".iHelp").click(help); $(".iBack").click(function() { $(".dGameOver,.dGame").addClass("hide"); $(".dIndex").removeClass("hide"); return !1 }); $(".iInfo").click(function() { $(".dIndex,.dGame,.dInfo,.dRule,.dList").addClass("hide"); $(".dInfo").removeClass("hide") }); $(".iNext").click(function() { $(".dGame1").addClass("hide"); $(".dGame2").removeClass("hide") }); $(".iRule").click(function() { $(".dRule").removeClass("hide") }); $(".iRuleClose").click(function() { $(".dRule").addClass("hide") }); $(".iRule1").click(function() { $(".dIndex").addClass("hide"); $(".dRule1").removeClass("hide") }); $(".iRule1Close").click(function() { $(".dRule1").addClass("hide"); $(".dIndex").removeClass("hide") }); $(".iClose1").click(function() { $(".dForm").addClass("hide") }); $(".iSave").click(function() { if (0 > new Date - eval("new " + (a.msg.StartTime + "").replace(/\//g, ""))) alert("\u6d3b\u52a8\u672a\u5f00\u59cb!"); else if (0 < new Date - eval("new " + (a.msg.EndTime + "").replace(/\//g, ""))) alert("\u6d3b\u52a8\u5df2\u7ed3\u675f!"); else if (!_Mvar.go) if (_Mvar.go = 1, $("#truename").val()) { var c = $("#phone").val(); isNaN(c) || 11 != c.length ? (_Mvar.go = 0, alert("\u8bf7\u7559\u4e0b\u60a8\u7684\u624b\u673a\u53f7\uff01")) : $.ajax({ url: _Mvar.domain + "/UpCoinMobile/PowerRegiste" + _Mvar.jsoncallback, data: $("#form1").serialize(), dataType: "json", success: function(a) {}, complete: function() { alert("\u4fe1\u606f\u63d0\u4ea4\u6210\u529f\uff01"); $(".dForm,.dIndex").addClass("hide"); a.user = { Tel: 1 }; $("#loading,.dGame").removeClass("hide"); b = 1; cc.game.run(); _Mvar.go = 0 } }) } else _Mvar.go = 0, alert("\u8bf7\u7559\u4e0b\u60a8\u7684\u59d3\u540d\uff01") }); $(".iStart2").click(function() { location.href = "index.html" }); $(".iStart4").click(function() { $(".dGame1").addClass("hide"); if ($(".tPrize").html()) $(".dResult").removeClass("hide"); else { $(".dGame2").removeClass("hide"); var b = 0; a.data && a.data.Num && (b = a.data.Num); var d = a.msg.MaxCoin - b; $(".tHelper").html(b); $(".tHelper1").html(d); $(".tJingdu").css("width", b / a.msg.MaxCoin * 100 + "%"); d ? $(".dGame2_1").removeClass("hide") : ($(".findhelp").addClass("hide"), $(".dGame2_2").removeClass("hide")) } }); $(".iStart3").click(function() { if (!_Mvar.go) { _Mvar.go = 1; $("#sts").val("P1"); var a = "\u53ef\u80fd\u662f\u7f51\u7edc\u95ee\u9898,\u8bf7\u91cd\u8fdb\u9875\u9762\u91cd\u8bd5!"; $.ajax({ url: _Mvar.domain + "/UpCoinMobile/PowerRegiste" + _Mvar.jsoncallback, data: $("#form1").serialize(), cache: !1, dataType: "json", success: function(b) { b && b.success && ($(".tPrize").html(b.data), $(".tPrize1").attr("src", "images/" + _Mvar.prize.indexOf(b.data.substr(0, 1)) + ".jpg"), $(".dResult").removeClass("hide"), $(".dGame2,.dGame2_2").addClass("hide"), a = b.data, a = "") }, complete: function() { a && alert(a); _Mvar.go = 0 } }) } }); $(".iSave2").click(function() { if (0 > new Date - eval("new " + (a.msg.StartTime + "").replace(/\//g, ""))) alert("\u6d3b\u52a8\u672a\u5f00\u59cb!"); else if (0 < new Date - eval("new " + (a.msg.EndTime + "").replace(/\//g, ""))) alert("\u6d3b\u52a8\u5df2\u7ed3\u675f!"); else if (!_Mvar.go) { _Mvar.go = 1; var b = $("#truename").val(); if (b) { var d = $("#phone").val(); isNaN(d) || 11 != d.length ? (_Mvar.go = 0, alert("\u8bf7\u7559\u4e0b\u60a8\u7684\u624b\u673a\u53f7\uff01")) : ($("#truename1").val(b), $("#phone1").val(d), $.ajax({ url: _Mvar.domain + "/UpCoinMobile/UpCoinDZData" + _Mvar.jsoncallback, data: $("#form").serialize(), dataType: "json", success: function(b) { b ? b.success ? (a.data = { Tel: "121212" }, alert("\u4fe1\u606f\u63d0\u4ea4\u6210\u529f!"), $(".dForm").addClass("hide"), _Mvar.times += 1, $("#otherid1").val(_Mvar.times), postData1(), $(".dIndex,.dGameOver").addClass("hide"), $(".dGame").removeClass("hide"), mg_Game.on = 0, mg_Game.reStart()) : b.msg && alert(b.msg) : alert("\u53ef\u80fd\u662f\u7f51\u7edc\u539f\u56e0\uff0c\u8bf7\u7a0d\u540e\u518d\u8bd5!") }, error: function() { alert("\u53ef\u80fd\u662f\u7f51\u7edc\u539f\u56e0\uff0c\u8bf7\u7a0d\u540e\u518d\u8bd5!") }, complete: function() {} }), $.ajax({ url: _Mvar.domain + "/UpCoinMobile/UpCoinDZData" + _Mvar.jsoncallback, data: $("#form1").serialize(), dataType: "json", success: function(a) {}, error: function() {}, complete: function() { _Mvar.go = 0 } })) } else _Mvar.go = 0, alert("\u8bf7\u7559\u4e0b\u60a8\u7684\u59d3\u540d\uff01") } }); $(".iSave1").click(function() { if (!_Mvar.go) { _Mvar.go = 1; var a = $("#truename1").val(); a ? (a = $("#phone1").val(), isNaN(a) || 11 != a.length ? (_Mvar.go = 0, alert("\u8bf7\u7559\u4e0b\u60a8\u6b63\u786e\u7684\u624b\u673a\u53f7\u7801!")) : ($("#truename").val($("#truename1").val()), $("#phone").val($("#phone1").val()), $("#sts").val("A"), $("#wxid").val(_Mvar.wxid), $.ajax({ url: _Mvar.domain + "/UpCoinMobile/PowerRegiste" + _Mvar.jsoncallback, data: $("#form1").serialize(), dataType: "json", success: function(a) { a && (a.success ? (alert("\u4fe1\u606f\u63d0\u4ea4\u6210\u529f!"), _Mvar.uid = a.msg, $(".dRotateResult").addClass("hide"), $(".dIndex").removeClass("hide")) : alert("\u53ef\u80fd\u662f\u7f51\u7edc\u539f\u56e0\uff0c\u8bf7\u7a0d\u540e\u518d\u8bd5!")) }, error: function() { alert("\u53ef\u80fd\u662f\u7f51\u7edc\u539f\u56e0\uff0c\u8bf7\u7a0d\u540e\u518d\u8bd5!") }, complete: function() { _Mvar.go = 0 } }))) : (_Mvar.go = 0, alert("\u8bf7\u7559\u4e0b\u60a8\u7684\u59d3\u540d!")) } }); $(".iList111").click(function() { $(".dResult").addClass("hide"); $(".dList1").removeClass("hide"); if (!_Mvar.go) { _Mvar.go = 1; var a = '\x3cul class\x3d"info_one"\x3e\x3cli\x3e\x3c/li\x3e\x3cli\x3e\u53ef\u80fd\u662f\u7f51\u7edc\u95ee\u9898,\u6570\u636e\u65e0\u6cd5\u52a0\u8f7d,\u8bf7\u91cd\u8bd5!\x3c/li\x3e\x3c/ul\x3e'; $.ajax({ url: _Mvar.domain + "/UpCoinMobile/PowerList" + _Mvar.jsoncallback, data: $("#form1").serialize(), dataType: "json", success: function(b) { if (b) { $(".info_one").remove(); $(".dAll").html(b.success); $(".dTotal").html(b.msg); var e = b.data.length; e && (a = ""); for (var f = 0; f < e; f += 1) a += '\x3cul class\x3d"info_one"\x3e\x3cli\x3e\x3cimg src\x3d"' + (1 < b.data[f].Img.length ? b.data[f].Img.substr(0, b.data[f].Img.length - 1) + "46" : b.data[f].Img) + '"\x3e\x3c/li\x3e\x3cli\x3e\x3cspan class\x3d"name"\x3e' + b.data[f].Name + '\x3c/span\x3e\x3c/li\x3e\x3cli class\x3d"kj_num"\x3e\uffe5' + b.data[f].Coin + "\x3c/li\x3e\x3c/ul\x3e" } }, complete: function() { a && ($(".dRList1").after(a), $(".dList1 .info_one:last").addClass("no_dashed")); _Mvar.go = 0 } }) } }) } function help() { $("#sts").val("H"); $("#wxnum").val(_Mvar.wxNum); $.ajax({ url: _Mvar.domain + "/UpCoinMobile/PowerRegiste" + _Mvar.jsoncallback, data: $("#form1").serialize(), dataType: "json", success: function(a) {}, complete: function() {} }) } function getList() { var a = "\x3cul\x3e\u53ef\u80fd\u662f\u7f51\u7edc\u539f\u56e0\uff0c\u8bf7\u91cd\u8bd5!\x3c/ul\x3e"; $.ajax({ url: _Mvar.domain + "/UpCoinMobile/PowerList2" + _Mvar.jsoncallback, data: $("#form1").serialize(), dataType: "json", success: function(b) { var c = ""; if (b) if ($(".tAll").html(b.success), b.success) { b = b.msg; var d = b.length; if (d) { for (var e = 0; e < d; e += 1) c += '\x3cul class\x3d"listmd' + (e % 2 ? " jishuline" : "") + '"\x3e\x3cli\x3e\x3cimg src\x3d"' + (1 < b[e].HeadimgUrl.length ? b[e].HeadimgUrl.substr(0, b[e].HeadimgUrl.length - 1) + "46" : b[e].HeadimgUrl) + '"/\x3e\x3cspan\x3e' + (8 < b[e].NickName.length ? b[e].NickName.substr(0, 8) : b[e].NickName) + "\x3c/span\x3e\x3c/li\x3e\x3cli\x3e" + b[e].Tel + "\x3c/li\x3e\x3cli\x3e" + b[e].Remark + "\x3c/li\x3e\x3c/ul\x3e"; a = c } else a = '\x3cul class\x3d"listmd"\x3e\u6682\u65e0\u7528\u6237\u83b7\u5956\x3c/ul\x3e' } else a = b.msg.length ? b.msg : '\x3cul class\x3d"listmd"\x3e\u6682\u65e0\u7528\u6237\u53c2\u4e0e\x3c/ul\x3e' }, complete: function() { $(".dList1").html(a) } }) } function getList1() { var a = '\x3cul class\x3d"listmd"\x3e\x3cli\x3e\x3c/li\x3e\x3cli\x3e\u53ef\u80fd\u662f\u7f51\u7edc\u539f\u56e0\uff0c\u8bf7\u91cd\u8bd5!\x3c/li\x3e\x3c/ul\x3e'; $.ajax({ url: _Mvar.domain + "/UpCoinMobile/PowerList1" + _Mvar.jsoncallback, data: $("#form1").serialize(), dataType: "json", success: function(b) { var c = ""; if (b && b.success) { var d = b.data, e = b.data.length; $(".tAll").html(e); if (e) { for (var f = 0; f < e; f += 1) c += '\x3cul class\x3d"listmd"\x3e\x3cli\x3e' + (f + 1) + '\x3c/li\x3e\x3cli\x3e\x3cimg src\x3d"' + (1 < d[f].Img.length ? d[f].Img.substr(0, d[f].Img.length - 1) + "46" : d[f].Img) + '"\x3e\x3cspan\x3e' + (8 < d[f].Name.length ? d[f].Name.substr(0, 8) : d[f].Name) + "\x3c/span\x3e\x3c/li\x3e\x3cli\x3e" + d[f].Coin + "\x3c/li\x3e\x3c/ul\x3e"; a = c; b.data1 && $(".dListResult1").html('\x3ctr class\x3d"my_phb"\x3e\x3ctd width\x3d"25%"\x3e' + (b.data1.count ? b.data1.count : "") + '\x3c/td\x3e\x3ctd width\x3d"50%"\x3e\x3cimg src\x3d"' + (1 < b.data1.Img.length ? b.data1.Img.substr(0, b.data1.Img.length - 1) + "46" : b.data1.Img) + '" alt\x3d""\x3e' + (8 < b.data1.Name.length ? b.data1.Name.substr(0, 8) : b.data1.Name) + '\x3c/td\x3e\x3ctd width\x3d"25%"\x3e' + b.data1.Coin + "\x3c/td\x3e\x3c/tr\x3e") } else a = '\x3cul class\x3d"listmd"\x3e\x3cli\x3e\x3c/li\x3e\x3cli\x3e\u6682\u65e0\u7528\u6237\u53c2\u4e0e\x3c/li\x3e\x3c/ul\x3e' } else a = b.msg && b.msg.length ? b.msg : '\x3cul class\x3d"listmd"\x3e\x3cli\x3e\x3c/li\x3e\x3cli\x3e\u65e0\u6cd5\u8bfb\u53d6\u6570\u636e\x3c/li\x3e\x3c/ul\x3e' }, error: function() { a = '\x3cul class\x3d"listmd"\x3e\x3cli\x3e\x3c/li\x3e\x3cli\x3e\u65e0\u6cd5\u8bfb\u53d6\u6570\u636e\x3c/li\x3e\x3c/ul\x3e' }, complete: function() { $(".dListResult").html(a) } }) } function postData() { $.ajax({ url: _Mvar.domain + "/UpCoinMobile/UpCoinDZData" + _Mvar.jsoncallback, data: $("#form1").serialize(), dataType: "json", success: function(a) { a && a.success && ($(".iOrder").html(a.msg), $(".dOrder").removeClass("hide"), shareData.title = "\u6211\u5728\u5954\u8dd1\u5427\uff01soho \u6e38\u620f\u91cc\u62ff\u4e86" + $("#num").val() + "\u79ef\u5206,\u76ee\u524d\u6392\u540d\u7b2c" + a.msg + ",\u5feb\u6765\u4e00\u8d77\u6311\u6218\u5427!", wxShare()) }, error: function() {}, complete: function() {} }) } function postData1() { $.ajax({ url: _Mvar.domain + "/UpCoinMobile/UpCoinDZData" + _Mvar.jsoncallback, data: $("#form1").serialize(), dataType: "json", success: function(a) { a || alert("\u53ef\u80fd\u662f\u7f51\u7edc\u539f\u56e0\uff0c\u8bf7\u7a0d\u540e\u518d\u8bd5!") }, error: function() { alert("\u53ef\u80fd\u662f\u7f51\u7edc\u539f\u56e0\uff0c\u8bf7\u7a0d\u540e\u518d\u8bd5!") }, complete: function() {} }) } cc.game.onStart = function() { cc.log(cc.sys.isNative); !cc.sys.isNative && document.getElementById("cocosLoading") && document.body.removeChild(document.getElementById("cocosLoading")); cc.view.enableAutoFullScreen(!1); cc.view.enableRetina(!1); cc.view.adjustViewPort(!0); cc.view.setDesignResolutionSize(320, 568, cc.ResolutionPolicy.EXACT_FIT); cc.view.resizeWithBrowserSize(!0); cc.loader.load(g_resources, function(a, b, c) { a = Math.min(100 * c / b | 0, 100); $("#loadnum").html("\u52a0\u8f7d\u4e2d" + a + "%") }, function() { $("#loading").addClass("hide"); cc.director.runScene(new PlayScene) }) };