Cocos2d 2.0 - 3 numbers on the bottom left

前端 未结 2 398
慢半拍i
慢半拍i 2020-12-28 08:55

I have 3 numbers on the bottom left part of the screen on my Cocos2D 2.0 project:

82
0.016
60.0

60 is probably FPS and what about the other

相关标签:
2条回答
  • 2020-12-28 09:12

    The top number is the number of sprites in your CCLayer, etc..

    The middle is the FPS's milliseconds.

    The bottom is of course your FPS! :)

    0 讨论(0)
  • 2020-12-28 09:27
    82    <-- number of draw calls
    0.016 <-- time it took to render the frame, here: 1.0/60.0 = 60 fps
    60.0  <-- frames per second
    

    The first number (82) is the number of draw calls (which is fairly high). Typically each node that renders something on the screen (sprites, labels, particle fx, etc) increases that number by one. Draw calls are expensive, so it is very important to keep that number down. One way to do so is by batching draw calls - cocos2d v3 does this automatically.

    The time it took to render a frame, in seconds. Since you need to draw a new frame every 0.016666666 seconds in order to achieve 60 frames per second (1/60 = 0,0166…) it's just the inverse of the framerate.

    The last number is the number of frames per second aka framerate aka fps. This value, like the previous one, is averaged over several frames so that it doesn't fluctuate as much.

    Note that iOS devices always have VSynch (vertical synchronization) on. A game can render a frame every 0.0166 seconds - if every frame takes 0.017 seconds to compute, the framerate is effectively halved to 30 fps. You can only have fps in concrete steps: 60, 30, 20, 15, 12, 10 ...

    Since the fps display is averaged over a couple frames it hides this fact. So if the display stats show 45 fps would be a sequence of frames where every other frame took longer than 0.0166 seconds. In fps numbers the individual fps of most recent frames would have been: 60, 30, 60, 30, 60, 30.

    0 讨论(0)
提交回复
热议问题