I have a SpriteKit game in which there are balls that bounce around. Despite using a texture atlas (a .spriteatlas folder located in my .xcassets folder), I'm getting 2 draw calls for each ball.
Some facts:
SKSpriteNode
's.textureNamed(_:)
.view.ignoresSiblingOrder = true
.zPosition
is not set -- not on the parent and not on the child.Based on what I've learned about how the scene is rendered, I would expect to see all the parent nodes rendered in a single pass, with additional passes for the child nodes (though, even that is suspicious since I have ignoresSiblingOrder
set to true
).
What am I not understanding, here? Why does my draw count increase so drastically as more balls are added to the scene?
Thank you!
UPDATE:
If I don't add the child nodes to the balls, the draw count for the balls is 1 regardless of how many balls there are. So, it's definitely an issue with the child nodes, not the parents.
I solved the problem by setting zPosition
to the same value on both the parent and child.
parentNode.zPosition = 1.0
childNode.zPosition = 1.0
There are now a total of 2 draws for the balls regardless of how many balls there are.