CocosCreator引擎修改与定制

1.CCGame.js 修改部分数据脚本的加载时机,避免首屏卡顿

// Load game scripts
var jsList = config[CONFIG_KEY.jsList];
if (jsList && jsList.length > 0) {
cc.loader.load(jsList, function (err) {
if (err) throw new Error(JSON.stringify(err));
self._prepared = true;
if (cb) cb();
self.emit(self.EVENT_GAME_INITED);
});
}
else {
if (cb) cb();
self.emit(self.EVENT_GAME_INITED);
}

2.CCLoader.js 加载代码回退处理

1.6.1 -> 1.5.1避免加载并发时回调次数不足

回退后该代码在1.6.1中运行稳定,最新版本需要验证

回退仅处理了items.destroy()这一条语句的位置

var queue = LoadingItems.create(this, progressCallback, function (errors, items) {
callInNextTick(function () {
if (completeCallback) {
if (singleRes) {
let id = res.url;
completeCallback.call(self, items.getError(id), items.getContent(id));
}
else {
completeCallback.call(self, errors, items);
}
completeCallback = null;
//++
items.destroy();
} if (CC_EDITOR) {
for (let id in self._cache) {
if (self._cache[id].complete) {
self.removeItem(id);
}
}
}
//-- items.destroy();
});
});

3.CCView.js 判断分辨率,切换适配模式(ipx/全面屏)

setResolutionPolicy: function (resolutionPolicy) {
//增加对于ipx全面屏的特殊处理(横版游戏)
if(cc.view._frameSize.width / cc.view._frameSize.height > 1.778 /*1136/640*/){
resolutionPolicy = cc.ResolutionPolicy.SHOW_ALL //cc.ResolutionPolicy.FIXED_HEIGHT
}
//end
var _t = this;
if (resolutionPolicy instanceof cc.ResolutionPolicy) {
_t._resolutionPolicy = resolutionPolicy;
}
// Ensure compatibility with JSB
else {
var _locPolicy = cc.ResolutionPolicy;
if(resolutionPolicy === _locPolicy.EXACT_FIT)
_t._resolutionPolicy = _t._rpExactFit;
if(resolutionPolicy === _locPolicy.SHOW_ALL)
_t._resolutionPolicy = _t._rpShowAll;
if(resolutionPolicy === _locPolicy.NO_BORDER)
_t._resolutionPolicy = _t._rpNoBorder;
if(resolutionPolicy === _locPolicy.FIXED_HEIGHT)
_t._resolutionPolicy = _t._rpFixedHeight;
if(resolutionPolicy === _locPolicy.FIXED_WIDTH)
_t._resolutionPolicy = _t._rpFixedWidth;
}
},

4.CCInputManager.js 部分iframe情况下点击偏移处理

注释掉全部两处element.focus(验证无误)

5.脚本跨域获取error堆栈信息

downloader.js

function downloadScript

增加script element属性

s.crossOrigin = true

上一篇:HDU 3037 Saving Beans(Lucas定理模板题)


下一篇:eclipse 中 大小写切换:ctrl+shift+x 转为大写 ctrl+shift+y 转为小写