tsconfig.json配置:https://www.tslang.cn/docs/handbook/compiler-options.html
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;
creator 3.2.1版本构建后有一份备份代码没有删除,在asset/script-backup中:https://forum.cocos.org/t/topic/117427
这份代码是明文的,打包apk原生包的时候可以删除。坑爹的cocos
安卓构建之后多出一份备份明文资源:build/android/asset/script-backup,可以手动删除script-backup文件夹
在之后的版本script-backup文件移到了asset文件夹外,可以不用处理了tween动画在队列parallel中使用scale,new Vec3(1.2, 1.2, 1.2)需要传入3个参数,传入2个参数会导致node的触摸事件失效,动画没有问题。如果该node有添加触摸事件的时候,必须3个参数。
let scale1 = t().to(0.35, {scale: new Vec3(1.15, 1.15)});
正确写法,三个参数:let scale1 = t().to(0.35, {scale: new Vec3(1.15, 1.15, 1.15)});
-
小于3.4.0版本,resources下的自动合图资源会生成一份合图和一份散图,修改把合图配置勾选上,如图:
图片拖进去没有Spriteframe:https://forum.cocos.org/t/topic/134322/3
3.6.1 value.cpp 451行 toDouble() 报错
/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;
}