如何遍历CGPath的坐标?

时间:2015-02-20 02:32:58

标签: ios swift sprite-kit uibezierpath

当用户将手指移到它上面时,我试图让精灵跟随圆形路径,而不是动画,而是像旋转轮,你可以控制方向和速度......任何想法都会非常有用。谢谢

let blueDotCategoryName = "blue"
var blueDot = SKSpriteNode()

//...    

override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
/* Called when a touch begins */
let touch = touches.anyObject() as UITouch
let touchLocation = touch.locationInNode(self)
let node = self.nodeAtPoint(touchLocation)
if node.name == blueDotCategoryName {
    fingerIsOn = true
}
}



override func touchesMoved(touches: NSSet, withEvent event: UIEvent) {
if fingerIsOn {
    let touch = touches.anyObject() as UITouch
    let touchLocation = touch.locationInNode(self)
    let prevTouchLocation = touch.previousLocationInNode(self)
    let blueDot = self.childNodeWithName(blueDotCategoryName) as     SKSpriteNode
   // var newPosition = coordinates in circle UIBezierPath
   // blueDot.position = ...
}
/*        
var circle = UIBezierPath()
circle.addArcWithCenter(CGPoint(x: 0, y: 0), radius: (self.frame.width / 6.7), startAngle: 0, endAngle: 360, clockwise: true)       
*/

}
override func touchesEnded(touches: NSSet, withEvent event: UIEvent) {
fingerIsOn = false
}

0 个答案:

没有答案