为什么带有 libgdx 引擎的 AIDE 在尝试加载我的图像时崩溃?
Why is AIDE with libgdx engine crashing while trying to load my images?
我在 phone 上使用 AIDE 使用 libgdx 引擎编写此程序。当我 运行 程序时,它几乎立即崩溃了。我没有机会做太多,但我已经将问题缩小到尝试加载我自己的图片。当我 delete/disable 代码 "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:无法仅加载 8 位像素图。
这是其余的:。
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 com.badlogic.gdx.utils.GdxRuntimeException:无法加载文件:button_center.png
10-23 19:48:59.061 3786 4066 E AndroidRuntime 在 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 在 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 Caused by: java.io.IOException: couldn't load pixmap 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 com.badlogic.gdx.utils.GdxRuntimeException:无法加载文件:button_center.png
10-23 19:48:59.061 3786 4066 E AndroidRuntime 在 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 在 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 Caused by: java.io.IOException: couldn't load pixmap 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-2
通过谷歌搜索 "Caused by: java.io.IOException: couldn't load pixmap 8bit only" 进行一些挖掘后,我发现由于某种原因它无法加载 16 位 png 图像。我不知道如何将其更改为 8 位图像,所以我去了 lunapics 并将文件扩展名换成了 gif。该应用程序现在运行良好。
我在 phone 上使用 AIDE 使用 libgdx 引擎编写此程序。当我 运行 程序时,它几乎立即崩溃了。我没有机会做太多,但我已经将问题缩小到尝试加载我自己的图片。当我 delete/disable 代码 "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:无法仅加载 8 位像素图。
这是其余的:。
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 com.badlogic.gdx.utils.GdxRuntimeException:无法加载文件:button_center.png 10-23 19:48:59.061 3786 4066 E AndroidRuntime 在 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 在 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 Caused by: java.io.IOException: couldn't load pixmap 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 com.badlogic.gdx.utils.GdxRuntimeException:无法加载文件:button_center.png 10-23 19:48:59.061 3786 4066 E AndroidRuntime 在 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 在 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 Caused by: java.io.IOException: couldn't load pixmap 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-2
通过谷歌搜索 "Caused by: java.io.IOException: couldn't load pixmap 8bit only" 进行一些挖掘后,我发现由于某种原因它无法加载 16 位 png 图像。我不知道如何将其更改为 8 位图像,所以我去了 lunapics 并将文件扩展名换成了 gif。该应用程序现在运行良好。