Search code examples
androidandengine

AutoParallaxBackground vertically in GLES2, AndEngine


How do I move an AutoParallaxBackground vertically in andengine? This is such a simple problem, but I can't find a solution to it!

I use GLES2, and I use the code that code in the example that comes with AndEngine http://code.google.com/p/andengineexamples/source/browse/src/org/anddev/andengine/examples/AutoParallaxBackgroundExample.java.

The thing is that you can't change or add vertical speed anywhere since there is no class created for the AutoParallaxBackground - it is only the parameters in the main class that you can change.


Solution

  • I believe there is no easy way to do that. You will have to modify it to suit your needs, which should be easy enough.

    Edit: For some reason, this question popped up in my feed again, so I looked into the matter a bit more. I believe the key to make this work is to change the method onDraw of ParallaxEntity. There is a call to OpenGL's glTranslatef method which has only one of the three parameters (x, y, z) filled in, so the obvious solution would be to provide the second parameter as well.