mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-02 00:13:09 +08:00
Merge pull request #1844 from jareguo/master
remove jsb versions polyfill
This commit is contained in:
@@ -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');
|
||||
|
||||
+7
-8
@@ -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
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
@@ -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;
|
||||
};
|
||||
@@ -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);
|
||||
@@ -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);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user