tsconfig.json配置:https://www.tslang.cn/docs/handbook/compiler-options.html
3.x內(nèi)存優(yōu)化:https://forum.cocos.org/t/topic/123202/7
System.import('./src/application.js').then(({ createApplication }) => {
return createApplication({
loadJsListFile: (url) => require(url),
});
}).then((application) => {
return application.import('cc').then((cc) => {
require('jsb-adapter/jsb-engine.js');
cc.sys.__init();
// cc.macro.CLEANUP_IMAGE_CACHE = false;
cc.macro.CLEANUP_IMAGE_CACHE = true;
cc.dynamicAtlasManager.enabled = false;
}).then(() => {
return application.start({
settings: window._CCSettings,
findCanvas: () => {
var container = document.createElement('div');
var frame = document.documentElement;
var canvas = window.__canvas;
return { frame, canvas, container };
},
});
});
}).catch((err) => {
console.error(err.toString());
});
替換部分:
// cc.macro.CLEANUP_IMAGE_CACHE = false;
cc.macro.CLEANUP_IMAGE_CACHE = true;
cc.dynamicAtlasManager.enabled = false;
場景切換內(nèi)存泄漏:https://github.com/cocos-creator/engine/pull/9640
creator 3.2.1版本構(gòu)建后有一份備份代碼沒有刪除闽瓢,在asset/script-backup中:https://forum.cocos.org/t/topic/117427
這份代碼是明文的扣讼,打包apk原生包的時(shí)候可以刪除⊥址坑爹的cocos
安卓構(gòu)建之后多出一份備份明文資源:build/android/asset/script-backup耻姥,可以手動(dòng)刪除script-backup文件夾
在之后的版本script-backup文件移到了asset文件夾外,可以不用處理了tween動(dòng)畫在隊(duì)列parallel中使用scale蒸健,new Vec3(1.2婉商, 1.2, 1.2)需要傳入3個(gè)參數(shù)据某,傳入2個(gè)參數(shù)會(huì)導(dǎo)致node的觸摸事件失效,動(dòng)畫沒有問題挽唉。如果該node有添加觸摸事件的時(shí)候筷狼,必須3個(gè)參數(shù)。
let scale1 = t().to(0.35, {scale: new Vec3(1.15, 1.15)});
正確寫法埂材,三個(gè)參數(shù):let scale1 = t().to(0.35, {scale: new Vec3(1.15, 1.15, 1.15)});
-
小于3.4.0版本严拒,resources下的自動(dòng)合圖資源會(huì)生成一份合圖和一份散圖竖独,修改把合圖配置勾選上,如圖:合圖.png
圖片拖進(jìn)去沒有Spriteframe:https://forum.cocos.org/t/topic/134322/3
3.6.1 value.cpp 451行 toDouble() 報(bào)錯(cuò)
/Applications/CocosCreator/Creator/3.6.1/CocosCreator.app/Contents/Resources/resources/3d/engine/native/cocos/bindings/jswrapper/Value.cpp
double Value::toDouble() const {
CC_ASSERT(_type == Type::Number || _type == Type::Boolean || _type == Type::BigInt || _type == Type::String);
if (LIKELY(_type == Type::Number)) {
return _u._number;
}
if (_type == Type::BigInt) {
// CC_LOG_WARNING("convert int64 to double")
return static_cast<double>(_u._bigint);
}
if (_type == Type::String) {
return std::stod(*_u._string);
}
return _u._boolean ? 1.0 : 0.0;
}
修改
double Value::toDouble() const {
// CC_LOG_DEBUG("---- %d", static_cast<int>(_type));
if ( _type == Type::Undefined) {
return 0.0;
}
CC_ASSERT(_type == Type::Number || _type == Type::Boolean || _type == Type::BigInt || _type == Type::String);
if (LIKELY(_type == Type::Number)) {
return _u._number;
}
if (_type == Type::BigInt) {
// CC_LOG_WARNING("convert int64 to double")
return static_cast<double>(_u._bigint);
}
if (_type == Type::String) {
return std::stod(*_u._string);
}
return _u._boolean ? 1.0 : 0.0;
}