简体   繁体   English

无法加载文件:assets / libgdx128.png

[英]Couldn't load file: assets/libgdx128.png

I'm building a game in LibGDX and have began adding visual aspects of the game such as the logo. 我正在LibGDX中构建游戏,并且已经开始添加游戏的视觉效果,例如徽标。 Considering that I've been using the default libgdxXXX.png files as placeholders for my logo, and that I'm replacing them with my logo, I didn't feel it had any more purpose in my program. 考虑到我一直在使用默认的libgdxXXX.png文件作为徽标的占位符,并且我将其替换为徽标,因此我认为程序中没有其他用途。 I decide to delete it; 我决定删除它; but it decide to not compile and come up with this error: 但它决定不编译并提出此错误:

Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: assets/libgdx128.png
at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:148)
at com.badlogic.gdx.backends.lwjgl.LwjglGraphics.setupDisplay(LwjglGraphics.java:196)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:142)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:124)
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: File not found: assets/libgdx128.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:145)
... 3 more

Somehow, when I return the files from the Trash (I use Linux), it works again! 不知何故,当我从“废纸rash”(我使用Linux)返回文件时,它又可以正常工作了! I have checked my code and found nothing I wrote referred to those files. 我检查了我的代码,发现没有写任何内容引用这些文件。 When I deleted the files 1 by 1, the error changes from libgdx128.png to libgdx64.png to libgdx32.png to libgdx16.png respectively. 当我按1删除文件时,错误分别从libgdx128.png更改为libgdx64.png,从libgdx32.png更改为libgdx16.png。 I have changed all the references from libgdx128.png to my logo.png in my code; 我已在代码中将所有引用从libgdx128.png更改为我的logo.png; yet when I try to delete the libgdx logo and run my program, it fails to compile! 但是,当我尝试删除libgdx徽标并运行程序时,它无法编译! Any ideas? 有任何想法吗?

I found out my problem. 我发现了我的问题。 I forgot all about this code at DesktopLauncher.java: 我在DesktopLauncher.java中忘记了所有有关此代码的信息:

for (int size : new int[] { 128, 64, 32, 16 }) {
    configuration.addIcon("assets/libgdx" + size + ".png", FileType.Internal);
}

I did not know it was referencing to the files I have deleted. 我不知道这是指我已删除的文件。 The configuration.addIcon(); configuration.addIcon(); was the code setting the program icon - similar to how a favicon works. 是设置程序图标的代码-类似于网站图标的工作方式。 I will be adding my own icon now that I know what the code does. 现在我知道代码的作用了,我将添加自己的图标。

Hope this helps anyone else confused about the error. 希望这可以帮助其他对错误感到困惑的人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM