cocos2dx setDisplayStats

本文探讨了游戏开发中降低Draw Calls数量及提高帧率的重要性,详细解释了Draw Calls的含义、如何通过纹理拼接减少Draw Calls,并分析了渲染帧所需时间与帧率的关系。建议游戏开发者优化Draw Calls与帧率,以提升游戏性能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

82    <-- number of draw calls 0.016 <-- time it took to render the frame 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. If you use a CCSpriteBatchNode and add 100 sprites to it, it will increase the draw call only by 1.

82 is a pretty high draw call number - depending on the game's complexity and assuming it is well optimized to reduce draw calls, the number of draw calls should be around 10 to 40. Assuming all 82 draw calls are sprites, then creating a texture atlas out of the sprite images (use TexturePacker, Zwoptex, SpriteHelper) in order to use CCSpriteBatchNode you could reduce the number of draw calls to 1. Draw calls are expensive, so it is very important to keep that number down.

The time it took to render a frame is in milliseconds. Since you need to draw a new frame every 0.016666666 seconds in order to achieve 60 frames per second (1/60 = 0,0166…) this number can tell you how close your game is to dropping below 60 fps. Yours is pretty close, you have practically no room left for additional game logic or visuals before the framerate will drop below 60 fps.

The last number is the number of frames per second. This value, like the previous one, is averaged over several frames so that it doesn't fluctuate as much (makes it hard to read).

PS: one other thing to keep in mind is that the bottom two values become misleading can not be compared for framerates below 15 fps. For example cocos2d might show 0.0 for the time it took to render a frame at such a low framerate.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值