title: How to rotate sprite in sprite kit with swift
body: <p>Hi my problem is regarding the rotation of two sprites. When I touch the right half of the screen the rotation starts and moving sprite2 and sprite3. If I touch the left half of the screen the rotation stops because velocity-velocity = 0. If I touch the left half again the rotation begins. </p>
  
  <p>However, if I touch the half of the screen corresponding with the current rotational-direction the velocity is duplicated. I want to be able to change the direction of the rotation, but for the speed to remain constant. </p>
  
  <p>Video demonstrating the problem: <a href="http://youtu.be/HxLwl1QZiNM" rel="nofollow">http://youtu.be/HxLwl1QZiNM</a></p>
  
  <pre><code>import SpriteKit
  
  class GameScene: SKScene {
      let sprite = SKSpriteNode(imageNamed:"bWhite")
      let sprite2 = SKSpriteNode(imageNamed:"bBlue")
      let sprite3 = SKSpriteNode(imageNamed:"bRed")
      let circle = SKSpriteNode(imageNamed:"bCircle")       
  
      override func didMoveToView(view: SKView) {
          /* Setup your scene here */
          backColor = SKColor(red: 0, green: 0, blue: 0, alpha: 1)
          self.backgroundColor = backColor
  
          sprite.setScale(1.25)
          sprite2.setScale(1)
          sprite3.setScale(1)
          sprite.position = CGPointMake(self.frame.size.width/2, (self.frame.size.height/2)-200);
          circle.position = CGPointMake(self.frame.size.width/2, (self.frame.size.height/2)-200);
          sprite3.zRotation = 172.77
          sprite2.anchorPoint = CGPointMake(-1.10, 0.5);
          sprite3.anchorPoint = CGPointMake(-1.10, 0.5);
  
          self.addChild(sprite)
          self.addChild(circle)
          sprite.addChild(sprite2)
          sprite.addChild(sprite3)
      }
  
  override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
          /* Called when a touch begins */
          for touch: AnyObject in touches {
              let location = touch.locationInNode(self)
  
              let action = SKAction.rotateByAngle(CGFloat(M_PI), duration:1)
              let action2 = SKAction.rotateByAngle(CGFloat(-M_PI), duration:1)
  
              if (location.x &gt; self.frame.size.width / 2)
              {
                  sprite2.runAction(SKAction.repeatActionForever(action2))
                  sprite3.runAction(SKAction.repeatActionForever(action2))
              } else {
                  sprite2.runAction(SKAction.repeatActionForever(action))
                  sprite3.runAction(SKAction.repeatActionForever(action))
              }     
          }
      }
  </code></pre>