Is the order of SKNode.nodesAtPoint guaranteed?

2019-07-09 05:49发布

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条回答
何必那么认真
2楼-- · 2019-07-09 06:10

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.

查看更多
登录 后发表回答