title: How to move sprite just left or right using CoreMotion?
body: <p>For this game I am creating, I want the Sprite "Character" to either move left or right by me tilting the device either left or right. </p>
  
  <p>I have looked into it and changed the code, but it seems like that it does not work. </p>
  
  <p>When I run it, the "Character" moves in only one direction and still goes either up or down. </p>
  
  <p>I would just like the "Character" to move only left or right, not up or down. </p>
  
  <p>Any help on this?</p>
  
  <p>Here is a look at the GameScene.swift file:</p>
  
  <pre><code>import SpriteKit
  
  import CoreMotion
  
  class GameScene: SKScene {
  
  let motionManager = CMMotionManager()
  
  var Ground = SKSpriteNode()
  
  var Character = SKSpriteNode()
  
  override func didMoveToView(view: SKView) {
      /* Setup your scene here */
  
      Character = SKSpriteNode(imageNamed: "NinjaGhost")
      Character.physicsBody = SKPhysicsBody(circleOfRadius:    Character.size.height)
      Character.size = CGSize(width: 200, height: 200)
      Character.physicsBody?.allowsRotation = false
      Character.zPosition = 2
      Character.position = CGPoint(x: self.frame.width / 2, y: self.frame.height / 2)
      self.addChild(Character)
  
      Ground = SKSpriteNode(imageNamed: "Dirt Background")
      Ground.size = CGSize(width: 1920, height: 1080)
      Ground.zPosition = 1
      Ground.position = CGPoint(x: self.frame.width / 2, y: self.frame.height / 2)
      self.addChild(Ground)
  
      motionManager.startAccelerometerUpdates()
      motionManager.accelerometerUpdateInterval = 0.1
      motionManager.startAccelerometerUpdatesToQueue(NSOperationQueue.mainQueue() ) {
          (data, error) in
  
  self.physicsWorld.gravity = CGVectorMake(CGFloat((data?.acceleration.x)!) * 1, 0)
  }
  }
  
  
  
  
  
  
  
  override func touchesBegan(touches: Set&lt;UITouch&gt;, withEvent event: UIEvent?) {
     /* Called when a touch begins */
  
  }
  
  override func update(currentTime: CFTimeInterval) {
      /* Called before each frame is rendered */
  
  
  
  }
  
  
  
  
  
  
  
  }
  </code></pre>