Adding multiple layers to one scene doesn't work

Hello, I am trying to create a PopupLayer above my GameScene layer. My code looks like this:

Scene* GameScene::createScene()
{
    Scene* scene = Scene::create();
    auto layer = GameScene::create();
    auto popup = PopupLayer::create();
    scene->addChild(layer, 0);
    scene->addChild(popup, 200);
    layer->setPopupLayer((PopupLayer*)popup);

    return scene;
}

And then in PopupLayer::init() I am trying to draw label on the screen… it doesn’t show any label at all. Any Ideas what could be wrong? Do you need more code? what exactly?

I’m pretty sure there is nothing wrong with the code you posted. I tried creating a createScene function that created a scene, added 2 layers to it and had each layer add something to itself so I could see that they were working, and both things they added appeared.

You will probably have to post PopupLayer::init(), and possibly GameScene::setPopupLayer() if you think that is relative to the issue.

@durisvk I solved the problem by pushing a scene with popup layer onto the existing scene. Any selections on the popup scene, I communicated to the root scene by custom events. I didn’t have much success with adding layers and adjusting z-orders.

hth,

I fixed this. The problem was that PopupLayer::init() method was never called. I forgot to overload the PopupLayer::create() method. Now it’s fiixed