Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c SpriteKit-记录调试信息,如fps、NodeCount_Objective C_Debugging_Sprite Kit - Fatal编程技术网

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);
}