GameSalad Project - Parallax Demo
A very rough GameSalad template showing horizontal and vertical parallax backgrounds.
It requires game attributes to store the location of the player/character, and the width and height of the level/scene (not backgrounds). Both backgrounds have two change attributes on them to move accordingly when the player/character moves
self.Position.X = (self.Size.Width / 200) * (100-((game.Player X / game.Level Width) * 100))
self.Position.Y = (self.Size.Height / 200) * (100-((game.Player Y / game.Level Height) * 100))
In theory (self.Size.Width / 100) should work but I found that when you went too far left or right the background scrolled off of the screen and was destroyed. You may need to play around with that number. 200 seems fine.
In this example project the level size was set to the same size as the device 320×568. I’ve not tested it on a bigger scene because I didn’t want to have to move the camera too, but as long as the backgrounds are a lot bigger than the level/scene and you change the game attributes with the correct size it might be ok.
Drag the character (white box) around the screen to see the backgrounds scroll vertically and horizontally.
Please note that I may have got the backgrounds layered in the wrong order. I know the furthest layer away should move the slowest so I believe that would be the smallest sized background. And the largest size background towards the front.
You should be able to add as many different layered backgrounds as you want as they all use the same formulas for x and y movement.
If I ever work on a game where this is needed and I find a much better method of doing this I will update it.
Click the link above to download the zip file.