-1

我最近开始学习 LibGdx 我做了一个闪屏。它在桌面上运行得很好,但是当我尝试在 android 模拟器/模拟器或 android 手机上运行时,它无法运行。它只显示黑屏。请帮我解决这个问题。我已在此查询中附加到项目的链接。

https://docs.google.com/file/d/0B38mBPsRVO3ScU83M1dXblItS00/edit?usp=sharing

我在这里添加代码 Android 应用程序

AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration();
cfg.useGL20 = true;

主要 LibGdx 项目代码

public void show() {
    batch = new SpriteBatch();

    Texture splashTexture = new Texture("image/splash.PNG");
    splash = new Sprite(splashTexture);
    splash.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

}

public void render(float delta) {
    Gdx.gl.glClearColor(0, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    batch.begin();
    splash.draw(batch);
    batch.end();
}

它是简单的闪屏代码。我在网上做了研究,但没有发现任何有用的东西。请帮我解决这个问题。

4

2 回答 2

1

由于我不会下载随机 RAR,并且您没有发布代码,因此我将做出有根据的猜测。

可能出现的问题:

  • 您的设备不支持或不完全支持 OpenGL ES 2。我已经看到设备支持 2,但仍然需要纹理大小的 2 次方(例如 Droid 1)。尝试将纹理填充到 2 次方的大小。
  • 您甚至没有尝试使用 OpenGL ES 2。在您的主要活动中,请确保您有类似于以下内容的内容:

    AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration();
    cfg.useGL20 = true;
    

如果您发布源代码并且不要求人们进行下载,您更有可能获得有针对性的答案。

于 2013-09-17T10:26:38.030 回答
1
@Override
public void show() {
 manaer=new AssetManager();
    batch = new SpriteBatch();

    manager.load("Image/splash.PNG",Texture.class);
    manager.finishLoading();
    Texture splashTexture = manager.get("Image/splash.PNG",Texture.class);
    splash = new Sprite(splashTexture);
    splash.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

}

事情是你的资产在绘制之前没有完全加载。所以使用 manager.finishloading() 你强制代码停止执行,直到图像被加载

于 2013-09-17T11:15:00.873 回答