gpt4 book ai didi

android - 尝试使用 TextureAtlas 读取包文件时出现异常

转载 作者:行者123 更新时间:2023-11-29 14:51:57 25 4
gpt4 key购买 nike

这不可行吗?

    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

感谢您的帮助!

最佳答案

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

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

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

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

关于android - 尝试使用 TextureAtlas 读取包文件时出现异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15190460/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com