cocos creator编译发布后报:Cannot set property 'showFPS' of null
出现环境:win10
项目引用:项目中有从Git上获取的辅助子文件包,但是在项目中没有主动引用
cocos creator版本:2.4.3
出现的情况:将项目编译打包为Web Mobile平台后,使用URL阅览项目时出现,游戏脚本失效,其他组件正常运行,F12查看网页后台出现:
Uncaught TypeError: Cannot set property 'showFPS' of null
at Object.setDisplayStats (cocos2d-js-min.0eb30.js:formatted:13654)
at Object.window.__require.DDMain../DDBatchEventCenter (index.fc871.js:1)
at i (index.fc871.js:1)
at index.fc871.js:1
at Object.window.__require.DDJiesuanAD../DDAssert (index.fc871.js:1)
at i (index.fc871.js:1)
at index.fc871.js:1
at Object.window.__require.DDAd../DDAndroidNativeADCtrl (index.fc871.js:1)
at i (index.fc871.js:1)
at index.fc871.js:1
发现问题:从 Object.setDisplayStats 和 showFPS 可以大致知道是项目在初始化调用显示FPS信息块的时候出错了,这时全局搜索 setDisplayStats() 方法发现只有从Git上拉取的脚本内有,但是又不能修改这个脚本,就只能到编译好的项目下找到 cocos2d-js-min.0eb30.js 文件内的检测方法将其删除;
解决方法:
,cc.game.config.showFPS=!!t //将其从 cocos2d-js-min.0eb30.js内删除
后记:删除后项目脚本可以运行,项目也可以跑了,就是不知道有什么后遗症;