mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 16:12:40 +08:00
@@ -589,9 +589,9 @@ cc.Director = Class.extend(/** @lends cc.Director# */{
|
||||
sgScene = scene._sgNode;
|
||||
|
||||
// Re-attach or replace persist nodes
|
||||
CC_BUILD && CC_DEBUG && console.time('AttachPersist');
|
||||
for (let i = 0; i < persistNodeList.length; i++) {
|
||||
let node = persistNodeList[i];
|
||||
CC_BUILD && CC_DEBUG && console.time('AttachPersist');
|
||||
var existNode = scene.getChildByUuid(node.uuid);
|
||||
if (existNode) {
|
||||
// scene also contains the persist node, select the old one
|
||||
|
||||
@@ -203,14 +203,14 @@ function enableInEditor (comp) {
|
||||
}
|
||||
}
|
||||
|
||||
function createInvokeImpl (code, useDt) {
|
||||
function createInvokeImpl (funcOrCode, useDt) {
|
||||
if (CC_EDITOR) {
|
||||
if (useDt) {
|
||||
return function (iterator, dt) {
|
||||
var array = iterator.array;
|
||||
for (iterator.i = 0; iterator.i < array.length; ++iterator.i) {
|
||||
var comp = array[iterator.i];
|
||||
code(comp, dt);
|
||||
funcOrCode(comp, dt);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -219,7 +219,7 @@ function createInvokeImpl (code, useDt) {
|
||||
var array = iterator.array;
|
||||
for (iterator.i = 0; iterator.i < array.length; ++iterator.i) {
|
||||
var comp = array[iterator.i];
|
||||
code(comp);
|
||||
funcOrCode(comp);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -235,7 +235,7 @@ function createInvokeImpl (code, useDt) {
|
||||
var body = 'var a=it.array;' +
|
||||
'for(it.i=0;it.i<a.length;++it.i){' +
|
||||
'var c=a[it.i];' +
|
||||
code +
|
||||
funcOrCode +
|
||||
'}';
|
||||
if (useDt) {
|
||||
return Function('it', 'dt', body);
|
||||
@@ -309,9 +309,10 @@ var ComponentScheduler = cc.Class({
|
||||
// schedule
|
||||
if (this._updating) {
|
||||
this.scheduleInNextFrame.push(comp);
|
||||
return;
|
||||
}
|
||||
this._scheduleImmediate(comp);
|
||||
else {
|
||||
this._scheduleImmediate(comp);
|
||||
}
|
||||
},
|
||||
|
||||
_onDisabled (comp) {
|
||||
@@ -432,6 +433,21 @@ var ComponentScheduler = cc.Class({
|
||||
|
||||
// call start
|
||||
this.startInvoker.invoke();
|
||||
// if (CC_PREVIEW) {
|
||||
// try {
|
||||
// this.startInvoker.invoke();
|
||||
// }
|
||||
// catch (e) {
|
||||
// // prevent start from getting into infinite loop
|
||||
// this.startInvoker._neg.array.length = 0;
|
||||
// this.startInvoker._zero.array.length = 0;
|
||||
// this.startInvoker._pos.array.length = 0;
|
||||
// throw e;
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// this.startInvoker.invoke();
|
||||
// }
|
||||
},
|
||||
|
||||
updatePhase (dt) {
|
||||
|
||||
@@ -234,7 +234,7 @@ proto.load = function(resources, progressCallback, completeCallback) {
|
||||
callInNextTick(function () {
|
||||
if (completeCallback) {
|
||||
if (singleRes) {
|
||||
var id = res.url;
|
||||
let id = res.url;
|
||||
completeCallback.call(self, items.getError(id), items.getContent(id));
|
||||
}
|
||||
else {
|
||||
@@ -244,7 +244,7 @@ proto.load = function(resources, progressCallback, completeCallback) {
|
||||
}
|
||||
|
||||
if (CC_EDITOR) {
|
||||
for (var id in self._cache) {
|
||||
for (let id in self._cache) {
|
||||
if (self._cache[id].complete) {
|
||||
self.removeItem(id);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
var pushToMap = require('../utils/misc').pushToMap;
|
||||
|
||||
function Entry (uuid, type) {
|
||||
this.uuid = uuid;
|
||||
this.type = type;
|
||||
@@ -133,30 +135,7 @@ proto.add = function (path, uuid, type, isMainAsset) {
|
||||
// (can not use path.slice because length of extname maybe 0)
|
||||
path = path.substring(0, path.length - cc.path.extname(path).length);
|
||||
var newEntry = new Entry(uuid, type);
|
||||
var pathToUuid = this._pathToUuid;
|
||||
var exists = pathToUuid[path];
|
||||
if (exists) {
|
||||
if (Array.isArray(exists)) {
|
||||
if (isMainAsset) {
|
||||
// load main asset first
|
||||
exists.unshift(newEntry);
|
||||
}
|
||||
else {
|
||||
exists.push(newEntry);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (isMainAsset) {
|
||||
pathToUuid[path] = [newEntry, exists];
|
||||
}
|
||||
else {
|
||||
pathToUuid[path] = [exists, newEntry];
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
pathToUuid[path] = newEntry;
|
||||
}
|
||||
pushToMap(this._pathToUuid, path, newEntry, isMainAsset);
|
||||
};
|
||||
|
||||
proto.reset = function () {
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
var JsonUnpacker = require('./json-unpacker');
|
||||
var pushToMap = require('../utils/misc').pushToMap;
|
||||
|
||||
// {assetUuid: packUuid|[packUuid]}
|
||||
// If value is array of packUuid, then the first one will be prioritized for download,
|
||||
@@ -57,24 +58,9 @@ module.exports = {
|
||||
var uuids = packs[packUuid];
|
||||
for (var i = 0; i < uuids.length; i++) {
|
||||
var uuid = uuids[i];
|
||||
var allIncludedPacks = uuidToPack[uuid];
|
||||
if (allIncludedPacks) {
|
||||
if (Array.isArray(allIncludedPacks)) {
|
||||
allIncludedPacks.push(packUuid);
|
||||
}
|
||||
else {
|
||||
uuidToPack[uuid] = allIncludedPacks = [allIncludedPacks, packUuid];
|
||||
}
|
||||
if (uuids.length === 1) {
|
||||
// the smallest pack must be at the beginning of the array to download more first
|
||||
var swapToLast = allIncludedPacks[0];
|
||||
allIncludedPacks[0] = allIncludedPacks[allIncludedPacks.length - 1];
|
||||
allIncludedPacks[allIncludedPacks.length - 1] = swapToLast;
|
||||
}
|
||||
}
|
||||
else {
|
||||
uuidToPack[uuid] = packUuid;
|
||||
}
|
||||
// the smallest pack must be at the beginning of the array to download more first
|
||||
var pushFront = uuids.length === 1;
|
||||
pushToMap(uuidToPack, uuid, packUuid, pushFront);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -139,3 +139,25 @@ for (let i = 0; i < 64; ++i) BASE64_VALUES[BASE64_KEYS.charCodeAt(i)] = i;
|
||||
|
||||
// decoded value indexed by base64 char code
|
||||
misc.BASE64_VALUES = BASE64_VALUES;
|
||||
|
||||
// set value to map, if key exists, push to array
|
||||
misc.pushToMap = function (map, key, value, pushFront) {
|
||||
var exists = map[key];
|
||||
if (exists) {
|
||||
if (Array.isArray(exists)) {
|
||||
if (pushFront) {
|
||||
exists.push(exists[0]);
|
||||
exists[0] = value;
|
||||
}
|
||||
else {
|
||||
exists.push(value);
|
||||
}
|
||||
}
|
||||
else {
|
||||
map[key] = (pushFront ? [value, exists] : [exists, value]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
map[key] = value;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -62,12 +62,6 @@ if (CC_DEV) {
|
||||
return typeof obj === 'function';
|
||||
};
|
||||
});
|
||||
js.get(cc.js, "isFunction", function () {
|
||||
cc.warnID(1400, 'cc.js.isFunction', '"typeof obj === \'function\'"');
|
||||
return function(obj) {
|
||||
return typeof obj === 'function';
|
||||
};
|
||||
});
|
||||
|
||||
/**
|
||||
* Check the obj whether is number or not
|
||||
@@ -101,12 +95,6 @@ if (CC_DEV) {
|
||||
return Array.isArray(obj);
|
||||
};
|
||||
});
|
||||
js.get(cc.js, "isArray", function () {
|
||||
cc.warnID(1400, 'cc.js.isArray', '"Array.isArray(obj)"');
|
||||
return function(obj) {
|
||||
return Array.isArray(obj);
|
||||
};
|
||||
});
|
||||
|
||||
js.get(cc, "isUndefined", function () {
|
||||
cc.warnID(1400, 'cc.isUndefined', '"typeof obj === \'undefined\'"');
|
||||
@@ -114,12 +102,6 @@ if (CC_DEV) {
|
||||
return typeof obj === 'undefined';
|
||||
};
|
||||
});
|
||||
js.get(cc.js, "isUndefined", function () {
|
||||
cc.warnID(1400, 'cc.js.isUndefined', '"typeof obj === \'undefined\'"');
|
||||
return function(obj) {
|
||||
return typeof obj === 'undefined';
|
||||
};
|
||||
});
|
||||
|
||||
js.get(cc, "isObject", function () {
|
||||
cc.warnID(1400, 'cc.isObject', '"typeof obj === \'object\'"');
|
||||
@@ -128,13 +110,6 @@ if (CC_DEV) {
|
||||
};
|
||||
});
|
||||
|
||||
js.get(cc.js, "isObject", function () {
|
||||
cc.warnID(1400, 'cc.js.isObject', '"typeof obj === \'object\'"');
|
||||
return function(obj) {
|
||||
return typeof obj === "object";
|
||||
};
|
||||
});
|
||||
|
||||
/**
|
||||
* cc.Point is the class for point object, please do not use its constructor to create points, use cc.p() alias function instead.
|
||||
* @class cc.Point
|
||||
@@ -698,6 +673,3 @@ if (CC_DEV) {
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// remove after 1.6
|
||||
js.obsolete(cc.loader, 'cc.loader.loadResAll', 'loadResDir');
|
||||
|
||||
Reference in New Issue
Block a user