Director::getInstance()->getRunningScene() returns NULL after director->runWithScene(scene)

What im missing here ?
i try to get the current running Scene
like this in the AppDelegate.cpp :

 director->runWithScene(scene);
    Scene* pCurrentScene = Director::getInstance()->getRunningScene();   

looking in the director source code i can see that the _runningScene is was set only in

void Director::setNextScene()

what do i miss here ? and how to get the running Scene?

What is the problem? Does it return a null pointer?

You already have your running scene: scene

With getRunningScene() as you posted.

I want to query it from different place in the code and as the director supposed to be my central point of data ,
logically i don’t understand , why the getRunningScene() return NULL , while i have already the _runningScene in the Director class there
why not to set it ?,

Hi,
This happened to me as well. Till the single frame has been outputted it will give your NULL as it should.
I have asked question as well in another thread posted below.

@EvilDeveloper
Thanks for the link. this is what it is. … i guess . there allot of things i don’t “logically” understand in the engine.
when i see method as “getRunningScene()” i expect to get “THE” running scene not some wired logic behind it
especially when i call it after i call the function :

director->runWithScene(scene);

As already explained by the former posts of @EvilDeveloper, the scene is not actually running. It has to prepare itself and render some frames, change its state to running.

If you have to reference to your actual scene before that happens, just use your scene object, which is passed to the runWithScene function call, as I already suggested.