Frage

This seems like a really easy question, but I can't seem to find the answer anywhere. I am making a game using Sprite Kit, and I would like to get the count of how many SKNodes I currently have on the screen. I can see the count on the bottom right corner in my debugging information, but I'm not sure how to access it as an integer I can use to program with. Any suggestions?

War es hilfreich?

Lösung

Apple docs say, "An SKScene object represents a scene of content in Sprite Kit. A scene is the root node in a tree of Sprite Kit nodes..."

So, use the following statement in your SKScene class, see if it outputs the correct number.

NSLog(@"%lu", (unsigned long)[self.children count]);
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top