swift – Sprite-kit:在圆形路径中移动元素

我正试图让元素在cercle的边缘移动.

>我已经在屏幕中间创建并定位了一个cercle:

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)

>然后我创建了另一个精灵并在其上添加一个动作:

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)

宇宙飞船的第一次旋转(见下图)完全遵循圆的边缘,但第二次迭代改变了宇宙飞船的位置并将其移出屏幕边界.
这是正常的还是我做错了什么?

谢谢.

+ follow:duration:产生与 follow:asOffset:orientToPath:duration:相同的效果,asOffset和orientToPath参数设置为true.

关于docs中的asOffset参数:

If true,the points in the path are relative offsets to the node’s
starting position. If false,the points in the node are absolute
coordinate values.

所以,你应该明确地将它设置为false:

let circularMove = SKAction.follow(circle.CGPath,asOffset: false,orientToPath: true,duration: 5)

相关文章

软件简介:蓝湖辅助工具,减少移动端开发中控件属性的复制和粘...
现实生活中,我们听到的声音都是时间连续的,我们称为这种信...
前言最近在B站上看到一个漂亮的仙女姐姐跳舞视频,循环看了亿...
【Android App】实战项目之仿抖音的短视频分享App(附源码和...
前言这一篇博客应该是我花时间最多的一次了,从2022年1月底至...
因为我既对接过session、cookie,也对接过JWT,今年因为工作...