Is this structure correct?

Is this structure correct?
0.0 0


Hi! I’m doing a cocos2dx game, and I have (maybe) a simple question.

My game structure is:

Scene with level class layer
Level layer adds childs: room layer and HUD layer

When in one room I have an event, I need to send it to HUD layer (for show text).

There are a simple way to call a hudlayer function from room class, for example?

Now, I have a level class checking all the time for events and when it find one, it sends to hudlayer. I thinks this is not a good practice.

Thank you! :slight_smile:


In this situation you could for example use getParent() method from room layer to get level layer object and then use getChildByTag(int tag) method to get hud layer. Note that getChildByTag is not the best solution in terms of speed and you must set tag for hud layer before using it. However personally I think that it would be more logical to set HUD layer as a child of the scene.