Search code examples
c++cocos2d-x

Passing information to other CCScene's in Cocos2D-X?


How can I pass information in? Right now, there's a static constructor method called "create" but it's created from CCScene. How can I pass in my own arguments?


Solution

  • You can create another static method with whatever arguments you want in your Layer which returns Scene object.

    Here is pseudo code :

    CCScene* MyLayer::scene(bool arg0)
    {   
        CCScene * scene = NULL;
        do 
        {
            scene = CCScene::create();
            MyLayer* pLayer = MyLayer::create();
            scene->addChild(pLayer);
        } while (0);
        return scene;
    }