Scroll layers independently in any direction?

Get help using Construct 2

Post » Tue Feb 24, 2015 2:37 pm

Is there a good way to scroll layers in any direction, independently of each other?

For instance, in Super Mario World, in some of the castles, there was a parallax background layer, a game layer, and a moving blocks layer that would sweep from side-to-side sinusoidally. That moving blocks layer's offset in the screen was not just a simple scaled version of the camera coordinates.

In C2 I can't find an action that allows you to scroll individual layers to any location you want.
Or if you think of the "camera" as being the thing that is scrolling, I can't find an action that allows you to offset a layer relative to its default starting point.

Going back to the Mario Castle example, if you could specify layer offset via expression it might look like this:
  • layer_background.X = scrollx * 0.5
  • layer_game.X = scrollx
  • layer_movingBlocks.X = scrollx + ( sin( time ) * sweepDistance )


The best workaround I've found so far is a bit of a jury rig.

If, at the start of the layout, I set the "camera" scroll point to the coordinate ( scrollx-100 , scrolly-100 ), then the parallax rate of each layer is effectively that layer's offset in pixels. (I use "-100" instead of "-1" because the scroll rates are given in percentage form.)

I hope I'm not missing something really obvious, but I can't find anything built-in to use in place of this workaround.
B
24
S
15
G
8
Posts: 314
Reputation: 5,751

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 1 guest