Quantcast
Channel: Cocos Forums - Latest topics
Viewing all articles
Browse latest Browse all 17075

Why the layer must be created from my class and not from layer class?

$
0
0

@lionking0 wrote:

I am confused about something.
I have the following example:

mainMenu.h

class mainMenu : public Node {
public:
    static Scene* createScene();
    virtual bool init();
    void GoToGameScene(Ref *pSender);
    CREATE_FUNC(mainMenu);


private:
    mainMenu() {};
    ~mainMenu() {};


};

mainMenu.cpp

Scene* mainScene::createScene(){
    auto scene = Scene::create();
    auto layer = mainScene::create();
    scene->addChild(layer);

    return scene;
}

Focus on this part.

auto scene = Scene::create();
auto layer = mainScene::create();

Why do we create layer from mainScene not from Layer

For example: Why we do this:

auto layer = mainScene::create();

If we can do it, like creating a scene

auto layer = Layer::create();

Posts: 4

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 17075

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>