Another question: I call the function which generates sprites per time. But when I interrupt the game, for example picking up the call or double-click home button and go to task-manager, my scene doesn't stop and continue calling this function (oh, in this function i recall it per random time, cause in didMoveToView it calls once). So how stop the scene when game was interrupted? Thank you!
func spawnRocks(){
if gameOver == 0{
score++
scoreLabel.text = "\(score)"
let rockPosition = arc4random() % UInt32(self.frame.height/1.5)
var rockAmount = CGFloat(rockPosition) - self.frame.size.height/4
var rockTexture = SKTexture(imageNamed: randomRock())
rock = SKSpriteNode(texture: rockTexture)
rock.setScale(randomRockScale())
rock.position = CGPointMake(CGRectGetMidX(self.frame) + self.frame.size.width, CGRectGetMidY(self.frame) + rockAmount)
var moveRock = SKAction.moveByX(-self.frame.size.width*2, y: 0, duration: NSTimeInterval(randomRockMove()))
var removeRock = SKAction.removeFromParent()
var moveRemoveRock = SKAction.sequence([moveRock, removeRock])
rock.runAction(moveRemoveRock)
rockObject.addChild(rock)
NSTimer.scheduledTimerWithTimeInterval(NSTimeInterval(randomRockSpeed()), target: self, selector: Selector("spawnRocks"), userInfo: nil, repeats: false)
}
}