Game Development Community

Parallax Background for 2D platformer?

by Ryan Ray Lynch · in Torque Game Builder · 12/10/2011 (9:24 am) · 3 replies

Hello,

In a lot of 2D platformers, I see multiple layers of backgrounds that scroll alongside the character when the player moves, and comes to a stop when the player stops moving. I'm trying to mimic this in my 2D platformer, but I'm only seeing the option to either have the background scroll or to just keep it static.
I was hoping to have the backgrounds scroll left and right at different speeds (depending on distance) when the character moves, as well as have them move when the player goes higher or lower.

Not asking for anyone to make this for me, but could someone point me in the right direction to creating something like this, if possible?

I tried searching, but the results were not only old, but they mostly involved backgrounds that scroll on their own.

Thanks!,
Ryan

#1
12/11/2011 (4:32 pm)
Rather than scrolling the backgrounds, you could set the scroll position of the backgrounds based on where the camera is. So if the camera is at 1000x, your first background could be at position 500 horizontal, and the next distant layer could be at 250 horizontal. You'd need to do this in the scenegraph update so that it is smooth.
#2
12/11/2011 (6:49 pm)
I have the perfect thing for you, assuming you have access to the TDN. Anyhow, there's a behavior that adds exactly what you are looking for. Just attach the behavior, pick the "player" object, and set the speed. Check it out here:
tdn.garagegames.com/wiki/TGB/Behaviors/Parallax_Object
#3
07/28/2012 (9:47 am)
hi!! -> is this demo of the parallax scrolling working with torque2D_1_5?