Lock the Location of the On-Screen Controls
At the moment, when you switch from portrait to landscape mode, the on-screen controls are located outside of the camera’s viewport. The same is true when the player navigates beyond the view. You will fix both of these problems now.
Creating an Extension to Find the View’s Edges
You first need to implement something similar to what you did in Working with Different Screen Sizes to help you find the edges of the view. However, instead of making an extension that uses methods to return values, you’ll create an extension that uses computed properties, as they’re more efficient and help to produce cleaner, more succinct code.
Create a new file using the iOS Swift File template. Name this new file SKScene+ ...
Get Apple Game Frameworks and Technologies now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.