(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 delegate.maxLength) { res.value = res.value.slice(0, delegate.maxLength); } if (delegate._string !== res.value) { delegate.editBoxTextChanged(res.value); } } function onComplete(res) { self.endEditing(); jsb.inputBox.offConfirm(onConfirm); jsb.inputBox.offInput(onInput); jsb.inputBox.offComplete(onComplete); } jsb.inputBox.onInput(onInput); jsb.inputBox.onConfirm(onConfirm); jsb.inputBox.onComplete(onComplete); if (!cc.sys.isMobile) { this._delegate._hideLabels(); } jsb.inputBox.show({ defaultValue: delegate._string, maxLength: delegate.maxLength, multiple: multiline, confirmHold: false, confirmType: getKeyboardReturnType(delegate.returnType), inputType: inputTypeString, originX: rect.x, originY: rect.y, width: rect.width, height: rect.height }); this._editing = true; delegate.editBoxEditingDidBegan(); }, endEditing: function endEditing() { this._editing = false; if (!cc.sys.isMobile) { this._delegate._showLabels(); } jsb.inputBox.hide(); this._delegate.editBoxEditingDidEnded(); }, _getRect: function _getRect() { var node = this._delegate.node, scaleX = cc.view._scaleX, scaleY = cc.view._scaleY; var dpr = cc.view._devicePixelRatio; var math = cc.vmath; var matrix = math.mat4.create(); node.getWorldMatrix(matrix); var contentSize = node._contentSize; var vec3 = cc.v3(); vec3.x = -node._anchorPoint.x * contentSize.width; vec3.y = -node._anchorPoint.y * contentSize.height; math.mat4.translate(matrix, matrix, vec3); scaleX /= dpr; scaleY /= dpr; var finalScaleX = matrix.m00 * scaleX; var finaleScaleY = matrix.m05 * scaleY; var viewportRect = cc.view._viewportRect; return { x: matrix.m12 * finalScaleX + viewportRect.x, y: matrix.m13 * finaleScaleY + viewportRect.y, width: contentSize.width * finalScaleX, height: contentSize.height * finaleScaleY }; } }); })(); },{}],6:[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 gfx = cc.gfx; var middlewareMgr = middleware.MiddlewareManager.getInstance(); var director = cc.director; director.on(cc.Director.EVENT_BEFORE_DRAW, function () { middlewareMgr.update(director._deltaTime); }); var MiddlewareIA = cc.Class({ ctor: function ctor() { var tempFormat = gfx.VertexFormat.XY_UV_Color; this._vertexBuffer = { _format: tempFormat, _usage: gfx.USAGE_DYNAMIC, _glID: { _id: 0 } }; this._indexBuffer = { _format: gfx.INDEX_FMT_UINT16, _usage: gfx.USAGE_STATIC, _glID: { _id: 0 }, _bytesPerIndex: 2 }; this._primitiveType = gfx.PT_TRIANGLES; this._start = 0; this.count = -1; }, setVertexFormat: function setVertexFormat(format) { this._vertexBuffer._format = format; }, setGLIBID: function setGLIBID(glIBID) { this._indexBuffer._glID._id = glIBID; }, setGLVBID: function setGLVBID(glVBID) { this._vertexBuffer._glID._id = glVBID; } }); middleware.MiddlewareIA = MiddlewareIA; var renderInfoMgr = middleware.RenderInfoMgr.getInstance(); middleware.renderInfoMgr = renderInfoMgr; renderInfoMgr.renderInfo = renderInfoMgr.getRenderInfo(); renderInfoMgr.__middleware__ = middleware; renderInfoMgr.setResizeCallback(function () { this.renderInfo = this.getRenderInfo(); }); })(); },{}],7:[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 () { __restartVM(); }; jsb.onHide = function () { cc.game.emit(cc.game.EVENT_HIDE); }; jsb.onShow = function () { cc.game.emit(cc.game.EVENT_SHOW); }; jsb.onResize = function (size) { if (size.width === 0 || size.height === 0) return; window.resize(size.width, size.height); cc.view.setCanvasSize(window.innerWidth, window.innerHeight); }; },{}],8:[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'; function downloadScript(item, callback) { require(item.url); return null; } var audioDownloader = new jsb.Downloader(); var audioUrlMap = {}; // key: url, value: { loadingItem, callback } audioDownloader.setOnFileTaskSuccess(function (task) { var _audioUrlMap$task$req = audioUrlMap[task.requestURL], item = _audioUrlMap$task$req.item, callback = _audioUrlMap$task$req.callback; if (!(item && callback)) { return; } item.url = task.storagePath; item.rawUrl = task.storagePath; callback(null, item); delete audioUrlMap[task.requestURL]; }); audioDownloader.setOnTaskError(function (task, errorCode, errorCodeInternal, errorStr) { var callback = audioUrlMap[task.requestURL].callback; callback && callback(errorStr, null); delete audioUrlMap[task.requestURL]; }); function downloadAudio(item, callback) { if (/^http/.test(item.url)) { var index = item.url.lastIndexOf('/'); var fileName = item.url.substr(index + 1); 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 audio else { audioUrlMap[item.url] = { item: item, callback: callback }; audioDownloader.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); }; // 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': downloadAudio, 'ogg': downloadAudio, 'wav': downloadAudio, 'mp4': downloadAudio, 'm4a': downloadAudio, // 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, '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, 'mp4': loadAudio, 'm4a': loadAudio, // compressed texture 'pvr': loadCompressedTex, 'pkm': loadCompressedTex }); },{}],9:[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 math = cc.vmath; var _typedArray_temp = new Float32Array(16); var _mat4_temp = math.mat4.create(); function _mat4ToArray(typedArray, mat4) { typedArray[0] = mat4.m00; typedArray[1] = mat4.m01; typedArray[2] = mat4.m02; typedArray[3] = mat4.m03; typedArray[4] = mat4.m04; typedArray[5] = mat4.m05; typedArray[6] = mat4.m06; typedArray[7] = mat4.m07; typedArray[8] = mat4.m08; typedArray[9] = mat4.m09; typedArray[10] = mat4.m10; typedArray[11] = mat4.m11; typedArray[12] = mat4.m12; typedArray[13] = mat4.m13; typedArray[14] = mat4.m14; typedArray[15] = mat4.m15; } cc.Node.prototype.getWorldRTInAB = function () { this.getWorldRT(_mat4_temp); _mat4ToArray(_typedArray_temp, _mat4_temp); return _typedArray_temp; }; cc.Node.prototype.getWorldMatrixInAB = function () { this._updateWorldMatrix(); _mat4ToArray(_typedArray_temp, this._worldMatrix); return _typedArray_temp; }; },{}],10:[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(); } },{}],11:[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; var Skeleton = sp.Skeleton; var gfx = cc.gfx; var VertexFormat = gfx.VertexFormat; var assembler = Skeleton._assembler; var _slotColor = cc.color(0, 0, 255, 255); var _boneColor = cc.color(255, 0, 0, 255); var _originColor = cc.color(0, 255, 0, 255); var _getSlotMaterial = function _getSlotMaterial(comp, tex, src, dst) { var key = tex.url + src + dst; var baseMaterial = comp.sharedMaterials[0]; if (!baseMaterial) return null; var materialCache = comp._materialCache; var material = materialCache[key]; if (!material) { var baseKey = baseMaterial._hash; if (!materialCache[baseKey]) { material = baseMaterial; } else { material = new cc.Material(); material.copy(baseMaterial); } material.define('_USE_MODEL', true); material.define('USE_TINT', comp.useTint); material.setProperty('texture', tex); // update blend function var pass = material.effect.getDefaultTechnique().passes[0]; pass.setBlend(true, gfx.BLEND_FUNC_ADD, src, dst, gfx.BLEND_FUNC_ADD, src, dst); material.updateHash(key); materialCache[key] = material; } else if (material.getProperty('texture') !== tex) { material.setProperty('texture', tex); material.updateHash(key); materialCache[key] = material; } return material; }; // native enable useModel assembler.useModel = true; assembler.genRenderDatas = function (comp, batchData) {}; assembler.updateRenderData = function (comp, batchData) {}; assembler.renderIA = function (comp, renderer) { var nativeSkeleton = comp._skeleton; if (!nativeSkeleton) return; var node = comp.node; if (!node) return; var renderInfoOffset = comp._renderInfoOffset; if (!renderInfoOffset) return; var iaPool = comp._iaPool; var poolIdx = 0; var infoOffset = renderInfoOffset[0]; renderInfoOffset[0] = 0; var renderInfoMgr = middleware.renderInfoMgr; var renderInfo = renderInfoMgr.renderInfo; var materialIdx = 0, realTextureIndex = void 0, realTexture = void 0; // verify render border var border = renderInfo[infoOffset + materialIdx++]; if (border !== 0xffffffff) return; var matLen = renderInfo[infoOffset + materialIdx++]; var useTint = comp.useTint; if (matLen == 0) return; for (var index = 0; index < matLen; index++) { realTextureIndex = renderInfo[infoOffset + materialIdx++]; realTexture = comp.skeletonData.textures[realTextureIndex]; if (!realTexture) return; var material = _getSlotMaterial(comp, realTexture, renderInfo[infoOffset + materialIdx++], renderInfo[infoOffset + materialIdx++]); var glIB = renderInfo[infoOffset + materialIdx++]; var glVB = renderInfo[infoOffset + materialIdx++]; var indiceOffset = renderInfo[infoOffset + materialIdx++]; var segmentCount = renderInfo[infoOffset + materialIdx++]; var ia = iaPool[poolIdx]; if (!ia) { ia = new middleware.MiddlewareIA(); iaPool[poolIdx] = ia; } ia._start = indiceOffset; ia.count = segmentCount; ia.setVertexFormat(useTint ? VertexFormat.XY_UV_Two_Color : VertexFormat.XY_UV_Color); ia.setGLIBID(glIB); ia.setGLVBID(glVB); poolIdx++; comp._iaRenderData.ia = ia; comp._iaRenderData.material = material; renderer._flushIA(comp._iaRenderData); } if ((comp.debugBones || comp.debugSlots) && comp._debugRenderer) { var graphics = comp._debugRenderer; graphics.clear(); comp._debugData = comp._debugData || nativeSkeleton.getDebugData(); var debugData = comp._debugData; var debugIdx = 0; if (comp.debugSlots) { // Debug Slot graphics.strokeColor = _slotColor; graphics.lineWidth = 5; var debugSlotsLen = debugData[debugIdx++]; for (var i = 0; i < debugSlotsLen; 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(); } } if (comp.debugBones) { graphics.lineWidth = 5; graphics.strokeColor = _boneColor; graphics.fillColor = _slotColor; // Root bone color is same as slot color. var debugBonesLen = debugData[debugIdx++]; for (var _i = 0; _i < debugBonesLen; _i += 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 * 2); graphics.fill(); if (_i === 0) { graphics.fillColor = _originColor; } } } } }; })(); },{}],12:[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; // spine global time scale Object.defineProperty(sp, 'timeScale', { get: function get() { return this._timeScale; }, set: function set(value) { this._timeScale = value; spine.SpineAnimation.setGlobalTimeScale(value); }, configurable: true }); var skeletonDataProto = sp.SkeletonData.prototype; skeletonDataProto.destroy = function () { this._jsbTextures = null; spine.disposeSkeletonData(this._uuid); cc.Asset.prototype.destroy.call(this); }; skeletonDataProto.init = function () { if (this._inited) return; var uuid = this._uuid; if (!uuid) { cc.errorID(7504); return; } var atlasText = this.atlasText; if (!atlasText) { cc.errorID(7508, this.name); return; } var texValues = this.textures; var texKeys = this.textureNames; if (!(texValues && texValues.length > 0 && texKeys && texKeys.length > 0)) { cc.errorID(7507, this.name); return; } var jsbTextures = {}; for (var i = 0; i < texValues.length; ++i) { var spTex = new middleware.Texture2D(); spTex.setRealTextureIndex(i); spTex.setPixelsWide(texValues[i].width); spTex.setPixelsHigh(texValues[i].height); spTex.setTexParamCallback(function (texIdx, minFilter, magFilter, wrapS, warpT) { texValues[texIdx].setFilters(minFilter, magFilter); texValues[texIdx].setWrapMode(wrapS, warpT); }.bind(this)); jsbTextures[texKeys[i]] = spTex; } this._jsbTextures = jsbTextures; spine.initSkeletonData(uuid, this.skeletonJsonStr, atlasText, jsbTextures, this.scale); this._inited = true; }; var RenderFlow = cc.RenderFlow; var renderer = cc.renderer; var renderEngine = renderer.renderEngine; var renderCompProto = cc.RenderComponent.prototype; var animation = spine.SpineAnimation.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(trackEntry, 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); } }); }; var skeleton = sp.Skeleton.prototype; Object.defineProperty(skeleton, 'paused', { get: function get() { return this._paused || false; }, set: function set(value) { this._paused = value; if (this._skeleton) { this._skeleton.paused(value); } } }); Object.defineProperty(skeleton, 'debugSlots', { get: function get() { return this._debugSlots || false; }, set: function set(value) { this._debugSlots = value; this._updateDebugDraw(); if (this._skeleton) { this._skeleton.setDebugSlotsEnabled(this._debugSlots); } } }); Object.defineProperty(skeleton, 'debugBones', { get: function get() { return this._debugBones || false; }, set: function set(value) { this._debugBones = value; this._updateDebugDraw(); if (this._skeleton) { this._skeleton.setDebugBonesEnabled(this._debugBones); } } }); 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._skeleton) { this._skeleton.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._skeleton) { this._skeleton.setTimeScale(this._timeScale); } } }); Object.defineProperty(skeleton, "useTint", { get: function get() { return this._useTint || false; }, set: function set(value) { this._useTint = value; var baseMaterial = this.sharedMaterials[0]; if (!baseMaterial) return; baseMaterial.define('USE_TINT', this._useTint); // Update cache material useTint property var cache = this._materialCache; for (var mKey in cache) { var material = cache[mKey]; if (material) { material.define('USE_TINT', this._useTint); } } if (this._skeleton) { this._skeleton.setUseTint(this._useTint); } } }); var _onLoad = skeleton.onLoad; skeleton.onLoad = function () { if (_onLoad) { _onLoad.call(this); } this._iaPool = []; this._iaPool.push(new middleware.MiddlewareIA()); this._iaRenderData = new cc.IARenderData(); }; var _setMaterial = skeleton.setMaterial; skeleton.setMaterial = function (index, material) { _setMaterial.call(this, index, material); material.define('_USE_MODEL', true); }; // Shield use batch in native skeleton._updateBatch = function () {}; 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; } if (this._skeleton) { this._skeleton.stopSchedule(); this._skeleton._comp = null; this._skeleton = null; } var skeletonAni = new spine.SpineAnimation(); try { spine.initSkeletonRenderer(skeletonAni, uuid); } catch (e) { cc._throw(e); return; } this._skeleton = skeletonAni; this._skeleton._comp = this; this._skeleton.setOpacityModifyRGB(this.premultipliedAlpha); this._skeleton.setDebugSlotsEnabled(this.debugSlots); this._skeleton.setDebugBonesEnabled(this.debugBones); this._skeleton.setUseTint(this.useTint); this._skeleton.setTimeScale(this.timeScale); this._renderInfoOffset = this._skeleton.getRenderInfoOffset(); this._renderInfoOffset[0] = 0; // 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); }; skeleton.setAnimationStateData = function (stateData) { if (this._skeleton) { return this._skeleton.setAnimationStateData(stateData); } }; skeleton._activateMaterial = function () { var material = this.sharedMaterials[0]; if (!material) { material = cc.Material.getInstantiatedBuiltinMaterial('2d-spine', this); } else { material = cc.Material.getInstantiatedMaterial(material, this); } material.define('_USE_MODEL', true); this.setMaterial(0, material); this.markForUpdateRenderData(false); this.markForRender(false); this.markForCustomIARender(true); }; skeleton.onEnable = function () { renderCompProto.onEnable.call(this); if (this._skeleton) { this._skeleton.onEnable(); } this._activateMaterial(); if (this._renderInfoOffset) { this._renderInfoOffset[0] = 0; } }; skeleton.onDisable = function () { renderCompProto.onDisable.call(this); if (this._skeleton) { this._skeleton.onDisable(); } }; skeleton.update = null; skeleton.lateUpdate = function () { if (!this._skeleton) return; var nodeColor = this.node._color; var opacity = this.node._opacity; this.__preColor__ = this.__preColor__ || new cc.Color(255, 255, 255, 255); var preColor = this.__preColor__; var colorVal = nodeColor._val; nodeColor._fastSetA(opacity); if (!preColor || !nodeColor.equals(preColor)) { this._skeleton.setColor(nodeColor); preColor.set(nodeColor); } nodeColor._val = colorVal; }; skeleton.updateWorldTransform = function () { this._skeleton && this._skeleton.updateWorldTransform(); }; skeleton.setToSetupPose = function () { this._skeleton && this._skeleton.setToSetupPose(); }; skeleton.setBonesToSetupPose = function () { this._skeleton && this._skeleton.setBonesToSetupPose(); }; skeleton.setSlotsToSetupPose = function () { this._skeleton && this._skeleton.setSlotsToSetupPose(); }; skeleton.setSlotsRange = function (startSlotIndex, endSlotIndex) { this._skeleton && this._skeleton.setSlotsRange(startSlotIndex, endSlotIndex); }; skeleton.findBone = function (boneName) { if (this._skeleton) return this._skeleton.findBone(boneName); return null; }; skeleton.findSlot = function (slotName) { if (this._skeleton) return this._skeleton.findSlot(slotName); return null; }; skeleton.setSkin = function (skinName) { if (this._skeleton) return this._skeleton.setSkin(skinName); return null; }; skeleton.getAttachment = function (slotName, attachmentName) { if (this._skeleton) return this._skeleton.getAttachment(slotName, attachmentName); return null; }; skeleton.setAttachment = function (slotName, attachmentName) { this._skeleton && this._skeleton.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._skeleton) { this._skeleton.setMix(fromAnimation, toAnimation, duration); } }; skeleton.setAnimation = function (trackIndex, name, loop) { if (this._skeleton) { return this._skeleton.setAnimation(trackIndex, name, loop); } return null; }; skeleton.addAnimation = function (trackIndex, name, loop, delay) { if (this._skeleton) { delay = delay || 0; return this._skeleton.addAnimation(trackIndex, name, loop, delay); } return null; }; skeleton.findAnimation = function (name) { if (this._skeleton) return this._skeleton.findAnimation(name); return null; }; skeleton.getCurrent = function (trackIndex) { if (this._skeleton) { return this._skeleton.getCurrent(trackIndex); } return null; }; skeleton.clearTracks = function () { if (this._skeleton) { this._skeleton.clearTracks(); } }; skeleton.clearTrack = function (trackIndex) { if (this._skeleton) { this._skeleton.clearTrack(trackIndex); } }; skeleton.setStartListener = function (listener) { this._startListener = listener; if (this._skeleton) { this._skeleton.setStartListener(listener); } }; skeleton.setInterruptListener = function (listener) { this._interruptListener = listener; if (this._skeleton) { this._skeleton.setInterruptListener(listener); } }; skeleton.setEndListener = function (listener) { this._endListener = listener; if (this._skeleton) { this._skeleton.setEndListener(listener); } }; skeleton.setDisposeListener = function (listener) { this._disposeListener = listener; if (this._skeleton) { this._skeleton.setDisposeListener(listener); } }; skeleton.setCompleteListener = function (listener) { this._completeListener = listener; if (this._skeleton) { this._skeleton.setCompleteListener(listener); } }; skeleton.setEventListener = function (listener) { this._eventListener = listener; if (this._skeleton) { this._skeleton.setEventListener(listener); } }; skeleton.setTrackStartListener = function (entry, listener) { if (this._skeleton) { this._skeleton.setTrackStartListener(entry, listener); } }; skeleton.setTrackInterruptListener = function (entry, listener) { if (this._skeleton) { this._skeleton.setTrackInterruptListener(entry, listener); } }; skeleton.setTrackEndListener = function (entry, listener) { if (this._skeleton) { this._skeleton.setTrackEndListener(entry, listener); } }; skeleton.setTrackDisposeListener = function (entry, listener) { if (this._skeleton) { this._skeleton.setTrackDisposeListener(entry, listener); } }; skeleton.setTrackCompleteListener = function (entry, listener) { if (this._skeleton) { this._skeleton.setTrackCompleteListener(entry, listener); } }; skeleton.setTrackEventListener = function (entry, listener) { if (this._skeleton) { this._skeleton.setTrackEventListener(entry, listener); } }; skeleton.getState = function () { if (this._skeleton) { return this._skeleton.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.defaultSkin && this._skeleton.setSkin(this.defaultSkin); this.animation = this.defaultAnimation; } else { if (this._skeleton) { this._skeleton.stopSchedule(); this._skeleton._comp = null; this._skeleton = null; } } }; var _onDestroy = skeleton.onDestroy; skeleton.onDestroy = function () { _onDestroy.call(this); if (this._skeleton) { this._skeleton.stopSchedule(); this._skeleton._comp = null; this._skeleton = null; } this._materialCache = null; }; })(); },{}],13:[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); }; },{}],14:[function(require,module,exports){ "use strict"; /**************************************************************************** Copyright (c) 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 && cc.VideoPlayer && cc.VideoPlayer.Impl)) { return; } var math = cc.vmath; var _mat4_temp = math.mat4.create(); var _impl = cc.VideoPlayer.Impl; var _p = cc.VideoPlayer.Impl.prototype; _p._bindEvent = function () { var video = this._video, self = this; if (!video) { return; } //binding event var cbs = this.__eventListeners; cbs.loadedmetadata = function () { self._loadedmeta = true; self._dispatchEvent(_impl.EventType.META_LOADED); }; cbs.ended = function () { if (self._video !== video) return; self._playing = false; self._dispatchEvent(_impl.EventType.COMPLETED); }; cbs.play = function () { if (self._video !== video) return; self._playing = true; self._dispatchEvent(_impl.EventType.PLAYING); }; cbs.pause = function () { if (self._ignorePause || self._video !== video) return; self._playing = false; self._dispatchEvent(_impl.EventType.PAUSED); }; cbs.click = function () { self._dispatchEvent(_impl.EventType.CLICKED); }; cbs.stoped = function () { self._dispatchEvent(_impl.EventType.STOPPED); self._ignorePause = false; }; video.addEventListener("loadedmetadata", cbs.loadedmetadata); video.addEventListener("ended", cbs.ended); video.addEventListener("play", cbs.play); video.addEventListener("pause", cbs.pause); video.addEventListener("click", cbs.click); video.addEventListener("stoped", cbs.stoped); function onCanPlay() { if (this._loaded) return; this._loaded = true; this._dispatchEvent(_impl.EventType.READY_TO_PLAY); this._updateVisibility(); } cbs.onCanPlay = onCanPlay.bind(this); video.addEventListener('canplay', cbs.onCanPlay); video.addEventListener('canplaythrough', cbs.onCanPlay); video.addEventListener('suspend', cbs.onCanPlay); }; _p._updateVisibility = function () { if (!this._video) return; var video = this._video; if (this._visible) { this._video.setVisible(true); } else { this._video.setVisible(false); video.pause(); this._playing = false; } this._forceUpdate = true; }; _p._updateSize = function (width, height) {}; _p.createDomElementIfNeeded = function () { if (!jsb.VideoPlayer) { cc.warn('VideoPlayer only supports mobile platform.'); return null; } if (!this._video) { this._video = new jsb.VideoPlayer(); } }; _p.removeDom = function () { var video = this._video; if (video) { this._video.stop(); this._video.setVisible(false); var cbs = this.__eventListeners; cbs.loadedmetadata = null; cbs.ended = null; cbs.play = null; cbs.pause = null; cbs.click = null; cbs.onCanPlay = null; } this._video = null; this._url = ""; }; _p.setURL = function (path) { var source = void 0, extname = void 0; if (this._url === path) { return; } this.removeDom(); this._url = path; this.createDomElementIfNeeded(); this._bindEvent(); var video = this._video; if (!video) { return; } video.setVisible(this._visible); this._loaded = false; this._played = false; this._playing = false; this._loadedmeta = false; video.setURL(this._url); }; _p.getURL = function () { return this._url; }; _p.play = function () { var video = this._video; if (!video || !this._visible || this._playing) return; video.play(); this._playing = true; }; _p.pause = function () { var video = this._video; if (!this._playing || !video) return; video.pause(); this._playing = false; }; _p.resume = function () { var video = this._video; if (!this._playing || !video) return; video.resume(); this._playing = true; }; _p.stop = function () { var video = this._video; if (!video || !this._visible) return; this._ignorePause = true; video.stop(); this._playing = false; }; _p.setVolume = function (volume) {}; _p.seekTo = function (time) { var video = this._video; if (!video) return; if (this._loaded) { video.seekTo(time); } else { var cb = function cb() { video.seekTo(time); }; video.addEventListener(_impl._polyfill.event, cb); } if (_impl._polyfill.autoplayAfterOperation && this.isPlaying()) { setTimeout(function () { video.play(); }, 20); } }; _p.isPlaying = function () { return this._playing; }; _p.duration = function () { var video = this._video; var duration = -1; if (!video) return duration; duration = video.duration(); if (duration <= 0) { cc.logID(7702); } return duration; }; _p.currentTime = function () { var video = this._video; if (!video) return -1; return video.currentTime(); }; _p.setKeepAspectRatioEnabled = function (isEnabled) { if (!this._video) { return false; } return this._video.setKeepAspectRatioEnabled(isEnabled); }; _p.isKeepAspectRatioEnabled = function () { if (!this._video) { return false; } return this._video.isKeepAspectRatioEnabled(); }; _p.isFullScreenEnabled = function () { return this._fullScreenEnabled; }; _p.setEventListener = function (event, callback) { this._EventList[event] = callback; }; _p.removeEventListener = function (event) { this._EventList[event] = null; }; _p._dispatchEvent = function (event) { var callback = this._EventList[event]; if (callback) callback.call(this, this, this._video.src); }; _p.onPlayEvent = function () { var callback = this._EventList[_impl.EventType.PLAYING]; callback.call(this, this, this._video.src); }; _p.enable = function () { var list = _impl.elements; if (list.indexOf(this) === -1) list.push(this); this.setVisible(true); }; _p.disable = function () { var list = _impl.elements; var index = list.indexOf(this); if (index !== -1) list.splice(index, 1); this.setVisible(false); }; _p.destroy = function () { this.disable(); this.removeDom(); }; _p.setVisible = function (visible) { if (this._visible !== visible) { this._visible = !!visible; this._updateVisibility(); } }; _p.setFullScreenEnabled = function (enable) { var video = this._video; if (!video) { return; } this._fullScreenEnabled = enable; video.setFullScreenEnabled(enable); }; _p.updateMatrix = function (node) { if (!this._video || !this._visible) return; node.getWorldMatrix(_mat4_temp); if (!this._forceUpdate && this._m00 === _mat4_temp.m00 && this._m01 === _mat4_temp.m01 && this._m04 === _mat4_temp.m04 && this._m05 === _mat4_temp.m05 && this._m12 === _mat4_temp.m12 && this._m13 === _mat4_temp.m13 && this._w === node._contentSize.width && this._h === node._contentSize.height) { return; } // update matrix cache this._m00 = _mat4_temp.m00; this._m01 = _mat4_temp.m01; this._m04 = _mat4_temp.m04; this._m05 = _mat4_temp.m05; this._m12 = _mat4_temp.m12; this._m13 = _mat4_temp.m13; this._w = node._contentSize.width; this._h = node._contentSize.height; var scaleX = cc.view._scaleX, scaleY = cc.view._scaleY; var dpr = cc.view._devicePixelRatio; scaleX /= dpr; scaleY /= dpr; var container = cc.game.container; var a = _mat4_temp.m00 * scaleX, b = _mat4_temp.m01, c = _mat4_temp.m04, d = _mat4_temp.m05 * scaleY; var offsetX = container && container.style.paddingLeft ? parseInt(container.style.paddingLeft) : 0; var offsetY = container && container.style.paddingBottom ? parseInt(container.style.paddingBottom) : 0; var w = void 0, h = void 0; if (_impl._polyfill.zoomInvalid) { this._updateSize(this._w * a, this._h * d); a = 1; d = 1; w = this._w * scaleX; h = this._h * scaleY; } else { this._updateSize(this._w, this._h); w = this._w * scaleX; h = this._h * scaleY; } var appx = w * _mat4_temp.m00 * node._anchorPoint.x; var appy = h * _mat4_temp.m05 * node._anchorPoint.y; var viewport = cc.view._viewportRect; offsetX += viewport.x / dpr; offsetY += viewport.y / dpr; var tx = _mat4_temp.m12 * scaleX - appx + offsetX, ty = _mat4_temp.m13 * scaleY - appy + offsetY; var height = cc.view.getFrameSize().height; this._video.setFrame(tx, height - h - ty, this._w * a, this._h * d); }; _impl.EventType = { PLAYING: 0, PAUSED: 1, STOPPED: 2, COMPLETED: 3, META_LOADED: 4, CLICKED: 5, READY_TO_PLAY: 6 }; // video 队列,所有 vidoe 在 onEnter 的时候都会插入这个队列 _impl.elements = []; // video 在 game_hide 事件中被自动暂停的队列,用于回复的时候重新开始播放 _impl.pauseElements = []; cc.game.on(cc.game.EVENT_HIDE, function () { var list = _impl.elements; for (var element, i = 0; i < list.length; i++) { element = list[i]; if (element.isPlaying()) { element.pause(); _impl.pauseElements.push(element); } } }); cc.game.on(cc.game.EVENT_SHOW, function () { var list = _impl.pauseElements; var element = list.pop(); while (element) { element.play(); element = list.pop(); } }); })(); },{}],15:[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 && cc.WebView && cc.WebView.Impl)) { return; } var math = cc.vmath; var _mat4_temp = math.mat4.create(); cc.WebView.Impl = cc.Class({ extends: cc.WebView.Impl, ctor: function ctor() { // keep webview data this.jsCallback = null; this.interfaceSchema = null; } }); var _impl = cc.WebView.Impl; var _p = cc.WebView.Impl.prototype; _p._updateVisibility = function () { if (!this._iframe) return; this._iframe.setVisible(this._visible); this._forceUpdate = true; }; _p._updateSize = function (w, h) {}; _p._initEvent = function () { var iframe = this._iframe; if (iframe) { var cbs = this.__eventListeners, self = this; cbs.load = function () { self._dispatchEvent(_impl.EventType.LOADED); }; cbs.error = function () { self._dispatchEvent(_impl.EventType.ERROR); }; // native event callback this._iframe.setOnDidFinishLoading(cbs.load); this._iframe.setOnDidFailLoading(cbs.error); } }; _p._initExtraSetting = function () { this.jsCallback && this.setOnJSCallback(this.jsCallback); this.interfaceSchema && this.setJavascriptInterfaceScheme(this.interfaceSchema); // remove obj this.jsCallback = null; this.interfaceSchema = null; }; _p._setOpacity = function (opacity) { var iframe = this._iframe; if (iframe && iframe.style) { iframe.style.opacity = opacity / 255; // TODO, add impl to Native } }; _p.createDomElementIfNeeded = function (w, h) { if (!jsb.WebView) { cc.warn('WebView only supports mobile platform.'); return; } if (!this._iframe) { this._iframe = jsb.WebView.create(); this._initEvent(); this._initExtraSetting(); } }; _p.removeDom = function () { var iframe = this._iframe; if (iframe) { var cbs = this.__eventListeners; cbs.load = null; cbs.error = null; this._iframe = null; } }; _p.setOnJSCallback = function (callback) { var iframe = this._iframe; if (iframe) { iframe.setOnJSCallback(callback); } else { this.jsCallback = callback; } }; _p.setJavascriptInterfaceScheme = function (scheme) { var iframe = this._iframe; if (iframe) { iframe.setJavascriptInterfaceScheme(scheme); } else { this.interfaceSchema = scheme; } }; _p.loadData = function (data, MIMEType, encoding, baseURL) { var iframe = this._iframe; if (iframe) { iframe.loadData(data, MIMEType, encoding, baseURL); } }; _p.loadHTMLString = function (string, baseURL) { var iframe = this._iframe; if (iframe) { iframe.loadHTMLString(string, baseURL); } }; /** * Load an URL * @param {String} url */ _p.loadURL = function (url) { var iframe = this._iframe; if (iframe) { iframe.src = url; iframe.loadURL(url); this._dispatchEvent(_impl.EventType.LOADING); } }; /** * Stop loading */ _p.stopLoading = function () { cc.logID(7800); }; /** * Reload the WebView */ _p.reload = function () { var iframe = this._iframe; if (iframe) { iframe.reload(); } }; /** * Determine whether to go back */ _p.canGoBack = function () { var iframe = this._iframe; if (iframe) { return iframe.canGoBack(); } }; /** * Determine whether to go forward */ _p.canGoForward = function () { var iframe = this._iframe; if (iframe) { return iframe.canGoForward(); } }; /** * go back */ _p.goBack = function () { var iframe = this._iframe; if (iframe) { return iframe.goBack(); } }; /** * go forward */ _p.goForward = function () { var iframe = this._iframe; if (iframe) { return iframe.goForward(); } }; /** * In the webview execution within a period of js string * @param {String} str */ _p.evaluateJS = function (str) { var iframe = this._iframe; if (iframe) { return iframe.evaluateJS(); } }; /** * Limited scale */ _p.setScalesPageToFit = function () { var iframe = this._iframe; if (iframe) { return iframe.setScalesPageToFit(); } }; /** * The binding event * @param {_impl.EventType} event * @param {Function} callback */ _p.setEventListener = function (event, callback) { this._EventList[event] = callback; }; /** * Delete events * @param {_impl.EventType} event */ _p.removeEventListener = function (event) { this._EventList[event] = null; }; _p._dispatchEvent = function (event) { var callback = this._EventList[event]; if (callback) callback.call(this, this, this._iframe.src); }; _p._createRenderCmd = function () { return new _impl.RenderCmd(this); }; _p.destroy = function () { this.removeDom(); }; _p.setVisible = function (visible) { if (this._visible !== visible) { this._visible = !!visible; this._updateVisibility(); } }; _p.updateMatrix = function (node) { if (!this._iframe || !this._visible) return; node.getWorldMatrix(_mat4_temp); if (!this._forceUpdate && this._m00 === _mat4_temp.m00 && this._m01 === _mat4_temp.m01 && this._m04 === _mat4_temp.m04 && this._m05 === _mat4_temp.m05 && this._m12 === _mat4_temp.m12 && this._m13 === _mat4_temp.m13 && this._w === node._contentSize.width && this._h === node._contentSize.height) { return; } // update matrix cache this._m00 = _mat4_temp.m00; this._m01 = _mat4_temp.m01; this._m04 = _mat4_temp.m04; this._m05 = _mat4_temp.m05; this._m12 = _mat4_temp.m12; this._m13 = _mat4_temp.m13; this._w = node._contentSize.width; this._h = node._contentSize.height; var scaleX = cc.view._scaleX, scaleY = cc.view._scaleY; var dpr = cc.view._devicePixelRatio; scaleX /= dpr; scaleY /= dpr; var container = cc.game.container; var a = _mat4_temp.m00 * scaleX, b = _mat4_temp.m01, c = _mat4_temp.m04, d = _mat4_temp.m05 * scaleY; var offsetX = container && container.style.paddingLeft ? parseInt(container.style.paddingLeft) : 0; var offsetY = container && container.style.paddingBottom ? parseIn(container.style.paddingBottom) : 0; this._updateSize(this._w, this._h); var w = this._w * scaleX; var h = this._h * scaleY; var appx = w * _mat4_temp.m00 * node._anchorPoint.x; var appy = h * _mat4_temp.m05 * node._anchorPoint.y; var viewport = cc.view._viewportRect; offsetX += viewport.x / dpr; offsetY += viewport.y / dpr; var tx = _mat4_temp.m12 * scaleX - appx + offsetX, ty = _mat4_temp.m13 * scaleY - appy + offsetY; var height = cc.view.getFrameSize().height; // set webview rect this._iframe.setFrame(tx, height - h - ty, this._w * a, this._h * d); }; })(); },{}]},{},[1]);