title: SpriteKit Pause Resume Error
body: <pre><code>override func touchesEnded(_ touches: Set&lt;UITouch&gt;, with event: UIEvent?) {
  let touch = touches.first
  let touchLocation = touch!.location(in: self)
  if continueButton.contains(touchLocation) {
      scene?.view?.isPaused = false
      pauseMenu.removeFromParent()
      self.addChild(pauseButton)
      self.addChild(upButton)
      continueButton.removeFromParent()
  }
  }
  </code></pre>
  
  <p>I am having a Thread 1: Signal SIGABRT error when touches ended on the continue button. Something I have found is that if I declare the sprite (continue button) in touches ended the button does not get removed, however, when I declare the continue button sprite outside the function the continue button is removed.The problem is that sometimes the app will just crash showing the thread 1 error. Any ideas on how I can stop the crashing?</p>
  
  <pre><code>class GameScene: SKScene {
  var mainturret = SKSpriteNode(imageNamed: "Main Turret")
  var pauseButton = SKSpriteNode(imageNamed: "Pause Simbol")
  var angleToShoot = 0
  var touchIsOn = 0
  var pointTwoSecondInterval = 0
  let pauseMenu = SKSpriteNode(imageNamed: "Paused")
  var zombieSpawningTimer = Timer()
  var upButton = SKSpriteNode(imageNamed: "Up Button")
  let downButton = SKSpriteNode(imageNamed: "Down Button")
  let popUpMenu = SKSpriteNode(imageNamed: "TurretSpot")
  var continueButton = SKSpriteNode(imageNamed: "Continue")
  ...}
  </code></pre>
  
  <p>This is where the buttons are declared (outside the functions) </p>
  
  <pre><code>import UIKit
  
  @UIApplicationMain
  class AppDelegate: UIResponder, UIApplicationDelegate {
  </code></pre>
  
  <p>Error occurs on the third line of code.
  This is what the computer tells me.</p>
  
  <blockquote>
    <p>2017-06-30 07:32:26.053429-0600 Survive the Night[4635:1030550] <strong>*
    Terminating app due to uncaught exception
    'NSInvalidArgumentException', reason: 'Attemped to add a SKNode which
    already has a parent:  name:'(null)'
    texture:[ 'Up Button' (200 x 200)] position:{0, -254}
    scale:{0.57, 0.57} size:{56.800003051757812, 56.800003051757812}
    anchor:{0.5, 0.5} rotation:0.00'
    *</strong> First throw call stack: (0x188da6fd8 0x187808538 0x188da6f20 0x1984f1738 0x1984f1664 0x100073d40 0x100074908 0x1984d7050
    0x18ef0a46c 0x18ef05804 0x18eed6418 0x18f6cff64 0x18f6ca6c0
    0x18f6caaec 0x188d55424 0x188d54d94 0x188d529a0 0x188c82d94
    0x18a6ec074 0x18ef3b130 0x100078c5c 0x187c9159c) libc++abi.dylib:
    terminating with uncaught exception of type NSException</p>
  </blockquote>