我正在制作游戏。我想要2条单独的线顺时针旋转,当玩家触摸屏幕时,旋转应该变为逆时针。现在,当它变为逆时针时,UIBezierPath
翻转节点。我不希望翻转节点,只是旋转另一种方式。
func clockwise() {
let dx = leftside.position.x - self.frame.width / 2
let dy = leftside.position.y - self.frame.height / 2
let rad = atan2(dy, dx)
let path = UIBezierPath(arcCenter: CGPoint(x: self.frame.width / 2, y: self.frame.height / 2), radius: 85, startAngle: rad, endAngle: rad + CGFloat(M_PI * 4), clockwise: true)
let follow = SKAction.followPath(path.CGPath, asOffset: false, orientToPath: true, speed: 250)
leftside.runAction(SKAction.repeatActionForever(follow).reversedAction())
let dx1 = rightside.position.x - self.frame.width / 2
let dy1 = rightside.position.y - self.frame.height / 2
let rad1 = atan2(dy1, dx1)
let path1 = UIBezierPath(arcCenter: CGPoint(x: self.frame.width / 2, y: self.frame.height / 2), radius: 85, startAngle: rad1, endAngle: rad1 + CGFloat(M_PI * 4), clockwise: true)
let follow1 = SKAction.followPath(path1.CGPath, asOffset: false, orientToPath: true, speed: 250)
rightside.runAction(SKAction.repeatActionForever(follow1).reversedAction())
}
func counterclockwise() {
let dx = leftside.position.x - self.frame.width / 2
let dy = leftside.position.y - self.frame.height / 2
let rad = atan2(dy, dx)
let path = UIBezierPath(arcCenter: CGPoint(x: self.frame.width / 2, y: self.frame.height / 2), radius: 85, startAngle: rad, endAngle: rad + CGFloat(M_PI * 4), clockwise: true)
let follow = SKAction.followPath(path.CGPath, asOffset: false, orientToPath: true, speed: 250)
leftside.runAction(SKAction.repeatActionForever(follow))
let dx1 = rightside.position.x - self.frame.width / 2
let dy1 = rightside.position.y - self.frame.height / 2
let rad1 = atan2(dy1, dx1)
let path1 = UIBezierPath(arcCenter: CGPoint(x: self.frame.width / 2, y: self.frame.height / 2), radius: 85, startAngle: rad1, endAngle: rad1 + CGFloat(M_PI * 4), clockwise: true)
let follow1 = SKAction.followPath(path1.CGPath, asOffset: false, orientToPath: true, speed: 250)
rightside.runAction(SKAction.repeatActionForever(follow1))
}