Loading Targets and Bumpers from a Layout File

It’s time to build the other elements of classic pinball games: rectangular bumpers that block and repel the ball when hit, and circular targets that also repel the ball but add points to the player’s score.

Up to this point, we’ve been hard-coding all of our node positions. For a pinball game, you might want to have different layouts for the player to choose from—each with its own unique challenge. Let’s solve that by giving the table node the power to load layouts of targets and bumpers from configuration files.

Specifically, we’re going to use the property list, or plist, format which is Apple’s standard storage mechanism for simple arrays and dictionaries of values. Xcode includes a nice plist ...

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.