SpriteKit - RotateToAngle

时间:2016-01-05 03:00:45

标签: rotation sprite-kit skaction

我有一个对象,我希望它能够不断向右旋转&左:

override func didMoveToView(view: SKView) {
    /* Setup your scene here */

// I start it facing left side
    object.zRotation = CGFloat(M_PI / 4)
}

 override func update(currentTime: CFTimeInterval) {
        /* Called before each frame is rendered */


        let rotateRight = SKAction.rotateToAngle(CGFloat(-M_PI / 4), duration: 2)
        let rotateLeft = SKAction.rotateToAngle(CGFloat(M_PI / 4), duration: 2)

        let sequence = SKAction.sequence([rotateRight, rotateLeft])

        object.runAction(SKAction.repeatActionForever(sequence))
    }

问题是,它只旋转到右侧然后完全停止,它从不向左旋转并按原样重复。

0 个答案:

没有答案