April 2021
Beginner to intermediate
506 pages
11h 57m
English
In Creating a Custom Protocol to Detect Rotation Changes, you created a custom protocol to help detect when the view changes and the layout updates device rotation. While there’s nothing wrong with how you’ve done it, there is some room for improvement: you can move the GameViewControllerDelegate declaration and supporting protocol methods that are currently saved in the GameScene.swift file to its own file.
Create a new file using the iOS Swift File template. Name this new file GameScene+ViewUpdates.swift and replace its contents with the following code:
| | import SpriteKit |
| | |
| | extension GameScene: GameViewControllerDelegate { |
| | |
| | func didChangeLayout() { |
| | let w = view?.bounds.size.width ... |
Read now
Unlock full access