【发布时间】:2020-05-16 09:10:56
【问题描述】:
您好,我在 LibGDX 中运行我的项目的 android 有问题,在桌面上运行一切正常。我在桌面上的工作目录位于“ProjecktGKLibGDX\android\assets”位置(与 android 默认值相同),当我在 android 应用程序中运行 projekt 时,它会因错误而崩溃,而不是找不到文件之一(menu.png )。我为 Sprites 使用 atlas,它的工作方式如下: atlas= new TextureAtlas("Menu.atlas"); 这是我的地图集文件:
menu.png
format: RGBA8888
filter: Nearest,Nearest
repeat: none
EXIT
rotate: false
xy: 1, 418
size: 900, 415
orig: 900, 415
offset: 0, 0
index: -1
LOAD
rotate: false
xy: 1, 1
size: 900, 415
orig: 900, 415
offset: 0, 0
index: -1
menu2.png
format: RGBA8888
filter: Nearest,Nearest
repeat: none
PLAY
rotate: false
xy: 1, 418
size: 900, 415
orig: 900, 415
offset: 0, 0
index: -1
SAVE
rotate: false
xy: 1, 1
size: 900, 415
orig: 900, 415
offset: 0, 0
index: -1
menu3.png
format: RGBA8888
filter: Nearest,Nearest
repeat: none
open_menu
rotate: false
xy: 1, 1
size: 512, 512
orig: 512, 512
offset: 0, 0
index: -1
Atlas 和 png 图像在同一个文件夹中(“ProjecktGKLibGDX\android\assets”),soo android 可以读取 Atlas 文件但无法读取 png 文件。
com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: menu.PNG
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Error reading file: menu.PNG (Internal)
Caused by: java.io.FileNotFoundException: menu.PNG
【问题讨论】:
-
为什么错误报告缺少
menu.PNG 而不是menu.png? -
我在不同的帖子中读到,android 可以像 PNG soo 一样读取它,在一次测试中我改变了这一点,但它与 PNG 和 png 一起工作我也尝试将名称“menu.atlas”更改为“ menu.pack”,然后在android运行,他找不到文件menu.pack,在桌面运行它总是工作
-
注意信箱。在 Windows 上,即操作系统没有区别,并且会忽略字母大小写加载文件。但是在基于 linux 的系统上,作为 android 你必须匹配字母大小写。
标签: libgdx