0

Looking for solutions from creating the CCNode as a batchNode and viewing the sprites properly/accessing the children?

Any help is appreciated.

[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"sprites.plist"];
_actors = [CCSpriteBatchNode batchNodeWithFile:@"sprites.pvr.ccz"];
[_actors.texture setAntialiased:YES];

This is what I originally had. Here is what I currently have:

[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"sprites.plist"];
_actors = [CCNode node];
[_actors addChild:[CCSprite spriteWithImageNamed:@"sprites.pvr.ccz"]];
Lagoo87
  • 621
  • 1
  • 6
  • 20
  • i think that any CCNode reorders automagically when either a child is added, or when a child's zOrder is set to a new value. So ... not certain you need to duplicate the functionality. read this if you want to know more about batching : https://github.com/cocos2d/cocos2d-swift/wiki/Cocos2D-Render-Order-and-Batching – YvesLeBorg Sep 22 '14 at 17:06
  • Any chance you know about setting up the .plist to correspond with the sprite sheet now being a node? Thanks for the above post! – Lagoo87 Sep 22 '14 at 17:09
  • you dont need to ... with the new rendering engine, there is no restriction on 'batch node texture must be same as that of its children'. If all the children of a node are from the same texture, batching will be automatic. You only break batching if the render state changes (new texture, new shader, different uniforms ... ), but for plain vanilla sprites, if a node contains 1100 sprites from only one texture, you will get 1 draw call. – YvesLeBorg Sep 22 '14 at 17:12
  • So my problem is that I have added my sprite sheet to my actors node but cannot access the sprites the way I was previously. It cannot find sprites in the sheet. If I add the sprite sheet to SpriteFrameCache it seems as if its grabbing the wrong areas of the sheet. – Lagoo87 Sep 22 '14 at 17:30
  • show some code, maybe i can help then ... i am upgrading game with soldier.mapLayout that seems to match your use case (i think), and got it working now. – YvesLeBorg Sep 22 '14 at 17:33
  • so, i dont think you need to add the entire sprite sheet to the node. Just figure out how to anti-alias it. Instead, whenever you create a sprite from the plist, add THAT to the node. They will meet criteria for batching and you will get draw-call batching free of charge, assuming you only add sprites that reference ultimately this texture. – YvesLeBorg Sep 22 '14 at 18:11
  • Thanks Yves- but my sprites are still not loading the proper areas of the sheet. I'm not sure if the Node would scale the sheet? Or if SpriteBatchNode did automatically... and now I need to take care of it? – Lagoo87 Sep 22 '14 at 18:28
  • ahhhh .... your question was unclear ... i think you need to read this about 3.2 and pvr's : http://stackoverflow.com/questions/25701634/pvr-flipped-in-cocos2d-version-3-2-dilemma-when-porting-from-2-1/25715958#25715958 – YvesLeBorg Sep 22 '14 at 18:43
  • Ahh excellent thank you very much, this pointed me in the right direction. – Lagoo87 Sep 22 '14 at 19:17

1 Answers1

0

To fix this issue, I needed to activate the Flip PVR in TexturePacker option when exporting my SpriteSheet. Hopefully this helps some of you!

Lagoo87
  • 621
  • 1
  • 6
  • 20