ios - CCSpriteBatchNode stops adding children at around 15k -


i using ccspritebatchnode draw line 1 pixel @ time (using 1x1 swatch). need because user controlling line goes in real time (it's not drawing app think i'm doing comparable).

it turns out when add between 15-16k children batchnode stops registering new children. seems pen ran out of ink!

i poked around in cocos2d code little bit @ no point seem goes wrong. stops registering new child nodes. know why is?

first of all, , let me in way that's gigantic understatement:

ouch!

next, technical reason. sprites fail render have batched 16.384 of them. since each sprite uses quad (4 vertices) render sprite on screen, hit vertex limit of 65.536 vertices per batch operation.

more vertices won't drawn per batch operation (vbo buffer limit). technical limitation. try use ccspritebatchnode additional sprites - you're going down road here.

if need draw lines, worst possible approach can imagine. consider using line drawing (ccdrawline), individual pixels (ccdrawpixel believe exists too, 15k pixels terribly slow) or shaders accomplish same or similar effect. can batch drawing primitives cocos2d 2.1 using ccdrawnode.

one other solution i've used in yetipipi use limited number of sprites, 20 200, , draw them ccrendertexture. every time add new sprite, least used sprite re-used. not clearing rendertexture, can continue draw onto far fewer sprites while that's been drawn before remains. drawing sprites low opacity effect of drawing @ same position longer period of time in order make area more opaque.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -