gpt4 book ai didi

ios - 如何在另一个节点中创建一个节点

转载 作者:行者123 更新时间:2023-11-28 12:59:29 25 4
gpt4 key购买 nike

我有一个圆圈,一个 SKShapeNode,我想在其中创建一个子节点。我该怎么做?

func AddCircle() {        
Circle = SKShapeNode(circleOfRadius: circleRadius)
Circle.position = CGPoint(x: self.size.width/2, y: self.size.height/2)
Circle.strokeColor = UIColor.whiteColor()
self.addChild(Circle)
Circle.addChild(BooCharacter)
}

主角:

func AddCharacter() {
BooCharacter.size = CGSize(width: 30, height: 30)
BooCharacter.anchorPoint.y = 0
BooCharacter.zRotation = CGFloat(-M_PI_2)
BooCharacter.position.y += circleRadius
}

我想在我的圈子里创建一个对象,但我不知道你怎么写。

例如,我尝试在我的圆圈内添加一个矩形:

func AddRect() {
Rect = SKShapeNode()
Rect.path = UIBezierPath(roundedRect: CGRect(x:0, y: 250, width: 256, height: 256), cornerRadius: 64).CGPath
Rect.fillColor = UIColor.whiteColor()
}
func AddCircle() {
Circle = SKShapeNode(circleOfRadius: circleRadius)
Circle.position = CGPoint(x: self.size.width/2, y: self.size.height/2)
Circle.strokeColor = UIColor.whiteColor()
self.addChild(Circle)
Circle.addChild(BooCharacter)
Circle.addChild(Rect)

但还是不行。

我想像这样在我的圆圈内创建和添加三角形

enter image description here

最佳答案

虽然我没有看到 BooCharacter 的创建位置,但您做的完全正确 - 您确定是在某处创建的吗?使用 addChild() 将节点添加到您的场景,或将一个节点添加到另一个节点是正确的,并且应该适用于所有类型的 SKNode

关于ios - 如何在另一个节点中创建一个节点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34251449/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com