Is the order of SKNode.nodesAtPoint guaranteed?

2019-07-09 06:22发布

问题:

SKNode has a method nodesAtPoint which returns an array of children nodes that intersect given point. Is the order of the elements in such array deterministic (e.g. by drawing order)?

I could not find an answer in documentation, so probably the answer is "no", but I would like to verify.

回答1:

Nope, Sprite Kit does not take into account z-position when traversing the node-tree (definitely for performance reasons). You can easily see this by adding a few nodes to a scene in-order and then changing the z-positions. The order will always be based on the position of the node within the node-tree, rather than the z-position.