문제

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?

도움이 되었습니까?

해결책

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]);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top