Skip to content

Instantly share code, notes, and snippets.

@veeneck
Last active August 29, 2015 14:12
Show Gist options
  • Select an option

  • Save veeneck/a5f2dd16bf11843141cd to your computer and use it in GitHub Desktop.

Select an option

Save veeneck/a5f2dd16bf11843141cd to your computer and use it in GitHub Desktop.
Cache enumerateChildNodes
/// If cache is established
if self.updateListeners.count > 0 {
for listener in self.updateListeners {
listener(currentTime)
}
}
/// Rebuild the cache
else {
self.layers[WorldLayer.World.rawValue].enumerateChildNodesWithName("Character") {
node, stop in
let realNode = node as CharacterNode
/// Call update on the node, and then add the update function to the cache
realNode.updateWithTime(currentTime)
self.updateListeners.append(realNode.updateWithTime)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment