java - AndEngine GLES 2 - 黑屏,无错误

标签 java android andengine andengine-gles-2

我正在使用 AndEngine GLES 2 为 Android 编写游戏。一切正常 - 我有一个背景图像,有四处移动的 Sprite ,甚至还有一些音乐 - 直到最近我尝试了一些新的东西(我希望能够在两个不同的场景之间切换),当显示屏变黑时。

我仍然可以执行游戏并且没有显示任何错误。显示了我在游戏期间所做的所有日志条目,甚至音乐也在播放,所以我知道游戏正在“正常”运行,但我看不到任何图像。没有什么。全黑。

所以我想,将所有内容改回出现此“错误”之前的状态,就可以解决问题。但是还是黑屏。

我什至尝试注释除背景图片以外的所有内容 - 什么都没有。

现在如果问的不是太多的话,谁能看一下这段简短的代码并告诉我那里有什么问题?

这是我使用的变量:

private SmoothCamera camera;
private BitmapTextureAtlas bitmapTextureAtlas;  
private Scene scene;
private Sprite background;

EngineOptions 我从未更改过,所以它们应该没问题。

@Override
public EngineOptions onCreateEngineOptions() {
    float positionX = 80f; // horizontal (x) position of the camera
    float positionY = 280f; // vertical (y) position of the camera
    float velocityX = 200f; // velocity of the horizontal camera movement
    float velocityY = 200f; // velocity of the vertical camera movement
    float zoomFactor = 1f; // the camera's zoom Factor (standard := 1)
    this.camera = new SmoothCamera(positionX, positionY, this.getWindowManager().getDefaultDisplay().getWidth(), this.getWindowManager().getDefaultDisplay().getHeight(), velocityX, velocityY, zoomFactor);
    EngineOptions options = new EngineOptions(true, ScreenOrientation.LANDSCAPE_SENSOR, new RatioResolutionPolicy(this.camera.getWidth(), this.camera.getHeight()), this.camera);
    return options;
}

我在这里创建了 TextureAtlas 并加载了一个背景图片

@Override
protected void onCreateResources() {
    // create the TextureAtlas
    BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");
    this.bitmapTextureAtlas = new BitmapTextureAtlas(this.getTextureManager(), 1024, 1600, TextureOptions.NEAREST);

    // background
    this.background = new Sprite(0, 0, BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(this.bitmapTextureAtlas, this, "background.png", 0, 0, 1, 1), this.getVertexBufferObjectManager());
    this.mEngine.getTextureManager().loadTexture(this.bitmapTextureAtlas);
}

最后 Scene 被实例化,背景被附加。

@Override
protected Scene onCreateScene() {
    this.scene = new Scene();
    this.scene.attachChild(this.background);        
    return this.scene;
}

现在为什么这个小 Activity 不显示?我忘了:它是一个 SimpleBaseGameActivity。

好吧,由于 AndEngine GLES2 没有在模拟器上运行,我必须使用我的手机 (Samsung Galaxy GIO),无法在另一台机器上测试该应用程序。

有没有人遇到过类似的问题? 非常感谢任何帮助,感谢您抽出宝贵时间!

  • 克里斯托夫

最佳答案

我觉得问题出在这里:

this.bitmapTextureAtlas = new BitmapTextureAtlas(this.getTextureManager(), 1024, 1600, TextureOptions.NEAREST);

Atlas 的尺寸应该是 2 的幂。

关于java - AndEngine GLES 2 - 黑屏,无错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10446945/

相关文章:

java - Dropwizard :"error processing your request"用于从数据库中检索数据

java - 如何生成随机列表并插入到listview中

java - 将 id 存储在 spinner 控件中

android - 显示不同级别的不同场景。和引擎

android - 无法在 AndEngine 中加载 Sprite

java - 填充许多元素时 SWT TreeViewer 速度很慢

java - Android 中 R.java 中的语法错误

android - AChartEngine 在轴上方显示 x 轴标签

java - 无法在 Google App Emulator 中添加 google 帐户

android - 无法解析类型 org.andengine.entity.shape.IAreaShape。