Generating Barriers

You’ve already created the only external variables on which blockRunner depends. Now you can jump into the function itself:

func blockRunner() {        for(block, blockStatus) in self.blockStatuses {            var thisBlock = self.childNodeWithName(block)            if blockStatus.shouldRunBlock() {                blockStatus.timeGapForNextRun = random()                blockStatus.currentInterval = 0                blockStatus.isRunning = true            }            if blockStatus.isRunning {                if thisBlock.position.x > blockMaxX {                    thisBlock.position.x -= CGFloat(self.groundSpeed)                }else {                    thisBlock.position.x = self.origBlockPositionX ...

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.