50% of the time I feel like I get what I expect, and then the other 50% of the time, I find myself going "!?!?!? Why in the world is cocos2d putting this here?!?"
example:
parent: CCNode, anchorpoint (0.5, 0.5), position (screenWidth / 2, screenHeight / 2)
child: CCSprite, anchorpoint (0.5, 0.5), position (0,0), textureRect CGRectZero, contentSize manually set to scale of child of child
child of child: CCSprite, anchorpoint (0.5, 0.5), position (0,0), same texture as "child", has a textureRect of something like (0,0,25,1), rotation of 90. Its scaleY is set to 384.
Where do I expect the child of child? In the middle of the screen of course. The anchor point is in the middle of it.
Where does it actually appear? On the left side of the screen. Why? No idea. Makes no sense.
OMG...
So, it has to do with when the sprite is added to the parent!!!
If you do:
CCSprite *sprite = [[CCSprite alloc] initWithFile:@"test.png" rect:CGRect(0,0,1,1)];
sprite.anchorPoint = ccp(0.5, 0.5);
sprite.scaleX = 384;
[node addChild:sprite];
Then the positioning is TOTALLY wrong. But if you do:
CCSprite *sprite = [[CCSprite alloc] initWithFile:@"test.png" rect:CGRect(0,0,1,1)];
[node addChild:sprite];
sprite.anchorPoint = ccp(0.5, 0.5);
sprite.scaleX = 384;
Then it is positioned properly... Totally bogus. Unbelievable, I wasted so many hours on this. Hopefully this helps someone in the future who is screaming at the nonsense.