0
votes

I have an iPad application containing a grid of 400 CCSprites, some of which contain several sprites already layered together. I have not used CCSpriteBatchNode as I believe the ZOrder needs to be the same for all items in the node, and this isn't the case. Performance is acceptable. However, I need to optionally overlay a small dot in the centre of each of the 400 sprites (if the user wants a grid displayed to help with layout). The problem is, by adding another CCSprite (using addChild) I now have over 800 sprites on the screen and it's hitting the performance hard. Is there a way to draw the new sprite onto the one that's already there that doesn't affect performance? (I guess like dynamically generating a new sprite made up of the parts, but that isn't a set of stacked CCSprites)

I'm using Cocos2d V2.3 - I did attempt to convert the project to Cocos2d V3, but found performance slightly worse, and it caused many scaling issues, which, given the project is close to completion, mean it's better to finish this in V2.3.

Many thanks in advance for any suggestions. PS: I found some similar questions but they dealt with how to stack sprites - this isn't a problem, I can do that, it's the drawing a new sprite that I'm struggling with.

2
tough ... if the dot is really a dot (not too too complex), you could try a shader on the CCSprite you want to 'dotify' ... that adds no draw calls, and performance impact should be minimal. You could control the .hasDot shader with a uniform.YvesLeBorg
Any idea how I would do that, or a good resource to help? I've never used shaders, so wouldn't have a clue where to start. Is there some way to dynamically create a texture from several sprites, which I could then use for the displayed sprite?Chris K
try batch node, see if that fixes performance. if it does, rework zorder to use vertexz instead (may need to enable depth buffering). btw, are you sure there is a v2.3? I think 2.2 is the latest v2.x official release.LearnCocos2D

2 Answers

0
votes

Change textures of existing sprites to the textures with the dot.
If this solution doesn't match your case, please supply a screen shot (or part of screen shot), or more detailed description of the sprites on your scene.

-1
votes

The answer comes in the form of CCRenderTexture - draw all the sprites into a a single texture, and then use that for a single CCSprite.