我發現,它可能使用單一SKShapeNode對象呈現多個多邊形:使用單個SKShapeNode呈現多個重疊的多邊形?
class GameScene: SKScene {
override func didMove(to view: SKView) {
let polygons = [
[
CGPoint(x: 0, y: 0),
CGPoint(x: 100, y: 100),
CGPoint(x: 100, y: 0)
],
[
CGPoint(x: 50, y: 50),
CGPoint(x: 50, y: 150),
CGPoint(x: 150, y: 150),
CGPoint(x: 150, y: 50),
],
]
let path = CGMutablePath()
for points in polygons {
path.addLines(between: points)
path.closeSubpath()
}
let node = SKShapeNode(path: path)
node.fillColor = UIColor.red
addChild(node)
}
}
然而,在多邊形重疊的任何空間呈現爲空:
是否有可能填補那些空白的空間,同時繼續使用單個節點?
簡短的答案是...你不能。但是,您可以從多邊形創建圖像,從圖像創建紋理,並從紋理創建精靈節點。 – 0x141E
你解決了這個問題嗎? – 0x141E
@ 0x141E我嘗試了紋理生成方法,但是在每一幀上執行它都太慢了,這是我需要的一個形狀轉換節點。 – scribu