我在加载我正在做的项目的级别时遇到了一些问题。我已经将.tmx文件和.png图像放在“Assets”文件夹中,但我一直有这个错误:
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);
导致错误的原因是什么?
答案 0 :(得分:1)
.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内的同一文件夹中。