打包 apk 測試遇到奇怪的問題,
[ERROR]: E/ ERROR: Uncaught TypeError: Error 6903, please go to https://github.com/cocos-creator/engine/blob/develop/EngineErrorMap.md#6903 to see details., location: src/cocos-js/cc.js:0:0
官網說這是資源加載有問題, 測試了確定不是加載不到, 是在後續流程使用clone出錯
public static createEffect(path: any, cb: any, parent: any) {
this.loadRes("/gamePackages/effects/" + path, Prefab, function (err: any,
prefab: any) {
if (err) {
cb('err', null);
return;
}
//實際是這裡出錯
var node = instantiate(prefab);
if (!parent) {
parent = find("Canvas");
}
parent.addChild(node);
cb(null, node);
});
}
測試了發現instantiate(prefab) 有問題, prefab載入的並非是prefab資源
public static loadRes(url: string, type: any, cb: Function = () => { }) {
resources.load(url, (err: any, res: any) => {
if (err) {
error(err.message || err);
cb(err, res);
return;
}
cb && cb(null, res);
})
}
由於 BonusTime.Prefab 跟 BonusTime.anim 原本在同一個層級目錄所造成的, resources.load 加載到的是 animation 資源
後來把 BonusTime.anim 改名成 BonusTimeaAim.anim 結果發現 animation.on("finished" 在動畫結束後調用沒有正常調用, 查看了下 animation 配置, 估計是因為修改了命名造成
let ani = node.getComponent(Animation);
ani.play('bonusTime');
ani.once(Animation.EventType.FINISHED, () => {
node && node.destroy();
callback(null);
}, this);
後來測試發現轉盤點Start會卡死, 看了看日誌也沒發現問題在哪
看了下代碼, 因為轉盤很單純的, 後來去排查老版本發現也有問題, 那就不是替換造成的了, 查了裡面的animation發現有missing, 把 animation.play 關閉後就好了
沒有留言:
張貼留言