Chapter 9 Operating the Camera and Using References Nodes

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

The Pragmatic Programmers
The Pragmatic Programmers

--

👈 Next Steps | TOC | Add a Camera to Track the Player 👉

In the previous two chapters, you spent most of your time in the Scene Editor creating a new world and adding a player to explore it. The trouble is, once that player ventures out too far beyond the edges of the screen, she’s gone — poof!

In this chapter, you’ll discover how to keep the player visible as she moves around the scene. You might think that using constraints is the way to go, but that limits the area the player can explore. That’s not to say you won’t use constraints to set a boundary around the edges of the world — you will — but first, you need to find a way that allows the player to roam beyond the viewable display while also keeping her visible at all times.

But that’s not all you’ll be doing in this chapter. You’ll also modify the project so that it supports portrait and landscape orientations across all devices. At the moment, there are a few problems:

  • The player sprite appears much larger when you rotate the device.
  • The on-screen controls disappear when you rotate the device.
  • The on-screen controls show up in different places on different devices.

As you work through this chapter, you’ll also discover new ways of structuring your code by taking the…

--

--

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.