Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java LibGDX中的纹理图谱_Java_Libgdx - Fatal编程技术网

Java LibGDX中的纹理图谱

Java LibGDX中的纹理图谱,java,libgdx,Java,Libgdx,我正在尝试加载一个png文件,但我不知道为什么它不工作,因为我已经检查了文件路径,并使用TexturePacker制作了纹理图集。同一路径中的其他图像工作正常。任何帮助都将不胜感激 SpriteBatch batch; Texture img, img2, img4; private Player player, player2; private Texture start, continued; TextureRegion my, my2, my3; TextureRegionDrawable

我正在尝试加载一个png文件,但我不知道为什么它不工作,因为我已经检查了文件路径,并使用TexturePacker制作了纹理图集。同一路径中的其他图像工作正常。任何帮助都将不胜感激

SpriteBatch batch;
Texture img, img2, img4;
private Player player, player2;
private Texture start, continued;
TextureRegion my, my2, my3;
TextureRegionDrawable myt, myt2, myt3;
Button button, button2;
Stage stage, stage2;
String fonte, starte, opcoes;
BitmapFont yesa, funciona;
Image ima;
Texture img3;
Sprite spider;
TextureAtlas textatlas;
FileHandle f;


 public void create(){

 Stage stage = new Stage();
    OrthographicCamera camera = new OrthographicCamera();
    camera.setToOrtho(false, 800, 480);
    batch = new SpriteBatch();
    textatlas = new TextureAtlas("TA/Agorafunfa.png");
    TextureAtlas.AtlasRegion a = textatlas.findRegion("spider");
    spider = new Sprite(a);
    //player2 = new Player("spider.png", Info.WIDTH / 2, Info.HEIGHT / 2);
    player = new Player("playerr.png", Info.WIDTH / 2, Info.HEIGHT / 2);
    img = new Texture("Captura.PNG");
    myt = new TextureRegionDrawable(my);
    yesa = new BitmapFont(Gdx.files.internal("yesa.fnt"));
    fonte = "Escape Planet";
    img2 = new Texture("comeca.png");
    img4 = new Texture("comeca.png");
    img3 = new Texture("saturno.png");
    ima = new Image(img3);
    myt2 = new TextureRegionDrawable(my2);
    funciona = new BitmapFont(Gdx.files.internal("yesa.fnt"));
    starte = "Começar";
    myt3 = new TextureRegionDrawable(my3);
    opcoes = "Opções";
    TextureRegion tx = new TextureRegion(img2);
    Drawable dr = new TextureRegionDrawable(tx);
 }
出现以下错误:

Exception in thread "LWJGL Application" 
 com.badlogic.gdx.utils.GdxRuntimeException: Error reading pack file: 
 TA/Agorafunfa.png
 at com.badlogic.gdx.graphics.g2d.TextureAtlas$TextureAtlasData.<init> 
 (TextureAtlas.java:187)
 at com.badlogic.gdx.graphics.g2d.TextureAtlas.<init>(TextureAtlas.java:231)
 at com.badlogic.gdx.graphics.g2d.TextureAtlas.<init>(TextureAtlas.java:226)
 at com.badlogic.gdx.graphics.g2d.TextureAtlas.<init>(TextureAtlas.java:216)
 at com.badlogic.gdx.graphics.g2d.TextureAtlas.<init> 
(TextureAtlas.java:211)
 at com.mygdx.game.MyGdxGame.create(MyGdxGame.java:63)
 at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop
(LwjglApplication.java:149)
at 
com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run
(LwjglApplication.java:126)
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Invalid line: 
at 
com.badlogic.gdx.graphics.g2d.TextureAtlas.readTuple(TextureAtlas.java:443)
at com.badlogic.gdx.graphics.g2d.TextureAtlas$TextureAtlasData.<init> 
(TextureAtlas.java:115)... 7 more
线程“LWJGL应用程序”中的异常 com.badlogic.gdx.utils.GdxRuntimeException:读取包文件时出错: TA/Agorafunfa.png 位于com.badlogic.gdx.graphics.g2d.TextureAtlas$TextureAtlasData。 (TextureAtlas.java:187) 位于com.badlogic.gdx.graphics.g2d.TextureAtlas。(TextureAtlas.java:231) 位于com.badlogic.gdx.graphics.g2d.TextureAtlas。(TextureAtlas.java:226) 位于com.badlogic.gdx.graphics.g2d.TextureAtlas。(TextureAtlas.java:216) 位于com.badlogic.gdx.graphics.g2d.TextureAtlas。 (TextureAtlas.java:211) 在com.mygdx.game.MyGdxGame.create上(MyGdxGame.java:63) 位于com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop (LwjglApplication.java:149) 在 com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run (LwjglApplication.java:126) 原因:com.badlogic.gdx.utils.GdxRuntimeException:无效行: 在 com.badlogic.gdx.graphics.g2d.TextureAtlas.readTuple(TextureAtlas.java:443) 位于com.badlogic.gdx.graphics.g2d.TextureAtlas$TextureAtlasData。 (TextureAtlas.java:115)。。。还有7个
创建纹理地图集后,您应获得两个文件:
.png
图像和地图集文件,具有相同的名称和扩展名,如
.atlas
.pack

所以你应该使用这个文件

可能:

textatlas = new TextureAtlas("TA/Agorafunfa.atlas"); // Or Agorafunfa.pack or simillar

创建纹理图集后,您应获得两个文件:
.png
图像和具有相同名称和扩展名的图集文件,如
.atlas
.pack

所以你应该使用这个文件

可能:

textatlas = new TextureAtlas("TA/Agorafunfa.atlas"); // Or Agorafunfa.pack or simillar