Building a Scrolling Table with an Edge Body

Pinball wouldn’t be pinball without the familiar curved table design that guides the launched ball up and around. We want to have that same feel, so we’re going to build a special kind of physics body, called an edge body, that will act as the walls of the table.

But more than that, we want this table to be taller than the screen and scroll to keep the ball centered. That means we need a node to contain the ball, the plunger, and all the other nodes that belong to the game. We’ll reposition that special node representing the table to give the illusion of a camera following the ball.

We’ll start by creating a new file named RCWTableNode.h with this class interface:

06-Physics/step12/PhysicsBall/RCWTableNode.h ...

Get Build iOS Games with Sprite Kit 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.