diff --git a/cocos2d/core/load-pipeline/CCLoader.js b/cocos2d/core/load-pipeline/CCLoader.js index e3cba03f14..f15ed636b8 100644 --- a/cocos2d/core/load-pipeline/CCLoader.js +++ b/cocos2d/core/load-pipeline/CCLoader.js @@ -381,10 +381,14 @@ JS.mixin(CCLoader.prototype, { } this.load(res, function (errors, items) { var results = []; - for (var key in items.map) { - var item = items.getContent(key); - self.setAutoReleaseRecursively(item, false); - results.push(item); + for (var i = 0; i < res.length; ++i) { + var uuid = res[i].uuid; + var item = items.getContent(uuid); + if (item) { + // should not release these assets, even if they are static referenced in the scene. + self.setAutoReleaseRecursively(uuid, false); + results.push(item); + } } if (completeCallback) { completeCallback(errors, results); diff --git a/cocos2d/core/platform/utils.js b/cocos2d/core/platform/utils.js index b38154bf89..64d028388e 100644 --- a/cocos2d/core/platform/utils.js +++ b/cocos2d/core/platform/utils.js @@ -26,6 +26,8 @@ module.exports = { isDomNode: typeof window === 'object' && (typeof Node === 'function' ? function (obj) { + // If "TypeError: Right-hand side of 'instanceof' is not callback" is thrown, + // it should because window.Node was overwritten. return obj instanceof Node; } : function (obj) { diff --git a/index.js b/index.js index 131ca7f84c..01547f0451 100644 --- a/index.js +++ b/index.js @@ -58,7 +58,7 @@ else { cc._initDebugSetting(1); // DEBUG_MODE_INFO } -// LOAD EXTENDS FOR FIREBALL +// LOAD EXTENDS FOR CREATOR require('./extends'); @@ -70,6 +70,14 @@ if (CC_EDITOR) { * var isDomNode = cc._require('./cocos2d/core/platform/utils').isDomNode; */ cc._require = require; + /* + * Checks if the extension is loaded. + * This method is used to make editor code more elegant, so only available in editor. + * @param {string} moduleName - such as 'sp', 'dragonBones', 'TiledMap'... etc. + */ + cc.hasExtension = function (moduleName) { + return moduleName in global || moduleName in cc; + }; } if (isMainProcess) {