How do I Parallax Objects On One Layer?

Get help using Construct 2

Post » Tue Aug 09, 2016 11:09 pm

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?

Thanks :)
B
25
S
7
Posts: 79
Reputation: 2,267

Post » Tue Aug 09, 2016 11:37 pm

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.
B
50
S
23
G
17
Posts: 291
Reputation: 12,432

Post » Tue Aug 09, 2016 11:52 pm

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. :)
B
25
S
7
Posts: 79
Reputation: 2,267

Post » Wed Aug 10, 2016 1:57 am

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

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
81
S
34
G
40
Posts: 3,032
Reputation: 30,424


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 2 guests