SpriteKit - getting closest nodes
问题 Is there a way of getting the closest nodes to a node? I'm just about to write a method to iterate all nodes and calculate distances etc... but wondered if there is a better way? I have 30 nodes and need the 2 nearest nodes to each of the 30 nodes (if that makes sense). 回答1: As of iOS 10, you can use the Spatial Partitioning features of GampelayKit. In 2D either GKQuadtree or GKRTree depending on your needs. From the docs: Quadtrees and R-trees have different performance tradeoffs for