0

Any ideas for how I could draw a child node behind a parent node in Sprite Kit?

Parents are always rendered before children and zPosition only works on siblings.

For example, a side-on picture of a dog - two of the legs would be behind the body (the parent node).

Caroline
  • 4,875
  • 2
  • 31
  • 47
  • For a good explanation on zPosition look at this previous Q&A. http://stackoverflow.com/questions/21709235/spritekit-not-respecting-zposition – sangony Jun 02 '14 at 00:06
  • Yes, I saw that, thank you. My problem is "If the nodes have different parents, zPosition has no effect". In my example of the dog, the leg would have a different parent to the body. – Caroline Jun 02 '14 at 00:49
  • 1
    Although it does not answer your actual question, my advice would be to have the body of the dog in another SKSpriteNode child of `DogNode : SKNode`. This should provide you with some degree of control. – CloakedEddy Sep 29 '14 at 13:48
  • Actually, that's what I have done - it also helps with rotation, as I rotate the SKNode, and the child SKSpriteNode is off center, and it's much easier than moving the anchor point. Also, it seems to work now - I've done different zPosition numbering down the tree, and children are going behind parents. – Caroline Sep 30 '14 at 22:34

0 Answers0