How do I Parallax Objects On One Layer?

0 favourites
  • 4 posts
From the Asset Store
Set of 10 Parallax Background to make pixel art game.
  • Hello and thanks for looking,

    Im making a game with several objects parallaxing in the backgrounds resulting in me using 7 layers. I'd rather not use that many. Is there a way to move the objects according to the scroll speed so I can put them all on one layer?

    I have scrollX following a camera which is lerping the main character so the screen only scrolls when the camera/character reaches an X threshhold - how would I go about making the objects scroll with the camera?


  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Just to make sure, if you're worried about performance impact from using too many layers, don't be. Number of layers shouldn't affect performance. In fact, moving all the objects through events rather than letting them sit still on their own layer would probably be less efficient.

    That said, depending on what you're using to move the character, you can possibly use the character's movement speed and angle of motion to nudge objects in the opposite direction at different rates. E.g. something like,

    Character is moving

    --> move Object A [Character.Speed/2] at angle [Character.Angle+180]

    --> move Object B [Character.Speed/4] at angle [Character.Angle+180]

    This means Object B will travel at half the speed of Object A in the opposite direction that the character is moving, thus making a sort of parallax effect.

    You can also have a look here at Somebody's effects, namely the Seamless and Scroll effects. They can be used to achieve similar things, albeit per object.

  • Thanks for the reply Sup. Yeah, Im worried about performance and possibly incompatibility issues with mobile as 7 layers just seemed to me to be overkill and to get it to look correct I'd have to add an 8th layer for my floor texture so as not to occlude the parallaxing objects. Im going to try the suggestion you gave and if it comes out wonky I'll just use the 8 layers. Thanks so much for your reply.

  • I have 20 layers and no issues... Layer count shouldn't affect anything unless you have too many objects moving around in complex ways.


Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)