Chapter 10. Working with the Outside World
iOS devices can interact with a wide range of other devices. Some of these devices, such as external screens and game controllers, are particularly useful when you’re building games!
iOS has supported multiple screens since iOS 2, and has supported game controllers since iOS 7. Game controllers are handheld devices that provide physical buttons for your players to use, and have both advantages and disadvantages when compared with touchscreens. Because a game controller has physical buttons, the player’s hands can feel where the controls are, which makes it a lot easier to keep attention focused on the action in the game. Additionally, game controllers can have analog inputs: a controller can measure how hard a button is being held down, and the game can respond accordingly. However, game controllers have fixed buttons that can’t change their position, or look and feel, which means that you can’t change your controls on the fly.
Game controllers that work with iOS devices must obey a set of design constraints specified by Apple; these constraints mean that you can rely on game controllers built by different manufacturers to all behave in a consistent way and provide the same set of controls for your games. To make matters more complex, there are several different profiles of game controller. The simplest (and usually cheapest) is the standard game controller (see Figure 10-1), which features two shoulder buttons, four face buttons, a pause ...
Get iOS Swift Game Development Cookbook, 3rd Edition 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.