To create a parallax effect for the background, we have to create a new class similar to how we created the
MovingSprite class. So, go to File | New | File and create a new swift file called
In the file, import SpriteKit at the top of the file and create some constants. In the class, we will just take the name of the file that we want for the parallax effect. Then we will create two sprites called
sprite2 from it. We will take a value of speed at which we want to move the sprites. We will then take the instance of the
GameplayScene class so that we can add the sprites to the gameplay class. We will also create a global constant to get the size of the view:
import Foundation import SpriteKit ...