我正在尝试暂停游戏中的许多精灵。是否有一种方法可以暂停具有给定zPosition
或所有低于给定zPosition
的精灵?这些精灵可能还在update方法中更新物理体。
我正在尝试暂停游戏中的许多精灵。是否有一种方法可以暂停具有给定zPosition
或所有低于给定zPosition
的精灵?这些精灵可能还在update方法中更新物理体。
self.enumerateChildNodes(withName: "//*") {
node, stop in
if node.zPosition > 1 && node.zPosition < 4 {
// do whatever you want with these nodes (sprites, labels..)
if node is SKSpriteNode { // you can use also this filter to pause only SKSpriteNode types
node.isPaused = true
}
}
}
您还可以决定使用特定的“名称”而不是在第一行中使用“*”来仅对具有此名称的节点进行分组。