# How do I zoom and scroll to a fixed point

0 favourites
• 5 posts
From the Asset Store
Connect the dots in the correct order and draw happy animals!
• I must be having a brain freeze.. Can't figure out how to zoom and scroll with lerp, so that one point of the layer (tip of the flag) always remain in the same fixed position on the screen (where the red cross is).

Zooming is simple:

Set layout scale to lerp(LayoutScale, newScale, dt)

But how do I scroll?

• ## Try Construct 3

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

Construct 3 users don't see these ads
• I must be having a brain freeze.. Can't figure out how to zoom and scroll with lerp, so that one point of the layer (tip of the flag) always remain in the same fixed position on the screen (where the red cross is).

Zooming is simple:

Set layout scale to lerp(LayoutScale, newScale, dt)

But how do I scroll?

scroll behavior?

• Use this equation for x and y. Solving for scrollx1 and scrolly1 should do it

(X-scrollx0)/scale0 = (x-scrollx1)/scale1

• This kinda works - you move the camera position towards the focus point as a fraction of the current scale

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

It goes a bit squiffy if you release and click again before the scale has returned to 1 (I think because the offset values are recalculated whilst its still scaling?) so umm... don't do that <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":-)" title="Smile">

• Thank you, so simple!

I went the wrong way - started by converting coordinates from layer with parallax 100 to layer without the parallax, calculating the offset, converting back and eventually got stuck.

• 5 posts