Hi All
Quick Question as has always plagued me
We add our layers (Or single layer in my case) in the create scene function. We use “auto”. Now we cannot access that layer in other functions

I tried adding “cocos2d::Layer* mainLayer;” to the header file and dropping “auto” but I get a error “a nonstatic member reference must be relative to a specific object”.
How can we add a variable layer in header file and then add that to the scene in the create scene fucntion
Additional related question to be clear
Scene* TestScene::createScene(){
auto scene = Scene::create();
auto layer = TestScene::create();
scene->addChild(layer);
return scene;
}
The code above seems to be a standard set up with a scene. i remember then always using the next piece for code throughout the init function
this->addchild()
What does “this” point to then? What are we adding this child to (Layer or scene). I understand this and that in Java as to what it means. I assume same concept.
So again to be clear, how can we make that layer accessible to all the class functions ? How do we add more layers. If we create another layer(Which i can do), how do we add it to the scene correctly(this->addchild(layer, 1)??)
Links to reading are fine. I did search and never found anything specific to this and i find it hard make sense of the class structure in relation to this
Thanks