• Runtimes
  • Spine player 报错 "Assets could not be loaded."

AssetManagerBase.ts:300


    
   GET http://xx.xx.198.175:8081/crab/crab.atlas 404 (Not Found)

downloadText @ AssetManagerBase.ts:300
loadTextureAtlas @ AssetManagerBase.ts:163
initialize @ Player.ts:364
SpinePlayer @ Player.ts:266
(anonymous) @ index2.html:16
AssetManagerBase.ts:300


    
   GET http://xx.xx.198.175:8081/crab/crab.json 404 (Not Found)

downloadText @ AssetManagerBase.ts:300
downloadJson @ AssetManagerBase.ts:304
loadJson @ AssetManagerBase.ts:116
initialize @ Player.ts:361
SpinePlayer @ Player.ts:266
(anonymous) @ index2.html:16
Player.ts:1079 Uncaught Error: Error: Assets could not be loaded.
{"./crab/crab.atlas":"Couldn't load texture atlas ./crab/crab.atlas: status 404, ","./crab/crab.json":"Couldn't load JSON ./crab/crab.json: status 404, "}
at SpinePlayer.showError (Player.ts:1079:27)
at SpinePlayer.loadSkeleton (Player.ts:451:9)
at SpinePlayer.drawFrame (Player.ts:821:41)
at Player.ts:810:94

我的另一个导出的动画能够正常展示,但是这一个报错,引用地址是对的,但是资源加载却是 404,是什么原因?

Related Discussions
...

根据你提供的信息和错误日志,问题的根本原因是资源文件(crab.atlascrab.json)无法加载,导致 404 错误。这通常意味着这些文件在指定的路径下不存在或路径不正确。

以下是一些可能的解决方案:

  1. 检查文件路径:确保 crab.atlascrab.json 文件确实存在于 http://xx.xx.198.175:8081/crab/ 路径下。你可以手动访问这些 URL 来确认文件是否存在。

  2. 文件名和扩展名:确保文件名和扩展名完全匹配。比如,确保文件名没有拼写错误,扩展名是 .atlas 而不是 .atlas.txt 或其他。

  3. 服务器配置:确保你的服务器正确配置并能够提供这些文件。检查服务器日志以获取更多信息。

  4. CORS 设置:如果你在跨域请求这些资源,确保服务器已正确配置 CORS 头。

  5. 本地测试:如果你在本地测试,确保你使用的是本地服务器而不是直接从文件系统加载。直接从文件系统加载通常会导致 CORS 问题。

你可以参考以下代码示例来确保你的文件路径和加载方式正确:

new spine.SpinePlayer("player", {
    jsonUrl: "http://xx.xx.198.175:8081/crab/crab.json",
    atlasUrl: "http://xx.xx.198.175:8081/crab/crab.atlas",
    animation: "walk",
    backgroundColor: "#666666",
});

确保 jsonUrlatlasUrl 指向正确的文件路径。

    Spinebot 使用了本地服务器,相同目录结构的另一个动画资源文件加载正常。扩展名检查没问题。

    不好意思,文件名的问题,不用看了。。。

      zangbianxuegu I am glad to hear that the problem has been resolved! I will archive your email as well.