I want to access a sprite in a scene, but I cannot get the running scene from outside the scene class.
The scene is created using:
Scene* MyScene::createScene() { auto scene = Scene::create(); auto layer = MyScene::create(); scene->addChild(layer); return scene; } bool MyScene::init() { this->addChild(sprite,100, 1234); } But if I then access the running scene from outside the class, it has no children.
Director::getInstance()->getRunningScene() //should be the MyScene instance with sprite children, but has no children. I also tried giving the scene layer a tagname, but with the same result.
scene->addChild(layer,100,TAGNAME); ... Director::getInstance()->getRunningScene()->getChildByTag(TAGNAME) //returns NULL because getRunningScene has no children. The only way I can access the scene is making a static reference in my AppDelegate, but this doesn't seem a proper way. How can I get the current scene correctly from outside the class?