Positioning Obstacles

The game’s foundation is complete. You have created views for the start screen and the main play area, and you have imported all the image assets. Now you can weave the graphics into your views. First, you should add the ground. The player’s avatar would drop into a blue abyss without it, and no one wants that. You can associate this node with the bar.png graphic. If you haven’t imported this picture, please refer to the “Importing Image Assets” section, earlier in this chapter. After the asset is ready, position it in PlayScene, like this:

override func didMoveToView(view: SKView!) {    self.backgroundColor = UIColor(hex: 0x80D9FF)    self.runningBar.anchorPoint = CGPointMake(0, 0.5)    self.runningBar.position ...

Get Learning Swift™ Programming 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.