Frage

When I try to load my TextureAtlas through the AssetManager, it throws the following exception:

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

When I load my atlas normally (using: new TextureAtlas("data/atlas/mainmenu/mainmenu.atlas");) it works just fine. I need the assetmanager to load my files through the resolutionfileresolver so I made the following setup:

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();
}

The exception occurs on manager.load("data/atlas/mainmenu", TextureAtlas.class);

My .atlas file is located at assets\data\atlas\mainmenu\mainmenu.atlas The png it points to at the first line is mainmenu.png which is located in the same directory and since it can find a line with 'mainmenu.png' i assume that it also found the correct atlas file.

I tried adding the resolution extensions as well (mainmenu.atlas.568x1136 and mainmenu.png.568x1136) but with the same result.

I have searched a lot of places for help but can't seem to find my problem anywhere.

If someone could help me I would really appreciate it!

Also, I can't seem to find a lot of information on the ResolutionFileResolver. What files should have the resolution extension (i gave it to both my atlas and img file) and is there an easier way to generate the resolution resources than manually adding the extension?

EDIT Added the 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
War es hilfreich?

Lösung

"When I load my atlas normally (using: new TextureAtlas("data/atlas/mainmenu/mainmenu.atlas");) it works just fine."

"The exception occurs on manager.load("data/atlas/mainmenu", TextureAtlas.class);"

"My .atlas file is located at assets\data\atlas\mainmenu\ mainmenu.atlas"

Add .atlas to the path when your packfile is called mainmenu.atlas and not just mainmenu.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top