title: SpriteKit issue with zPosition
body: <p>I am encountering an issue with the zPosition of nodes on my SpriteKit scene.  </p>
  
  <p><em>I am building a manager node that enables "layer like" management of nodes zPosition, essentially enabling you to get rid of the manual management of the zPosition property and instead to add nodes with methods like <code>addNodeUnder(node:SKNode)</code> and also to create groups.</em></p>
  
  <p>Here is a test scene I have made :<br>
  <a href="https://i.stack.imgur.com/dJlhS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dJlhS.png" alt="We can see a blue node, itself under a green node, itself under a yellow node, itself under a red node."></a>  </p>
  
  <p>The problem is that with the operations I have made, the green and the yellow node should be <strong>on top</strong> of the red node.  </p>
  
  <p>I made my own little debugger, displaying the SceneKit "scene graph" in hierarchical order :  </p>
  
  <pre><code>Node of type LMManagerNode  has zPosition = 0.0 and has children :
             Node of type LMWarpperNode  has zPosition = 0.0 and has children :
                       Node of type SKSpriteNode ('Red node') has zPosition = 0.0.
  
             Node of type LMWarpperNode  has zPosition = -100.0 and has children :
                       Node of type SKSpriteNode ('Blue node') has zPosition = 0.0.
  
             Node of type LMWarpperNode  has zPosition = 100.0 and has children :
                       Node of type LMGroupNode ('Test group') has zPosition = 0.0 and has children :
                                 Node of type LMWarpperNode  has zPosition = -150.0 and has children :
                                           Node of type SKSpriteNode ('Yellow node') has zPosition = 0.0.
  
                                 Node of type LMWarpperNode  has zPosition = -200.0 and has children :
                                           Node of type SKSpriteNode ('Green node') has zPosition = 0.0.
  </code></pre>
  
  <p>As you can see :</p>
  
  <ul>
  <li>The red node is contained inside a node that has <code>zPosition = 0</code></li>
  <li>The blue node is contained inside a node that has <code>zPosition = -100</code></li>
  <li>The yellow and green nodes are contained inside a group node, itself contained inside a node that has <code>zPosition = 100</code></li>
  </ul>
  
  <p>Since the node that contains the red node has <code>zPosition = 0</code> and the node that contains the green and yellow nodes has <code>zPosition = 100</code>, shouldn't these two nodes be <strong>on top</strong> of the red node ?  </p>
  
  <p><em>The <code>ignoresSiblingOrder</code> of my <code>SKView</code> is set to <code>false</code> by the way...</em></p>
  
  <p>EDIT : That's weird : yellowNode.zPosition = 1000 does make the yellow node go on top of the red node. How can it be possible ?  </p>
  
  <p>EDIT #2 Here is the code of my debugging function :  </p>
  
  <pre><code>func renderNodeHieararchyForNode(node:SKNode, index:Int) {
  
      var i = 0
      var beginning = ""
      while i != index {
          beginning += "          "
          i++
          if i == index {
              beginning += " "
          }
      }
  
      print("\(beginning)Node of type \(node.dynamicType) \(node.name != nil ? "('\(node.name!)')" : "") has zPosition = \(node.zPosition)\(node.children.count &gt; 0 ? " and has children :" : ".")")
      for (i,child) in node.children.enumerate() {
          renderNodeHieararchyForNode(child, index: index+1)
  
          if i == node.children.count-1 {
              print("")
          }
      }
  
  }
  
  func renderNodeHiearchyForNode(node:SKNode) {
      renderNodeHieararchyForNode(node, index: 0)
  }
  </code></pre>
  
  <p>As you can see, I use only the SpriteKit framework methods to display it, so the output of my debugger is definitely correct.</p>