In the last days I am building my first iOS game using Spritekit. During this process, I needed to create a “rain” of objects (nodes) that are generated continuously, frame by frame, like it was actually rain. In a few simple steps, I will show you how to create this type of effect.
First of all we need to create our Spritekit project. From this template we can delete everything that is useless, such as all the elements inside GameScene.sks.
Now we need to create a new class, in my case RainFall, that inherits SKNode. Then we initialize an image: SKSpriteNode, and create a random variable that will be multiplied by the width of the scene. In this way the nodes will spawn randomly over the whole width of the scene. Next we add the physicBody declaring a texture and the dimensions for the node. In addition to dimensions, we also need to create a CategoryBitMask and collisions (later on we will see how to set up them). …
Passing data from the Contents.swift to the LiveViewController.swift could cause some difficulties, given that currently no official resources are available regarding this topic. Let’s see how to do it together.
First of all you need to download the Official Template from the Apple Developer website: template