April 2021
Beginner to intermediate
506 pages
11h 57m
English
While it’s possible to add all of your code to the GameScene class, it’s usually not the best plan and can create problems further down the road when you want to extend your game’s features. Instead, you’ll create a separate Player class to keep your codebase free of the muck that causes spaghetti code.
To further organize your code, you’ll put your new class in its own file. From Xcode’s App menu, select File ▶ New ▶ File... or press ⌘N on your keyboard to create a new file:

When prompted, select the iOS Swift File template as shown in the image, then click Next.
In the Save As field, enter the name, Player.swift and ...
Read now
Unlock full access