尝试加载图片时,为什么带有libgdx引擎的AIDE会崩溃?

时间:2017-10-24 00:25:33

标签: java libgdx aide-ide

我在手机上使用AIDE使用libgdx引擎编写此程序。当我运行程序时,它几乎立即崩溃。我没有机会做多少但是我已经把问题缩小到试图加载我自己的照片。当我删除/禁用代码"纹理(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:无法仅加载pixmap 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 3786 4066 E AndroidRuntime 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 at com.badlogic.gdx.graphics.Texture。(Texture.java:121) 10-23 19:48:59.061 3786 4066 E AndroidRuntime at com.badlogic.gdx.graphics.Texture。(Texture.java:100) 10-23 19:48:59.061 3786 4066 E AndroidRuntime at com.badlogic.gdx.graphics.Texture。(Texture.java:92) 10-23 19:48:59.061 3786 4066 E AndroidRuntime at 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 at com.badlogic.gdx.backends.android.AndroidGraphics.onSurfaceChanged(AndroidGraphics.java:236) 10-23 19:48:59.061 3786 4066 E androidRuntime at android.opengl.GLSurfaceView $ 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:无法仅加载pixmap 8bit 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-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 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 at com.badlogic.gdx.graphics.Texture。(Texture.java:121) 10-23 19:48:59.061 3786 4066 E AndroidRuntime at com.badlogic.gdx.graphics.Texture。(Texture.java:100) 10-23 19:48:59.061 3786 4066 E AndroidRuntime at com.badlogic.gdx.graphics.Texture。(Texture.java:92) 10-23 19:48:59.061 3786 4066 E AndroidRuntime at 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 at com.badlogic.gdx.backends.android.AndroidGraphics.onSurfaceChanged(AndroidGraphics.java:236) 10-23 19:48:59.061 3786 4066 E androidRuntime at android.opengl.GLSurfaceView $ 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:无法仅加载pixmap 8bit 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

1 个答案:

答案 0 :(得分:0)

通过谷歌搜索进行一些挖掘“引起:java.io.IOException:无法仅加载pixmap 8bit”我发现由于某种原因它无法加载16位png图像。我不知道如何将其更改为8位图像,所以我去了lunapics并将文件扩展名交换为gif。该应用程序现在运行良好。