Clean Up the Default Template

Apple Game Frameworks and Technologies — by Tammy Coron (22 / 193)

The Pragmatic Programmers
The Pragmatic Programmers

--

👈 Explore the Default Template | TOC | Set the Supported Device Orientation 👉

As with most default project templates, the default iOS Game template includes a lot of boilerplate code and files you won’t need, so it’s best to remove these things.

In the Project Navigator, select the GameScene.sks and Actions.sks files. You’ll learn more about SKS files in Chapter 7, Building Scenes with the Scene Editor, but for now, right-click these two files, select Delete, and then Move to Trash, as shown in the image.

images/CreatingScenesWithSpritesAndNodes/spritekit-remove-files.png

Still inside the Project Navigator, select the GameScene.swift file, which opens the file in the Source Editor on the right. This file controls the main game scene, and it comes packed with all sorts of properties and methods. As you work through this book, you’ll learn more about this file, but for now, delete everything in that file and replace it with this:

​ ​import​ ​SpriteKit​
​ ​import​ ​GameplayKit​

​ ​class​ ​GameScene​: ​SKScene​ {

​ ​override​ ​func​ ​didMove​(to view: ​SKView​) {

​ }
​ }

This code imports the SpriteKit and GameplayKit frameworks and declares a GameScene class with a single, empty method named didMove(to:). This…

--

--

The Pragmatic Programmers
The Pragmatic Programmers

We create timely, practical books and learning resources on classic and cutting-edge topics to help you practice your craft and accelerate your career.