我能够在两个对象的碰撞点绘制一个圆,但是我想为其创建一个漂亮的动画(顺时针)。我了解如何在单视图应用程序中执行此操作,但无法在SpriteKit中使用相同的实现。如何在SpriteKit中做到这一点?
这是我添加圆圈的代码-
func drawCircleOnCollisionPoint(arrowName:String) {
let circle:SKShapeNode = SKShapeNode(circleOfRadius: 15)
circle.position = (arrowsCollidedWithTarget[arrowName]?.contactPoint)!
circle.strokeColor = SKColor.red
circle.glowWidth = 1.0
circle.fillColor = SKColor.clear
circle.zPosition = 50
self.addChild(circle)
DispatchQueue.main.asyncAfter(deadline: .now() + timeBetweenGames) {
circle.removeFromParent()
}
}
答案 0 :(得分:0)
尝试一下:
let action = SKAction.rotate(byAngle:-360,持续时间:30)
circle.run(SKAction.repeatForever(action))