简体   繁体   中英

libGDX AssetManager file not found *.pack

Hi I have some problems with the texture atlas packer assetmanager from libgdx.... maybe someone had the same issue... I pack my textures in my desktop app like this ... which is running and the pack files are generated...

public class DesktopLauncher {
private static boolean rebuildAtlas = false;
private static boolean drawDebugOutline = true;

public static void main (String[] arg) {
    if (rebuildAtlas) {
        Settings settings = new Settings();
        settings.maxWidth = 1024;
        settings.maxHeight = 1024;
        settings.duplicatePadding = false;
        settings.debug = drawDebugOutline;
        TexturePacker.process(settings, "asset_raw/images", "../android/assets/images", "ppack.pack");
    }

in my assetloader class i load this or i try too ...

public void init (AssetManager assetManager) {
    this.assetManager = assetManager;

    // set asset manager error handler
    assetManager.setErrorListener(this);
    assetManager.load("../android/assets/images/ppack.pack",TextureAtlas.class);


    // start loading assets and wait until finished
    assetManager.finishLoading();
    Gdx.app.debug(TAG, "# of assets loaded: "+ assetManager.getAssetNames().size);
    for (String a : assetManager.getAssetNames())
        Gdx.app.debug(TAG, "asset: " + a);

    TextureAtlas atlas = assetManager.get(../android/assets/images/ppack.pack");

...

However i get the error :

com.mygdx.game.Assets: Couldn't load asset '../android/assets/images/ppack.pack'

But the file exist and has no strange upper lower or antoher strange symbol in its name

any suggestions ?

You shouldn't need

"../android/assets/"

remove this part. If you get the error again check your Working Directory under Run/Debug configurations (Android Studio) and specify your assets folder.

https://github.com/libgdx/libgdx/wiki/Managing-your-assets

solved it by setting the working directory to .../gdx/first; and loading the ppack.atlas and not the .pack

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM