Cocos2d:CCSpriteBatch 节点是否只绘制可见属性设置为 true 的精灵? [英] Cocos2d: Does CCSpriteBatch node draw only sprites with visible property set to true?

查看:22
本文介绍了Cocos2d:CCSpriteBatch 节点是否只绘制可见属性设置为 true 的精灵?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Does CCSpriteBatch node draw only sprites with visible property set to true?

Or does it consider also the screen size? In other words. If a sprite within the node is outside the screen, will the performance of the opengl draw call reflect that?

解决方案

No and no.

CCSpriteBatchNode always draws all child sprites. I'm not sure exactly what makes sprites with visible = NO not to appear on screen, but technically it does draw all quads every time. It also doesn't take into account the screen area.

Sprites that are not batched behave differently. If a non-batched sprite is not visible, it's simply not drawn. Sprites outside the screen are drawn however. Cocos2D has no function ality to skip drawing of nodes outside the screen/window boundaries.

The following is hearsay, from what I've read over the past years, so take it with a grain of salt:

Too many batched sprites still affects performance negatively even if they are not visible or outside the screen. The GPU is responsible for cancelling draws of quads that are not visible due to being entirely outside the screen. It still needs to process those quads.

This is the main problem of cocos2d's tilemap implementation and why it is so slow with large tilemaps. Internally tilemaps also use the same sprite batching technique.

这篇关于Cocos2d:CCSpriteBatch 节点是否只绘制可见属性设置为 true 的精灵?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆