如何枚举 Sprite Kit 场景中的所有节点? [英] How to enumerate ALL nodes in a Sprite Kit scene?
问题描述
我想枚举场景中的所有节点.不仅是场景本身的孩子,还有那些的孩子,以及那些的孩子等等......所以我希望能够遍历整个节点层次结构.
I want to enumerate all the nodes in my scene. Not just the ones that are a child of the scene itself, but also the children of those, and the children of those etc... So I want to be able to go through the whole node hierarchy.
有没有办法在不知道节点树有多深的情况下做到这一点?
Is there a method to do that without knowing how deep the node tree goes?
推荐答案
是的,使用 enumerateChildNodesWithName:usingBlock:
并传递 //*
作为节点名称.您应该可以在任何节点上调用它.
Yep, use enumerateChildNodesWithName:usingBlock:
and pass //*
as the node name. You should be able to call that on any node.
它实际上是 苹果文档:
//* 此搜索字符串匹配节点树中的每个节点.
//* This search string matches every node in the node tree.
这篇关于如何枚举 Sprite Kit 场景中的所有节点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!