SkAction未在SKShapenode上运行

时间:2015-03-06 00:25:11

标签: ios swift sprite-kit skaction

使用SKShapeNode创建一个圆圈,然后创建一个旋转圆圈的动作,但什么也没发生。当我更改要应用于SKSpriteNode的操作时,它可以正常工作。

添加圆圈:

//adding largeCircle
let largeCircleRadius : CGFloat = 199
var largeCirclePath = CGPathCreateMutable();
let startAngle : CGFloat = 6.64
let endAngle : CGFloat = 2 * 6.64
CGPathAddArc(largeCirclePath, nil, 0.0, 0.0, largeCircleRadius, startAngle, endAngle , true)
let round = SKShapeNode(path: largeCirclePath, centered: false)

round.strokeColor = UIColor(red: 0.45, green: 0.45, blue: 1.0, alpha: 1)
round.lineWidth = 5
round.position = CGPointMake(CGRectGetWidth(frame) / 2.0, CGRectGetHeight(frame) / 2.0)
round.physicsBody = SKPhysicsBody(edgeChainFromPath: largeCirclePath)
round.physicsBody?.categoryBitMask = roundGroup
round.zPosition = 2
self.addChild(round)

行动:

override func touchesMoved(touches: NSSet, withEvent event: UIEvent) {
    func movePlatform() {
        let oneRevolution = SKAction.rotateByAngle(360, duration: 1.0)
        let repeat = SKAction.repeatAction(oneRevolution, count: 1)
        round.runAction(repeat)      
    }
    movePlatform();
}

0 个答案:

没有答案