Add Support for All Devices and Orientations

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

The Pragmatic Programmers
The Pragmatic Programmers

--

👈 Use Reference Nodes in Y our Scene | TOC | Resize the Player Node on Device Rotation 👉

While not technically a heads-up display (HUD), the D-pad controller and Attack button share a similar quality in that they need to be visible at all times. At the moment, however, once the player moves beyond a certain point, the on-screen controls disappear.

One way to fix this “player movement/control visibility” problem — and the one generally recommended by Apple — is to make the HUD content a child of the camera node. That fix would look something like the image in the Scene Graph View.

images/OperatingTheCameraAndUsingReferenceNodes/scene-editor-camera-children.png

While this isn’t a bad idea, it does limit what you’re able to do, so you’ll learn another way.

But this “player movement/control visibility” problem isn’t the only problem you need to fix. Build and run the program — partly to make sure everything still works properly with your new reference nodes, but more important, to see these secondary problems firsthand.

When the game launches, don’t move the player; instead, rotate the device so that its orientation is landscape. Notice how the controls “fall off” the bottom of the screen. But that’s not all. Also…

--

--

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.