围绕不是 .anchorPoint 的内部点旋转 SkSpriteNode

Rotate SkSpriteNode around internal point that is not .anchorPoint

所以我使用这段代码顺时针或逆时针旋转对象。

    override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {

    let touch = touches.first as UITouch!
    let touchPosition = touch.locationInNode(self)
    let newRotationDirection : rotationDirection = touchPosition.x < CGRectGetMidX(self.frame) ? .clockwise : .counterClockwise

    if currentRotationDirection != newRotationDirection && currentRotationDirection != .none {
        reverseRotation()
        currentRotationDirection = newRotationDirection
    }
    else if (currentRotationDirection == .none) {
        setupRotationWith(direction: newRotationDirection)
        currentRotationDirection = newRotationDirection
    }
}



func reverseRotation(){
    let oldRotateAction = ship.actionForKey("rotate")
    let newRotateAction = SKAction.reversedAction(oldRotateAction!)
    ship.runAction(newRotateAction(), withKey: "rotate")
}



func stopRotation(){
    ship.removeActionForKey("rotate")
}



func setupRotationWith(direction direction: rotationDirection){
    let angle : CGFloat = (direction == .clockwise) ? CGFloat(M_PI) : -CGFloat(M_PI)
    let rotate = SKAction.rotateByAngle(angle, duration: 2)
    let repeatAction = SKAction.repeatActionForever(rotate)
    ship.runAction(repeatAction, withKey: "rotate")
}

我的问题是,这会围绕 SKSpriteNode 的锚点创建顺时针或逆时针旋转。

但是我希望对象围绕 SKSprite 内部的另一个点旋转(从精灵图像的底部向上大约 4/5 的距离)。我假设我不能使用通过 CGPointMake 定义的设定点,因为我希望精灵独立地在屏幕上移动,这行不通吗?

有什么建议吗?

您是否尝试过将精灵的 anchorPoint 属性 设置为您希望精灵围绕其旋转的点?

ship.anchorPoint = CGPoint(x: 0, y: 4/5)

这是您要找的吗?