Better Programming

Advice for programmers.

Follow publication

Member-only story

Build SwiftUI Games Using SpriteKit

Mark Lucking
Better Programming
Published in
4 min readJun 16, 2021

--

Gem glowing in the dark
Photo by Michael Dziedzic on Unsplash.

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:

--

--

Mark Lucking
Mark Lucking

Written by Mark Lucking

Coding for 35+ years, enjoying using and learning Swift/iOS development. Writer @ Better Programming, @The StartUp, @Mac O’Clock, Level Up Coding & More

Write a response