当我尝试通过 AssetManager 加载我的 TextureAtlas 时,它会引发以下异常:
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: com.badlogic.gdx.utils.GdxRuntimeException: Error reading pack file: data/atlas/mainmenu
at com.badlogic.gdx.assets.AssetManager.handleTaskError(AssetManager.java:517)
at com.badlogic.gdx.assets.AssetManager.update(AssetManager.java:351)
at com.badlogic.gdx.assets.AssetManager.finishLoading(AssetManager.java:372)
at nl.gameplayinc.tubularballs.util.Assets.load(Assets.java:31)
at nl.gameplayinc.tubularballs.util.Assets.create(Assets.java:24)
at nl.gameplayinc.tubularballs.screen.SplashScreen.show(SplashScreen.java:28)
at com.badlogic.gdx.Game.setScreen(Game.java:62)
at nl.gameplayinc.tubularballs.TubularBalls.setScreen(TubularBalls.java:70)
at nl.gameplayinc.tubularballs.TubularBalls.create(TubularBalls.java:27)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:136)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:114)
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Error reading pack file: data/atlas/mainmenu
at com.badlogic.gdx.graphics.g2d.TextureAtlas$TextureAtlasData.<init>(TextureAtlas.java:177)
at com.badlogic.gdx.assets.loaders.TextureAtlasLoader.getDependencies(TextureAtlasLoader.java:58)
at com.badlogic.gdx.assets.loaders.TextureAtlasLoader.getDependencies(TextureAtlasLoader.java:34)
at com.badlogic.gdx.assets.AssetLoadingTask.handleSyncLoader(AssetLoadingTask.java:98)
at com.badlogic.gdx.assets.AssetLoadingTask.update(AssetLoadingTask.java:87)
at com.badlogic.gdx.assets.AssetManager.updateTask(AssetManager.java:454)
at com.badlogic.gdx.assets.AssetManager.update(AssetManager.java:349)
... 9 more
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Invalid line: mainmenu.png
at com.badlogic.gdx.graphics.g2d.TextureAtlas.readValue(TextureAtlas.java:425)
at com.badlogic.gdx.graphics.g2d.TextureAtlas$TextureAtlasData.<init>(TextureAtlas.java:110)
... 15 more
当我正常加载我的地图集时(使用:)new TextureAtlas("data/atlas/mainmenu/mainmenu.atlas"
;)它工作得很好。我需要资产管理器通过 resolutionfileresolver 加载我的文件,所以我进行了以下设置:
public void create()
{
Resolution _568x1136 = new Resolution(568, 1136, ".568x1136");
ResolutionFileResolver resolver = new ResolutionFileResolver(new InternalFileHandleResolver(), _568x1136);
manager = new AssetManager();
manager.setLoader(TextureAtlas.class, new TextureAtlasLoader(resolver));
load();
}
private void load()
{
manager.load("data/atlas/mainmenu", TextureAtlas.class);
manager.finishLoading();
}
异常发生在manager.load("data/atlas/mainmenu", TextureAtlas.class);
我的 .atlas 文件位于 assets\data\atlas\mainmenu\mainmenu.atlas 它在第一行指向的 png 是 mainmenu.png,它位于同一目录中,因为它可以找到带有 'mainmenu.png 的行' 我假设它也找到了正确的 atlas 文件。
我也尝试添加分辨率扩展(mainmenu.atlas.568x1136 和 mainmenu.png.568x1136),但结果相同。
我搜索了很多地方寻求帮助,但似乎无法在任何地方找到我的问题。
如果有人可以帮助我,我将不胜感激!
此外,我似乎无法在 ResolutionFileResolver 上找到很多信息。哪些文件应该具有分辨率扩展名(我将它提供给我的 atlas 和 img 文件),有没有比手动添加扩展名更简单的方法来生成分辨率资源?
编辑添加了 mainmenu.atlas
mainmenu.png
format: RGBA8888
filter: Nearest,Nearest
repeat: none
background
rotate: false
xy: 2, 617
size: 640, 1136
orig: 640, 1136
offset: 0, 0
index: -1
btnbuy
rotate: false
xy: 2, 537
size: 414, 78
orig: 414, 78
offset: 0, 0
index: -1
btncredits
rotate: false
xy: 2, 457
size: 414, 78
orig: 414, 78
offset: 0, 0
index: -1
btnhighscores
rotate: false
xy: 2, 58
size: 414, 77
orig: 414, 77
offset: 0, 0
index: -1
btninfo
rotate: false
xy: 2, 377
size: 414, 78
orig: 414, 78
offset: 0, 0
index: -1
btnmute
rotate: false
xy: 418, 537
size: 94, 78
orig: 94, 78
offset: 0, 0
index: -1
btnnewgame
rotate: false
xy: 2, 297
size: 414, 78
orig: 414, 78
offset: 0, 0
index: -1
btnrate
rotate: false
xy: 755, 1329
size: 58, 424
orig: 58, 424
offset: 0, 0
index: -1
btnresumegame
rotate: false
xy: 2, 217
size: 414, 78
orig: 414, 78
offset: 0, 0
index: -1
btntutorial
rotate: false
xy: 2, 137
size: 414, 78
orig: 414, 78
offset: 0, 0
index: -1
btnunmute
rotate: false
xy: 815, 1675
size: 94, 78
orig: 94, 78
offset: 0, 0
index: -1
display
rotate: false
xy: 2, 2
size: 343, 54
orig: 343, 54
offset: 0, 0
index: -1
longtube
rotate: false
xy: 644, 617
size: 109, 1136
orig: 109, 1136
offset: 0, 0
index: -1