I am writing an Android game using AndEngine GLES 2 . Everything worked properly - I had a background image, there were sprites around and even some kind of music - until recently, I tried something new (I wanted to switch between two different scenes) when the display turned black.
I could still execute the game and no errors were found. All the entries in the magazines that I made during the game were shown, even the music played, so I knew that the game was working "correctly", but I did not see any image. Nothing. All are black.
So, I thought, everything changed, before this “error” appeared, it would do the trick. But still the screen is black.
I even tried to comment everything, but the background image is nothing.
Now, if this is not too much to ask, can someone please take a look at this short piece of code and tell me what is wrong there?
These are the variables that I use:
private SmoothCamera camera;
private BitmapTextureAtlas bitmapTextureAtlas;
private Scene scene;
private Sprite background;
EngineOptions I've never changed, so they should be fine.
@Override
public EngineOptions onCreateEngineOptions() {
float positionX = 80f;
float positionY = 280f;
float velocityX = 200f;
float velocityY = 200f;
float zoomFactor = 1f;
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;
}
Here I create a TextureAtlas and load the background image .
@Override
protected void onCreateResources() {
BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");
this.bitmapTextureAtlas = new BitmapTextureAtlas(this.getTextureManager(), 1024, 1600, TextureOptions.NEAREST);
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);
}
Finally, the Scene is created and the background is snapped.
@Override
protected Scene onCreateScene() {
this.scene = new Scene();
this.scene.attachChild(this.background);
return this.scene;
}
Now why won't this little activity be displayed? I forgot: its SimpleBaseGameActivity.
Well, since AndEngine GLES2 does not work on the emulator, I have to use my phone (Samsung Galaxy GIO) and cannot test the application on another machine.
- ?
!