我在手机上使用 AIDE 使用 libgdx 引擎编写此程序。当我运行该程序时,它几乎立即崩溃。我没有机会做太多事情,但我已将问题缩小到尝试加载我自己的图片。当我删除/禁用代码“Texture(Gdx.files.internal("button_center.png"));” 该程序能够运行。另一个图像是在启动项目时预加载的,不存在任何问题。我尝试将我的图像移动到与工作图像相同的文件夹并刷新构建,但应用程序仍然崩溃。
这是代码:
package pavlov.murderdoggyalpha;
import com.badlogic.gdx.*;
import com.badlogic.gdx.graphics.*;
import com.badlogic.gdx.graphics.g2d.*;
import pavlov.murderdoggyalpha.*;
public class MyGdxGame implements ApplicationListener
{
Texture texture;
Texture butDownLeft;
Texture butLeft;
Texture butUpLeft;
Texture butDown;
Texture butCenter;
Texture butUp;
Texture butDownRight;
Texture butRight;
Texture butUpRight;
SpriteBatch batch;
int touchX;
int touchY;
@Override
public void create()
{
texture = new Texture(Gdx.files.internal("android.jpg"));
butCenter = new Texture(Gdx.files.internal("button_center.png"));
batch = new SpriteBatch();
}
@Override
public void render()
{
Gdx.gl.glClearColor(1, 1, 1, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
batch.draw(texture, touchX, touchY,
Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
if (Gdx.input.justTouched());
{
touchX = Gdx.input.getX();
touchY = Gdx.input.getY();
}
batch.end();
}
@Override
public void dispose()
{
}
@Override
public void resize(int width, int height)
{
}
@Override
public void pause()
{
}
@Override
public void resume()
{
}
}
我相信这是错误日志。我提前道歉,我是新手。
这对我来说很突出:
原因:java.io.IOException:无法仅加载 8bit 像素图。
这是其余的:。
10-23 19:48:59.061 3786 4066 E AndroidRuntime 致命异常:GLThread 30571 10-23 19:48:59.061 3786 4066 E AndroidRuntime 进程:pavlov.murderdoggyalpha,PID:3786 10-23 19:48:59.061 AndroidRuntime 3786 E com.badlogic.gdx.utils.GdxRuntimeException:无法加载文件:button_center.png 10-23 19:48:59.061 3786 4066 E AndroidRuntime at com.badlogic.gdx.graphics.Pixmap.(Pixmap.java:140) 10 -23 19:48:59.061 3786 4066 E AndroidRuntime at com.badlogic.gdx.graphics.glutils.FileTextureData.prepare(FileTextureData.java:64) 10-23 19:48:59.061 3786 4066 E AndroidRuntime at com.badlogic.gdx .graphics.Texture.load(Texture.java:130) 10-23 19:48:59。061 3786 4066 E AndroidRuntime 在 com.badlogic.gdx.graphics.Texture.(Texture.java:121) 10-23 19:48:59.061 3786 4066 E AndroidRuntime 在 com.badlogic.gdx.graphics.Texture.(Texture.java :100) 10-23 19:48:59.061 3786 4066 E AndroidRuntime 在 com.badlogic.gdx.graphics.Texture.(Texture.java:92) 10-23 19:48:59.061 3786 4066 E AndroidRuntime 在 pavlov.murderdoggyalpha。 MyGdxGame$0$debug.create(MyGdxGame.java:35) 10-23 19:48:59.061 3786 4066 E AndroidRuntime at pavlov.murderdoggyalpha.MyGdxGame.create(MyGdxGame.java) 10-23 19:48:59.061 3786 4066 E AndroidRuntime在 com.badlogic.gdx.backends.android.AndroidGraphics.onSurfaceChanged(AndroidGraphics.java:236) 10-23 19:48:59.061 3786 4066 E AndroidRuntime 在 android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1519) 10-23 19:48:59.061 3786 4066 E AndroidRuntime 在 android.opengl.GLSurfaceView$ GLThread.run(GLSurfaceView.java:1240) 10-23 19:48:59.061 3786 4066 E AndroidRuntime 原因:java.io.IOException: 无法加载像素图 8bit only 10-23 19:48:59.061 3786 4066 E AndroidRuntime在 com.badlogic.gdx.graphics.g2d.Gdx2DPixmap.(Gdx2DPixmap.java:57) 10-23 19:48:59.061 3786 4066 E AndroidRuntime 在 com.badlogic.gdx.graphics.Pixmap.(Pixmap.java:138) 10-23 19:48:59.061 3786 4066 E AndroidRuntime ... 10 更多 10-23 19:48:59。061 3786 4066 E AndroidRuntime 致命异常:GLThread 30571 10-23 19:48:59.061 3786 4066 E AndroidRuntime 进程:pavlov.murderdoggyalpha,PID:3786 10-23 19:48:59.061 3786 4066 E AndroidRuntime.bad.util .GdxRuntimeException:无法加载文件:button_center.png 10-23 19:48:59.061 3786 4066 E AndroidRuntime at com.badlogic.gdx.graphics.Pixmap.(Pixmap.java:140) 10-23 19:48:59.061 3786 4066 E AndroidRuntime 在 com.badlogic.gdx.graphics.glutils.FileTextureData.prepare(FileTextureData.java:64) 10-23 19:48:59.061 3786 4066 E AndroidRuntime 在 com.badlogic.gdx.graphics.Texture.load( Texture.java:130) 10-23 19:48:59。061 3786 4066 E AndroidRuntime 在 com.badlogic.gdx.graphics.Texture.(Texture.java:121) 10-23 19:48:59.061 3786 4066 E AndroidRuntime 在 com.badlogic.gdx.graphics.Texture.(Texture.java :100) 10-23 19:48:59.061 3786 4066 E AndroidRuntime 在 com.badlogic.gdx.graphics.Texture.(Texture.java:92) 10-23 19:48:59.061 3786 4066 E AndroidRuntime 在 pavlov.murderdoggyalpha。 MyGdxGame$0$debug.create(MyGdxGame.java:35) 10-23 19:48:59.061 3786 4066 E AndroidRuntime at pavlov.murderdoggyalpha.MyGdxGame.create(MyGdxGame.java) 10-23 19:48:59.061 3786 4066 E AndroidRuntime在 com.badlogic.gdx.backends.android.AndroidGraphics.onSurfaceChanged(AndroidGraphics.java:236) 10-23 19:48:59.061 3786 4066 E AndroidRuntime 在 android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1519) 10-23 19:48:59.061 3786 4066 E AndroidRuntime 在 android.opengl.GLSurfaceView$ GLThread.run(GLSurfaceView.java:1240) 10-23 19:48:59.061 3786 4066 E AndroidRuntime 原因:java.io.IOException: 无法加载像素图 8bit only 10-23 19:48:59.061 3786 4066 E AndroidRuntime在 com.badlogic.gdx.graphics.g2d.Gdx2DPixmap.(Gdx2DPixmap.java:57) 10-23 19:48:59.061 3786 4066 E AndroidRuntime 在 com.badlogic.gdx.graphics.Pixmap.(Pixmap.java:138) 10-23 19:48:59.061 3786 4066 E AndroidRuntime ... 10 更多 10-2061 3786 4066 E AndroidRuntime 在 android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1519) 10-23 19:48:59.061 3786 4066 E AndroidRuntime 在 android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240 ) 10-23 19:48:59.061 3786 4066 E AndroidRuntime 原因:java.io.IOException: 无法加载 pixmap 8bit only 10-23 19:48:59.061 3786 4066 E AndroidRuntime at com.badlogic.gdx.graphics。 g2d.Gdx2DPixmap.(Gdx2DPixmap.java:57) 10-23 19:48:59.061 3786 4066 E AndroidRuntime at com.badlogic.gdx.graphics.Pixmap.(Pixmap.java:138) 10-23 19:48:59.061 3786 4066 E AndroidRuntime ... 10 更多 10-2061 3786 4066 E AndroidRuntime 在 android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1519) 10-23 19:48:59.061 3786 4066 E AndroidRuntime 在 android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240 ) 10-23 19:48:59.061 3786 4066 E AndroidRuntime 原因:java.io.IOException: 无法加载 pixmap 8bit only 10-23 19:48:59.061 3786 4066 E AndroidRuntime at com.badlogic.gdx.graphics。 g2d.Gdx2DPixmap.(Gdx2DPixmap.java:57) 10-23 19:48:59.061 3786 4066 E AndroidRuntime at com.badlogic.gdx.graphics.Pixmap.(Pixmap.java:138) 10-23 19:48:59.061 3786 4066 E AndroidRuntime ... 10 更多 10-2还有 10 个 10-2还有 10 个 10-2GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1519) 10-23 19:48:59.061 3786 4066 E AndroidRuntime at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240) 10-23 19:48:59.061 3786 4066 E AndroidRuntime 原因:java.io.IOException:无法仅加载 8 位像素图 10-23 19:48:59.061 3786 4066 E AndroidRuntime at com.badlogic.gdx.graphics.g2d.Gdx2DPixmap.(Gdx2DPixmap.java:57 ) 10-23 19:48:59.061 3786 4066 E AndroidRuntime at com.badlogic.gdx.graphics.Pixmap.(Pixmap.java:138) 10-23 19:48:59.061 3786 4066 E AndroidRuntime ... 10 更多 10- 2GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1519) 10-23 19:48:59.061 3786 4066 E AndroidRuntime at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240) 10-23 19:48:59.061 3786 4066 E AndroidRuntime 原因:java.io.IOException:无法仅加载 8 位像素图 10-23 19:48:59.061 3786 4066 E AndroidRuntime at com.badlogic.gdx.graphics.g2d.Gdx2DPixmap.(Gdx2DPixmap.java:57 ) 10-23 19:48:59.061 3786 4066 E AndroidRuntime at com.badlogic.gdx.graphics.Pixmap.(Pixmap.java:138) 10-23 19:48:59.061 3786 4066 E AndroidRuntime ... 10 更多 10- 2061 3786 4066 E AndroidRuntime at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240) 10-23 19:48:59.061 3786 4066 E AndroidRuntime 原因:java.io.IOException:无法仅加载 8 位像素图10-23 19:48:59.061 3786 4066 E AndroidRuntime at com.badlogic.gdx.graphics.g2d.Gdx2DPixmap.(Gdx2DPixmap.java:57) 10-23 19:48:59.061 3786 4066 E AndroidRuntime at com.badlogic.gdx .graphics.Pixmap.(Pixmap.java:138) 10-23 19:48:59.061 3786 4066 E AndroidRuntime ... 10 更多 10-2061 3786 4066 E AndroidRuntime at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240) 10-23 19:48:59.061 3786 4066 E AndroidRuntime 原因:java.io.IOException:无法仅加载 8 位像素图10-23 19:48:59.061 3786 4066 E AndroidRuntime at com.badlogic.gdx.graphics.g2d.Gdx2DPixmap.(Gdx2DPixmap.java:57) 10-23 19:48:59.061 3786 4066 E AndroidRuntime at com.badlogic.gdx .graphics.Pixmap.(Pixmap.java:138) 10-23 19:48:59.061 3786 4066 E AndroidRuntime ... 10 更多 10-2t 仅加载 8 位像素图 10-23 19:48:59.061 3786 4066 E AndroidRuntime at com.badlogic.gdx.graphics.g2d.Gdx2DPixmap.(Gdx2DPixmap.java:57) 10-23 19:48:59.061 3786 4066 E AndroidRuntime at com.badlogic.gdx.graphics.Pixmap.(Pixmap.java:138) 10-23 19:48:59.061 3786 4066 E AndroidRuntime ... 10 更多 10-2t 仅加载 8 位像素图 10-23 19:48:59.061 3786 4066 E AndroidRuntime at com.badlogic.gdx.graphics.g2d.Gdx2DPixmap.(Gdx2DPixmap.java:57) 10-23 19:48:59.061 3786 4066 E AndroidRuntime at com.badlogic.gdx.graphics.Pixmap.(Pixmap.java:138) 10-23 19:48:59.061 3786 4066 E AndroidRuntime ... 10 更多 10-2