title: Sprite-kit: Moving an element in circular path
body: <p>I'm trying make an element move by the edge of circle.</p>
  
  <ul>
  <li>I have created and positioned a circle in the middle of the screen:</li>
  </ul>
  
  <pre class="lang-swift prettyprint-override"><code>var base = SKShapeNode(circleOfRadius: 200 ) // Size of Circle
  base.position = CGPointMake(frame.midX, frame.midY)  
  base.strokeColor = SKColor.blackColor()
  base.glowWidth = 1.0
  base.fillColor = UIColor(hue:1, saturation:0.76, brightness:0.94, alpha:1)
  base.zPosition = 0
  self.addChild(base)
  </code></pre>
  
  <ul>
  <li>Then I've created another sprite and added an action on it:</li>
  </ul>
  
  <pre class="lang-swift prettyprint-override"><code>main = SKSpriteNode(imageNamed:"Spaceship")
  main.xScale = 0.15
  main.yScale = 0.15
  main.zPosition = 1
  let circle = UIBezierPath(roundedRect: CGRectMake((self.frame.width/2) - 200, CGRectGetMidY(self.frame) - 200,400, 400), cornerRadius: 200)
  let circularMove = SKAction.followPath(circle.CGPath, duration: 5.0)
  main.runAction(SKAction.repeatAction(circularMove,count: 2))
  self.addChild(main)
  </code></pre>
  
  <p>The first rotation(see image below) of the spaceship follow exactly the edges of the circle but the second iteration changes the position of the spaceship and move it outside the screen bounds.
  Is this normal or am I doing something wrong ?</p>
  
  <p>Thanks.</p>
  
  <p><a href="https://i.stack.imgur.com/pgTDY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pgTDY.png" alt="enter image description here"></a></p>