Particles
These pages about winter and snow are lacking an important ingredient — snow!
In my opinion, no interactive book is complete without particles. These are elements like fire and rain and explosions and snow. A particle is usually one small image. This image is repeated many times in different sizes, colors and directions.
SpriteKit particles are really easy to create with the SpriteKit Particle Editor. Click File/New/File…. Choose the iOS/Resource/SpriteKit Particle File template and click Next.
From the Particle Template dropdown, choose Snow. I encourage you to experiment with the other particle templates later.
Click Next and name the file Snow, then click Create. The particle file will open and “real” snow will animate in front of you.
Each particle is an instance of a spark texture, but the image is sized differently for each particle. The snowflakes also descend in different speeds and directions. Playing with particles is unfortunately beyond the scope of this tutorial, but all these settings can be changed in the Attributes Inspector.
Open Scene01.sks. You’ll notice that there are two backgrounds here. The backgrounds are exactly the same except that backgroundAlpha has a transparent section for the window. You’ll sandwich the snow between these two backgrounds.
Drag your Snow.sks file from the Project navigator to the top center of the window in the background image. Change:
-
Name: snow
-
Position: X: 263, Y: 200, Z: -8
Here you set the Z position so that the emitter is sandwiched between the two background nodes.
Click Animate to see the snow fall outside the window! Now it’s looking really wintry.
Where To Go From Here?
I hope you enjoyed working through this tutorial. I love working with Tammy Coron’s art. :]
At this point the story is up to you! You can download the complete sample project and compare notes if you’d like.
If you want to learn more about SpriteKit, be sure to check out our book 2D Apple Games by Tutorials.
If you have any questions or comments, feel free to join in the discussion below!