(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i 0 && arguments[0] !== undefined ? arguments[0] : gfx.CULL_BACK; var passIdx = arguments.length > 1 ? arguments[1] : undefined; _setCullMode.call(this, cullMode, passIdx); this._nativeObj.setCullMode(cullMode, passIdx === undefined ? -1 : passIdx); }, setBlend: function setBlend() { var enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; var blendEq = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : gfx.BLEND_FUNC_ADD; var blendSrc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : gfx.BLEND_SRC_ALPHA; var blendDst = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : gfx.BLEND_ONE_MINUS_SRC_ALPHA; var blendAlphaEq = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : gfx.BLEND_FUNC_ADD; var blendSrcAlpha = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : gfx.BLEND_SRC_ALPHA; var blendDstAlpha = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : gfx.BLEND_ONE_MINUS_SRC_ALPHA; var blendColor = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 0xffffffff; var passIdx = arguments.length > 8 ? arguments[8] : undefined; _setBlend.call(this, enabled, blendEq, blendSrc, blendDst, blendAlphaEq, blendSrcAlpha, blendDstAlpha, blendColor, passIdx); this._nativeObj.setBlend(enabled, blendEq, blendSrc, blendDst, blendAlphaEq, blendSrcAlpha, blendDstAlpha, blendColor, passIdx === undefined ? -1 : passIdx); }, setDepth: function setDepth(depthTest, depthWrite, depthFunc, passIdx) { _setDepth.call(this, depthTest, depthWrite, depthFunc, passIdx); this._nativeObj.setDepth(depthTest, depthWrite, depthFunc, passIdx === undefined ? -1 : passIdx); }, setStencilEnabled: function setStencilEnabled(enabled, passIdx) { _setStencilEnabled.call(this, enabled, passIdx); this._nativeObj.setStencilTest(enabled, passIdx === undefined ? -1 : passIdx); }, setStencil: function setStencil() { var enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : gfx.STENCIL_INHERIT; var stencilFunc = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : gfx.DS_FUNC_ALWAYS; var stencilRef = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; var stencilMask = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0xff; var stencilFailOp = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : gfx.STENCIL_OP_KEEP; var stencilZFailOp = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : gfx.STENCIL_OP_KEEP; var stencilZPassOp = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : gfx.STENCIL_OP_KEEP; var stencilWriteMask = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 0xff; var passIdx = arguments.length > 8 ? arguments[8] : undefined; _setStencil.call(this, enabled, stencilFunc, stencilRef, stencilMask, stencilFailOp, stencilZFailOp, stencilZPassOp, stencilWriteMask, passIdx); this._nativeObj.setStencil(stencilFunc, stencilRef, stencilMask, stencilFailOp, stencilZFailOp, stencilZPassOp, stencilWriteMask, passIdx === undefined ? -1 : passIdx); }, define: function define(name, value, passIdx, force) { _define.call(this, name, value, passIdx, force); this._nativeObj.define(name, value, passIdx === undefined ? -1 : passIdx); }, updateHash: function updateHash(hash) { this._nativeObj.updateHash(hash); }, setProperty: function setProperty(name, val, passIdx, directly) { _setProperty.call(this, name, val, passIdx); var prop = this.getProperty(name); if (prop !== undefined) { this._nativeObj.setProperty(name, prop, passIdx === undefined ? -1 : passIdx, directly); } } }); },{}],30:[function(require,module,exports){ "use strict"; /**************************************************************************** Copyright (c) 2018 Xiamen Yaji Software Co., Ltd. http://www.cocos.com Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated engine source code (the "Software"), a limited, worldwide, royalty-free, non-assignable, revocable and non-exclusive license to use Cocos Creator solely to develop games on your target platforms. You shall not use Cocos Creator software for developing other software or tools that's used for developing games. You are not granted to publish, distribute, sublicense, and/or sell copies of Cocos Creator. The software or tools in this License Agreement are licensed, not sold. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ cc.game.restart = function () { // Need to clear scene, or native object destructor won't be invoke. cc.director.getScene().destroy(); cc.Object._deferredDestroy(); __restartVM(); }; jsb.onPause = function () { cc.game.emit(cc.game.EVENT_HIDE); }; jsb.onResume = function () { cc.game.emit(cc.game.EVENT_SHOW); }; function resize(size) { // size should be the css style size.width /= cc.view._devicePixelRatio; size.height /= cc.view._devicePixelRatio; window.resize(size.width, size.height); } jsb.onResize = function (size) { if (size.width === 0 || size.height === 0) return; // getSafeAreaEdge is asynchronous on iOS, so callback later is required if (CC_JSB && cc.sys.os === cc.sys.OS_IOS) { var edges = jsb.Device.getSafeAreaEdge(); var hasSafeArea = edges.x > 0 || edges.y > 0 || edges.z > 0 || edges.w > 0; if (hasSafeArea) { setTimeout(function () { if (cc.Vec4.strictEquals(edges, jsb.Device.getSafeAreaEdge())) { setTimeout(resize, 200, size); } else { resize(size); } }, 0); return; } } resize(size); }; },{}],31:[function(require,module,exports){ /**************************************************************************** Copyright (c) 2013-2016 Chukong Technologies Inc. Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. http://www.cocos.com Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated engine source code (the "Software"), a limited, worldwide, royalty-free, non-assignable, revocable and non-exclusive license to use Cocos Creator solely to develop games on your target platforms. You shall not use Cocos Creator software for developing other software or tools that's used for developing games. You are not granted to publish, distribute, sublicense, and/or sell copies of Cocos Creator. The software or tools in this License Agreement are licensed, not sold. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ 'use strict'; var jsbUtils = require('./jsb-utils'); function downloadScript(item, callback) { require(item.url); return null; } var mediaDownloader = new jsb.Downloader(); var mediaUrlMap = {}; // key: url, value: { loadingItem, callback } mediaDownloader.setOnFileTaskSuccess(function (task) { var _mediaUrlMap$task$req = mediaUrlMap[task.requestURL], item = _mediaUrlMap$task$req.item, callback = _mediaUrlMap$task$req.callback; if (!(item && callback)) { return; } item.url = task.storagePath; item.rawUrl = task.storagePath; callback(null, item); delete mediaUrlMap[task.requestURL]; }); mediaDownloader.setOnTaskError(function (task, errorCode, errorCodeInternal, errorStr) { var callback = mediaUrlMap[task.requestURL].callback; callback && callback(errorStr, null); delete mediaUrlMap[task.requestURL]; }); function downloadMedia(item, callback) { if (/^http/.test(item.url)) { var fileName = jsbUtils.murmurhash2_32_gc(item.url) + cc.path.extname(item.url); var storagePath = jsb.fileUtils.getWritablePath() + fileName; // load from local cache if (jsb.fileUtils.isFileExist(storagePath)) { item.url = storagePath; item.rawUrl = storagePath; callback && callback(null, item); } // download remote media file else { mediaUrlMap[item.url] = { item: item, callback: callback }; mediaDownloader.createDownloadFileTask(item.url, storagePath); } // Don't return anything to use async loading. } else { return item.url; } } function loadAudio(item, callback) { var loadByDeserializedAsset = item._owner instanceof cc.AudioClip; if (loadByDeserializedAsset) { return item.url; } else { var audioClip = new cc.AudioClip(); // obtain user url through nativeUrl audioClip._setRawAsset(item.rawUrl, false); // obtain download url through _nativeAsset audioClip._nativeAsset = item.url; return audioClip; } } function downloadImage(item, callback) { var img = new Image(); img.src = item.url; img.onload = function (info) { callback(null, img); }; img.onerror = function (event) { callback(new Error('load image fail:' + img.src), null); }; // Don't return anything to use async loading. } function _getFontFamily(fontHandle) { var ttfIndex = fontHandle.lastIndexOf(".ttf"); if (ttfIndex === -1) return fontHandle; var slashPos = fontHandle.lastIndexOf("/"); var fontFamilyName; if (slashPos === -1) { fontFamilyName = fontHandle.substring(0, ttfIndex) + "_LABEL"; } else { fontFamilyName = fontHandle.substring(slashPos + 1, ttfIndex) + "_LABEL"; } if (fontFamilyName.indexOf(' ') !== -1) { fontFamilyName = '"' + fontFamilyName + '"'; } return fontFamilyName; } function downloadText(item) { var url = item.url; var result = jsb.fileUtils.getStringFromFile(url); if (typeof result === 'string' && result) { return result; } else { return new Error('Download text failed: ' + url); } } function downloadBinary(item) { var url = item.url; var result = jsb.fileUtils.getDataFromFile(url); if (result) { return result; } else { return new Error('Download binary file failed: ' + url); } } function loadFont(item, callback) { var url = item.url; var fontFamilyName = _getFontFamily(url); var fontFace = new FontFace(fontFamilyName, "url('" + url + "')"); document.fonts.add(fontFace); fontFace.load(); fontFace.loaded.then(function () { callback(null, fontFamilyName); }, function () { cc.warnID(4933, fontFamilyName); callback(null, fontFamilyName); }); } function loadCompressedTex(item) { return item.content; } cc.loader.addDownloadHandlers({ // JS 'js': downloadScript, 'jsc': downloadScript, // Images 'png': downloadImage, 'jpg': downloadImage, 'bmp': downloadImage, 'jpeg': downloadImage, 'gif': downloadImage, 'ico': downloadImage, 'tiff': downloadImage, 'webp': downloadImage, 'image': downloadImage, 'pvr': downloadImage, 'pkm': downloadImage, // Audio 'mp3': downloadMedia, 'ogg': downloadMedia, 'wav': downloadMedia, 'm4a': downloadMedia, // Video 'mp4': downloadMedia, 'avi': downloadMedia, 'mov': downloadMedia, 'mpg': downloadMedia, 'mpeg': downloadMedia, 'rm': downloadMedia, 'rmvb': downloadMedia, // Text 'txt': downloadText, 'xml': downloadText, 'vsh': downloadText, 'fsh': downloadText, 'atlas': downloadText, 'tmx': downloadText, 'tsx': downloadText, 'json': downloadText, 'ExportJson': downloadText, 'plist': downloadText, 'fnt': downloadText, 'binary': downloadBinary, 'bin': downloadBinary, 'dbbin': downloadBinary, 'skel': downloadBinary, 'default': downloadText }); cc.loader.addLoadHandlers({ // Font 'font': loadFont, 'eot': loadFont, 'ttf': loadFont, 'woff': loadFont, 'svg': loadFont, 'ttc': loadFont, // Audio 'mp3': loadAudio, 'ogg': loadAudio, 'wav': loadAudio, 'm4a': loadAudio, // compressed texture 'pvr': loadCompressedTex, 'pkm': loadCompressedTex }); },{"./jsb-utils":38}],32:[function(require,module,exports){ "use strict"; /**************************************************************************** Copyright (c) 2018 Xiamen Yaji Software Co., Ltd. http://www.cocos.com Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated engine source code (the "Software"), a limited, worldwide, royalty-free, non-assignable, revocable and non-exclusive license to use Cocos Creator solely to develop games on your target platforms. You shall not use Cocos Creator software for developing other software or tools that's used for developing games. You are not granted to publish, distribute, sublicense, and/or sell copies of Cocos Creator. The software or tools in this License Agreement are licensed, not sold. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ (function () { if (window.middleware === undefined) return; var ParticleSystem = cc.ParticleSystem; if (ParticleSystem === undefined) return; var PSProto = ParticleSystem.prototype; PSProto.initProperties = function () { this._simulator = new middleware.ParticleSimulator(); this._previewTimer = null; this._focused = false; this._texture = null; this._renderData = null; this._simulator.__particleSystem__ = this; this._simulator.setFinishedCallback(function () { var self = this.__particleSystem__; self._finishedSimulation(); }); this._simulator.setStopCallback(function () { var self = this.__particleSystem__; self.stopSystem(); }); this._initProperties(); }; // value type properties var propertiesList = ["positionType", "emissionRate", "totalParticles", "duration", "emitterMode", "life", "lifeVar", "startSize", "startSizeVar", "endSize", "endSizeVar", "startSpin", "startSpinVar", "endSpin", "endSpinVar", "angle", "angleVar", "speed", "speedVar", "radialAccel", "radialAccelVar", "tangentialAccel", "tangentialAccelVar", "rotationIsDir", "startRadius", "startRadiusVar", "endRadius", "endRadiusVar", "rotatePerS", "rotatePerSVar"]; propertiesList.forEach(function (getSetName) { var varName = "_" + getSetName; Object.defineProperty(PSProto, getSetName, { get: function get() { this[varName] === undefined && (this[varName] = 0); return this[varName]; }, set: function set(val) { this[varName] = val; this._simulator && (this._simulator[getSetName] = val); } }); }); // object type properties var objPropList = ['gravity', 'sourcePos', 'posVar', 'startColor', 'startColorVar', 'endColor', 'endColorVar']; PSProto._initProperties = function () { // init properties for (var key in propertiesList) { var propName = propertiesList[key]; this[propName] = this[propName]; } for (var _key in objPropList) { var _propName = objPropList[_key]; this[_propName] = this[_propName]; } }, Object.defineProperty(PSProto, 'gravity', { get: function get() { !this._gravity && (this._gravity = cc.v2(0, 0)); return this._gravity; }, set: function set(val) { if (!val) return; !this._gravity && (this._gravity = cc.v2(0, 0)); this.gravity.x = val.x; this.gravity.y = val.y; this._simulator && this._simulator.setGravity(val.x, val.y, 0); } }); Object.defineProperty(PSProto, 'sourcePos', { get: function get() { !this._sourcePos && (this._sourcePos = cc.v2(0, 0)); return this._sourcePos; }, set: function set(val) { if (!val) return; !this._sourcePos && (this._sourcePos = cc.v2(0, 0)); this._sourcePos.x = val.x; this._sourcePos.y = val.y; this._simulator && this._simulator.setSourcePos(val.x, val.y, 0); } }); Object.defineProperty(PSProto, 'posVar', { get: function get() { !this._posVar && (this._posVar = cc.v2(0, 0)); return this._posVar; }, set: function set(val) { if (!val) return; !this._posVar && (this._posVar = cc.v2(0, 0)); this._posVar.x = val.x; this._posVar.y = val.y; this._simulator && this._simulator.setPosVar(val.x, val.y, 0); } }); Object.defineProperty(PSProto, 'startColor', { get: function get() { !this._startColor && (this._startColor = cc.color(255, 255, 255, 255)); return this._startColor; }, set: function set(val) { if (!val) return; !this._startColor && (this._startColor = cc.color(255, 255, 255, 255)); this._startColor.r = val.r; this._startColor.g = val.g; this._startColor.b = val.b; this._startColor.a = val.a; this._simulator && this._simulator.setStartColor(val.r, val.g, val.b, val.a); } }); Object.defineProperty(PSProto, 'startColorVar', { get: function get() { !this._startColorVar && (this._startColorVar = cc.color(0, 0, 0, 0)); return this._startColorVar; }, set: function set(val) { if (!val) return; !this._startColorVar && (this._startColorVar = cc.color(0, 0, 0, 0)); this._startColorVar.r = val.r; this._startColorVar.g = val.g; this._startColorVar.b = val.b; this._startColorVar.a = val.a; this._simulator && this._simulator.setStartColorVar(val.r, val.g, val.b, val.a); } }); Object.defineProperty(PSProto, 'endColor', { get: function get() { !this._endColor && (this._endColor = cc.color(255, 255, 255, 0)); return this._endColor; }, set: function set(val) { if (!val) return; !this._endColor && (this._endColor = cc.color(255, 255, 255, 0)); this._endColor.r = val.r; this._endColor.g = val.g; this._endColor.b = val.b; this._endColor.a = val.a; this._simulator && this._simulator.setEndColor(val.r, val.g, val.b, val.a); } }); Object.defineProperty(PSProto, 'endColorVar', { get: function get() { !this._endColorVar && (this._endColorVar = cc.color(0, 0, 0, 0)); return this._endColorVar; }, set: function set(val) { if (!val) return; !this._endColorVar && (this._endColorVar = cc.color(0, 0, 0, 0)); this._endColorVar.r = val.r; this._endColorVar.g = val.g; this._endColorVar.b = val.b; this._endColorVar.a = val.a; this._simulator && this._simulator.setEndColorVar(val.r, val.g, val.b, val.a); } }); Object.defineProperty(PSProto, 'particleCount', { get: function get() { if (!this._simulator) { return 0; } return this._simulator.getParticleCount(); } }); Object.defineProperty(PSProto, 'active', { get: function get() { if (!this._simulator) { return false; } return this._simulator.active(); } }); PSProto.onLoad = function () { this._simulator.bindNodeProxy(this.node._proxy); }; // shield in native PSProto.update = null; PSProto.lateUpdate = null; PSProto._resetAssembler = function () { this._assembler = new renderer.CustomAssembler(); this._assembler.setUseModel(true); this.node._proxy.setAssembler(this._assembler); }; var _onEnable = PSProto.onEnable; PSProto.onEnable = function () { _onEnable.call(this); if (this._simulator) { this._simulator.onEnable(); } }; var _onDisable = PSProto.onDisable; PSProto.onDisable = function () { _onDisable.call(this); if (this._simulator) { this._simulator.onDisable(); } }; PSProto._onTextureLoaded = function () { this._simulator.updateUVs(this._renderSpriteFrame.uv); this._syncAspect(); this._simulator.aspectRatio = this._aspectRatio || 1.0; this._updateMaterial(); this.markForRender(true); }; var _updateMaterial = PSProto._updateMaterial; PSProto._updateMaterial = function () { _updateMaterial.call(this); var material = this._materials[0]; material && this._simulator.setEffect(material.effect._nativeObj); }; var _initWithDictionary = PSProto._initWithDictionary; PSProto._initWithDictionary = function (content) { _initWithDictionary.call(this, content); this._initProperties(); }; var __preload = PSProto.__preload; PSProto.__preload = function () { __preload.call(this); this._initProperties(); }; })(); },{}],33:[function(require,module,exports){ "use strict"; /**************************************************************************** Copyright (c) 2018 Xiamen Yaji Software Co., Ltd. http://www.cocos.com Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated engine source code (the "Software"), a limited, worldwide, royalty-free, non-assignable, revocable and non-exclusive license to use Cocos Creator solely to develop games on your target platforms. You shall not use Cocos Creator software for developing other software or tools that's used for developing games. You are not granted to publish, distribute, sublicense, and/or sell copies of Cocos Creator. The software or tools in this License Agreement are licensed, not sold. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ // JS to Native bridges if (window.JavascriptJavaBridge && cc.sys.os == cc.sys.OS_ANDROID) { jsb.reflection = new JavascriptJavaBridge(); cc.sys.capabilities["keyboard"] = true; } else if (window.JavaScriptObjCBridge && (cc.sys.os == cc.sys.OS_IOS || cc.sys.os == cc.sys.OS_OSX)) { jsb.reflection = new JavaScriptObjCBridge(); } },{}],34:[function(require,module,exports){ "use strict"; (function () { if (!cc.SkinnedMeshRenderer) return; var SkinnedMeshAssembler = cc.SkinnedMeshRenderer.__assembler__.prototype; cc.js.mixin(SkinnedMeshAssembler, { updateRenderData: function updateRenderData(comp) { comp.calcJointMatrix(); comp.node._renderFlag |= cc.RenderFlow.FLAG_UPDATE_RENDER_DATA; } }); })(); },{}],35:[function(require,module,exports){ "use strict"; /**************************************************************************** Copyright (c) 2018 Xiamen Yaji Software Co., Ltd. http://www.cocos.com Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated engine source code (the "Software"), a limited, worldwide, royalty-free, non-assignable, revocable and non-exclusive license to use Cocos Creator solely to develop games on your target platforms. You shall not use Cocos Creator software for developing other software or tools that's used for developing games. You are not granted to publish, distribute, sublicense, and/or sell copies of Cocos Creator. The software or tools in this License Agreement are licensed, not sold. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ (function () { if (window.sp === undefined || window.spine === undefined || window.middleware === undefined) return; sp.VertexEffectDelegate = spine.VertexEffectDelegate; jsb.generateGetSet(spine); // spine global time scale Object.defineProperty(sp, 'timeScale', { get: function get() { return this._timeScale; }, set: function set(value) { this._timeScale = value; spine.SkeletonAnimation.setGlobalTimeScale(value); }, configurable: true }); var _slotColor = cc.color(0, 0, 255, 255); var _boneColor = cc.color(255, 0, 0, 255); var _meshColor = cc.color(255, 255, 0, 255); var _originColor = cc.color(0, 255, 0, 255); var skeletonDataProto = sp.SkeletonData.prototype; var _gTextureIdx = 1; var _textureKeyMap = {}; var _textureMap = new WeakMap(); var skeletonDataMgr = spine.SkeletonDataMgr.getInstance(); spine.skeletonDataMgr = skeletonDataMgr; skeletonDataMgr.setDestroyCallback(function (textureIndex) { if (!textureIndex) return; var texKey = _textureKeyMap[textureIndex]; if (texKey && _textureMap.has(texKey)) { _textureMap["delete"](texKey); delete _textureKeyMap[textureIndex]; } }); var skeletonCacheMgr = spine.SkeletonCacheMgr.getInstance(); spine.skeletonCacheMgr = skeletonCacheMgr; skeletonDataProto.destroy = function () { this.reset(); skeletonCacheMgr.removeSkeletonCache(this._uuid); cc.Asset.prototype.destroy.call(this); }; skeletonDataProto.reset = function () { if (this._skeletonCache) { spine.disposeSkeletonData(this._uuid); this._jsbTextures = null; this._skeletonCache = null; } this._atlasCache = null; }; skeletonDataProto.getRuntimeData = function () { if (!this._skeletonCache) { this.init(); } return this._skeletonCache; }; skeletonDataProto.init = function () { if (this._skeletonCache) return; var uuid = this._uuid; if (!uuid) { cc.errorID(7504); return; } var skeletonCache = spine.retainSkeletonData(uuid); if (skeletonCache) { this._skeletonCache = skeletonCache; return; } var atlasText = this.atlasText; if (!atlasText) { cc.errorID(7508, this.name); return; } var textures = this.textures; var textureNames = this.textureNames; if (!(textures && textures.length > 0 && textureNames && textureNames.length > 0)) { cc.errorID(7507, this.name); return; } var jsbTextures = {}; for (var i = 0; i < textures.length; ++i) { var texture = textures[i]; var textureIdx = this.recordTexture(texture); var spTex = new middleware.Texture2D(); spTex.setRealTextureIndex(textureIdx); spTex.setPixelsWide(texture.width); spTex.setPixelsHigh(texture.height); spTex.setTexParamCallback(function (texIdx, minFilter, magFilter, wrapS, warpT) { var tex = this.getTextureByIndex(texIdx); tex.setFilters(minFilter, magFilter); tex.setWrapMode(wrapS, warpT); }.bind(this)); spTex.setNativeTexture(texture.getImpl()); jsbTextures[textureNames[i]] = spTex; } this._jsbTextures = jsbTextures; var filePath = null; if (this.skeletonJsonStr) { filePath = this.skeletonJsonStr; } else { filePath = cc.loader.md5Pipe ? cc.loader.md5Pipe.transformURL(this.nativeUrl) : this.nativeUrl; } this._skeletonCache = spine.initSkeletonData(uuid, filePath, atlasText, jsbTextures, this.scale); }; skeletonDataProto.recordTexture = function (texture) { var index = _gTextureIdx; var texKey = _textureKeyMap[index] = { key: index }; _textureMap.set(texKey, texture); _gTextureIdx++; return index; }; skeletonDataProto.getTextureByIndex = function (textureIdx) { var texKey = _textureKeyMap[textureIdx]; if (!texKey) return; return _textureMap.get(texKey); }; var renderCompProto = cc.RenderComponent.prototype; var animation = spine.SkeletonAnimation.prototype; // The methods are added to be compatibility with old versions. animation.setCompleteListener = function (listener) { this._compeleteListener = listener; this.setCompleteListenerNative(function (trackEntry) { var loopCount = Math.floor(trackEntry.trackTime / trackEntry.animationEnd); this._compeleteListener && this._compeleteListener(trackEntry, loopCount); }); }; // The methods are added to be compatibility with old versions. animation.setTrackCompleteListener = function (trackEntry, listener) { this._trackCompeleteListener = listener; this.setTrackCompleteListenerNative(trackEntry, function (trackEntryNative) { var loopCount = Math.floor(trackEntryNative.trackTime / trackEntryNative.animationEnd); this._trackCompeleteListener && this._trackCompeleteListener(trackEntryNative, loopCount); }); }; // Temporary solution before upgrade the Spine API animation.setAnimationListener = function (target, callback) { this._target = target; this._callback = callback; this.setStartListener(function (trackEntry) { if (this._target && this._callback) { this._callback.call(this._target, this, trackEntry, sp.AnimationEventType.START, null, 0); } }); this.setInterruptListener(function (trackEntry) { if (this._target && this._callback) { this._callback.call(this._target, this, trackEntry, sp.AnimationEventType.INTERRUPT, null, 0); } }); this.setEndListener(function (trackEntry) { if (this._target && this._callback) { this._callback.call(this._target, this, trackEntry, sp.AnimationEventType.END, null, 0); } }); this.setDisposeListener(function (trackEntry) { if (this._target && this._callback) { this._callback.call(this._target, this, trackEntry, sp.AnimationEventType.DISPOSE, null, 0); } }); this.setCompleteListener(function (trackEntry, loopCount) { if (this._target && this._callback) { this._callback.call(this._target, this, trackEntry, sp.AnimationEventType.COMPLETE, null, loopCount); } }); this.setEventListener(function (trackEntry, event) { if (this._target && this._callback) { this._callback.call(this._target, this, trackEntry, sp.AnimationEventType.EVENT, event, 0); } }); }; sp.Skeleton._assembler = null; var skeleton = sp.Skeleton.prototype; var AnimationCacheMode = sp.Skeleton.AnimationCacheMode; Object.defineProperty(skeleton, 'paused', { get: function get() { return this._paused || false; }, set: function set(value) { this._paused = value; if (this._nativeSkeleton) { this._nativeSkeleton.paused(value); } } }); Object.defineProperty(skeleton, "premultipliedAlpha", { get: function get() { if (this._premultipliedAlpha === undefined) { return true; } return this._premultipliedAlpha; }, set: function set(value) { this._premultipliedAlpha = value; if (this._nativeSkeleton) { this._nativeSkeleton.setOpacityModifyRGB(this._premultipliedAlpha); } } }); Object.defineProperty(skeleton, "timeScale", { get: function get() { if (this._timeScale === undefined) return 1.0; return this._timeScale; }, set: function set(value) { this._timeScale = value; if (this._nativeSkeleton) { this._nativeSkeleton.setTimeScale(this._timeScale); } } }); var _updateDebugDraw = skeleton._updateDebugDraw; skeleton._updateDebugDraw = function () { _updateDebugDraw.call(this); if (this._nativeSkeleton && !this.isAnimationCached()) { this._nativeSkeleton.setDebugMeshEnabled(this.debugMesh); this._nativeSkeleton.setDebugSlotsEnabled(this.debugSlots); this._nativeSkeleton.setDebugBonesEnabled(this.debugBones); } }; var _updateUseTint = skeleton._updateUseTint; skeleton._updateUseTint = function () { _updateUseTint.call(this); if (this._nativeSkeleton) { this._nativeSkeleton.setUseTint(this.useTint); } this._assembler && this._assembler.clearEffect(); }; var _updateBatch = skeleton._updateBatch; skeleton._updateBatch = function () { _updateBatch.call(this); if (this._nativeSkeleton) { this._nativeSkeleton.setBatchEnabled(this.enableBatch); } this._assembler && this._assembler.clearEffect(); }; var _onLoad = skeleton.onLoad; skeleton.onLoad = function () { if (_onLoad) { _onLoad.call(this); } }; skeleton._resetAssembler = function () { this._assembler = new renderer.CustomAssembler(); this.node._proxy.setAssembler(this._assembler); }; var _updateMaterial = skeleton._updateMaterial; var _materialHashMap = {}; var _materialId = 1; skeleton._updateMaterial = function () { _updateMaterial.call(this); this._assembler && this._assembler.clearEffect(); var baseMaterial = this.getMaterial(0); if (this._nativeSkeleton && baseMaterial) { var originHash = baseMaterial.effect.getHash(); var id = _materialHashMap[originHash] || _materialId++; _materialHashMap[originHash] = id; baseMaterial.effect.updateHash(id); var nativeEffect = baseMaterial.effect._nativeObj; this._nativeSkeleton.setEffect(nativeEffect); } }; skeleton.setSkeletonData = function (skeletonData) { null != skeletonData.width && null != skeletonData.height && this.node.setContentSize(skeletonData.width, skeletonData.height); var uuid = skeletonData._uuid; if (!uuid) { cc.errorID(7504); return; } var texValues = skeletonData.textures; var texKeys = skeletonData.textureNames; if (!(texValues && texValues.length > 0 && texKeys && texKeys.length > 0)) { cc.errorID(7507, skeletonData.name); return; } if (this._nativeSkeleton) { this._nativeSkeleton.stopSchedule(); this._nativeSkeleton._comp = null; this._nativeSkeleton = null; } var nativeSkeleton = null; if (this.isAnimationCached()) { nativeSkeleton = new spine.SkeletonCacheAnimation(uuid, this._cacheMode == AnimationCacheMode.SHARED_CACHE); } else { nativeSkeleton = new spine.SkeletonAnimation(); try { spine.initSkeletonRenderer(nativeSkeleton, uuid); } catch (e) { cc._throw(e); return; } nativeSkeleton.setDebugSlotsEnabled(this.debugSlots); nativeSkeleton.setDebugMeshEnabled(this.debugMesh); nativeSkeleton.setDebugBonesEnabled(this.debugBones); } this._nativeSkeleton = nativeSkeleton; nativeSkeleton._comp = this; nativeSkeleton.setUseTint(this.useTint); nativeSkeleton.setOpacityModifyRGB(this.premultipliedAlpha); nativeSkeleton.setTimeScale(this.timeScale); nativeSkeleton.setBatchEnabled(this.enableBatch); nativeSkeleton.bindNodeProxy(this.node._proxy); nativeSkeleton.setColor(this.node.color); this._skeleton = nativeSkeleton.getSkeleton(); // init skeleton listener this._startListener && this.setStartListener(this._startListener); this._endListener && this.setEndListener(this._endListener); this._completeListener && this.setCompleteListener(this._completeListener); this._eventListener && this.setEventListener(this._eventListener); this._interruptListener && this.setInterruptListener(this._interruptListener); this._disposeListener && this.setDisposeListener(this._disposeListener); this._updateMaterial(); this.markForRender(true); }; skeleton._updateColor = function () { if (this._nativeSkeleton) { this._nativeSkeleton.setColor(this.node.color); } }; skeleton.setAnimationStateData = function (stateData) { if (this._nativeSkeleton && !this.isAnimationCached()) { this._stateData = stateData; return this._nativeSkeleton.setAnimationStateData(stateData); } }; skeleton.onEnable = function () { renderCompProto.onEnable.call(this); if (this._nativeSkeleton) { this._nativeSkeleton.onEnable(); } }; skeleton.onDisable = function () { renderCompProto.onDisable.call(this); if (this._nativeSkeleton) { this._nativeSkeleton.onDisable(); } }; skeleton.setVertexEffectDelegate = function (effectDelegate) { if (this._nativeSkeleton && !this.isAnimationCached()) { this._nativeSkeleton.setVertexEffectDelegate(effectDelegate); } }; skeleton.update = function () { var nativeSkeleton = this._nativeSkeleton; if (!nativeSkeleton) return; var node = this.node; if (!node) return; if (!this.isAnimationCached() && (this.debugBones || this.debugSlots || this.debugMesh) && this._debugRenderer) { var graphics = this._debugRenderer; graphics.clear(); graphics.lineWidth = 2; var debugData = this._debugData || nativeSkeleton.getDebugData(); if (!debugData) return; var debugIdx = 0, debugType = 0, debugLen = 0; while (true) { debugType = debugData[debugIdx++]; if (debugType == 0) break; debugLen = debugData[debugIdx++]; switch (debugType) { case 1: // slots graphics.strokeColor = _slotColor; for (var i = 0; i < debugLen; i += 8) { graphics.moveTo(debugData[debugIdx++], debugData[debugIdx++]); graphics.lineTo(debugData[debugIdx++], debugData[debugIdx++]); graphics.lineTo(debugData[debugIdx++], debugData[debugIdx++]); graphics.lineTo(debugData[debugIdx++], debugData[debugIdx++]); graphics.close(); graphics.stroke(); } break; case 2: // mesh graphics.strokeColor = _meshColor; for (var _i = 0; _i < debugLen; _i += 6) { graphics.moveTo(debugData[debugIdx++], debugData[debugIdx++]); graphics.lineTo(debugData[debugIdx++], debugData[debugIdx++]); graphics.lineTo(debugData[debugIdx++], debugData[debugIdx++]); graphics.close(); graphics.stroke(); } break; case 3: // bones graphics.strokeColor = _boneColor; graphics.fillColor = _slotColor; // Root bone color is same as slot color. for (var _i2 = 0; _i2 < debugLen; _i2 += 4) { var bx = debugData[debugIdx++]; var by = debugData[debugIdx++]; var x = debugData[debugIdx++]; var y = debugData[debugIdx++]; // Bone lengths. graphics.moveTo(bx, by); graphics.lineTo(x, y); graphics.stroke(); // Bone origins. graphics.circle(bx, by, Math.PI * 1.5); graphics.fill(); if (_i2 === 0) { graphics.fillColor = _originColor; } } break; default: return; } } } }; skeleton.updateWorldTransform = function () { if (this._nativeSkeleton && !this.isAnimationCached()) { this._nativeSkeleton.updateWorldTransform(); } }; skeleton.setToSetupPose = function () { if (this._nativeSkeleton) { this._nativeSkeleton.setToSetupPose(); } }; skeleton.setBonesToSetupPose = function () { if (this._nativeSkeleton) { this._nativeSkeleton.setBonesToSetupPose(); } }; skeleton.setSlotsToSetupPose = function () { if (this._nativeSkeleton) { this._nativeSkeleton.setSlotsToSetupPose(); } }; skeleton.setSlotsRange = function (startSlotIndex, endSlotIndex) { if (this._nativeSkeleton && !this.isAnimationCached()) { this._nativeSkeleton.setSlotsRange(startSlotIndex, endSlotIndex); } }; skeleton.updateAnimationCache = function (animName) { if (!this.isAnimationCached()) return; if (this._nativeSkeleton) { if (animName) { this._nativeSkeleton.updateAnimationCache(animName); } else { this._nativeSkeleton.updateAllAnimationCache(); } } }; skeleton.invalidAnimationCache = function () { if (!this.isAnimationCached()) return; if (this._nativeSkeleton) { this._nativeSkeleton.updateAllAnimationCache(); } }; skeleton.findBone = function (boneName) { if (this._nativeSkeleton) return this._nativeSkeleton.findBone(boneName); return null; }; skeleton.findSlot = function (slotName) { if (this._nativeSkeleton) return this._nativeSkeleton.findSlot(slotName); return null; }; skeleton.setSkin = function (skinName) { if (this._nativeSkeleton) return this._nativeSkeleton.setSkin(skinName); return null; }; skeleton.getAttachment = function (slotName, attachmentName) { if (this._nativeSkeleton) return this._nativeSkeleton.getAttachment(slotName, attachmentName); return null; }; skeleton.setAttachment = function (slotName, attachmentName) { this._nativeSkeleton && this._nativeSkeleton.setAttachment(slotName, attachmentName); }; skeleton.getTextureAtlas = function (regionAttachment) { cc.warn("sp.Skeleton getTextureAtlas not support in native"); return null; }; skeleton.setMix = function (fromAnimation, toAnimation, duration) { if (this._nativeSkeleton && !this.isAnimationCached()) { this._nativeSkeleton.setMix(fromAnimation, toAnimation, duration); } }; skeleton.setAnimation = function (trackIndex, name, loop) { if (this._nativeSkeleton) { if (this.isAnimationCached()) { return this._nativeSkeleton.setAnimation(name, loop); } else { return this._nativeSkeleton.setAnimation(trackIndex, name, loop); } } return null; }; skeleton.addAnimation = function (trackIndex, name, loop, delay) { if (this._nativeSkeleton) { delay = delay || 0; if (this.isAnimationCached()) { return this._nativeSkeleton.addAnimation(name, loop, delay); } else { return this._nativeSkeleton.addAnimation(trackIndex, name, loop, delay); } } return null; }; skeleton.findAnimation = function (name) { if (this._nativeSkeleton) return this._nativeSkeleton.findAnimation(name); return null; }; skeleton.getCurrent = function (trackIndex) { if (this._nativeSkeleton && !this.isAnimationCached()) { return this._nativeSkeleton.getCurrent(trackIndex); } return null; }; skeleton.clearTracks = function () { if (this._nativeSkeleton && !this.isAnimationCached()) { this._nativeSkeleton.clearTracks(); } }; skeleton.clearTrack = function (trackIndex) { if (this._nativeSkeleton && !this.isAnimationCached()) { this._nativeSkeleton.clearTrack(trackIndex); } }; skeleton.setStartListener = function (listener) { this._startListener = listener; if (this._nativeSkeleton) { if (this.isAnimationCached()) { this._nativeSkeleton.setStartListener(function (animationName) { var self = this._comp; self._startEntry.animation.name = animationName; self._startListener && self._startListener(self._startEntry); }); } else { this._nativeSkeleton.setStartListener(listener); } } }; skeleton.setInterruptListener = function (listener) { this._interruptListener = listener; if (this._nativeSkeleton && !this.isAnimationCached()) { this._nativeSkeleton.setInterruptListener(listener); } }; skeleton.setEndListener = function (listener) { this._endListener = listener; if (this._nativeSkeleton) { if (this.isAnimationCached()) { this._nativeSkeleton.setEndListener(function (animationName) { var self = this._comp; self._endEntry.animation.name = animationName; self._endListener && self._endListener(self._endEntry); }); } else { this._nativeSkeleton.setEndListener(listener); } } }; skeleton.setDisposeListener = function (listener) { this._disposeListener = listener; if (this._nativeSkeleton && !this.isAnimationCached()) { this._nativeSkeleton.setDisposeListener(listener); } }; skeleton.setCompleteListener = function (listener) { this._completeListener = listener; if (this._nativeSkeleton) { if (this.isAnimationCached()) { this._nativeSkeleton.setCompleteListener(function (animationName) { var self = this._comp; self._endEntry.animation.name = animationName; self._completeListener && self._completeListener(self._endEntry); }); } else { this._nativeSkeleton.setCompleteListener(listener); } } }; skeleton.setEventListener = function (listener) { this._eventListener = listener; if (this._nativeSkeleton && !this.isAnimationCached()) { this._nativeSkeleton.setEventListener(listener); } }; skeleton.setTrackStartListener = function (entry, listener) { if (this._nativeSkeleton && !this.isAnimationCached()) { this._nativeSkeleton.setTrackStartListener(entry, listener); } }; skeleton.setTrackInterruptListener = function (entry, listener) { if (this._nativeSkeleton && !this.isAnimationCached()) { this._nativeSkeleton.setTrackInterruptListener(entry, listener); } }; skeleton.setTrackEndListener = function (entry, listener) { if (this._nativeSkeleton && !this.isAnimationCached()) { this._nativeSkeleton.setTrackEndListener(entry, listener); } }; skeleton.setTrackDisposeListener = function (entry, listener) { if (this._nativeSkeleton && !this.isAnimationCached()) { this._nativeSkeleton.setTrackDisposeListener(entry, listener); } }; skeleton.setTrackCompleteListener = function (entry, listener) { if (this._nativeSkeleton && !this.isAnimationCached()) { this._nativeSkeleton.setTrackCompleteListener(entry, listener); } }; skeleton.setTrackEventListener = function (entry, listener) { if (this._nativeSkeleton && !this.isAnimationCached()) { this._nativeSkeleton.setTrackEventListener(entry, listener); } }; skeleton.getState = function () { if (this._nativeSkeleton && !this.isAnimationCached()) { return this._nativeSkeleton.getState(); } }; skeleton._ensureListener = function () { cc.warn("sp.Skeleton _ensureListener not need in native"); }; skeleton._updateSkeletonData = function () { if (this.skeletonData) { this.skeletonData.init(); this.setSkeletonData(this.skeletonData); this.attachUtil.init(this); this.attachUtil._associateAttachedNode(); this._preCacheMode = this._cacheMode; this.defaultSkin && this._nativeSkeleton.setSkin(this.defaultSkin); this.animation = this.defaultAnimation; } else { if (this._nativeSkeleton) { this._nativeSkeleton.stopSchedule(); this._nativeSkeleton._comp = null; this._nativeSkeleton = null; } } }; var _onDestroy = skeleton.onDestroy; skeleton.onDestroy = function () { _onDestroy.call(this); if (this._nativeSkeleton) { this._nativeSkeleton.stopSchedule(); this._nativeSkeleton._comp = null; this._nativeSkeleton = null; } this._stateData = null; this._materialCache = null; }; //////////////////////////////////////////////////////////// // adapt attach util //////////////////////////////////////////////////////////// var attachUtilProto = sp.AttachUtil.prototype; var _attachUtilInit = attachUtilProto.init; attachUtilProto.init = function (skeletonComp) { _attachUtilInit.call(this, skeletonComp); this._nativeSkeleton = skeletonComp._nativeSkeleton; this._attachUtilNative = null; }; var _generateAllAttachedNodes = attachUtilProto.generateAllAttachedNodes; attachUtilProto.generateAllAttachedNodes = function () { var res = _generateAllAttachedNodes.call(this); this._associateAttachedNode(); return res; }; var _generateAttachedNodes = attachUtilProto.generateAttachedNodes; attachUtilProto.generateAttachedNodes = function (boneName) { var res = _generateAttachedNodes.call(this, boneName); this._associateAttachedNode(); return res; }; var _associateAttachedNode = attachUtilProto._associateAttachedNode; attachUtilProto._associateAttachedNode = function () { if (!this._inited) return; var rootNode = this._skeletonNode.getChildByName('ATTACHED_NODE_TREE'); if (!rootNode || !rootNode.isValid) return; // associate js _associateAttachedNode.call(this); // associate native if (!this._attachUtilNative) { if (this._skeletonComp.isAnimationCached()) { this._attachUtilNative = new spine.CacheModeAttachUtil(); } else { this._attachUtilNative = new spine.RealTimeAttachUtil(); } this._nativeSkeleton.setAttachUtil(this._attachUtilNative); } this._attachUtilNative.associateAttachedNode(this._skeleton, this._skeletonNode._proxy); }; })(); },{}],36:[function(require,module,exports){ /**************************************************************************** Copyright (c) 2013-2016 Chukong Technologies Inc. Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. http://www.cocos.com Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated engine source code (the "Software"), a limited, worldwide, royalty-free, non-assignable, revocable and non-exclusive license to use Cocos Creator solely to develop games on your target platforms. You shall not use Cocos Creator software for developing other software or tools that's used for developing games. You are not granted to publish, distribute, sublicense, and/or sell copies of Cocos Creator. The software or tools in this License Agreement are licensed, not sold. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ 'use strict'; var sys = cc.sys; sys.getNetworkType = jsb.Device.getNetworkType; sys.getBatteryLevel = jsb.Device.getBatteryLevel; sys.garbageCollect = jsb.garbageCollect; sys.restartVM = __restartVM; sys.isObjectValid = __isObjectValid; sys.getSafeAreaRect = function () { // x(top), y(left), z(bottom), w(right) var edge = jsb.Device.getSafeAreaEdge(); var screenSize = cc.view.getFrameSize(); // Get leftBottom and rightTop point in UI coordinates var leftBottom = new cc.Vec2(edge.y, screenSize.height - edge.z); var rightTop = new cc.Vec2(screenSize.width - edge.w, edge.x); // Returns the real location in view. var relatedPos = { left: 0, top: 0, width: screenSize.width, height: screenSize.height }; cc.view.convertToLocationInView(leftBottom.x, leftBottom.y, relatedPos, leftBottom); cc.view.convertToLocationInView(rightTop.x, rightTop.y, relatedPos, rightTop); // convert view point to design resolution size cc.view._convertPointWithScale(leftBottom); cc.view._convertPointWithScale(rightTop); return cc.rect(leftBottom.x, leftBottom.y, rightTop.x - leftBottom.x, rightTop.y - leftBottom.y); }; },{}],37:[function(require,module,exports){ "use strict"; /**************************************************************************** Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. https://www.cocos.com/ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated engine source code (the "Software"), a limited, worldwide, royalty-free, non-assignable, revocable and non-exclusive license to use Cocos Creator solely to develop games on your target platforms. You shall not use Cocos Creator software for developing other software or tools that's used for developing games. You are not granted to publish, distribute, sublicense, and/or sell copies of Cocos Creator. The software or tools in this License Agreement are licensed, not sold. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ (function () { if (!cc.TiledMap) return; var RenderFlow = cc.RenderFlow; // tiled layer var TiledLayer = cc.TiledLayer.prototype; var _addUserNode = TiledLayer.addUserNode; TiledLayer.addUserNode = function (node) { var result = _addUserNode.call(this, node); if (result) { var proxy = node._proxy; proxy && proxy.enableVisit(false); } }; var _removeUserNode = TiledLayer.removeUserNode; TiledLayer.removeUserNode = function (node) { var result = _removeUserNode.call(this, node); if (result) { var proxy = node._proxy; proxy && proxy.enableVisit(true); } }; // override _activateMaterial to upload hash value to native var _activateMaterial = TiledLayer._activateMaterial; TiledLayer._activateMaterial = function () { _activateMaterial.call(this); var materials = this._materials; for (var i = 0; i < materials.length; i++) { var m = materials[i]; if (m) m.getHash(); } }; // tiledmap buffer var TiledMapBuffer = cc.TiledMapBuffer.prototype; TiledMapBuffer._updateOffset = function () { var offsetInfo = this._offsetInfo; offsetInfo.vertexOffset = this.vertexOffset; offsetInfo.indiceOffset = this.indiceOffset; offsetInfo.byteOffset = this.byteOffset; }; // tiledmap render data list var TiledMapRenderDataList = cc.TiledMapRenderDataList.prototype; TiledMapRenderDataList._pushRenderData = function () { var renderData = {}; renderData.ia = {}; renderData.nodesRenderList = []; this._dataList.push(renderData); }; TiledMapRenderDataList.reset = function () { this._offset = 0; var assembler = this._nativeAssembler; assembler._effect.length = 0; assembler.reset(); }; TiledMapRenderDataList.setNativeAssembler = function (assembler) { this._nativeAssembler = assembler; }; TiledMapRenderDataList.popRenderData = function (buffer) { if (this._offset >= this._dataList.length) { this._pushRenderData(); } var renderData = this._dataList[this._offset]; renderData.nodesRenderList.length = 0; this._nativeAssembler.clearNodes(this._offset); var ia = renderData.ia; ia._meshIndex = buffer.getCurMeshIndex(); ia._start = buffer.indiceOffset; ia._count = 0; ia._verticesStart = buffer.vertexOffset; ia._index = this._offset; this._offset++; return renderData; }; TiledMapRenderDataList.pushNodesList = function (renderData, nodesList) { var nodesRenderList = renderData.nodesRenderList; nodesRenderList.push(nodesList); var nativeNodes = []; for (var j = 0; j < nodesRenderList.length; j++) { var _nodesList = nodesRenderList[j]; if (!_nodesList) continue; for (var idx = 0; idx < _nodesList.length; idx++) { var dataComp = _nodesList[idx]; if (!dataComp) continue; nativeNodes.push(dataComp.node._id); } } this._nativeAssembler.updateNodes(renderData.ia._index, nativeNodes); }; var ModelBatcherDelegate = cc.Class({ ctor: function ctor() { this._nativeAssembler = null; }, setNativeAssembler: function setNativeAssembler(assembler) { this._nativeAssembler = assembler; }, setBuffer: function setBuffer(buffer) { this._buffer = buffer; }, _flushIA: function _flushIA(ia) { var iaIndex = ia._index; var meshIndex = ia._meshIndex; this._nativeAssembler.updateMeshIndex(iaIndex, meshIndex); var verticesStart = ia._verticesStart; var verticesOffset = this._buffer.vertexOffset; var vertexCount = verticesOffset - verticesStart; this._nativeAssembler.updateVerticesRange(iaIndex, verticesStart, vertexCount); this._nativeAssembler.updateIndicesRange(iaIndex, ia._start, ia._count); this._nativeAssembler.updateMaterial(iaIndex, this.material); }, _flush: function _flush() {} }); var TiledMapAssembler = cc.TiledLayer.__assembler__.prototype; var _fillBuffers = TiledMapAssembler.fillBuffers; cc.js.mixin(TiledMapAssembler, { _extendNative: function _extendNative() { renderer.TiledMapAssembler.prototype.ctor.call(this); }, // override _updateRenderData function avoid base class cover material _updateRenderData: function _updateRenderData() { if (!this._renderComp || !this._renderComp.isValid) return; this.updateRenderData(this._renderComp); }, updateRenderData: function updateRenderData(comp) { if (!comp._modelBatcherDelegate) { comp._buffer = new cc.TiledMapBuffer(null, cc.gfx.VertexFormat.XY_UV_Color); comp._renderDataList = new cc.TiledMapRenderDataList(); comp._modelBatcherDelegate = new ModelBatcherDelegate(); comp._buffer.setNativeAssembler(this); comp._renderDataList.setNativeAssembler(this); comp._modelBatcherDelegate.setBuffer(comp._buffer); comp._modelBatcherDelegate.setNativeAssembler(this); } _fillBuffers.call(this, comp, comp._modelBatcherDelegate); comp.node._renderFlag |= RenderFlow.FLAG_UPDATE_RENDER_DATA; } }, renderer.TiledMapAssembler.prototype); })(); },{}],38:[function(require,module,exports){ "use strict"; var jsbUtils = { /**************************************************************************** Copyright (c) 2011 Gary Court http://github.com/garycourt/murmurhash-js Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ murmurhash2_32_gc: function murmurhash2_32_gc(str, seed) { var l = str.length, h = seed ^ l, i = 0, k; while (l >= 4) { k = str.charCodeAt(i) & 0xff | (str.charCodeAt(++i) & 0xff) << 8 | (str.charCodeAt(++i) & 0xff) << 16 | (str.charCodeAt(++i) & 0xff) << 24; k = (k & 0xffff) * 0x5bd1e995 + (((k >>> 16) * 0x5bd1e995 & 0xffff) << 16); k ^= k >>> 24; k = (k & 0xffff) * 0x5bd1e995 + (((k >>> 16) * 0x5bd1e995 & 0xffff) << 16); h = (h & 0xffff) * 0x5bd1e995 + (((h >>> 16) * 0x5bd1e995 & 0xffff) << 16) ^ k; l -= 4; ++i; } switch (l) { case 3: h ^= (str.charCodeAt(i + 2) & 0xff) << 16; case 2: h ^= (str.charCodeAt(i + 1) & 0xff) << 8; case 1: h ^= str.charCodeAt(i) & 0xff; h = (h & 0xffff) * 0x5bd1e995 + (((h >>> 16) * 0x5bd1e995 & 0xffff) << 16); } h ^= h >>> 13; h = (h & 0xffff) * 0x5bd1e995 + (((h >>> 16) * 0x5bd1e995 & 0xffff) << 16); h ^= h >>> 15; return h >>> 0; } }; module.exports = jsbUtils; },{}],39:[function(require,module,exports){ "use strict"; /**************************************************************************** Copyright (c) 2018 Xiamen Yaji Software Co., Ltd. http://www.cocos.com Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated engine source code (the "Software"), a limited, worldwide, royalty-free, non-assignable, revocable and non-exclusive license to use Cocos Creator solely to develop games on your target platforms. You shall not use Cocos Creator software for developing other software or tools that's used for developing games. You are not granted to publish, distribute, sublicense, and/or sell copies of Cocos Creator. The software or tools in this License Agreement are licensed, not sold. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ var nativeCameraProto = renderer.Camera.prototype; var _setNode = nativeCameraProto.setNode; cc.js.mixin(nativeCameraProto, { setNode: function setNode(node) { this._persistentNode = node; _setNode.call(this, node); } }); },{}],40:[function(require,module,exports){ "use strict"; /**************************************************************************** Copyright (c) 2018 Xiamen Yaji Software Co., Ltd. http://www.cocos.com Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated engine source code (the "Software"), a limited, worldwide, royalty-free, non-assignable, revocable and non-exclusive license to use Cocos Creator solely to develop games on your target platforms. You shall not use Cocos Creator software for developing other software or tools that's used for developing games. You are not granted to publish, distribute, sublicense, and/or sell copies of Cocos Creator. The software or tools in this License Agreement are licensed, not sold. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ var nativeLightProto = renderer.Light.prototype; var _setNode = nativeLightProto.setNode; cc.js.mixin(nativeLightProto, { setNode: function setNode(node) { this._node = node; _setNode.call(this, node); } }); },{}],41:[function(require,module,exports){ "use strict"; /**************************************************************************** Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. https://www.cocos.com/ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated engine source code (the "Software"), a limited, worldwide, royalty-free, non-assignable, revocable and non-exclusive license to use Cocos Creator solely to develop games on your target platforms. You shall not use Cocos Creator software for developing other software or tools that's used for developing games. You are not granted to publish, distribute, sublicense, and/or sell copies of Cocos Creator. The software or tools in this License Agreement are licensed, not sold. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ (function () { if (!cc.MeshBuffer) return; var MeshBuffer = cc.MeshBuffer.prototype; MeshBuffer.init = function (batcher, vertexFormat) { this.byteOffset = 0; this.indiceOffset = 0; this.vertexOffset = 0; this._vertexFormat = vertexFormat; this._vertexBytes = this._vertexFormat._bytes; this._vDatas = []; this._uintVDatas = []; this._iDatas = []; this._arrOffset = 0; this._vData = null; this._uintVData = null; this._iData = null; this._initVDataCount = 256 * vertexFormat._bytes; // actually 256 * 4 * (vertexFormat._bytes / 4) this._initIDataCount = 256 * 6; this._offsetInfo = { byteOffset: 0, vertexOffset: 0, indiceOffset: 0 }; this._renderDataList = new renderer.RenderDataList(); this._reallocBuffer(); }; MeshBuffer.setNativeAssembler = function (assembler) { if (assembler !== this._nativeAssembler) { this._nativeAssembler = assembler; assembler.setRenderDataList(this._renderDataList); } }; MeshBuffer._updateVIDatas = function () { var offset = this._arrOffset; this._vDatas[offset] = this._vData; this._uintVDatas[offset] = this._uintVData; this._iDatas[offset] = this._iData; this._renderDataList.updateMesh(offset, this._vData, this._iData); }; MeshBuffer.getNativeAssembler = function () { return this._nativeAssembler; }; MeshBuffer.getCurMeshIndex = function () { return this._arrOffset; }; MeshBuffer.uploadData = function () {}; MeshBuffer.switchBuffer = function () { var offset = ++this._arrOffset; this.byteOffset = 0; this.vertexOffset = 0; this.indiceOffset = 0; if (offset < this._vDatas.length) { this._vData = this._vDatas[offset]; this._uintVData = this._uintVDatas[offset]; this._iData = this._iDatas[offset]; } else { this._reallocBuffer(); } }; MeshBuffer.checkAndSwitchBuffer = function (vertexCount) { if (this.vertexOffset + vertexCount > 65535) { this.switchBuffer(); if (!this._nativeAssembler) return; this._nativeAssembler.updateIADatas && this._nativeAssembler.updateIADatas(this._arrOffset, this._arrOffset); } }; MeshBuffer.used = function (vertexCount, indiceCount) { if (!this._nativeAssembler) return; this._nativeAssembler.updateVerticesRange(this._arrOffset, 0, vertexCount); this._nativeAssembler.updateIndicesRange(this._arrOffset, 0, indiceCount); }; MeshBuffer.request = function (vertexCount, indiceCount) { this.requestStatic(vertexCount, indiceCount); return this._offsetInfo; }; MeshBuffer._reallocBuffer = function () { this._reallocVData(true); this._reallocIData(true); this._updateVIDatas(); }; MeshBuffer._reallocVData = function (copyOldData) { var oldVData; if (this._vData) { oldVData = new Uint8Array(this._vData.buffer); } this._vData = new Float32Array(this._initVDataCount); this._uintVData = new Uint32Array(this._vData.buffer); var newData = new Uint8Array(this._uintVData.buffer); if (oldVData && copyOldData) { for (var i = 0, l = oldVData.length; i < l; i++) { newData[i] = oldVData[i]; } } }; MeshBuffer._reallocIData = function (copyOldData) { var oldIData = this._iData; this._iData = new Uint16Array(this._initIDataCount); if (oldIData && copyOldData) { var iData = this._iData; for (var i = 0, l = oldIData.length; i < l; i++) { iData[i] = oldIData[i]; } } }; MeshBuffer.reset = function () { this._arrOffset = 0; this._vData = this._vDatas[0]; this._uintVData = this._uintVDatas[0]; this._iData = this._iDatas[0]; this.byteOffset = 0; this.indiceOffset = 0; this.vertexOffset = 0; if (!this._nativeAssembler) return; for (var i = 0, len = this._vDatas.length; i < len; i++) { this._nativeAssembler.updateVerticesRange(i, 0, 0); this._nativeAssembler.updateIndicesRange(i, 0, 0); } }; MeshBuffer.destroy = function () { this.reset(); }; })(); },{}],42:[function(require,module,exports){ "use strict"; /**************************************************************************** Copyright (c) 2018 Xiamen Yaji Software Co., Ltd. http://www.cocos.com Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated engine source code (the "Software"), a limited, worldwide, royalty-free, non-assignable, revocable and non-exclusive license to use Cocos Creator solely to develop games on your target platforms. You shall not use Cocos Creator software for developing other software or tools that's used for developing games. You are not granted to publish, distribute, sublicense, and/or sell copies of Cocos Creator. The software or tools in this License Agreement are licensed, not sold. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ var RenderFlow = cc.RenderFlow; cc.js.mixin(renderer.NodeProxy.prototype, { _ctor: function _ctor() { this._owner = null; }, init: function init(owner) { this._owner = owner; var spaceInfo = owner._spaceInfo; this._owner._dirtyPtr = spaceInfo.dirty; this._dirtyPtr = spaceInfo.dirty; this._parentPtr = spaceInfo.parent; this._zOrderPtr = spaceInfo.zOrder; this._cullingMaskPtr = spaceInfo.cullingMask; this._opacityPtr = spaceInfo.opacity; this._is3DPtr = spaceInfo.is3D; this._skewPtr = spaceInfo.skew; this._isVisitingTraversal = false; owner._proxy = this; this.updateOpacity(); this.update3DNode(); this.updateZOrder(); this.updateCullingMask(); this.updateSkew(); owner.on(cc.Node.EventType.SIBLING_ORDER_CHANGED, this.updateZOrder, this); }, initNative: function initNative() { this.setName(this._owner._name); this.updateParent(); this.updateOpacity(); this.update3DNode(); this.updateZOrder(); this.updateSkew(); this.updateCullingMask(); }, destroy: function destroy() { this.destroyImmediately(); this._owner.off(cc.Node.EventType.SIBLING_ORDER_CHANGED, this.updateZOrder, this); this._owner._proxy = null; this._owner = null; }, updateParent: function updateParent() { var parent = this._owner._parent; if (parent) { var parentSpaceInfo = parent._spaceInfo; this._parentPtr[0] = parentSpaceInfo.unitID; this._parentPtr[1] = parentSpaceInfo.index; var parentDirtyPtr = parentSpaceInfo.dirty; parentDirtyPtr[0] |= RenderFlow.FLAG_REORDER_CHILDREN; this._dirtyPtr[0] |= RenderFlow.FLAG_OPACITY; } else { this._parentPtr[0] = 0xffffffff; this._parentPtr[1] = 0xffffffff; } this.notifyUpdateParent(); }, updateZOrder: function updateZOrder() { this._zOrderPtr[0] = this._owner._localZOrder; var parent = this._owner._parent; if (parent && parent._proxy) { parent._proxy._dirtyPtr[0] |= RenderFlow.FLAG_REORDER_CHILDREN; } }, updateCullingMask: function updateCullingMask() { this._cullingMaskPtr[0] = this._owner._cullingMask; }, updateOpacity: function updateOpacity() { this._opacityPtr[0] = this._owner.opacity; this._dirtyPtr[0] |= RenderFlow.FLAG_OPACITY; }, update3DNode: function update3DNode() { this._is3DPtr[0] = this._owner.is3DNode ? 0x1 : 0x0; this._dirtyPtr[0] |= RenderFlow.FLAG_LOCAL_TRANSFORM; }, updateSkew: function updateSkew() { var skewPtr = this._skewPtr; var owner = this._owner; var skx = owner._skewX; var sky = owner._skewY; skewPtr[0] = skx; skewPtr[1] = sky; if (!this._isVisitingTraversal && (skx !== 0 || sky !== 0)) { this.switchTraverseToVisit(); this._isVisitingTraversal = true; } } }); },{}],43:[function(require,module,exports){ /**************************************************************************** Copyright (c) 2018 Xiamen Yaji Software Co., Ltd. http://www.cocos.com Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated engine source code (the "Software"), a limited, worldwide, royalty-free, non-assignable, revocable and non-exclusive license to use Cocos Creator solely to develop games on your target platforms. You shall not use Cocos Creator software for developing other software or tools that's used for developing games. You are not granted to publish, distribute, sublicense, and/or sell copies of Cocos Creator. The software or tools in this License Agreement are licensed, not sold. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ 'use strict'; var RenderFlow = cc.RenderFlow; var LOCAL_TRANSFORM = RenderFlow.FLAG_LOCAL_TRANSFORM; var COLOR = RenderFlow.FLAG_COLOR; var UPDATE_RENDER_DATA = RenderFlow.FLAG_UPDATE_RENDER_DATA; var POSITION_ON = 1 << 0; cc.Node.prototype.setLocalDirty = function (flag) { this._localMatDirty |= flag; this._worldMatDirty = true; this._dirtyPtr[0] |= RenderFlow.FLAG_TRANSFORM; }; cc.js.getset(cc.Node.prototype, "_renderFlag", function () { return this._dirtyPtr[0]; }, function (flag) { this._dirtyPtr[0] = flag; if (flag & UPDATE_RENDER_DATA || flag & COLOR) { cc.RenderFlow.register(this); } }); cc.PrivateNode.prototype._posDirty = function (sendEvent) { var parent = this.parent; if (parent) { // Position correction for transform calculation this._trs[0] = this._originPos.x - (parent._anchorPoint.x - 0.5) * parent._contentSize.width; this._trs[1] = this._originPos.y - (parent._anchorPoint.y - 0.5) * parent._contentSize.height; } this.setLocalDirty(cc.Node._LocalDirtyFlag.POSITION); if (sendEvent === true && this._eventMask & POSITION_ON) { this.emit(cc.Node.EventType.POSITION_CHANGED); } }; },{}],44:[function(require,module,exports){ "use strict"; /**************************************************************************** Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. https://www.cocos.com/ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated engine source code (the "Software"), a limited, worldwide, royalty-free, non-assignable, revocable and non-exclusive license to use Cocos Creator solely to develop games on your target platforms. You shall not use Cocos Creator software for developing other software or tools that's used for developing games. You are not granted to publish, distribute, sublicense, and/or sell copies of Cocos Creator. The software or tools in this License Agreement are licensed, not sold. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ (function () { if (!cc.QuadBuffer) return; var QuadBuffer = cc.QuadBuffer.prototype; QuadBuffer._fillQuadBuffer = function () { var count = this._initIDataCount / 6; var buffer = this._iData; for (var i = 0, idx = 0; i < count; i++) { var vertextID = i * 4; buffer[idx++] = vertextID; buffer[idx++] = vertextID + 1; buffer[idx++] = vertextID + 2; buffer[idx++] = vertextID + 1; buffer[idx++] = vertextID + 3; buffer[idx++] = vertextID + 2; } }; QuadBuffer._reallocBuffer = function () { this._reallocVData(true); this._reallocIData(); this._fillQuadBuffer(); this._updateVIDatas(); }; QuadBuffer.uploadData = function () {}; QuadBuffer.switchBuffer = function () { cc.MeshBuffer.prototype.switchBuffer.call(this); }; })(); },{}],45:[function(require,module,exports){ "use strict"; var proto = cc.RenderData.prototype; cc.RenderData.prototype.init = function (assembler) { this._renderDataList = new renderer.RenderDataList(); assembler.setRenderDataList(this._renderDataList); this._nativeAssembler = assembler; }; var originClear = proto.clear; proto.clear = function () { originClear.call(this); this._renderDataList.clear(); }; var originUpdateMesh = proto.updateMesh; proto.updateMesh = function (meshIndex, vertices, indices) { originUpdateMesh.call(this, meshIndex, vertices, indices); if (vertices && indices) { this._renderDataList.updateMesh(meshIndex, vertices, indices); } }; proto.updateMeshRange = function (verticesCount, indicesCount) { this._nativeAssembler.updateVerticesRange(0, 0, verticesCount); this._nativeAssembler.updateIndicesRange(0, 0, indicesCount); }; },{}],46:[function(require,module,exports){ "use strict"; /**************************************************************************** Copyright (c) 2018 Xiamen Yaji Software Co., Ltd. http://www.cocos.com Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated engine source code (the "Software"), a limited, worldwide, royalty-free, non-assignable, revocable and non-exclusive license to use Cocos Creator solely to develop games on your target platforms. You shall not use Cocos Creator software for developing other software or tools that's used for developing games. You are not granted to publish, distribute, sublicense, and/or sell copies of Cocos Creator. The software or tools in this License Agreement are licensed, not sold. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ var RenderFlow = cc.RenderFlow; RenderFlow.FLAG_REORDER_CHILDREN = 1 << 29; RenderFlow.FLAG_WORLD_TRANSFORM_CHANGED = 1 << 30; RenderFlow.FLAG_OPACITY_CHANGED = 1 << 31; var _dirtyTargets = []; var _dirtyWaiting = []; var _rendering = false; var director = cc.director; RenderFlow.render = function (scene) { _rendering = true; RenderFlow.validateRenderers(); for (var i = 0, l = _dirtyTargets.length; i < l; i++) { var node = _dirtyTargets[i]; node._inJsbDirtyList = false; var comp = node._renderComponent; if (!comp) continue; var assembler = comp._assembler; if (!assembler) continue; var flag = node._dirtyPtr[0]; if (flag & RenderFlow.FLAG_UPDATE_RENDER_DATA) { node._dirtyPtr[0] &= ~RenderFlow.FLAG_UPDATE_RENDER_DATA; assembler._updateRenderData && assembler._updateRenderData(); } if (flag & RenderFlow.FLAG_COLOR) { node._dirtyPtr[0] &= ~RenderFlow.FLAG_COLOR; comp._updateColor && comp._updateColor(); } } _dirtyTargets.length = 0; this._nativeFlow.render(scene._proxy, director._deltaTime); _dirtyTargets = _dirtyWaiting.slice(0); _dirtyWaiting.length = 0; _rendering = false; }; RenderFlow.init = function (nativeFlow) { cc.EventTarget.call(this); this._nativeFlow = nativeFlow; }; RenderFlow.register = function (target) { if (target._inJsbDirtyList) return; if (_rendering) { _dirtyWaiting.push(target); } else { _dirtyTargets.push(target); } target._inJsbDirtyList = true; }; },{}]},{},[24]);