gpt4 book ai didi

Swift SpriteKit 创建可变路径 (CGMutablePathRef)

转载 作者:行者123 更新时间:2023-11-28 16:15:05 25 4
gpt4 key购买 nike

我在堆栈溢出时发现了这段代码。

CGMutablePathRef path = CGPathCreateMutable()
CGPathMoveToPoint(path, nil, 0, -(self.tileSize.height / 2))
CGPathAddLineToPoint(path, nil, (self.tileSize.width / 2), 0)
CGPathAddLineToPoint(path, nil, 0, (self.tileSize.height / 2))
CGPathAddLineToPoint(path, nil, -(self.tileSize.width / 2), 0)
CGPathCloseSubpath(path)

它是答案的一部分,代码应该创建一条具有等距图 block 形状的路径,但它不起作用。所以有人知道为什么以及如何创建这个 mutablePath 吗?谢谢。

最佳答案

如果您的问题是代码无法编译,您只需将其从 Objective-C 转换为 Swift

let path = CGPathCreateMutable()
CGPathMoveToPoint(path, nil, 0, -(self.tileSize.height / 2))
CGPathAddLineToPoint(path, nil, (self.tileSize.width / 2), 0)
CGPathAddLineToPoint(path, nil, 0, (self.tileSize.height / 2))
CGPathAddLineToPoint(path, nil, -(self.tileSize.width / 2), 0)
CGPathCloseSubpath(path)

关于Swift SpriteKit 创建可变路径 (CGMutablePathRef),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39182414/

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