Tell me more ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I have a CCSprite that has CCSprite children, and those CCSprite children have CCSprite children.

The contentSize property doesn't seem to include all children/subchildren, and seems to only work for the base node. I could write a recursive method to traverse a CCSprite for all children/subchildren and calculate a proper boundingbox, but am curious as to if I am missing something and it's possible to get that information without doing so.

I'l be a little surprised if such a method doesn't exist, but I can't seem to find it.

share|improve this question

1 Answer

I think you would need to perform your own traversal to calculate the total size. The contentSize property is more relevant to the size of the texture the sprite is based on, rather than any children it contains. CCNode for example has a default contentSize of CGSizeZero because it isn't based on a texture.

share|improve this answer
I actually ended up doing just that. I'm just kind of amazed it doesn't exist. Would seem to be a very worthwhile method to have for CCNode! I'll post my solution here, I posted it over on StackOverflow. – prototypical Jan 9 at 16:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.