Using a marching ants effect to create a gear belt
Now that we have animated our circular and worm gears, next, we need to make some belts that can be used to wrap around those gears and connect them.
What we are actually doing is creating a marching ants effect. You probably have used this effect before, but without knowing what it was called – anytime you used your mouse or trackpad and outlined a view or created a bounding box around objects to select them, you were using the marching ants effect. You may remember that in Chapter 6 when we used the Lasso Selection tool in Mac’s Previews app, the little dashes that outlined the portion of the image selected were an example of this effect.
So, to create our gear belt, let’s start this section by adding another new file, which we’ll call BeltView
. Then, as we usually do, we’ll add the variables that make everything work first, inside the BeltView
struct:
@State var animateBelt: Bool = false...