HudLayer in cocos2dx v3.4

  • Kay_Karthik
    Likes 0

    Problem Description

    I created a scene which has two layers.

    MainScene

         -GameLayer

         -HudLayer

    The GameLayer has all the main objects of the game and the HudLayer has pause button,score label etc.

    When i update the gamelayer and the layer scrolls , the nodes of HudLayer are also moving which should not happen.

    I am posting the code of how i created the scene with two layers.


    Scene *MainScene::createScene()
    {
        auto scene = Scene::createWithPhysics();
        scene->getPhysicsWorld()->setDebugDrawMask( PhysicsWorld::DEBUGDRAW_ALL );
        scene->getPhysicsWorld()->setGravity(Vect(0,-10));
        scene->getPhysicsWorld()->setAutoStep(false);

        GameLayer *layer1 = GameLayer::create();
        HUDLayer *layer2 = HUDLayer::create();

        scene->addChild(layer1,1);
        scene->addChild(layer2,2);

        return scene;
    }

    Can you please tell me how to make the HudLayer static so  that it is always on top of the screen while the GameLayer scrolls?

  • Sonar Systems admin
    Likes 0

    What is scrolling on the game layer aka how are you making it scroll?

Login to reply