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

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

问题描述

CCSpriteBatch节点是否仅绘制可见属性设置为true的sprite?

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

还是考虑屏幕尺寸?换一种说法。如果节点中的sprite在屏幕之外,opengl绘图调用的性能会反映出这一点吗?

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?

推荐答案

CCSpriteBatchNode总是绘制所有的子sprite。我不知道什么让sprite with visible = 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.

没有批量处理的精灵的行为不同。如果一个非分批的sprite是不可见的,它只是不绘制。然后绘制屏幕外的子画面。 Cocos2D没有函数跳过屏幕/窗口边界外绘制节点。

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:

太多的批处理sprite仍会影响性能,即使它们不可见或在屏幕外。 GPU负责取消由于完全在屏幕外部而不可见的四边形的绘制。它仍然需要处理这些四边形。

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.

这是cocos2d的tilemap实现的主要问题,为什么它是如此缓慢与大的tilemaps。内部tilemaps也使用相同的sprite批处理技术。

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天全站免登陆