In the cocos2d engine, there is a method to add an object as a child of another.
So for example in this line of code in a Game.m file:
CCMenu *menu = [CCMenu menuWithItems:pauseButton, nil];
pauseButton.position = ccp(s.width/2 - pauseButton.contentSize.width/2, (-s.height/2)
+ pauseButton.contentSize.height/2);
[self addChild:menu z:100];
You can see the menu instance of CCMenu is added as a child to the class object of Game. What does this actually do? Is it for memory purposes?
This kind of hierarchy system helps organize and reference your game components. And display them.
Game.mis your scene, and it will be displaying your game elements. However, it has no idea what those elements are. So the scene has a list of children, and it will “display” them (sprites, buttons, labels, etc…). So you add a child to the scene as a way to tell the scene that this child needs to be displayed, because it is a visual element.