Structure your nodes for maximum performance.
As a high-level graphics framework, you configure your scene by laying out nodes, and
Sprite builds the Metal draw calls for you that actually render the content. Thus, you have little control over the amount of low-level graphics work that SpriteKit does, but this article gives you hints that can speed up SpriteKit's efforts.
Show Draw Count
Each draw call is an expensive operation; the more graphical elements you can pack into a single draw, the faster your scene can be rendered, and thus the higher frames per second it can achieve.
You can see the number of draw calls it's taking to render your scene live on the
SKView by enabling
In general, all scene nodes can be rendered in a single draw call that came from the same
SKTexture, for example:
Sprite nodes that use the same
Sprite nodes whose texture specifies a subrectangle of the same texture through the
With Rect: in Texture:
For all other SpriteKit nodes that draw, pay attention to the
shows statistic as you develop your app to gain an understanding of which configurations affect draw count.
Show Node Count
The number of nodes in your scene relates to the number of draw calls. Therefore, minimizing the number of nodes in your scene is a good practice to keep the draw call count down. Showing the node count in your scene is done through the
The number of nodes in your scene can also affect performance if you enumerate all of your nodes within the update life cycle. While the
should property can prune offscreen nodes out of an issued draw call, SpriteKit must still enumerate all nodes in your scene to figure out which ones are offscreen, and this is an expensive operation. As a result, eliminating offscreen nodes yourself by using
remove is the fastest way to cull nonvisible nodes. Once a node is removed from the node tree,
Sprite no longer needs to consider whether it's onscreen or offscreen every frame.