Account for offset when using Scroll to on parallax layer

Get help using Construct 2

Post » Thu Dec 08, 2016 4:08 am

What's a good way of accounting for the the offset introduced to "Scroll to" when scrolling to an object on a layer with parallax not set to 100,100?


Example File of the problem.
https://drive.google.com/open?id=0B0Ci6 ... VRIcnlQdVU
Arrow keys move sprite.
1 toggles which layer the sprite is on.
B
88
S
14
G
9
Posts: 101
Reputation: 9,962

Post » Thu Dec 08, 2016 10:30 pm

That is a weird gimmick. Doing this, i learned some more about parallax.

https://www.dropbox.com/s/uyhmjgkzxgvrp ... .capx?dl=0

Question is, and please do tell me, how/in what logic you are gonna use this ?
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Fri Dec 09, 2016 2:40 am

I fiddled around more after posting and came to a solution that seemed to work. Adding the canvas offset to the scroll to
Code: Select all
Scroll to
X: Sprite.X+CanvastolayerX("normal",Sprite.X,Sprite.Y)-CanvasToLayerX(Sprite.LayerName,Sprite.X,Sprite.Y)
Y: Sprite.Y+CanvastolayerY("normal",Sprite.X,Sprite.Y)-CanvasToLayerY(Sprite.LayerName,Sprite.X,Sprite.Y)


Updated example file
https://drive.google.com/open?id=0B0Ci6 ... VdPMFZqVU0

You're example works really well also. I can't tell but I think yours maybe smoother and I don't know why. I played with adding a lerp to the scroll to, and that smoothed it out some.

Now I'm trying to figure out the offset if I throw layerscale into the mix, no luck so far.
As to why I'm figuring it out. No reason really I was playing with Parallax and layer scale and wanted to better understand them.
B
88
S
14
G
9
Posts: 101
Reputation: 9,962


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 6 guests