diff --git a/jsb/index.js b/jsb/index.js index 6c8cce60b8..2cce93f4c7 100644 --- a/jsb/index.js +++ b/jsb/index.js @@ -25,20 +25,6 @@ 'use strict'; -// Check version -var _engineNumberVersion = (function () { - var result = /Cocos2d\-JS\sv([\d]+)\.([\d]+)/.exec(cc.ENGINE_VERSION); - if (result && result[1]) { - return { - major: parseInt(result[1]), - minor: parseInt(result[2]) - }; - } - else { - return null; - } -})(); - var originLog = console.log; // overwrite original console.log @@ -129,8 +115,4 @@ require('./jsb-tiledmap'); require('./jsb-box2d'); require('./jsb-dragonbones'); -if (cc.runtime) { - require('./versions/jsb-polyfill-runtime'); -} - require('../extends'); diff --git a/jsb/jsb-etc.js b/jsb/jsb-etc.js index a9b31d8d2a..1d6b1ec301 100644 --- a/jsb/jsb-etc.js +++ b/jsb/jsb-etc.js @@ -177,16 +177,15 @@ window.clearTimeout = clearInterval; // SocketIO if (window.SocketIO) { window.io = window.SocketIO; + SocketIO.prototype._jsbEmit = SocketIO.prototype.emit; + SocketIO.prototype.emit = function (uri, delegate) { + if (typeof delegate === 'object') { + delegate = JSON.stringify(delegate); + } + this._jsbEmit(uri, delegate); + }; } -SocketIO.prototype._jsbEmit = SocketIO.prototype.emit; -SocketIO.prototype.emit = function (uri, delegate) { - if (typeof delegate === 'object') { - delegate = JSON.stringify(delegate); - } - this._jsbEmit(uri, delegate); -}; - cc.Node.prototype.setIgnoreAnchorPointForPosition = cc.Node.prototype.ignoreAnchorPointForPosition; // ccsg diff --git a/jsb/versions/jsb-polyfill-runtime.js b/jsb/versions/jsb-polyfill-runtime.js deleted file mode 100644 index e5e175a68c..0000000000 --- a/jsb/versions/jsb-polyfill-runtime.js +++ /dev/null @@ -1,169 +0,0 @@ -/**************************************************************************** - Copyright (c) 2016 Chukong Technologies Inc. - - 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. - Chukong Aipu 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 _imageArray = []; - -function _addDownloadList (url,picName,suffix,option,cb) { - var item = { - info: { - url: url, - suffix:suffix, - picName:picName, - option: option - }, - cb: [cb] - }; - _imageArray.push(item); - return item; -} - -function _getDownloadItem (picName) { - for (var i = 0, l = _imageArray.length; i < l; i++) { - var item = _imageArray[i]; - if (item.info.picName === picName) { - return item; - } - } - return null; -} - -function _delDownloadList (picName) { - for (var i = 0, l = _imageArray.length; i < l; i++) { - var item = _imageArray[i]; - if (item.info.picName === picName) { - _imageArray.splice(i,1); - break; - } - } -} - -function loadImage (loadItem, callback) { - var url = loadItem.url; - - var cachedTex = cc.textureCache.getTextureForKey(url); - if (cachedTex) { - callback && callback(null, cachedTex); - } - else if (url.match(jsb.urlRegExp)) { - var picName; - var picSuffix = [".png", ".jpg", ".jpeg", ".gif", ".bmp"]; - var hasSuffix = false; - var suffix; - - for (var i = 0; i < picSuffix.length; i++) { - var item = picSuffix[i]; - if (url.indexOf(item) !== -1) { - hasSuffix = true; - suffix = item; - break; - } - } - var conf = loadItem.option; - if (conf) { - picName = cc.md5Encode(url + "cocos" + conf.width + "_" + conf.height); - } else { - cc.log("download default image"); - picName = cc.md5Encode(url); - } - cc.log("picName is " + picName); - var imageConfig = conf; - cachedTex = cc.textureCache._addImage(picName); - if (cachedTex instanceof cc.Texture2D) { - cc.log("loadImg find texture from cache"); - callback && callback(null, cachedTex); - } else { - var listItem = _getDownloadItem(picName); - if (listItem) { - cc.log("the same picture is downloading"); - listItem.cb.push(callback); - return; - } else { - listItem = _addDownloadList(url, picName, suffix, imageConfig, callback); - } - jsb.loadRemoteImg(JSON.stringify(listItem.info), function (configJsonText) { - var config = JSON.parse(configJsonText); - cc.log("callback from loadRemoteImg config is " + configJsonText); - var item = _getDownloadItem(config.picName); - if (!item && callback) { - callback(new Error("Load image failed: " + url), null); - return; - } - if (item.cb) { - for (var i = 0; i < item.cb.length; i++) { - cc.log("in callback list now i is " + i); - var texture = null; - var error = null; - if (config.isSuccess) { - cc.log("begin load texture picName is " + item.info.picName); - texture = cc.textureCache._addImage(item.info.picName); - if(!texture instanceof cc.Texture2D){ - texture = null; - error = new Error("add image fail: " + url); - } - } else { - error = new Error("download image fail" + url); - } - var cbItem = item.cb[i]; - if (cbItem) { - cbItem(error, texture); - } else { - cc.log("ERROR: callback is null"); - } - } - } - _delDownloadList(item); - }); - } - } - else { - cc.textureCache._addImageAsync(url, function (tex){ - if (tex instanceof cc.Texture2D) { - callback && callback(null, tex); - } - else { - callback && callback(new Error('Load image failed: ' + url)); - } - }); - } -} - -cc.loader.addLoadHandlers({ - // Images - 'png' : loadImage, - 'jpg' : loadImage, - 'bmp' : loadImage, - 'jpeg' : loadImage, - 'gif' : loadImage, - 'ico' : loadImage, - 'tiff' : loadImage, - 'webp' : loadImage, - 'image' : loadImage -}); - -cc.Follow.prototype._ctor = function (followedNode, rect) { - if(followedNode) - rect ? this.initWithTarget(followedNode, rect) - : this.initWithTarget(followedNode); -}; \ No newline at end of file diff --git a/jsb/versions/jsb-polyfill-v3.5.js b/jsb/versions/jsb-polyfill-v3.5.js deleted file mode 100644 index adf6029d21..0000000000 --- a/jsb/versions/jsb-polyfill-v3.5.js +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013-2016 Chukong Technologies Inc. - - 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. - Chukong Aipu 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'; - -if (!cc.Scheduler.prototype.unscheduleAllForTarget) { - cc.Scheduler.prototype.unscheduleAllForTarget = function (target) { - this.unscheduleAllCallbacksForTarget(target); - }; -} - -if (!cc.Scheduler.prototype._unschedule) { - cc.Scheduler.prototype._unschedule = cc.Scheduler.prototype.unscheduleCallbackForTarget; -} - -cc.SpriteFrame.prototype.initWithTexture = function (texture, rect, rotated, offset, originalSize, _uuid) { - function check(texture) { - if (texture && texture.isLoaded()) { - var _x, _y; - if (rotated) { - _x = rect.x + rect.height; - _y = rect.y + rect.width; - } - else { - _x = rect.x + rect.width; - _y = rect.y + rect.height; - } - if (_x > texture.getPixelWidth()) { - cc.errorID(3300, _uuid); - } - if (_y > texture.getPixelHeight()) { - cc.errorID(3400, _uuid); - } - } - } - - offset = cc.p(0, 0); - originalSize = originalSize || rect; - rotated = rotated || false; - - if (this.insetTop === undefined) { - this.insetTop = 0; - this.insetBottom = 0; - this.insetLeft = 0; - this.insetRight = 0; - } - - var locTexture; - if (!texture && _uuid) { - // deserialize texture from uuid - var info = cc.AssetLibrary._getAssetInfoInRuntime(_uuid); - if (!info) { - cc.errorID(3114, _uuid); - return; - } - - this._textureFilename = info.url; - - locTexture = cc.textureCache.addImage(info.url); - this._initWithTexture(locTexture, rect, rotated, offset, originalSize); - } - else { - if (cc.js.isString(texture)){ - this._textureFilename = texture; - locTexture = cc.textureCache.addImage(this._textureFilename); - this._initWithTexture(locTexture, rect, rotated, offset, originalSize); - } else if (texture instanceof cc.Texture2D) { - this._textureFilename = ''; - this._initWithTexture(texture, rect, rotated, offset, originalSize); - } - } - this.emit('load'); - check(this.getTexture()); - return true; -}; diff --git a/jsb/versions/jsb-polyfill-v3.8.js b/jsb/versions/jsb-polyfill-v3.8.js deleted file mode 100644 index 8a2992cf56..0000000000 --- a/jsb/versions/jsb-polyfill-v3.8.js +++ /dev/null @@ -1,37 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013-2016 Chukong Technologies Inc. - - 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. - Chukong Aipu 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'; - -// Overwrite main loop -var scheduleTarget = { - update: function (dt) { - // Call start for new added components - cc.director.emit(cc.Director.EVENT_BEFORE_UPDATE); - // Update for components - cc.director.emit(cc.Director.EVENT_COMPONENT_UPDATE, dt); - } -}; -cc.Director.getInstance().getScheduler().scheduleUpdateForTarget(scheduleTarget, -1000, false); \ No newline at end of file diff --git a/jsb/versions/jsb-polyfill-v3.9.js b/jsb/versions/jsb-polyfill-v3.9.js deleted file mode 100644 index f14a6820b1..0000000000 --- a/jsb/versions/jsb-polyfill-v3.9.js +++ /dev/null @@ -1,43 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013-2016 Chukong Technologies Inc. - - 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. - Chukong Aipu 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'; - -cc.Scale9Sprite.prototype.setRenderingType = function (type) { - if (this._renderingType === type) return; - this._renderingType = type; - - if (!this.isScale9Enabled()){ - this.setScale9Enabled(true); - } - - if (type === cc.Scale9Sprite.RenderingType.SIMPLE) { - // Should modify based on trim size - this.setInsetLeft(0); - this.setInsetTop(0); - this.setInsetBottom(0); - this.setInsetRight(0); - } -};