This is happening because SKShapeNode fillColor
is set. Obviously, when either fillColor
or strokeColor
are set, each of them require additional node and additional draw pass . By default there is already strokeColor set (one node, one draw pass) and because of fillColor
is set additionally, two nodes (and two drawing passes) are required for shape to be rendered.
SKShapeNode
is not a performant solution in many cases, because of obvious reasons. One SKShapeNode
requires at least one draw call. There are some interesting post related to this topic, for example this one or this one.
But still IMO, SKShapeNode
should be avoided if it's not the only solution. Just because of performance reasons. And in your case, if you for example want to have many different kind of balls, the performant solution would be to use texture atlas and SKSpriteNode
for representing those textures. This way you can render as much balls as you like in single draw pass.
Note that draw passes are much more important than number of nodes when it comes to performance. SpriteKit can render hundreds of nodes at 60fps if amount of drawing passes required for scene rendering is low.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…