Note that there are some explanatory texts on larger screens.

plurals
  1. POCCSpriteBatchNode: Does the Child of Child receive drawing performance gains?
    text
    copied!<p>I have a <code>CCSpriteBatchNode</code> with a configuration like this:</p> <pre><code>CCSpriteBatchNode ChildA1 ChildB1 ChildB2 .... ChildB999 ChildA2 ChildA3 ... </code></pre> <p>Where all children (ChildA1,ChildB1,ChildA2...) are <code>CCSprite</code> objects. The <code>CCSpriteBatchNode</code> and all children but <code>ChildA1</code> is created via:</p> <pre><code>[CCSprite spriteWithSpriteFrameName:@"FileName.png"]; </code></pre> <p><code>ChildA1</code> is created like this:</p> <pre><code>// Create Parent Sprite CCSprite* childA1 = [[CCSprite alloc] init]; childA1.contentSize = CGSizeMake(37.5,37.5); childA1.anchorPoint = ccp(0,0); [batchNode addChild:childA1 z:0 tag:1]; // Add Child Sprites [childA1 addChild:childB1 z:0 tag:1]; [childA1 addChild:childB2 z:0 tag:1]; [childA1 addChild:childB3 z:0 tag:1]; // Continue adding childB4-childB999 </code></pre> <p>Note: This renders just fine, and I see the output I expect, where <code>childB1</code>'s position is relative to <code>childA1</code>, and moving <code>childA1</code> results in <code>childB1</code> moving.</p> <p>My question is this: Will I see a performance gain in the drawing each of <code>childB1</code>-<code>childB999</code>? From what I understand, the <code>CCSpriteBatchNode</code> optimizes the drawing of all children within a <code>CCSpriteBatchNode</code> by drawing all its child <code>CCSprites</code> together. Does this also apply to the children of those <code>CCSprites</code>? </p> <p>For those who want to know why I'm doing this: There are many layers within this game and grouping <code>CCSprites</code> inside of a <code>CCSprite</code> within a <code>CCSpriteBatchNode</code> allows me to manipulate a group of <code>CCSprites</code> by manipulating only the parent of that group of sprites. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload