【发布时间】:2017-06-21 07:46:18
【问题描述】:
我正在使用以下代码使精灵节点在 Xcode spritekit 中绕圈移动。
let circleDiameter = CGFloat(100)
// center our path based on our sprites initial position
let pathCenterPoint = CGPoint(
x: object.position.x - circleDiameter,
y: object.position.y - circleDiameter/2)
// create the path our sprite will travel along
let circlePath = CGPath(ellipseIn: CGRect(origin: pathCenterPoint, size: CGSize(width: circleDiameter, height: circleDiameter)), transform: nil)
// create a followPath action for our sprite
let followCirclePath = SKAction.follow(circlePath, asOffset: false, orientToPath: false, duration: 3)
// make our sprite run this action forever
object.run(SKAction.repeatForever(followCirclePath).reversed(), withKey: “moving”)
world.addChild(object)
问题是,精灵节点的起始位置总是位于圆形路径的右侧。我知道我可以使用 .reversed() 来改变精灵节点的方向,但这不是我要问的。
如何将“起点”更改为圆形路径的左侧?
谢谢各位!请参考下图:D
【问题讨论】:
标签: swift sprite-kit skspritenode