For my game, I create game scene for which I set HUD to it.

First my game scene use BoundCamera, so I use hud to set score text, dollar text and setting button. Now on game scene when I touch on setting button, the child scene (setting scene) come up because I attached it to game scene.

I use child scene because of pause/resume functionality added to the setting scene.

When child scene display on the screen at the same time hud content also displayed on the sceeen. But I don't want that hud content of my child scene (setting scene).

From other post of this forum I found that made hud.setVisible(false).

But this solution does not work for me because the touch area of hud's children remain active even though it were not displayed on the screen. So when player touch on these areas the effect of touch become available even if the hud is not displayed on the screen.

Also I like to mention that my development platform is AndEngine. I hope someone give me best guidance on this.


1 Answer 1


I don't know why this question was tagged with cocos2d-iphone, but here it is the answer for cocos2d-iphone:

In cocos2d you solve this problem by using the Z index ordering. Layers with lower Z index get rendered first.

Check the Cocos2D 2.0 Docs.

[self addChild:[GameLayer node] z:0 tag:KGameLayer];

[self addChild:[HudLayer node] z:1 tag:KHudLayer];

[self addChild:[TopLayer node] z:2 tag:KTopLayer];

Now in order to show/hide a layer you can use the visible property of a node, check the documentation.

@implementation HudLayer                               

-(void) showLayer: (BOOL) shouldShow
  self.visible = shouldShow;
  self.isTouchEnabled = shouldShow;
  menu.isTouchEnabled = shouldShow;

Now when you display the menu and want to hide the HudLayer, you only have to get the HudLayer by tag, and call shwoLayer with NO.


In AndEngine you should be able to set the isVisible property of the HudLayer to false, check the source code of BaseEntity

public boolean isVisible() {
  return this.mVisible;

public void setVisible(final boolean pVisible) {
  this.mVisible = pVisible;

I assume that the HudLayer in AndEngine is a Layer object, and as I checked the Layer object is a subclass of BaseEntity, hence you should be able to call setVisible on the HudLayer.

  • \$\begingroup\$ I up vote your answer because you give some concept that is important for us. But this thing does not work in andengine. Because zIndex of hud is higher by default. \$\endgroup\$
    – Siddharth
    Commented Jan 17, 2013 at 16:21
  • \$\begingroup\$ check my latest edit. Overall I think that your only chance is to browse through the Andengine source code. \$\endgroup\$
    – user6395
    Commented Jan 17, 2013 at 16:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .