Hello Scirra community,
I made a template that helps developers easily add parallax backgrounds to side-scrolling games. Check it out here : https://www.scirra.com/store/royalty-fr ... ounds-1289
The template computes each background's position and width from the scrollx and scrolly system parameters.
The backgrounds move nicely as you can see in this video : https://youtu.be/0YkXoFELqWE
There is however one limitation you have to comply with : if you scroll the layout, you have to do it before including the event sheet where I implemented the parallax effect. That way, the parallax effect will always use the newest values of scrollx and scrolly (system expressions).
The problem with this implementation is that if you add ScrollTo or MagiCam behavior to a sprite, my parallax effect will use the old values of scrollx and scrolly every tick to compute the backgrounds' position and width. This will cause the backgrounds to move in a jumpy way.
What I advise my clients to do is to remove the ScrollTo behavior, then manually scroll to the sprite in the event sheet, then include the parallax effect's event sheet after this event and any event that modifies the layout's scrollx and scrolly.
Is there a way to have my parallax algorithm always use the newest values of scrollx and scrolly no matter where I include it in the event sheet? It would also be great to keep using ScrollTo or MagiCam behavior while still getting the newest values of scrollx and scrolly.
If you experienced a similar problem previously, could you suggest a solution? My clients and I would really appreciate it! Thank you.