Does the .visible property affect performance?

I can convert the .visible value to CCNodes, but I wonder if a holistic node can consume less memory / processing than visible? Can I set the .visible property to NO when my objects are off-screen for optimization? Or is cocos2d already doing this for me?

+3
source share
2 answers

Invisible nodes are usually skipped when it comes to visualization. On the other hand, nodes with visible typing in YES will call OpenGL draw calls whether they are enabled or not on the screen (see Riq's comment here ). i.e. cocos2d does not seem to do any culling for off-screen elements.

If this is true, I would simply simply set visible = NO (no harm and definitely not difficult!) If they are completely disconnected from the screen to avoid calling additional drawing calls. Also note that these off-screen node objects are still physically present and still occupy the same memory, even if they have a visible set of NO. In addition, if these nodes are already starting some animations / actions, they will continue to update off-screen if you have not painted them.

+4
source

Check out this post on the cocos2d official forum

render invisible sprites in spritebatchnode cheap?

Performance difference between visible = no and removeChild

Poor execution - many sprites with the same texture

Alternatively, you can test it yourself, but I think this post will help.

Setting IMO visible = NO is sufficient, but depends on the number of sprites.

+2
source

Source: https://habr.com/ru/post/909150/


All Articles