# How do I implement an AutoParallax Background in AndEngine GLES1?

I'm using AndEngine GLES1. In my game, I use AnalogOnScreenControl to move a sprite and when it moves vertically, the background image also moves vertically. I want to do something like this: that is in this link. I know that AutoParallax Background or BackgroundParallaxScrolling may be used. But how do I use it in my game?

Have you looked at the AutoParallax example code in AndEngine? It creates the parallax background layers iike this:

final Scene scene = new Scene();
final AutoParallaxBackground autoParallaxBackground = new AutoParallaxBackground(0, 0, 0, 5);
final VertexBufferObjectManager vertexBufferObjectManager = this.getVertexBufferObjectManager();
autoParallaxBackground.attachParallaxEntity(new ParallaxEntity(0.0f, new Sprite(0, CAMERA_HEIGHT - this.mParallaxLayerBack.getHeight(), this.mParallaxLayerBack, vertexBufferObjectManager)));
autoParallaxBackground.attachParallaxEntity(new ParallaxEntity(-5.0f, new Sprite(0, 80, this.mParallaxLayerMid, vertexBufferObjectManager)));
autoParallaxBackground.attachParallaxEntity(new ParallaxEntity(-10.0f, new Sprite(0, CAMERA_HEIGHT - this.mParallaxLayerFront.getHeight(), this.mParallaxLayerFront, vertexBufferObjectManager)));
scene.setBackground(autoParallaxBackground);


You can read the rest of the code here.

• Sorry for my outside question. I want to ask that is it possible to create this type truck in andengine? Because whenever I create any vehicle it stretches out from the joint. I don't know why this happen. Mar 5 '13 at 19:10
• Ask it in a separate question, or no one will find it! Mar 5 '13 at 19:48
• I Tried this code but VertexBufferObjectManager is not Working.
– Bin
Mar 6 '13 at 9:20
• Can you post the stack trace? Can you run the built in examples, in general? Mar 6 '13 at 16:14
• I have red line on VertexBufferObjectManager and i solve my problem with tileCollision example, link of this example is here:link Thanks.
– Bin
Mar 7 '13 at 5:36