# How to get the complete width of SKSpriteNode which has many child nodes

I have a Sprite node with many 6 child nodes. Each are placed one after another in X-axis. I want to know the complete with of the Sksprite node.

SKSpriteNode *array = [SKSpriteNode node];



array.size.width dosen't get me any size, so how should i get the complete width of array with child nodes..

If i add multiple sprites to NSMutalbleArray then how can i get the width of the complete array.

To get the complete bounding rectangle of a node and its child nodes you use the calculateAccumulatedFrame method. It's a member of SKNode.

I ran into this when adding my SKSpriteNodes to separate SKNodes as layers for parallax and HUD elements. I kept getting (0,0) width/height for my bounding rect on the SKNode, and I found this.

It returns a CGRect, and you can use it like so:

CGRect layerSize = [_layer calculateAccumulatedFrame];
float widthVar = layerSize.size.width;
//etc...

• Fantastic! This had been bugging me for over 2 months! I was going to adjust a child node in another project, and kept getting 0. Ended up tackling it using the parent node's size, and gave up on this aspect. Thank you – Septronic Mar 18 '16 at 11:39
• No problem. Nothing better than answering a question 2 years before it was asked! – MentatOfDune Apr 19 '16 at 22:05
• Lols! It's back to the future. – Septronic Apr 20 '16 at 23:02