[英]runAction in swift, make object follow a path
I'm trying to make an object follow a circular path every time I press a button, but it gives me an error in the last line that says UIImageView
does not have a member named runAction
. 每次按下按钮时,我都试图让一个对象遵循循环路径,但它在最后一行中给出了一个错误,即UIImageView
没有名为runAction
的成员 。 I already tried with .addAnimation
but it still won't work. 我已经尝试过.addAnimation
但它仍然无法正常工作。
let path = CGPathCreateMutable()
let circle = UIBezierPath(roundedRect: CGRectMake(0, 0, 100, 100), cornerRadius: 100)
let followCircle = SKAction.followPath(circle.CGPath, asOffset: true, orientToPath: false, duration: 5.0)
blueDot.runAction(SKAction(followCircle))
Solely based on the short code snippet and on the fact that 仅基于短代码片段和事实
'UIImageView' does not have a member named 'runAction' 'UIImageView'没有名为'runAction'的成员
I would say that the object blueDot
is an UIImageView
object and according to the docs , it doesn't have runAction
method. 我会说对象blueDot
是一个UIImageView
对象,根据文档 ,它没有runAction
方法。 Probably you have mistakenly assigned an UIImageView
to that variable instead of SKNode
or one of its subclasses. 可能你错误地将UIImageView
分配给该变量而不是SKNode
或其子类之一。 You should probably check if that is so and fix the issue by assigning a proper SKNode
object to it. 您应该检查是否是这样,并通过SKNode
分配适当的SKNode
对象来解决问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.