title: Unable to move sprite left or right in SpriteKit
body: <p><a href="https://github.com/bmh3110/JackTheGiantGame" rel="nofollow">https://github.com/bmh3110/JackTheGiantGame</a></p>
  
  <p>I'm unable to move my sprite left or right when the screen is touched. I'm just starting this game and I can't even get it to work. I've had this problem for a few days and it's getting really frustrating.</p>
  
  <p>GameplayScene.swift</p>
  
  <pre><code>import SpriteKit
  
  class GameplayScene: SKScene {
      var player : Player?
      var canMove = false
      var moveLeft = false
      var center : CGFloat?
  
      override func didMoveToView(view: SKView) {
          center = (self.scene?.size.width)! / (self.scene?.size.height)!
          player = self.childNodeWithName("Player") as? Player!
      }
  
      override func update(currentTime: NSTimeInterval) {
          managePlayer()
      }
  
      override func touchesBegan(touches: Set&lt;UITouch&gt;, withEvent event: UIEvent?) {
          for touch in touches {
              let location = touch.locationInNode(self)
  
              if location.x &gt; center {
                  moveLeft = false
              } else {
                  moveLeft = true
              }
          }
  
          canMove = true
      }
  
      override func touchesEnded(touches: Set&lt;UITouch&gt;, withEvent event: UIEvent?) {
      }
  
      func managePlayer() {
          if canMove {
              player?.movePlayer(moveLeft)
          }
      }
  }
  </code></pre>
  
  <p>Player.swift</p>
  
  <pre><code>import SpriteKit
  
  class Player: SKSpriteNode {
      func movePlayer(moveLeft: Bool) {
          if moveLeft {
              self.position.x = self.position.x - 7
          } else {
              self.position.x = self.position.x + 7 
          }
      }
  }
  </code></pre>