Animating a gear shaft image
Continuing on to the next component, we need a gear shaft. A gear shaft is a cylindrical rod that has round gears at each end and is used to attach other gears or belts together, ultimately producing some form of output or work. For example, within the motor in your car, there is a gear shaft that turns due to the gasoline combusting. The output or work produced by that process moves the car forward. Our gear shaft won’t move a car, but instead, will turn a fan. After creating this, as with the worm gear, we will animate the gear shaft by using animating rectangles. Again, this is because the image we are using is not round, so we cannot rotate it on the z-axis like the other gear images.
Let’s start off by creating a new SwiftUI View file, which we’ll call GearShaftView
. Next, let’s add the variables we need for this file; we only need one variable, and that’s to track the animation:
@State var animateRect: Bool...