Objective c SpriteKit-记录调试信息,如fps、NodeCount
我知道如何在屏幕上显示这些信息,但我想将它们记录在文件/控制台中,以便进行脱机调查。我该怎么做呢?您可以使用场景Objective c SpriteKit-记录调试信息,如fps、NodeCount,objective-c,debugging,sprite-kit,Objective C,Debugging,Sprite Kit,我知道如何在屏幕上显示这些信息,但我想将它们记录在文件/控制台中,以便进行脱机调查。我该怎么做呢?您可以使用场景-(void)update方法自己测量它。此方法调用需要计算的每个帧 - (void)update { self.frameCount++; // increase frame count value uint64_t currentTime = mach_absolute_time(); // get current time // according to this t
-(void)update
方法自己测量它。此方法调用需要计算的每个帧
- (void)update
{
self.frameCount++; // increase frame count value
uint64_t currentTime = mach_absolute_time(); // get current time
// according to this two values and last update method call time you're already can calculate the fps
self.lastUpdateTick = currentTime; // remember for the future method call
}
要获取节点计数值,您应该只对所有场景子节点的子节点进行计数。它可能是某种递归算法(未经测试)
您不能,因为您无法访问打印到屏幕上的信息。再加上有一长串fps号码会有什么好处呢?使用仪器进行性能分析。
- (NSUInteger)childrenOf:(SKNode *)node
{
NSUInteger count = 0;
for (SKNode *child in node.children)
count += [self childrenOf:child] + 1;
return count;
}
- (void)calculateSceneChildrenCount
{
NSUInteger count = [self childrenOf:self];
NSLog(@"count is %lu",count);
}