Hi —,
Looking at the video, this code is firing every tick whilst the player is overlapping a zone sprite (in fact you don't need the "every tick" condition, just checking for the overlap should trigger every tick). Whenever the player sprite moves over a new zone sprite it repositions the camera using lerp to ensure a smooth transition.
Breaking the code down:
lerp(a, b, x) is the linear interpolation of a to b by x. X is usually a value between 0 and 1 representing the percentage of the distance between a and b to travel.
clamp(i, lower, upper) returns lower if i is less than lower, upper if i is greater than upper, else return i. This is a handy expression to restrict the range of a variable.
So in this example, every tick the camera scroll position will move 0.1*60*dt (about 10) percent of the distance from the current camera scrollX position(a) towards the Player.X position(i), limited by the clamp expression to between 160 pixels from the left(lower) and right(upper) of the current zone, so if the player moves outside of that area the camera won't scroll any further until the player moves into the next zone.
If the player changes direction and reenters the central area of the zone then the camera will start to follow them again.
Hope that makes sense!