我在加载正在执行的项目级别时遇到一些问题。我已经将.tmx文件和.png图像从该级别放到“资产”文件夹中,但是我仍然遇到此错误:

Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: Downloads/simpleGraphics_tiles16x16.png
at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:147)
at com.badlogic.gdx.graphics.TextureData$Factory.loadFromFile(TextureData.java:98)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:100)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:96)
at com.badlogic.gdx.maps.tiled.TmxMapLoader.load(TmxMapLoader.java:84)
at com.badlogic.gdx.maps.tiled.TmxMapLoader.load(TmxMapLoader.java:65)
at com.proyecto.game.Screens.PlayScreen.<init>(PlayScreen.java:28)
at com.proyecto.game.MainMenuScreen.MainMenuScreen.render(MainMenuScreen.java:57)
at com.badlogic.gdx.Game.render(Game.java:46)
at com.proyecto.game.miProject.render(miProject.java:21)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:225)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:126)
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: File not found:
Downloads\simpleGraphics_tiles16x16.png (Internal)
at com.badlogic.gdx.files.FileHandle.read(FileHandle.java:136)
at com.badlogic.gdx.files.FileHandle.readBytes(FileHandle.java:222)
at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:144)
... 11 more


我也在使用此调用地图:

    maploader = new TmxMapLoader();
    map = maploader.load("Nivel1.tmx");
    renderer = new OrthogonalTiledMapRenderer(map);


是什么导致错误?

最佳答案

.tmx文件具有您的.png文件的条目。您将.tmx文件与所有关联的.png保留在资产中,但未在.tmx文件中编辑路径

可能是您在.tmx条目中输入了这样的内容:

<image source="Downloads\simpleGraphics_tiles16x16.png" width="64" height="64"/>


因此将其更改为:

<image source="simpleGraphics_tiles16x16.png" width="64" height="64"/>


我假设simpleGraphics_tiles16x16.png.tmx文件位于Assets中的同一文件夹中。

09-10 13:07