This question already has an answer here:
I'm developing a 2D Platform game, I have a 2D camera, some backgrounds, and everything is working good. Now I want to implement parallax scrolling to give the illusion of depth in my game, but i can't imagine how to make my different layers of background to move (most correctly, be rendered by the camera) with a different speed from each other).
In brief this is my game structure:
I have 3 layers of backgrounds: the first is the road level, where the player runs; the second is the intermediate; the third are some mountains very distant (in my mind). Everyone of these layers is created with seamless textures and organized with the tilemap technique, with every texture positioned one after the other. Of course I make the spritebatch draw only the visible ones.
The camera is a rectangle that follows player movements and goes just horizzontaly.
Since layers aren't moving, but only the camera is moving, I don't know how to make a background scroll with a different speed from another!