Image for post
Image for post

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.

#Create a SpriteKit Project

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.

Image for post
Image for post

#Create RainFall.swift

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.

#Download the Official Template

First of all you need to download the Official Template from the Apple Developer website: template

Image for post
Image for post

Vincenzo Sannino (Enzosan)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store