当我尝试通过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
答案 0 :(得分:3)
“当我正常加载我的地图集时(使用:new TextureAtlas(”data / atlas / mainmenu / mainmenu.atlas “);)它的工作正常。”
“在manager.load上发生异常(”data / atlas / mainmenu “,TextureAtlas.class);”
“我的.atlas文件位于assets \ data \ atlas \ mainmenu \ mainmenu.atlas ”
在调用packfile .atlas
而不只是mainmenu.atlas
时,将mainmenu
添加到路径中。