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?
1 Answer
\$\begingroup\$
\$\endgroup\$
5
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.
-
\$\begingroup\$ 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. \$\endgroup\$Siddharth– Siddharth2013-03-05 19:10:46 +00:00Commented Mar 5, 2013 at 19:10
-
\$\begingroup\$ Ask it in a separate question, or no one will find it! \$\endgroup\$Cameron Fredman– Cameron Fredman2013-03-05 19:48:27 +00:00Commented Mar 5, 2013 at 19:48
-
\$\begingroup\$ I Tried this code but VertexBufferObjectManager is not Working. \$\endgroup\$Bin– Bin2013-03-06 09:20:20 +00:00Commented Mar 6, 2013 at 9:20
-
\$\begingroup\$ Can you post the stack trace? Can you run the built in examples, in general? \$\endgroup\$Cameron Fredman– Cameron Fredman2013-03-06 16:14:15 +00:00Commented Mar 6, 2013 at 16:14
-