title: How would I pause my background when my heroNode makes in contact with the enemyNode in Swift Spritekit?
body: <p>I'm trying to pause my background when my hero node makes contact with the enemy. When I use this code I posted below the speed of the background doesn't stop it keeps going its normal speed. I tried declaring the "city" globally only but I get an error saying <code>Attempted to add a SKNode which already has a parent</code>. What am I doing wrong?</p>
  
  <pre><code>class GameScene: SKScene, SKPhysicsContactDelegate {    
      let city = SKSpriteNode(imageNamed: "skyline")
  }
  
  override func didMoveToView(view: SKView) {
      repeatCity()
  }
  
  
  func addCity() {
      let city = SKSpriteNode(imageNamed: "skyline")
      let moveToRight = SKAction.moveByX(-1000, y: 0, duration: 5.0)
      let repeatAction = SKAction.repeatActionForever(moveToRight)
  
  
  
      city.position = CGPointMake(self.size.width / 0.7, self.size.height / 1.9)
      city.zPosition = 13
      city.setScale(0.9)
      city.runAction(repeatAction)
      addChild(city)
  
  
  }
  
  func repeatCity() {
      let generateBlocks = SKAction.sequence([
          SKAction.runBlock(self.addCity),
          SKAction.waitForDuration(3.5)])
      let endlessAction = SKAction.repeatActionForever(generateBlocks)
      runAction(endlessAction)
  
  }
      func didBeginContact(contact:SKPhysicsContact){
  
      if firstBody.categoryBitMask == HeroCategory &amp;&amp; fourthBody.categoryBitMask == EnemyCategory {
  
          city.speed = 0
          theHero.physicsBody?.affectedByGravity = true
          println("contactwithEnemy!!!")
  
      }
  }
  </code></pre>