gpt4 book ai didi

java - 小 LibGdx 加载文件时遇到问题

转载 作者:搜寻专家 更新时间:2023-11-01 03:26:33 27 4
gpt4 key购买 nike

所以我一直在尝试将粒子效果文件加载到 libgdx,但我收到了一个文件未找到异常。

这是我的代码:

 particleEffect = new ParticleEffect();
particleEffect.load(Gdx.files.internal("bin/emiter.pahh"),Gdx.files.internal("bin/untitled.png"));

这是我的文件夹的样子

enter image description here :

这里是错误:

Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: bin/untitled.png/Untitled.png
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:107)
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: bin/untitled.png/Untitled.png
at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:140)
at com.badlogic.gdx.graphics.glutils.FileTextureData.prepare(FileTextureData.java:64)
at com.badlogic.gdx.graphics.Texture.load(Texture.java:175)
at com.badlogic.gdx.graphics.Texture.create(Texture.java:159)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:133)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:126)
at com.badlogic.gdx.graphics.g2d.ParticleEffect.loadTexture(ParticleEffect.java:195)
at com.badlogic.gdx.graphics.g2d.ParticleEffect.loadEmitterImages(ParticleEffect.java:190)
at com.badlogic.gdx.graphics.g2d.ParticleEffect.load(ParticleEffect.java:138)
at com.me.mygdxgame.MyGdxGame.create(MyGdxGame.java:124)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:121)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:104)
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: File not found: bin\untitled.png\Untitled.png (Internal)
at com.badlogic.gdx.files.FileHandle.read(FileHandle.java:127)
at com.badlogic.gdx.files.FileHandle.length(FileHandle.java:566)
at com.badlogic.gdx.files.FileHandle.readBytes(FileHandle.java:215)
at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:137)
... 11 more

可能是什么问题?

最佳答案

您的文件路径为:“assets/emiter.phh”

根据你的图片应该是:“assets/emiter.pahh”。

编辑:

我查看了您修改后的错误消息:

Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: com.badlogic.gdx.utils.GdxRuntimeException: File not found: assets\emiter.pahh (Internal)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:107)
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: File not found: assets\emiter.aphh (Internal)

名称在堆栈跟踪中间更改的事实让我感到困惑...

"File not found: assets\emiter.pahh (Internal)"
"File not found: assets\emiter.aphh (Internal)"

您确定您已经正确命名它吗,因为错误源自 libGDX 的文件句柄。另外,文件是否被放入您正在运行的项目的“bin”文件夹中?您应该能够在“my-gdx-game/bin/emitter.pahh”中看到该文件。

此外,必须尝试在 libGDX 测试项目中运行 ParticleEmitterTest 吗?

编辑2:

您需要更改以下两行:

particleEffect = new ParticleEffect();
particleEffect.load(Gdx.files.internal("bin/emiter.pahh"),
Gdx.files.internal("bin/untitled.png"));

到:

particleEffect = new ParticleEffect();
particleEffect.load(Gdx.files.internal("bin/emiter.pahh"),
Gdx.files.internal("bin"));

我相信图像的路径是在发射器文件中定义的:)。

关于java - 小 LibGdx 加载文件时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12586395/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com