0

I am developing the game using andengine.. i moving the background image using AutoParallaxBackground..Its working fine.. But i got a blank line between the images..No problem with images

ie: autoParallaxBackground.addParallaxEntity(new ParallaxEntity(-20.0f, new Sprite(0, 0, this.bgTextureRegion1)));

How to fix this issue ?

enter image description here

Device screen shot... Blank line visible at left corner

image size : 720x480 camera size: 720x480 mobile screen size: 320x240

3 Answers 3

3

The problem is caused by the black background of the TextureAtlas bleeding over to the image when bilinear filtering is applied. The solution is to double the leftmost and rightmost 1px line, so that the bleedover has the right color. Here's a nasty fix that should prove that this really is the problem, it however triples the time needed to load the background so it is not useful for production code. When you create the TextureAtlas for the background, do it similarly to this:

BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.backgroundBitmapTexture, this, "background.png", 0, 0);
BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.backgroundBitmapTexture, this, "background.png", 2, 0);
this.backgroundTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.backgroundBitmapTexture, this, "background.png", 1, 0);

What this does is to load the texture three times, the first two times shifted by one px left and right. The third call creates the actual texture region between the two.

3
  • yes. now problem fixed..Its working fine. But same think repeating 3 times..it will take more loading time ? ... I using 4 bg images in game
    – JohnRaja
    Sep 27, 2012 at 9:45
  • Yes, doing that will increase loading time, it's just a test to see whether you have the problem I was talking about. A more correct way is to extract the 1px line from the background as a separate image and load that small picture instead. Even better would be to access the texture and do it via OpenGL, but my kung-fu is not strong enough to do that :-) Does this answer your question?
    – JohnEye
    Sep 27, 2012 at 10:49
  • Yes.. extract answer.. but how and where to place 1px line from background image..
    – JohnRaja
    Sep 27, 2012 at 13:21
0

The Bilinear Texture Option was exactly the problem. In GLES2.0, you can either eliminate the TextureOptions.BILINEAR or you can change it to NEAREST_PREMULTIPLYALPHA.

0

implement preDraw() method for your background sprite and set pGLState.enableDither();

new Sprite(0, CAMERA_HIGHT,
                    this.mParallaxLayerBack, vertexBufferObjectManager) {

                @Override
                protected void preDraw(GLState pGLState, Camera pCamera) {

                    super.preDraw(pGLState, pCamera);
                    pGLState.enableDither();
                }

            }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.