Multi-threading in SpriteKit

Viewed 1549

I have divided this question into 2 parts. One more specific question about multithreading concerning a specific project. And one question about how multithreading ties into SpriteKit in general.

First question: I'm currently working on a test project to learn more about optimization in SpriteKit. In my test project I have over 2000 spriteNodes, each with some basic AI moving the node with actions.

I can see a significant increase in performance if set the Alpha = 0 to the nodes that are not currently within the screen area. But of course, performing this check in the update function on over 2000 nodes increases the load instead. Could it be possible to use multithreading in any way to take some load of the main thread. For example to make this check on an other thread.

General question: I couldn't find very much information about multithreading in SpriteKit so id like to get a better understanding about the whole topic, here are some guideline questions that I personally have. But if you want, and have the knowledge, feel free to expand outside this scope with any information you think is important.

  • When would it make sens to use multi-threading in SpriteKit?
  • What are the main limitations and pitfalls using multi-threading
  • How would I create a basic multi-thread example. Can I use swift to create the code? where do I put the code? were do I get started?
  • What things should i keep in mind regarding multi-threading and the rendering cycle.
  • Is there any difference between the threads. Are they "designed" to be used for different things?
  • Do you know any good article or learning resource to learn more about multi-threading?
2 Answers
Related