我一直在使用libgdx的Gdx.files.internal()时遇到了麻烦;似乎每次我将其作为桌面应用程序运行时都会出现以下主要错误:
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: File not found: \data\sounds\music\mainmusic.mp3 (Internal) at com.badlogic.gdx.files.FileHandle.read(FileHandle.java:136) at com.badlogic.gdx.backends.lwjgl.audio.Mp3$Music.(Mp3.java:42) ... 10 more
我已经阅读了5个不同的帖子,其中一个看起来是最有可能的问题,所以我尝试过...
- 在assets下创建一个data文件夹
- 刷新Eclipse资源管理器
- Project > clean
- 在bin(在core中)手动创建一个assets/data文件夹
- 三倍检查文件路径
- 重启IDE
完整路径为: /Flipcrew Legends-desktop/assets/data/sounds/music/mainmusic.mp3
public class SplashScreen implements Screen{
final FlipcrewLegends game;
Texture splashTexture;
Sprite splashSprite;
SpriteBatch batch;
TweenManager manager;
Music introMusic;
public SplashScreen(FlipcrewLegends game) {
this.game = game;
introMusic = Gdx.audio.newMusic(Gdx.files.internal("data/sounds/music/mainmusic.mp3"));
introMusic.setLooping(true);
}
然而,这个方法似乎正在起作用...
@Override
public void show() {
splashTexture = new Texture("data/images/main/splash.png");
splashTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
splashSprite = new Sprite(splashTexture);
splashSprite.setColor(1, 1, 1, 0);
}
路径: /Flipcrew Legends-desktop/assets/data/images/main/splash.png
// 因为 Gdx.audio.newMusic 没有直接的字符串路径方法,所以我无法尝试它
附加信息: -> 我已经尝试将核心文件夹中的资产文件夹复制到桌面文件夹中,但没有成功(删除后) -> 有一个帖子说libgdx通常从android文件夹中获取数据,然后应用于桌面(不幸的是,我只有桌面,没有android),但我猜测自那篇文章发布以来,libgdx已经夜间更新,也许已经添加了替代方案?
编辑:
刚才将 assets/data/etc.... 还原为 assets/etc.... 后, 即使是
new Texture(path);
也出现了同样的错误 - 仍然不能工作... 重新尝试上述方法,在发布后重新启动计算机,可能是编译问题。重新启动电脑,没有任何区别