异常试图读取TextureAtlas包文件时, [英] Exception when trying to read pack file with TextureAtlas

查看:335
本文介绍了异常试图读取TextureAtlas包文件时,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

应该不是这个工作?

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

相反,我得到: com.badlogic.gdx.utils.GdxRuntimeException:错误读取包文件:数据/ texture.png 是在上面吴的第一行

Instead I get: com.badlogic.gdx.utils.GdxRuntimeException: Error reading pack file: data/texture.png at the first line above O.o

感谢您的帮助!

推荐答案

首先,你需要创建一个纹理地图,使用的 TexturePacker 是libgdx的推荐方式。它产生的纹理图像和其他文件中(包含libgdx所需信息 TextureAtlas )。

First, you need to create a texture atlas, using TexturePacker is the recommended way for libgdx. It results in the texture image and another file (containing the required information for libgdx TextureAtlas).

在您的code,您需要提供地图集文件的构造,见<一href=\"http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/TextureAtlas.html#TextureAtlas%28com.badlogic.gdx.files.FileHandle%29\"相对=nofollow> TextureAtlas()文档,而不是图像本身:

In your code, you need to provide the atlas file to the constructor, see TextureAtlas() documentation, instead of the image itself:

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

(注意使用'atlas'文件图像文件的代替)

(Notice the use of the 'atlas'-file instead of the image file)

这篇关于异常试图读取TextureAtlas包文件时,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆