title: how to make infinite background in spriteKit swift 4
body: <p>I try to make an endless background through the nodes, but the background has not become infinite and is interrupted, the third background is not yet shown. After the first show, the number of nodes in the scene grows, how can this be fixed?</p>
  <p><a href="https://i.stack.imgur.com/J4Wx2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/J4Wx2.png" alt="enter image description here" /></a></p>
  <p><a href="https://i.stack.imgur.com/J4Wx2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uROCN.png" alt="enter image description here" /></a></p>
  <p><a href="https://i.stack.imgur.com/GVSJ1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GVSJ1.png" alt="enter image description here" /></a></p>
  <pre><code>import SpriteKit
  import GameplayKit
  
  class GameScene: SKScene {
  
  
     var bgNode: SKNode!
     var overlay: SKNode!
     var overlayWidth: CGFloat!
     //var viewSize: CGSize!
     var levelPositionX: CGFloat = 0.0
     //var speed: CGFloat = 5.5
  
  
     override func didMove(to view: SKView) {
      setupNode()
      //viewSize = CGSize(width: frame.size.width, height: 
                                                       
                                                frame.size.height )
      
    }
  
    func setupNode() {
      let worldNode = childNode(withName: &quot;World&quot;)!
      bgNode = worldNode.childNode(withName: &quot;Background&quot;)!
      overlay = bgNode.childNode(withName: &quot;Overlay&quot;)!.copy() as! 
    SKNode
      overlayWidth = overlay.calculateAccumulatedFrame().width
    }
  
     func createBackgroundOverlay() {
      let backgroundOverlay = overlay.copy() as! SKNode
      backgroundOverlay.position = CGPoint(x: 0.0, y: 0.0)
      
      bgNode.addChild(backgroundOverlay)
      levelPositionX += overlayWidth
  }
  
  func update() {
      bgNode.position.x -= 5
      if bgNode.position.x &lt;= -self.frame.size.width {
           bgNode.position.x = self.frame.size.width * 2
          createBackgroundOverlay()
          
        }
    }
  
    override func update(_ currentTime: TimeInterval) {
        update()
    }    
  </code></pre>