【问题标题】:Exception when trying to read pack file with TextureAtlas尝试使用 TextureAtlas 读取包文件时出现异常
【发布时间】:2013-03-03 20:27:53
【问题描述】:

这不应该工作吗?

    TextureAtlas atlas = new TextureAtlas(Gdx.files.internal("data/texture.png"));
    AtlasRegion region = atlas.findRegion("ape_glad");
    Sprite ape= new Sprite(region);

相反,我在 O.o 上方的第一行得到:com.badlogic.gdx.utils.GdxRuntimeException: Error reading pack file: data/texture.png >

感谢您的帮助!

【问题讨论】:

    标签: android textures libgdx


    【解决方案1】:

    首先,您需要创建一个纹理图集,使用TexturePacker 是libgdx 的推荐方式。它会生成纹理图像和另一个文件(包含 libgdx TextureAtlas 所需的信息)。

    在您的代码中,您需要将图集文件提供给构造函数,请参阅TextureAtlas() documentation,而不是图像本身:

    TextureAtlas atlas = new TextureAtlas(Gdx.files.internal("data/texture.atlas"));
    

    (注意使用'atlas'文件而不是图像文件)

    【讨论】:

    • 没有texture.pack这样的文件,只有texture.png。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-28
    • 1970-01-01
    • 1970-01-01
    • 2011-09-04
    相关资源
    最近更新 更多