SpriteKit子节点旋转父节点

时间:2019-05-04 00:38:35

标签: ios swift xcode unity3d sprite-kit

我想知道如何像围绕父节点旋转子节点一样 例如地球是父节点,月亮是子节点,所以我只希望月亮绕地球Spritekit旋转,请帮助谢谢!

//代码在底部

导入SpriteKit 导入GameplayKit

GameScene类:SKScene {

override func didMove(to view: SKView) {

    let colorSprite = SKSpriteNode(color: .red, size: CGSize(width: 75, height: 75))
    colorSprite.position = CGPoint(x: 0 , y: 0)

    let childNode = SKSpriteNode(color: .white, size: CGSize(width: 30, height: 30))

    childNode.position = CGPoint(x: 20, y: 0)


    colorSprite.addChild(childNode)

    self.addChild(colorSprite)

}



override func update(_ currentTime: TimeInterval) {
    // Called before each frame is rendered
}

}

// Image白色是子节点,红色是父节点 Spritekit Image

0 个答案:

没有答案