Member-only story
Build SwiftUI Games Using SpriteKit
SwiftUI, SpriteKit, and the missing touch gesture
SpriteKit has been around for almost ten years now, coming out at WWDC 2013, being revised in 2014, 2016, 2017, and 2019, and even being mentioned at WWDC 2020.
It is Apple’s framework for creating 2D games. It is easy to use and a very good way to teach young programmers their craft. Search all your favourite sources for documents talking about how to implement it. Most of the articles you’ll find focus either on the basics (as Felicity Johnson does in this article) or go all out (e.g. Dylan Shine put together a super-impressive guide on building a game).
They are both great articles and I want to build a game too, but I want to look at this more from Artturi Jalli’s point of view. This isn’t a game but illustrates how to use SpriteKit alongside SwiftUI.
Let’s go back to 2019 when Apple let it slip that you can now add an SKScene
into a SwiftUI interface. You do so with these immortal lines: