【问题标题】:libGDX AssetManager file not found *.pack找不到 libGDX AssetManager 文件 *.pack
【发布时间】:2016-04-27 10:29:45
【问题描述】:

您好,我对来自 libgdx 的纹理图集打包器资产管理器有一些问题......也许有人有同样的问题...... 我像这样在我的桌面应用程序中打包我的纹理......它正在运行并生成包文件......

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

在我的资产加载器类中,我加载这个或者我也尝试一下......

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");

...

但是我得到了错误:

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

但该文件存在,并且文件名中没有奇怪的上、下或其他奇怪的符号

有什么建议吗?

【问题讨论】:

    标签: java android libgdx texturepacker


    【解决方案1】:

    通过将工作目录设置为 .../gdx/first 来解决它; 并加载 ppack.atlas 而不是 .pack

    【讨论】:

      【解决方案2】:

      你不需要

      "../android/assets/"

      删除这部分。如果您再次收到错误,请检查 Run/Debug 配置 (Android Studio) 下的 Working Directory 并指定您的资产文件夹。

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

      【讨论】:

      • 我将工作目录更改为资产文件夹,但仍然出现错误 -.- Java 中的当前工作目录: ...\gdx\first\android\assets 和错误 com.mygdx。 game.Assets:无法加载资产“/ppack.pack”com.badlogic.gdx.utils.GdxRuntimeException:找不到文件:\ppack.pack(内部)
      • 您是否正在尝试执行桌面应用程序?
      • assetManager.load("images/ppack.pack",TextureAtlas.class); assetManager.get("images/ppack.pack",TextureAtlas.class);
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-06
      • 1970-01-01
      • 2019-04-14
      相关资源
      最近更新 更多