按照path反转

我正在做一个精灵来绕轨道,为此我做了一个精灵之后的path:

let dx1 = base1!.position.x - self.frame.width/2 let dy1 = base1!.position.y - self.frame.height/2 let rad1 = atan2(dy1, dx1) path1 = UIBezierPath(arcCenter: circle!.position, radius: (circle?.position.y)! - 191.39840698242188, startAngle: rad1, endAngle: rad1 + CGFloat(M_PI * 4), clockwise: true) let follow1 = SKAction.followPath(path1.CGPath, asOffset: false, orientToPath: true, speed: 200) base1?.runAction(SKAction.repeatActionForever(follow1)) 

这是有效的,精灵开始围绕这一点的轨道。 事情是,当用户触摸屏幕,我想让精灵开始逆时针旋转。 为此,我写了相同的代码顺时针旋转,但编辑最后一行:

 base1?.runAction(SKAction.repeatActionForever(follow1).reversedAction()) 

但问题是,虽然它逆时针旋转,精灵图像翻转水平。 我能做些什么来避免这种情况? 或者还有什么其他的方式来通过一个点的轨道精灵?

一个简单的方式来旋转一个点(即轨道)的精灵是创build一个容器节点,添加一个精灵的偏移量(相对于容器的中心)节点,并旋转容器节点。 这是一个如何做到这一点的例子:

 class GameScene: SKScene { let sprite = SKSpriteNode(imageNamed:"Spaceship") let node = SKNode() override func didMove(to view: SKView) { sprite.xScale = 0.125 sprite.yScale = 0.125 sprite.position = CGPoint (x:100, y:0) node.addChild(sprite) addChild(node) let action = SKAction.rotate(byAngle:CGFloat.pi, duration:5) node.run(SKAction.repeatForever(action), withKey:"orbit") } override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { if let action = node.action(forKey: "orbit") { // Reverse the rotation direction node.removeAction(forKey:"orbit") node.run(SKAction.repeatForever(action.reversed()),withKey:"orbit") // Flip the sprite vertically sprite.yScale = -sprite.yScale } } }