Sign in to follow this  
ahayweh

2D parallax...

Recommended Posts

ahayweh    164
Quick q : Any ideas on how to incorporate parallax scrolling? The question is now so much *how* but *where*? Right now I am trying to add it into the rendering code, but it doesn't seem to fit very well. Right now , each tile has a set of attributes associated with it ( type , layer etc ) to distinguish the seperate levels. The only problem where to set the different scrolling rates... ahayweh

Share this post


Link to post
Share on other sites
ToohrVyk    1595
This is not a scroll rate issue, it's a scale issue. Change the scale of the background layers in the renderer after you've applied the translation, and the background tiles will be smaller and move around more slowly without any additional effort on your part.

Share this post


Link to post
Share on other sites
JohnHurt    334
In my 2D engine (which is a while ago now), I had a scene manager which kept tiles and objects in seperate layers. These layers could be moved, updated and rendered seperately. To set the scroll speed of each layer you just set a "scroll factor" for it, which is basically just a number you multiply the current camera position by. So a layer with a factor of 1 will move at normal speed, 0.5 will move half as fast, 0 will be stationary etc. You could also have layers in front move faster, and also get layers to move the opposite way if you want to. With a bit of extra work you could also have layers auto-scroll, that way you can simulate clouds moving past in the background.

Share this post


Link to post
Share on other sites
ahayweh    164
Ahhh.. A layering system. That makes very good sense. Then I could pass a pointer to the system to the renderer... Thanks for the idea. I may have to dismantle some elements to get it to work though , but the approach is very sensible.

thx

Share this post


Link to post
Share on other sites
JohnHurt    334
Rather than passing in the layer system to the renderer, I would do it the other way round. Renderers shouldn't really need to know about high level scenegraph details, they just draw stuff ;) Think what would happen if you wanted to re-use your renderer for another project that didn't have the same type of scene management.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this