1

I'm using cocos2d 1.0.1.

I've created a CCSpriteBatchNode, it includes a CCSprite (let's name it parentLayer) which includes some X number of childs(CCSprites).

The problem is - when I rotate parentLayer all sprites (childs) correctly displayed, however bounding boxes are at the same place (where they've been before rotation), so world coordinates of those sprites won't be changed.

Off course, all of the above works great without CCSpriteBatchNode. But, I would like to use batch node due to amount of sprites involved.

The question is, is there any way to update bounding boxes & child positions correspondingly?

1 Answers1

0

How many sprites are we talking about? I would just go with a fast enumeration call to rotate each one individually. I nave never noticed a performance hit when doing this, have you?

CCArray *listOfChildren = [parentLayer children];
for (CCSprite *sprite in listOfChildren) {
    [sprite setRotation:someValue];
}
Sylvan
  • 526
  • 3
  • 6
  • Thanks for a fast reply. I tried this approach, but it won't change child's coordinates. All childs have a square shape and their anchor point == 0.5f, 0.5f, so they will just rotate at the same place where they've been. However, it could be possible to change anchor point to the center of the layer and then rotate, but then I'll have quite a complicated computations for collision and other stuff. –  Nov 08 '12 at 13:38
  • Your solution will work perfectly if there was a way to set anchorPoint of child to be based on parent's anchorPoint position. –  Nov 08 '12 at 18:12