ReplaceScene without replace HUD

ReplaceScene without replace HUD
0.0 0


Hi, Im programing a zelda like game but I have problems in transitions between, for example, 2 dungeon chambers.

The scene is a chamber, and when the player goes to top door, I use this function for change chamber:

CCDirector *director = CCDirector::sharedDirector();

The lives HUB is moving with scene too, and they have to be static. What I can do?

Can I do a “top class HUD layer” that can’t be afected for replaceScene?

Thank you and sorry for my english!


Since the hud layer is attached to your scene, it’ll be affected by CCDirector::sharedDirector()->replaceScene(…);

I’m not sure if Cocos2d-x has a way of ‘replacing scenes’ without affecting particular layers that are attached to it, but what I would try doing is the following:

Remove the HUD layer from the scene.
Replace the scene.
Attach the HUD layer to the new scene.

The very first time creating ‘HUD layer’ I would call ‘retain()’ so that it is not cleaned up by the garbage collector. But make sure to free it yourself to avoid any memory leaks.



Hi Santos Perez.
Did you find a solution ?
I am in the same need.