Instead of using mScene.setBackground(background)
take a look at background.attachParallaxEntity()
. The AndEngine example for autoparallax is a good example on how to do this. Here's the critical part:
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);
In that example, you can see it's using three different relative "speeds" relative to the camera movement. An alternative approach, in light of your comment that you'd like something to move at a constant speed, is to not think of it as officially a "background," but just treat it as a sprite, with a z-index behind your "foreground" entities, and use a MoveModifier to move the sprite at a constant speed. Here's what I mean:
private void moveBackground() {
//create your sprite
Sprite background = new Sprite(params);
//Give it movement.
background.registerEntityModifier(new MoveModifier(params...));
//Set its z-index to behind your entities.
background.setZIndex([some number lower than your foreground]);
//attach it to your scene.
scene.attachChild(background);
//tell the scene to sort itself so the Z indices are correct.
scene.sortChildren();
}
Don't forget when attaching or removing sprites that it must be done in one of the main threads.